Set due date in purchase invoice based on suppler invoice date (#12395)
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 81d2786..8de1a12 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -666,7 +666,7 @@
self.remove(item)
def set_payment_schedule(self):
- posting_date = self.get("posting_date") or self.get("transaction_date")
+ posting_date = self.get("bill_date") or self.get("posting_date") or self.get("transaction_date")
date = self.get("due_date")
due_date = date or posting_date
grand_total = self.get("rounded_total") or self.grand_total
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index c37a617..9ee82d2 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -1261,11 +1261,14 @@
payment_terms_template: function() {
var me = this;
if(this.frm.doc.payment_terms_template) {
+ var posting_date = this.frm.doc.bill_date ||
+ this.frm.doc.posting_date || this.frm.doc.transaction_date;
+
frappe.call({
method: "erpnext.controllers.accounts_controller.get_payment_terms",
args: {
terms_template: this.frm.doc.payment_terms_template,
- posting_date: this.frm.doc.posting_date || this.frm.doc.transaction_date,
+ posting_date: posting_date,
grand_total: this.frm.doc.rounded_total || this.frm.doc.grand_total
},
callback: function(r) {