Merge branch 'develop' into invalid_message_fix

This commit is contained in:
Anand Baburajan 2022-12-01 12:35:04 +05:30 committed by GitHub
commit 5b1743330d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,16 +48,20 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
await this.calculate_shipping_charges(); await this.calculate_shipping_charges();
// Advance calculation applicable to Sales/Purchase Invoice // Advance calculation applicable to Sales/Purchase Invoice
if(in_list(["Sales Invoice", "POS Invoice", "Purchase Invoice"], this.frm.doc.doctype) if (
&& this.frm.doc.docstatus < 2 && !this.frm.doc.is_return) { in_list(["Sales Invoice", "POS Invoice", "Purchase Invoice"], this.frm.doc.doctype)
&& this.frm.doc.docstatus < 2
&& !this.frm.doc.is_return
) {
this.calculate_total_advance(update_paid_amount); this.calculate_total_advance(update_paid_amount);
} }
if (in_list(["Sales Invoice", "POS Invoice"], this.frm.doc.doctype) && this.frm.doc.is_pos && if (
this.frm.doc.is_return) { in_list(["Sales Invoice", "POS Invoice"], this.frm.doc.doctype)
if (this.frm.doc.doctype == "Sales Invoice") { && this.frm.doc.s_pos
&& this.frm.doc.is_return
) {
this.set_total_amount_to_default_mop(); this.set_total_amount_to_default_mop();
}
this.calculate_paid_amount(); this.calculate_paid_amount();
} }
@ -68,8 +72,11 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
} }
// Update paid amount on return/debit note creation // Update paid amount on return/debit note creation
if(this.frm.doc.doctype === "Purchase Invoice" && this.frm.doc.is_return if (
&& (this.frm.doc.grand_total > this.frm.doc.paid_amount)) { this.frm.doc.doctype === "Purchase Invoice"
&& this.frm.doc.is_return
&& (this.frm.doc.grand_total > this.frm.doc.paid_amount)
) {
this.frm.doc.paid_amount = flt(this.frm.doc.grand_total, precision("grand_total")); this.frm.doc.paid_amount = flt(this.frm.doc.grand_total, precision("grand_total"));
} }
@ -776,20 +783,29 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
let base_grand_total = this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total; let base_grand_total = this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total;
if (this.frm.doc.party_account_currency == this.frm.doc.currency) { if (this.frm.doc.party_account_currency == this.frm.doc.currency) {
var total_amount_to_pay = flt((grand_total - this.frm.doc.total_advance var total_amount_to_pay = flt(
- this.frm.doc.write_off_amount), precision("grand_total")); grand_total - this.frm.doc.total_advance - this.frm.doc.write_off_amount,
precision("grand_total")
);
} else { } else {
var total_amount_to_pay = flt( var total_amount_to_pay = flt(
(flt(base_grand_total, precision("base_grand_total")) (
- this.frm.doc.total_advance - this.frm.doc.base_write_off_amount), flt(
base_grand_total,
precision("base_grand_total")
)
- this.frm.doc.total_advance - this.frm.doc.base_write_off_amount
),
precision("base_grand_total") precision("base_grand_total")
); );
} }
this.frm.doc.payments.find(pay => { this.frm.doc.payments.find(pay => {
if (pay.default) { if (pay.default) {
pay.amount = total_amount_to_pay; pay.amount = total_amount_to_pay;
} }
}); });
this.frm.refresh_fields(); this.frm.refresh_fields();
} }