Merge pull request #29991 from nextchamp-saqib/fix-pos-mop

fix(pos): minor fixes
This commit is contained in:
Saqib Ansari 2022-02-25 15:35:24 +05:30 committed by GitHub
commit dd566a68f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 19 deletions

View File

@ -439,7 +439,6 @@ class POSInvoice(SalesInvoice):
self.paid_amount = 0
def set_account_for_mode_of_payment(self):
self.payments = [d for d in self.payments if d.amount or d.base_amount or d.default]
for pay in self.payments:
if not pay.account:
pay.account = get_bank_cash_account(pay.mode_of_payment, self.company).get("account")

View File

@ -2285,13 +2285,17 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
}
coupon_code() {
var me = this;
frappe.run_serially([
() => this.frm.doc.ignore_pricing_rule=1,
() => me.ignore_pricing_rule(),
() => this.frm.doc.ignore_pricing_rule=0,
() => me.apply_pricing_rule()
]);
if (this.frm.doc.coupon_code || this.frm._last_coupon_code) {
// reset pricing rules if coupon code is set or is unset
const _ignore_pricing_rule = this.frm.doc.ignore_pricing_rule;
return frappe.run_serially([
() => this.frm.doc.ignore_pricing_rule=1,
() => this.frm.trigger('ignore_pricing_rule'),
() => this.frm.doc.ignore_pricing_rule=_ignore_pricing_rule,
() => this.frm.trigger('apply_pricing_rule'),
() => this.frm._last_coupon_code = this.frm.doc.coupon_code
]);
}
}
};

View File

@ -170,17 +170,20 @@ erpnext.PointOfSale.Payment = class {
});
frappe.ui.form.on('POS Invoice', 'coupon_code', (frm) => {
if (!frm.doc.ignore_pricing_rule) {
if (frm.doc.coupon_code) {
frappe.run_serially([
() => frm.doc.ignore_pricing_rule=1,
() => frm.trigger('ignore_pricing_rule'),
() => frm.doc.ignore_pricing_rule=0,
() => frm.trigger('apply_pricing_rule'),
() => frm.save(),
() => this.update_totals_section(frm.doc)
]);
}
if (!frm.doc.ignore_pricing_rule && frm.doc.coupon_code) {
frappe.run_serially([
() => frm.doc.ignore_pricing_rule=1,
() => frm.trigger('ignore_pricing_rule'),
() => frm.doc.ignore_pricing_rule=0,
() => frm.trigger('apply_pricing_rule'),
() => frm.save(),
() => this.update_totals_section(frm.doc)
]);
} else if (frm.doc.ignore_pricing_rule && frm.doc.coupon_code) {
frappe.show_alert({
message: __("Ignore Pricing Rule is enabled. Cannot apply coupon code."),
indicator: "orange"
});
}
});