fix: Mode of payment getting overwritten by defautl mode of payment for returns
This commit is contained in:
@@ -629,6 +629,13 @@ class calculate_taxes_and_totals(object):
|
||||
self.doc.other_charges_calculation = get_itemised_tax_breakup_html(self.doc)
|
||||
|
||||
def update_paid_amount_for_return(self, total_amount_to_pay):
|
||||
existing_amount = 0
|
||||
|
||||
for payment in self.doc.payments:
|
||||
existing_amount += payment.amount
|
||||
|
||||
# do not override user entered amount if equal to total_amount_to_pay
|
||||
if existing_amount != total_amount_to_pay:
|
||||
default_mode_of_payment = frappe.db.get_value('Sales Invoice Payment',
|
||||
{'parent': self.doc.pos_profile, 'default': 1},
|
||||
['mode_of_payment', 'type', 'account'], as_dict=1)
|
||||
|
||||
@@ -672,6 +672,12 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
|
||||
);
|
||||
}
|
||||
|
||||
let existing_amount = 0
|
||||
$.each(this.frm.doc.payments || [], function(i, row) {
|
||||
existing_amount += row.amount;
|
||||
})
|
||||
|
||||
if (existing_amount != total_amount_to_pay) {
|
||||
frappe.db.get_value('Sales Invoice Payment', {'parent': this.frm.doc.pos_profile, 'default': 1},
|
||||
['mode_of_payment', 'account', 'type'], (value) => {
|
||||
if (this.frm.is_dirty()) {
|
||||
@@ -687,10 +693,12 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
|
||||
this.frm.set_value('is_pos', 1);
|
||||
}
|
||||
this.frm.refresh_fields();
|
||||
this.calculate_paid_amount();
|
||||
}
|
||||
}, 'Sales Invoice');
|
||||
|
||||
} else {
|
||||
this.calculate_paid_amount();
|
||||
}
|
||||
},
|
||||
|
||||
set_default_payment: function(total_amount_to_pay, update_paid_amount) {
|
||||
|
||||
Reference in New Issue
Block a user