fix: in payment_entry 'Unallocated Amount' cal is broken #36369
Merged
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.
Business case:
for a customer who is paying more than his invoices amt,
Unallocated Amount
calculation should happen.at present it is not happening
Paid Amount : amt he is paying
Total Allocated Amount : amt total as per Sales Invoice
Unallocated Amount : extra amt, as he is paying more than total of pending
ie.
Unallocated Amount=Paid Amount-Total Allocated Amount
Actual :
Unallocated Amount remains empty
Expected:
Unallocated Amount=Paid Amount-Total Allocated Amount
Reason:
There is frm.doc.base_total_taxes_and_charges field used in calculation, which is undefined till the Payment Entry is saved.
hence, when this field is referred as part of calculation, it makes the entire calculation result as NaN
Ex:
unallocated_amount = (frm.doc.base_received_amount + total_deductions + frm.doc.base_total_taxes_and_charges - frm.doc.base_total_allocated_amount) / frm.doc.source_exchange_rate;
As, frm.doc.base_total_taxes_and_charges --> is undefined,
unallocated_amount result in NaN
Fix:
flt(frm.doc.base_total_taxes_and_charges) --> flt converts undefined to 0, and hence unallocated_amount calcuation becomes correct
Reference:
We have done similar fix.
#35239
GIF Before Fix
GIF After Fix