This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fixes Issue 467 #538
Closed
+27
−4
Closed
Fixes Issue 467 #538
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ export default AbstractModel.extend(DateFormat, NumberFormat, { | |
visit: DS.belongsTo('visit', { | ||
async: false | ||
}), | ||
lastUnpaidStatus: DS.attr('string'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this status is necessary. See code comments below. |
||
status: DS.attr('string'), | ||
remarks: DS.attr('string'), | ||
billDate: DS.attr('date'), | ||
|
@@ -108,14 +109,23 @@ export default AbstractModel.extend(DateFormat, NumberFormat, { | |
patientResponsibility: Ember.computed.sum('patientResponsibilityTotals'), | ||
|
||
paymentAmountChanged: function() { | ||
var payments = this.get('payments'), | ||
paidTotal = payments.reduce(function(previousValue, payment) { | ||
var payments = this.get('payments'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this code block could be simplified to just keep track of if the payments are valid and then set the status to paid if remainingBalance <=0 and hasValidPayments === true. There really isn't a need to do anything if those conditions are untrue. There shouldn't be a need to reset the status back to the status it is already set to. |
||
var hasValidPayments = false; | ||
var paidTotal = payments.reduce(function(previousValue, payment) { | ||
if (payment.get('isValid')) { | ||
hasValidPayments = true; | ||
return previousValue += this._getValidNumber(payment.get('amount')); | ||
}.bind(this), 0); | ||
} | ||
}.bind(this), 0); | ||
this.set('paidTotal', this._numberFormat(paidTotal, true)); | ||
var remainingBalance = this.get('remainingBalance'); | ||
if (remainingBalance <= 0) { | ||
if (remainingBalance <= 0 && hasValidPayments) { | ||
if (this.get('status') !== 'Paid') { | ||
this.set('lastUnpaidStatus', this.get('status')); | ||
} | ||
this.set('status', 'Paid'); | ||
} else if (this.get('status') == 'Paid') { | ||
this.set('status', this.get('lastUnpaidStatus')); | ||
} | ||
}.observes('payments.[]', '[email protected]'), | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cleanup code should not save the model because the model should not be saved on the cancel action, it should only be saved when the user clicks on the update/add action which is already handled elsewhere in the controller.