mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 14:39:19 +00:00
recalculate terms when document date changed (#12288)
* recalculate terms when document date changed * clean up
This commit is contained in:
@@ -521,6 +521,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
if(r.message) {
|
if(r.message) {
|
||||||
me.frm.set_value("due_date", r.message);
|
me.frm.set_value("due_date", r.message);
|
||||||
frappe.ui.form.trigger(me.frm.doc.doctype, "currency");
|
frappe.ui.form.trigger(me.frm.doc.doctype, "currency");
|
||||||
|
me.recalculate_terms();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -530,6 +531,29 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
recalculate_terms: function() {
|
||||||
|
const doc = this.frm.doc;
|
||||||
|
|
||||||
|
if (doc.payment_terms_template) {
|
||||||
|
this.payment_terms_template();
|
||||||
|
} else if (doc.payment_schedule) {
|
||||||
|
const me = this;
|
||||||
|
|
||||||
|
doc.payment_schedule.forEach(
|
||||||
|
function(term) {
|
||||||
|
if (term.payment_term) {
|
||||||
|
me.payment_term(doc, term.doctype, term.name);
|
||||||
|
} else {
|
||||||
|
frappe.model.set_value(
|
||||||
|
term.doctype, term.name, 'due_date',
|
||||||
|
doc.posting_date || doc.transaction_date
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
get_company_currency: function() {
|
get_company_currency: function() {
|
||||||
return erpnext.get_currency(this.frm.doc.company);
|
return erpnext.get_currency(this.frm.doc.company);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user