Skip to content

Commit

Permalink
fix: Creating landed cost voucher from connections
Browse files Browse the repository at this point in the history
(cherry picked from commit f2ceb00)
  • Loading branch information
Vishnu7025 authored and mergify[bot] committed May 18, 2023
1 parent 0a080ef commit 2631224
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions erpnext/public/js/controllers/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ frappe.ui.form.on("Sales Invoice", {
});

frappe.ui.form.on('Purchase Invoice', {
setup: (frm) => {
frm.make_methods = {
'Landed Cost Voucher': function () { frm.trigger('create_landedcost_voucher') },
}
},

mode_of_payment: function(frm) {
get_payment_mode_account(frm, frm.doc.mode_of_payment, function(account){
frm.set_value('cash_bank_account', account);
Expand All @@ -99,6 +105,20 @@ frappe.ui.form.on('Purchase Invoice', {

payment_terms_template: function() {
cur_frm.trigger("disable_due_date");
},

create_landedcost_voucher: function (frm) {
let lcv = frappe.model.get_new_doc('Landed Cost Voucher');
lcv.company = frm.doc.company;

let lcv_receipt = frappe.model.get_new_doc('Landed Cost Purchase Invoice');
lcv_receipt.receipt_document_type = 'Purchase Invoice';
lcv_receipt.receipt_document = frm.doc.name;
lcv_receipt.supplier = frm.doc.supplier;
lcv_receipt.grand_total = frm.doc.grand_total;
lcv.purchase_receipts = [lcv_receipt];

frappe.set_route("Form", lcv.doctype, lcv.name);
}
});

Expand Down

0 comments on commit 2631224

Please sign in to comment.