mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
fix due_date autopopulate commit
This commit is contained in:
@@ -185,24 +185,38 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
due_date_options_cache: {},
|
||||||
|
|
||||||
reference_name: function(doc, cdt, cdn) {
|
reference_name: function(doc, cdt, cdn) {
|
||||||
var d = frappe.get_doc(cdt, cdn);
|
var d = frappe.get_doc(cdt, cdn);
|
||||||
|
var me = this;
|
||||||
|
|
||||||
const get_invoice_due_dates = (invoice_name) => {
|
const get_invoice_due_dates = invoice_name => {
|
||||||
frappe.call({
|
const options = this.due_date_options_cache[invoice_name];
|
||||||
method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_invoice_due_dates",
|
const input = $(cur_frm.fields_dict["accounts"].wrapper).find("select[data-fieldname=reference_due_date]");
|
||||||
args: {name: invoice_name},
|
|
||||||
callback: function(r){
|
|
||||||
const wrapper = cur_frm.fields_dict["accounts"].wrapper;
|
|
||||||
const input = $(wrapper).find("select[data-fieldname=reference_due_date]");
|
|
||||||
|
|
||||||
input.children('option').remove();
|
if (options) {
|
||||||
|
input.empty();
|
||||||
$.each(r.message, function(key, value) {
|
input.add_options(options);
|
||||||
input.append(new Option(value.due_date, "", false, false));
|
frappe.model.set_value(cdt, cdn, "reference_due_date", options[0]);
|
||||||
});
|
}
|
||||||
}
|
else {
|
||||||
});
|
frappe.call({
|
||||||
|
method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_invoice_due_dates",
|
||||||
|
args: {name: invoice_name},
|
||||||
|
callback: function(r) {
|
||||||
|
const options = [];
|
||||||
|
$.each(r.message, function(key, value) {
|
||||||
|
options.push(value.due_date);
|
||||||
|
});
|
||||||
|
input.empty();
|
||||||
|
input.add_options(options);
|
||||||
|
frappe.model.set_value(cdt, cdn, "reference_due_date", options[0]);
|
||||||
|
me.due_date_options_cache[d.reference_name] = options;
|
||||||
|
console.log("input:", input);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(d.reference_name) {
|
if(d.reference_name) {
|
||||||
@@ -215,7 +229,7 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({
|
|||||||
if (d.reference_type==="Journal Entry" && !flt(d.credit) && !flt(d.debit)) {
|
if (d.reference_type==="Journal Entry" && !flt(d.credit) && !flt(d.debit)) {
|
||||||
this.get_outstanding('Journal Entry', d.reference_name, doc.company, d);
|
this.get_outstanding('Journal Entry', d.reference_name, doc.company, d);
|
||||||
}
|
}
|
||||||
if( in_list(d.reference_type), ["Sales Invoice", "Purchase Invoice"]) {
|
if( in_list(["Sales Invoice", "Purchase Invoice"]), d.reference_type) {
|
||||||
get_invoice_due_dates(d.reference_name);
|
get_invoice_due_dates(d.reference_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user