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

Payment set fee #670

Merged
merged 20 commits into from
Apr 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7b90609
Adding set fee to payment profiles
tangollama Sep 24, 2016
0e61aed
Missing translation strings
tangollama Sep 24, 2016
b97ef16
acceptance tests for payment profiles authored
tangollama Sep 24, 2016
ea76fd5
calculate the finalPatientResponsibility
tangollama Sep 24, 2016
b6cd465
finalPatientResponsibility and related translations
tangollama Sep 24, 2016
2d01465
Merge branch 'master' into payment-set-fee
tangollama Jan 10, 2017
a3ce0ff
resolving code style and formatting errors
tangollama Jan 15, 2017
6f165e9
Merge branch 'master' into payment-set-fee
tangollama Jan 15, 2017
5a4a074
code formatting corrections
tangollama Jan 15, 2017
d6f7530
Merge branch 'master' into payment-set-fee
tangollama Mar 29, 2017
00acd84
Ensuring that the patient responsibility and grand total both reflect…
tangollama Mar 29, 2017
344130a
Merge branch 'master' into payment-set-fee
jkleinsc Mar 29, 2017
abc6494
Merge branch 'master' into payment-set-fee
jkleinsc Mar 29, 2017
2e0726a
Merge branch 'payment-set-fee' of https://github.com/HospitalRun/fron…
jkleinsc Mar 29, 2017
949e56d
Merge branch 'master' into payment-set-fee
tangollama Apr 19, 2017
73e3fd8
fixing the billing messages
tangollama Apr 19, 2017
c3421fe
Merge branch 'master' into payment-set-fee
tangollama Apr 23, 2017
d2fcc81
Addressing a missing translation that was causing a test to fail.
tangollama Apr 23, 2017
23ec472
Addressing requested changes by @jkleinsc
tangollama Apr 26, 2017
1f0bd57
Merge branch 'master' into payment-set-fee
tangollama Apr 26, 2017
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
14 changes: 13 additions & 1 deletion app/invoices/edit/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
<td class="text-right">{{number-format model.discount}}</td>
<td class="text-right">{{number-format model.nationalInsurance}}</td>
<td class="text-right">{{number-format model.privateInsurance}}</td>
<td class="text-right">{{number-format model.patientResponsibility}}</td>
<td class="text-right">{{number-format model.finalPatientResponsibility}}</td>
<td></td>
</tr>
<tr>
Expand All @@ -197,6 +197,18 @@
<td class="text-right">{{number-format model.remainingBalance}}</td>
<td></td>
</tr>
{{#if model.paymentProfile}}
{{#if model.paymentProfile.setFee}}
<tr>
<td colspan="6">{{t 'billing.messages.flatFeeMsg' currency=(t 'labels.currencySymbol') setFee=model.paymentProfile.setFee}}</td>
</tr>
{{/if}}
{{#if model.paymentProfile.discountAmount}}
<tr>
<td colspan="6">{{t 'billing.messages.flatDiscountMsg' currency=(t 'labels.currencySymbol') discountAmount=model.paymentProfile.discountAmount}}</td>
</tr>
{{/if}}
{{/if}}
</table>
</div>
</div>
Expand Down
37 changes: 26 additions & 11 deletions app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,12 @@ export default {
paymentProfile: 'Payment Profile',
paymentsDeposits: 'Payments/Deposits',
pricingPanelOverrides: 'Pricing profile overrides',
pricingProfile: 'Pricing Profile'
pricingProfile: 'Pricing Profile',
setFee: 'Set Fee'
},
messages: {
flatFeeMsg: 'There is a flat fee for patient financial responsibility of {{currency}}{{setFee}}.',
flatDiscountMsg: 'There is a flat discount amount applied to the patient financial responsibility of {{currency}}{{discountAmount}}.'
}
},
buttons: {
Expand Down Expand Up @@ -783,6 +788,7 @@ export default {
country: 'Country',
cptcode: 'CPT Code',
creditTo: 'Credit To',
currencySymbol: '$',
date: 'Date',
dateCompleted: 'Date Completed',
dateOfBirth: 'Date of Birth',
Expand Down Expand Up @@ -1288,6 +1294,13 @@ export default {
visit: 'Visit'
}
},
pricing: {
labels: {
discountAmount: 'Discount Amount',
discountPercentage: 'Discount Percentage',
setFee: 'Set Fee'
}
},
print: { invoice: {
labels: {
billedBy: 'Billed by:',
Expand Down Expand Up @@ -1442,14 +1455,16 @@ export default {
visitSaved: 'Visit Saved'
}
},
vitals: { labels: {
dateRecorded: 'Date Recorded',
dbp: 'DBP',
heartRate: 'Heart Rate',
height: 'Height',
respiratoryRate: 'Respiratory Rate',
sbp: 'SBP',
temperature: 'Temperature',
weight: 'Weight'
} }
vitals: {
labels: {
dateRecorded: 'Date Recorded',
dbp: 'DBP',
heartRate: 'Heart Rate',
height: 'Height',
respiratoryRate: 'Respiratory Rate',
sbp: 'SBP',
temperature: 'Temperature',
weight: 'Weight'
}
}
};
24 changes: 22 additions & 2 deletions app/models/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export default AbstractModel.extend(DateFormat, NumberFormat, {
return get(this, 'status') === 'Paid';
}),

remainingBalance: computed('patientResponsibility', 'paidTotal', function() {
let patientResponsibility = get(this, 'patientResponsibility');
remainingBalance: computed('finalPatientResponsibility', 'paidTotal', function() {
let patientResponsibility = get(this, 'finalPatientResponsibility');
let paidTotal = get(this, 'paidTotal');
return this._numberFormat((patientResponsibility - paidTotal), true);
}),
Expand Down Expand Up @@ -98,6 +98,26 @@ export default AbstractModel.extend(DateFormat, NumberFormat, {

patientResponsibilityTotals: Ember.computed.mapBy('lineItems', 'amountOwed'),
patientResponsibility: Ember.computed.sum('patientResponsibilityTotals'),
finalPatientResponsibility: computed('patientResponsibility', 'paymentProfile', function() {
let setFee = this._getValidNumber(this.get('paymentProfile.setFee'));
let discountAmount = this._getValidNumber(this.get('paymentProfile.discountAmount'));
let patientResponsibility = this._getValidNumber(this.get('patientResponsibility'));
if (setFee > 0) {
if (setFee < patientResponsibility) {
return setFee;
} else {
return patientResponsibility;
}
} else if (discountAmount > 0) {
if (patientResponsibility - discountAmount > 0) {
return patientResponsibility - discountAmount;
} else {
return 0;
}
} else {
return patientResponsibility;
}
}),

paymentAmountChanged: function() {
let payments = get(this, 'payments').filter(function(payment) {
Expand Down
6 changes: 6 additions & 0 deletions app/models/price-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default AbstractModel.extend({
name: DS.attr('string'),
discountAmount: DS.attr('number'),
discountPercentage: DS.attr('number'),
setFee: DS.attr('number'),

validations: {
name: {
Expand All @@ -19,6 +20,11 @@ export default AbstractModel.extend({
numericality: {
allowBlank: true
}
},
setFee: {
numericality: {
allowBlank: true
}
}
}
});
7 changes: 4 additions & 3 deletions app/pricing/profiles/edit/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
updateButtonAction=updateButtonAction
updateButtonText=updateButtonText }}
{{#em-form model=model submitButton=false }}
{{em-input property="name" label="Name" class="required pricing-profile-name"}}
{{number-input property="discountPercentage" label="Discount Percentage" class="pricing-profile-percentage"}}
{{number-input property="discountAmount" label="Discount Amount" class="pricing-profile-discount"}}
{{em-input property="name" label=(t 'labels.name') class="required pricing-profile-name"}}
{{number-input property="discountPercentage" label=(t 'pricing.labels.discountPercentage') class="pricing-profile-percentage"}}
{{number-input property="discountAmount" label=(t 'pricing.labels.discountAmount') class="pricing-profile-discount"}}
{{em-input property="setFee" label=(t 'pricing.labels.setFee') class="pricing-set-fee"}}
{{/em-form}}
{{/modal-dialog}}
2 changes: 2 additions & 0 deletions app/pricing/profiles/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<th>{{t 'labels.name'}}</th>
<th>{{t 'billing.labels.discountAmount'}}</th>
<th>{{t 'billing.labels.discountPercentage'}}</th>
<th>{{t 'billing.labels.setFee'}}</th>
{{#if showActions}}
<th>{{t 'labels.actions'}}</th>
{{/if}}
Expand All @@ -14,6 +15,7 @@
<td class="pricing-profile-name">{{profile.name}}</td>
<td>{{profile.discountAmount}}</td>
<td>{{profile.discountPercentage}}</td>
<td>{{profile.setFee}}</td>
{{#if showActions}}
<td>
{{#if canEdit}}
Expand Down
51 changes: 51 additions & 0 deletions tests/acceptance/invoices-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,57 @@ test('print invoice', function(assert) {
});
});

// test pricing profile
test('pricing profiles', function(assert) {
runWithPouchDump('billing', function() {
authenticateUser();
visit('/pricing/profiles');
andThen(function() {
assert.equal(find('.btn-primary:contains(+ new item)').length, 1, 'We can add a new pricing profile');
click('button:contains(+ new item)');
waitToAppear('h4:contains(New Pricing Profile)');
});
// % discount
andThen(function() {
fillIn('.pricing-profile-name input', '50% profile');
fillIn('.pricing-profile-percentage input', '50');
click('button:contains(Add)');
waitToAppear('button:contains(Ok)');
click('button:contains(Ok)');
});
andThen(function() {
click('button:contains(+ new item)');
waitToAppear('h4:contains(New Pricing Profile)');
});
// flat discount
andThen(function() {
fillIn('.pricing-profile-name input', '$100 discount');
fillIn('.pricing-profile-discount input', '100');
click('button:contains(Add)');
waitToAppear('button:contains(Ok)');
click('button:contains(Ok)');
});
andThen(function() {
click('button:contains(+ new item)');
waitToAppear('h4:contains(New Pricing Profile)');
});
// flat fee
andThen(function() {
fillIn('.pricing-profile-name input', '$150 fee');
fillIn('.pricing-set-fee input', '150');
click('button:contains(Add)');
waitToAppear('button:contains(Ok)');
click('button:contains(Ok)');
});
visit('/invoices');
andThen(function() {
assert.equal(currentURL(), '/invoices');
assert.equal(find('.invoice-number:contains(inv00001)').length, 1, 'Invoice is available for modifying');
click('button:contains(Edit)');
});
});
});

test('delete invoice', function(assert) {
runWithPouchDump('billing', function() {
authenticateUser();
Expand Down