Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Modified line-item-detail model #917

Merged
merged 2 commits into from
Jan 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions app/models/line-item-detail.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
import AbstractModel from 'hospitalrun/models/abstract';
import DS from 'ember-data';
import Ember from 'ember';
import NumberFormat from 'hospitalrun/mixins/number-format';

const { computed, get } = Ember;

export default AbstractModel.extend(NumberFormat, {
// Attributes
department: DS.attr('string'),
expenseAccount: DS.attr('string'),
name: DS.attr('string'),
price: DS.attr('number'),
pricingItem: DS.belongsTo('pricing', {
async: false
}),
quantity: DS.attr('number'),
total: DS.attr('number'),

amountOwed: function() {
let price = this.get('price');
let quantity = this.get('quantity');
// Associations
pricingItem: DS.belongsTo('pricing', { async: false }),

amountOwed: computed('price', 'quantity', function() {
let price = get(this, 'price');
let quantity = get(this, 'quantity');
let total = 0;
if (this._validNumber(price) && this._validNumber(quantity)) {
total = this._numberFormat((price * quantity), true);
}
return total;
}.property('price', 'quantity')

})
});