Posting date trigger function commonified
This commit is contained in:
parent
4770a1abb5
commit
40e92b679b
@ -69,32 +69,6 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
||||
}
|
||||
},
|
||||
|
||||
posting_date: function() {
|
||||
var me = this;
|
||||
if (this.frm.doc.posting_date) {
|
||||
if (this.frm.doc.supplier) {
|
||||
return frappe.call({
|
||||
method: "erpnext.accounts.party.get_due_date",
|
||||
args: {
|
||||
"posting_date": me.frm.doc.posting_date,
|
||||
"party_type": "Supplier",
|
||||
"party": me.frm.doc.supplier,
|
||||
"company": me.frm.doc.company
|
||||
},
|
||||
callback: function(r, rt) {
|
||||
if(r.message) {
|
||||
me.frm.set_value("due_date", r.message);
|
||||
}
|
||||
erpnext.get_fiscal_year(me.frm.doc.company, me.frm.doc.posting_date);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
erpnext.get_fiscal_year(me.frm.doc.company, me.frm.doc.posting_date);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
supplier: function() {
|
||||
var me = this;
|
||||
if(this.frm.updating_party_details)
|
||||
|
@ -146,33 +146,6 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
posting_date: function() {
|
||||
var me = this;
|
||||
if (this.frm.doc.posting_date) {
|
||||
if (this.frm.doc.customer) {
|
||||
return frappe.call({
|
||||
method: "erpnext.accounts.party.get_due_date",
|
||||
args: {
|
||||
"posting_date": me.frm.doc.posting_date,
|
||||
"party_type": "Customer",
|
||||
"party": me.frm.doc.customer,
|
||||
"company": me.frm.doc.company
|
||||
},
|
||||
callback: function(r, rt) {
|
||||
if(r.message) {
|
||||
me.frm.set_value("due_date", r.message);
|
||||
}
|
||||
erpnext.get_fiscal_year(me.frm.doc.company, me.frm.doc.posting_date);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
erpnext.get_fiscal_year(me.frm.doc.company, me.frm.doc.posting_date);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
customer: function() {
|
||||
var me = this;
|
||||
|
@ -254,7 +254,29 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
},
|
||||
|
||||
posting_date: function() {
|
||||
erpnext.get_fiscal_year(this.frm.doc.company, this.frm.doc.posting_date);
|
||||
var me = this;
|
||||
if (this.frm.doc.posting_date) {
|
||||
if ((this.frm.doc.doctype == "Sales Invoice" && this.frm.doc.customer) ||
|
||||
(this.frm.doc.doctype == "Purchase Invoice" && this.frm.doc.supplier)) {
|
||||
return frappe.call({
|
||||
method: "erpnext.accounts.party.get_due_date",
|
||||
args: {
|
||||
"posting_date": me.frm.doc.posting_date,
|
||||
"party_type": me.frm.doc.doctype == "Sales Invoice" ? "Customer" : "Supplier",
|
||||
"party": me.frm.doc.doctype == "Sales Invoice" ? me.frm.doc.customer : me.frm.doc.supplier,
|
||||
"company": me.frm.doc.company
|
||||
},
|
||||
callback: function(r, rt) {
|
||||
if(r.message) {
|
||||
me.frm.set_value("due_date", r.message);
|
||||
}
|
||||
erpnext.get_fiscal_year(me.frm.doc.company, me.frm.doc.posting_date);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
erpnext.get_fiscal_year(me.frm.doc.company, me.frm.doc.posting_date);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
get_company_currency: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user