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

Commit

Permalink
Fixed issues preventing invoices from generating
Browse files Browse the repository at this point in the history
Fixes #423
  • Loading branch information
jkleinsc committed Apr 18, 2016
1 parent 64909cd commit bb1f68b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 44 deletions.
4 changes: 2 additions & 2 deletions app/invoices/edit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@ export default AbstractEditController.extend(NumberFormat, PatientSubmodule, Pub
}.bind(this));

labs.forEach(function(lab) {
if (!Ember.isEmpty(imaging.get('labType'))) {
if (!Ember.isEmpty(lab.get('labType'))) {
this._addSupplyCharge(Ember.Object.create({
pricingItem: imaging.get('labType'),
pricingItem: lab.get('labType'),
quantity: 1
}), 'Lab');
}
Expand Down
34 changes: 14 additions & 20 deletions app/invoices/edit/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
<div class="panel-body detail-section-content">
<table class="table">
<tr class="table-header">
<th>Description</th>
<th class="text-right">Actual Charges</th>
<th class="text-right">Discount</th>
<th class="text-right">PhilHealth</th>
<th class="text-right">HMO/COM</th>
<th class="text-right">Excess</th>
<th class="text-right">{{t 'labels.action'}}</th>
<th class="col-xs-5">Description</th>
<th class="col-xs-1 text-right">Actual Charges</th>
<th class="col-xs-1 text-right">Discount</th>
<th class="col-xs-1 text-right">PhilHealth</th>
<th class="col-xs-1 text-right">HMO/COM</th>
<th class="col-xs-1 text-right">Excess</th>
<th class="col-xs-2 text-right">{{t 'labels.action'}}</th>
</tr>
{{#each model.lineItemsByCategory as |categoryGroup|}}
<tr>
Expand All @@ -69,13 +69,11 @@
{{#each categoryGroup.items as |item|}}
<tr>
<td class="col-xs-5">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon glyphicon {{if item.showDetails 'glyphicon-minus' 'glyphicon-plus'}}"
{{action "toggleDetails" item bubbles=false }}> </span>
<strong>{{input class="form-control" value=item.name }}</strong>
</div>
</div>
</td>
<td class="col-xs-1 text-right">
{{number-format item.total}}
Expand Down Expand Up @@ -106,12 +104,12 @@
</tr>
{{#if item.showDetails}}
<tr>
<th colspan="2">{{t 'labels.name'}}</th>
<th>{{t 'labels.quantity'}}</th>
<th>Price</th>
<th>Expense To</th>
<th colspan="2" class="col-xs-6">{{t 'labels.name'}}</th>
<th class="col-xs-1">{{t 'labels.quantity'}}</th>
<th class="col-xs-1">Price</th>
<th class="col-xs-1">Expense To</th>
<th class="col-xs-1 text-right">Total</th>
<th>
<th class="col-xs-2">
{{#if canAddCharge}}
<button class="btn btn-primary" {{action "addItemCharge" item}}>
<span class="octicon octicon-plus"></span>Add Charge
Expand All @@ -121,12 +119,8 @@
</tr>
{{#each item.details as |detail|}}
<tr>
<td colspan="2" class="col-xs-6">
<div class="form-group">
<div class="input-group">
{{input class="form-control" value=detail.name }}
</div>
</div>
<td colspan="2" class="col-xs-6 input-group">
{{input class="form-control" value=detail.name }}
</td>
<td class="col-xs-1">
<div class="form-group">
Expand Down
27 changes: 20 additions & 7 deletions app/mixins/medication-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ export default Ember.Mixin.create({
if (!Ember.isEmpty(medicationTitle)) {
return medicationTitle;
} else {
this.get(inventoryAttribute).then((inventoryItem) => {
this.set('medicationTitle', inventoryItem.get('name'));
});
var inventoryObject = this.get(inventoryAttribute);
if (inventoryObject.then) {
this.get(inventoryAttribute).then((inventoryItem) => {
this.set('medicationTitle', inventoryItem.get('name'));
});
} else {
this.set('medicationTitle', inventoryObject.get('name'));
}
}
},

Expand All @@ -34,12 +39,20 @@ export default Ember.Mixin.create({
price: priceOfMedication
});
} else {
this.get(inventoryAttribute).then((inventoryItem) => {
var objectInventoryItem = this.get(inventoryAttribute);
if (objectInventoryItem.then) {
this.get(inventoryAttribute).then((inventoryItem) => {
resolve({
name: inventoryItem.get('name'),
price: inventoryItem.get('price')
});
});
} else {
resolve({
name: inventoryItem.get('name'),
price: inventoryItem.get('price')
name: objectInventoryItem.get('name'),
price: objectInventoryItem.get('price')
});
});
}
}
});
},
Expand Down
5 changes: 2 additions & 3 deletions app/models/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ export default AbstractModel.extend(DateFormat, NumberFormat, {
categoryList.total = this._calculateTotal(categoryList.items, 'total');
}.bind(this));
return byCategory;
}.property('lineItems.[].amountOwed'),

}.property('lineItems.@each.amountOwed'),
patientIdChanged: function() {
if (!Ember.isEmpty(this.get('patient'))) {
var patientDisplayName = this.get('patient.displayName'),
Expand All @@ -118,7 +117,7 @@ export default AbstractModel.extend(DateFormat, NumberFormat, {
if (remainingBalance <= 0) {
this.set('status', 'Paid');
}
}.observes('payments.[]', 'payments.[].amount'),
}.observes('payments.[]', 'payments.@each.amount'),

validations: {
patientTypeAhead: PatientValidation.patientTypeAhead,
Expand Down
20 changes: 8 additions & 12 deletions app/models/proc-charge.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,18 @@ export default AbstractModel.extend(MedicationDetails, {
dateCharged: DS.attr('date'),

medicationCharge: function() {
let medicationTitle = this.get('medicationTitle');
if (!Ember.isEmpty(medicationTitle)) {
return true;
}
var pricingItem = this.get('pricingItem'),
newMedicationCharge = this.get('newMedicationCharge');
return (Ember.isEmpty(pricingItem) || newMedicationCharge);
}.property('medicationTitle', 'pricingItem', 'newMedicationCharge'),
let medication = this.get('medication');
let newMedicationCharge = this.get('newMedicationCharge');
return (!Ember.isEmpty(medication) || !Ember.isEmpty(newMedicationCharge));
}.property('medication', 'newMedicationCharge'),

medicationName: function() {
return this.getMedicationName('medication');
}.property('medicationTitle', 'medication'),
return this.get('medication.name');
}.property('medication'),

medicationPrice: function() {
return this.getMedicationPrice('medication');
}.property('priceOfMedication', 'medication'),
return this.get('medication.price');
}.property('medication'),

validations: {
itemName: {
Expand Down

0 comments on commit bb1f68b

Please sign in to comment.