Calculate due date in Purchase Invoice on the basis of Supplier invoice date (#12913)

* pass bill_date as parameter and calculate due_date on that basis

* calculate payment_schedule on the basis of bill_date if present else posting_date

* add bill_date as an argument to get_party_details

* pass bill_date on supplier trigger in purchase invoice
This commit is contained in:
Shreya Shah
2018-02-16 13:05:21 +05:30
committed by Nabin Hait
parent 278af1befb
commit 3a9eec2e92
6 changed files with 50 additions and 42 deletions

View File

@@ -518,6 +518,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
args: {
"posting_date": me.frm.doc.posting_date,
"party_type": me.frm.doc.doctype == "Sales Invoice" ? "Customer" : "Supplier",
"bill_date": me.frm.doc.bill_date,
"party": me.frm.doc.doctype == "Sales Invoice" ? me.frm.doc.customer : me.frm.doc.supplier,
"company": me.frm.doc.company
},
@@ -561,9 +562,12 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
}
},
bill_date: function() {
this.posting_date();
},
recalculate_terms: function() {
const doc = this.frm.doc;
if (doc.payment_terms_template) {
this.payment_terms_template();
} else if (doc.payment_schedule) {
@@ -1272,14 +1276,14 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
var me = this;
const doc = this.frm.doc;
if(doc.payment_terms_template && doc.doctype !== 'Delivery Note') {
var posting_date = doc.bill_date || doc.posting_date || doc.transaction_date;
var posting_date = doc.posting_date || doc.transaction_date;
frappe.call({
method: "erpnext.controllers.accounts_controller.get_payment_terms",
args: {
terms_template: doc.payment_terms_template,
posting_date: posting_date,
grand_total: doc.rounded_total || doc.grand_total
grand_total: doc.rounded_total || doc.grand_total,
bill_date: doc.bill_date
},
callback: function(r) {
if(r.message && !r.exc) {
@@ -1297,6 +1301,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
method: "erpnext.controllers.accounts_controller.get_payment_term_details",
args: {
term: row.payment_term,
bill_date: this.frm.doc.bill_date,
posting_date: this.frm.doc.posting_date || this.frm.doc.transaction_date,
grand_total: this.frm.doc.rounded_total || this.frm.doc.grand_total
},