recalculate terms when document date changed (#12288)
* recalculate terms when document date changed * clean up
This commit is contained in:
parent
96b264b314
commit
650a1eeede
@ -521,6 +521,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
if(r.message) {
|
||||
me.frm.set_value("due_date", r.message);
|
||||
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() {
|
||||
return erpnext.get_currency(this.frm.doc.company);
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user