mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-17 00:25:01 +00:00
Merge pull request #48983 from diptanilsaha/pos_grand_total_default_mop
refactor(pos): disable grand total to default mode of payment
This commit is contained in:
@@ -421,6 +421,7 @@ erpnext.PointOfSale.Controller = class {
|
||||
init_payments() {
|
||||
this.payment = new erpnext.PointOfSale.Payment({
|
||||
wrapper: this.$components_wrapper,
|
||||
settings: this.settings,
|
||||
events: {
|
||||
get_frm: () => this.frm || {},
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
erpnext.PointOfSale.Payment = class {
|
||||
constructor({ events, wrapper }) {
|
||||
constructor({ events, settings, wrapper }) {
|
||||
this.wrapper = wrapper;
|
||||
this.events = events;
|
||||
this.disable_grand_total_to_default_mop = settings.disable_grand_total_to_default_mop;
|
||||
|
||||
this.init_component();
|
||||
}
|
||||
@@ -341,10 +342,11 @@ erpnext.PointOfSale.Payment = class {
|
||||
}
|
||||
|
||||
render_payment_section() {
|
||||
this.remove_grand_total_from_default_mop();
|
||||
this.render_payment_mode_dom();
|
||||
this.make_invoice_fields_control();
|
||||
this.update_totals_section();
|
||||
this.unset_grand_total_to_default_mop();
|
||||
this.focus_on_default_mop();
|
||||
}
|
||||
|
||||
after_render() {
|
||||
@@ -446,7 +448,19 @@ erpnext.PointOfSale.Payment = class {
|
||||
this.attach_cash_shortcuts(doc);
|
||||
}
|
||||
|
||||
remove_grand_total_from_default_mop() {
|
||||
if (!this.disable_grand_total_to_default_mop) return;
|
||||
const doc = this.events.get_frm().doc;
|
||||
const payments = doc.payments;
|
||||
payments.forEach((p) => {
|
||||
if (p.default) {
|
||||
frappe.model.set_value(p.doctype, p.name, "amount", 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
focus_on_default_mop() {
|
||||
if (this.disable_grand_total_to_default_mop) return;
|
||||
const doc = this.events.get_frm().doc;
|
||||
const payments = doc.payments;
|
||||
payments.forEach((p) => {
|
||||
@@ -629,19 +643,6 @@ erpnext.PointOfSale.Payment = class {
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
async unset_grand_total_to_default_mop() {
|
||||
const doc = this.events.get_frm().doc;
|
||||
let r = await frappe.db.get_value(
|
||||
"POS Profile",
|
||||
doc.pos_profile,
|
||||
"disable_grand_total_to_default_mop"
|
||||
);
|
||||
|
||||
if (!r.message.disable_grand_total_to_default_mop) {
|
||||
this.focus_on_default_mop();
|
||||
}
|
||||
}
|
||||
|
||||
validate_reqd_invoice_fields() {
|
||||
const doc = this.events.get_frm().doc;
|
||||
let validation_flag = true;
|
||||
|
||||
Reference in New Issue
Block a user