enhance reference_due_date behaviour:
- creates new api - get_invoice_due_dates - when reference_name is changed, populate reference_due_date
This commit is contained in:
parent
2883662ccb
commit
08d8ca0184
@ -187,6 +187,24 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({
|
||||
|
||||
reference_name: function(doc, cdt, cdn) {
|
||||
var d = frappe.get_doc(cdt, cdn);
|
||||
|
||||
const get_invoice_due_dates = (invoice_name) => {
|
||||
frappe.call({
|
||||
method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_invoice_due_dates",
|
||||
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();
|
||||
|
||||
$.each(r.message, function(key, value) {
|
||||
input.append(new Option(value.due_date, "", false, false));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(d.reference_name) {
|
||||
if (d.reference_type==="Purchase Invoice" && !flt(d.debit)) {
|
||||
this.get_outstanding('Purchase Invoice', d.reference_name, doc.company, d);
|
||||
@ -197,6 +215,9 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({
|
||||
if (d.reference_type==="Journal Entry" && !flt(d.credit) && !flt(d.debit)) {
|
||||
this.get_outstanding('Journal Entry', d.reference_name, doc.company, d);
|
||||
}
|
||||
if( in_list(d.reference_type), ["Sales Invoice", "Purchase Invoice"]) {
|
||||
get_invoice_due_dates(d.reference_name);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -889,3 +889,14 @@ def get_average_exchange_rate(account):
|
||||
exchange_rate = bank_balance_in_company_currency / bank_balance_in_account_currency
|
||||
|
||||
return exchange_rate
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_invoice_due_dates(name):
|
||||
result = frappe.get_list(
|
||||
doctype='GL Entry', group_by='name, due_date',
|
||||
filters={'voucher_no': name, "ifnull(due_date, '')": ('!=', '')},
|
||||
fields=['due_date'], distinct=True
|
||||
)
|
||||
|
||||
return result
|
||||
|
Loading…
x
Reference in New Issue
Block a user