Skip to content

Commit

Permalink
fix: fix creating documents from sales invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
Meike Nedwidek committed Jan 20, 2025
1 parent 5fb158a commit 135716c
Showing 1 changed file with 21 additions and 28 deletions.
49 changes: 21 additions & 28 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
setup(doc) {
this.setup_posting_date_time_check();
super.setup(doc);
this.frm.make_methods = {
Dunning: this.make_dunning.bind(this),
"Invoice Discounting": this.make_invoice_discounting.bind(this),
};
}
company() {
super.company();
Expand Down Expand Up @@ -125,12 +129,9 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
},
__("Create")
);

this.frm.add_custom_button(
__("Invoice Discounting"),
function () {
this.frm.events.create_invoice_discounting(this.frm);
},
this.make_invoice_discounting.bind(this),
__("Create")
);

Expand All @@ -139,22 +140,14 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
.reduce((prev, current) => prev || current, false);

if (payment_is_overdue) {
this.frm.add_custom_button(
__("Dunning"),
() => {
this.frm.events.create_dunning(this.frm);
},
__("Create")
);
this.frm.add_custom_button(__("Dunning"), this.make_dunning.bind(this), __("Create"));
}
}

if (doc.docstatus === 1) {
this.frm.add_custom_button(
__("Maintenance Schedule"),
function () {
this.frm.cscript.make_maintenance_schedule();
},
this.make_maintenance_schedule.bind(this),
__("Create")
);
}
Expand Down Expand Up @@ -189,6 +182,20 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
erpnext.accounts.unreconcile_payment.add_unreconcile_btn(me.frm);
}

make_invoice_discounting() {
frappe.model.open_mapped_doc({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_invoice_discounting",
frm: this.frm,
});
}

make_dunning() {
frappe.model.open_mapped_doc({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_dunning",
frm: this.frm,
});
}

make_maintenance_schedule() {
frappe.model.open_mapped_doc({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_maintenance_schedule",
Expand Down Expand Up @@ -1044,20 +1051,6 @@ frappe.ui.form.on("Sales Invoice", {
frm.set_df_property("return_against", "label", __("Adjustment Against"));
}
},

create_invoice_discounting: function (frm) {
frappe.model.open_mapped_doc({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_invoice_discounting",
frm: frm,
});
},

create_dunning: function (frm) {
frappe.model.open_mapped_doc({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_dunning",
frm: frm,
});
},
});

frappe.ui.form.on("Sales Invoice Timesheet", {
Expand Down

0 comments on commit 135716c

Please sign in to comment.