From 3b2998554d87ce510247c3017044f8da96bc0a1e Mon Sep 17 00:00:00 2001 From: Zain Date: Mon, 19 Aug 2024 10:13:41 +0000 Subject: [PATCH 1/6] chore: WIP commit (switch laptop) --- .../doctype/customs_tariff_tax/__init__.py | 0 .../customs_tariff_tax.json | 50 +++++ .../customs_tariff_tax/customs_tariff_tax.py | 8 + .../purchase_invoice/purchase_invoice.js | 183 ++++++++++++------ .../purchase_invoice/purchase_invoice.json | 15 +- .../purchase_invoice/purchase_invoice.py | 28 +++ .../purchase_taxes_and_charges.json | 4 +- erpnext/controllers/taxes_and_totals.py | 27 +++ erpnext/public/js/controllers/accounts.js | 99 +++++++++- .../public/js/controllers/taxes_and_totals.js | 33 +++- erpnext/public/js/controllers/transaction.js | 9 +- erpnext/stock/doctype/item/item.json | 2 +- erpnext/stock/get_item_details.py | 1 + 13 files changed, 390 insertions(+), 69 deletions(-) create mode 100644 erpnext/accounts/doctype/customs_tariff_tax/__init__.py create mode 100644 erpnext/accounts/doctype/customs_tariff_tax/customs_tariff_tax.json create mode 100644 erpnext/accounts/doctype/customs_tariff_tax/customs_tariff_tax.py diff --git a/erpnext/accounts/doctype/customs_tariff_tax/__init__.py b/erpnext/accounts/doctype/customs_tariff_tax/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/erpnext/accounts/doctype/customs_tariff_tax/customs_tariff_tax.json b/erpnext/accounts/doctype/customs_tariff_tax/customs_tariff_tax.json new file mode 100644 index 000000000000..0c79819e7693 --- /dev/null +++ b/erpnext/accounts/doctype/customs_tariff_tax/customs_tariff_tax.json @@ -0,0 +1,50 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2024-07-18 14:18:35.943218", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "customs_tariff_no", + "account_head", + "amount" + ], + "fields": [ + { + "fieldname": "account_head", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Account Head", + "options": "Account", + "read_only": 1 + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "options": "currency" + }, + { + "fieldname": "customs_tariff_no", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Customs Tariff Number", + "options": "Customs Tariff Number", + "read_only": 1 + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2024-08-13 13:35:13.118862", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Customs Tariff Tax", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/customs_tariff_tax/customs_tariff_tax.py b/erpnext/accounts/doctype/customs_tariff_tax/customs_tariff_tax.py new file mode 100644 index 000000000000..a4b7b5ec5e4c --- /dev/null +++ b/erpnext/accounts/doctype/customs_tariff_tax/customs_tariff_tax.py @@ -0,0 +1,8 @@ +# Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + +class CustomsTariffTax(Document): + pass diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 1b166bcf8e0c..f537e114da6e 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -12,14 +12,77 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. onload() { super.onload(); - if(!this.frm.doc.__islocal) { + if (!this.frm.doc.__islocal) { // show credit_to in print format - if(!this.frm.doc.supplier && this.frm.doc.credit_to) { + if (!this.frm.doc.supplier && this.frm.doc.credit_to) { this.frm.set_df_property("credit_to", "print_hide", 0); } } } + // item_code(doc, cdt, cdn) { + // let row = frappe.get_doc(cdt, cdn); + // console.log(row.customs_tariff_no); + // // this.get_item_details(row); + + // } + + // charge_type(doc, cdt, cdn) { + // let row = frappe.get_doc(cdt, cdn); + // this.populate_customs_tariff_number_table(cdt,cdn) + // } + + // account_head(doc,cdt,cdn){ + // let row = frappe.get_doc(cdt, cdn); + // this.populate_customs_tariff_number_table(cdt,cdn) + // } + + // before_taxes_remove(doc, cdt, cdn){ + // console.log("hello"); + // let row = frappe.get_doc(cdt, cdn); + // console.log(row.account_head); + // this.delete_rows(cdt, cdn) + // } + + + + + populate_customs_tariff_number_table(cdt, cdn) { + let numberOfItems = this.frm.doc.items.length; + console.log(numberOfItems); // Output the number of items to the console + console.log(this.frm.doc.items[0]) + let row = frappe.get_doc(cdt, cdn) + let customs_tariff_no = this.frm.doc.items[0].customs_tariff_no; + console.log(customs_tariff_no); + if (row.charge_type == "On HS Code" && row.account_head!==undefined && customs_tariff_no!==undefined){ + for (let i = 0; i < this.frm.doc.items.length; i++){ + console.log(i); + this.frm.toggle_display('customs_tariff_tax', true); + let rows = this.frm.add_child('customs_tariff_tax', { + account_head: row.account_head, + customs_tariff_number: this.frm.doc.items[i].customs_tariff_no + }); + } + this.frm.debounced_refresh_fields(); + } + } + + // amount(doc, cdt, cdn){ + // console.log("hello amount"); + // let row = frappe.get_doc(cdt, cdn); + // let total_cost = this.frm.doc.items[0].amount; + // let qty = this.frm.doc.items[0].qty; + // this.frm.doc.total_taxes_and_charges = (row.amount/total_cost)*qty; + // console.log(this.frm.doc.total_taxes_and_charges) + // } + + + + // this -> controller class + // this.frm -> form object + // this.frm.doc -> document object (data model) + + refresh(doc) { const me = this; super.refresh(); @@ -48,19 +111,19 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. ); this.frm.add_custom_button( __('Unblock Invoice'), - function() {me.unblock_invoice()}, + function () { me.unblock_invoice() }, __('Hold Invoice') ); } else if (!doc.on_hold) { this.frm.add_custom_button( __('Block Invoice'), - function() {me.block_invoice()}, + function () { me.block_invoice() }, __('Hold Invoice') ); } } - if( + if ( doc.docstatus == 1 && doc.outstanding_amount != 0 && !(doc.is_return && doc.return_against) @@ -71,7 +134,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. this.frm.page.set_inner_btn_group_as_primary(__('Create')); } - if (!doc.is_return && doc.docstatus==1) { + if (!doc.is_return && doc.docstatus == 1) { if ( (doc.outstanding_amount >= 0 || Math.abs(flt(doc.outstanding_amount)) < flt(doc.grand_total)) && frappe.model.can_create("Purchase Invoice") @@ -86,19 +149,19 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. } if (!doc.auto_repeat && frappe.model.can_create("Auto Repeat")) { - this.frm.add_custom_button(__('Subscription'), function() { + this.frm.add_custom_button(__('Subscription'), function () { erpnext.utils.make_subscription(doc.doctype, doc.name) }, __('Create')) } } if (doc.outstanding_amount > 0 && !cint(doc.is_return) && frappe.model.can_create("Payment Request")) { - this.frm.add_custom_button(__('Payment Request'), function() { + this.frm.add_custom_button(__('Payment Request'), function () { me.make_payment_request() }, __('Create')); } - if (doc.docstatus===0) { + if (doc.docstatus === 0) { if (frappe.model.can_read("Purchase Receipt")) { this.frm.add_custom_button(__('Purchase Receipt'), function () { erpnext.utils.map_current_doc({ @@ -173,7 +236,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. if (doc.docstatus == 1 && !doc.inter_company_reference) { if (me.frm.doc.__onload?.is_internal_supplier) { - me.frm.add_custom_button("Inter Company Invoice", function() { + me.frm.add_custom_button("Inter Company Invoice", function () { me.make_inter_company_invoice(me.frm); }, __('Create')); } @@ -190,7 +253,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. const me = this; frappe.call({ 'method': 'erpnext.accounts.doctype.purchase_invoice.purchase_invoice.unblock_invoice', - 'args': {'name': me.frm.doc.name}, + 'args': { 'name': me.frm.doc.name }, 'callback': (r) => me.frm.reload_doc() }); } @@ -218,12 +281,12 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. var dialog = new frappe.ui.Dialog({ title: __("Customer"), fields: [ - {"fieldtype": "Link", "label": __("Customer"), "fieldname": "customer", "options":"Customer", "mandatory":true}, - {"fieldtype": "Button", "label": __("Make Sales Order"), "fieldname": "make_sales_order", "cssClass": "btn-primary"}, + { "fieldtype": "Link", "label": __("Customer"), "fieldname": "customer", "options": "Customer", "mandatory": true }, + { "fieldtype": "Button", "label": __("Make Sales Order"), "fieldname": "make_sales_order", "cssClass": "btn-primary" }, ] }); - dialog.fields_dict.make_sales_order.$input.click(function() { + dialog.fields_dict.make_sales_order.$input.click(function () { var args = dialog.get_values(); dialog.hide(); return frappe.call({ @@ -234,8 +297,8 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. "source_name": me.frm.doc.name }, freeze: true, - callback: function(r) { - if(!r.exc) { + callback: function (r) { + if (!r.exc) { var doc = frappe.model.sync(r.message); frappe.set_route("Form", r.message.doctype, r.message.name); } @@ -253,7 +316,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. { fieldname: 'release_date', read_only: 0, - fieldtype:'Date', + fieldtype: 'Date', label: __('Release Date'), default: me.frm.doc.release_date, reqd: 1 @@ -261,7 +324,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. { fieldname: 'hold_comment', read_only: 0, - fieldtype:'Small Text', + fieldtype: 'Small Text', label: __('Reason For Putting On Hold'), default: "" }, @@ -272,7 +335,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. fields: fields }); - this.dialog.set_primary_action(__('Save'), function() { + this.dialog.set_primary_action(__('Save'), function () { const dialog_data = me.dialog.get_values(); frappe.call({ 'method': 'erpnext.accounts.doctype.purchase_invoice.purchase_invoice.block_invoice', @@ -297,7 +360,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. { fieldname: 'release_date', read_only: 0, - fieldtype:'Date', + fieldtype: 'Date', label: __('Release Date'), default: me.frm.doc.release_date }, @@ -308,9 +371,9 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. fields: fields }); - this.dialog.set_primary_action(__('Save'), function() { + this.dialog.set_primary_action(__('Save'), function () { me.dialog_data = me.dialog.get_values(); - if(me.can_change_release_date(me.dialog_data.release_date)) { + if (me.can_change_release_date(me.dialog_data.release_date)) { me.dialog_data.name = me.frm.doc.name; me.set_release_date(me.dialog_data); me.dialog.hide(); @@ -337,7 +400,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. } set_party_details() { - if(this.frm.updating_party_details) + if (this.frm.updating_party_details) return; var me = this; @@ -350,7 +413,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. letter_of_credit: this.frm.doc.letter_of_credit, account: this.frm.doc.credit_to, price_list: this.frm.doc.buying_price_list - }, function() { + }, function () { me.apply_pricing_rule(); me.frm.doc.apply_tds = me.frm.supplier_tds ? 1 : 0; me.frm.doc.tax_withholding_category = me.frm.supplier_tds; @@ -374,7 +437,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. credit_to() { var me = this; - if(this.frm.doc.credit_to) { + if (this.frm.doc.credit_to) { me.frm.call({ method: "frappe.client.get_value", args: { @@ -382,8 +445,8 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. fieldname: "account_currency", filters: { name: me.frm.doc.credit_to }, }, - callback: function(r, rt) { - if(r.message) { + callback: function (r, rt) { + if (r.message) { me.frm.set_value("party_account_currency", r.message.account_currency); me.set_dynamic_labels(); } @@ -400,9 +463,9 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. } is_paid() { - if(cint(this.frm.doc.is_paid)) { + if (cint(this.frm.doc.is_paid)) { this.frm.set_value("allocate_advances_automatically", 0); - if(!this.frm.doc.company) { + if (!this.frm.doc.company) { this.frm.set_value("is_paid", 0) frappe.msgprint(__("Please specify Company to proceed")); } @@ -435,8 +498,8 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. } on_submit() { - $.each(this.frm.doc["items"] || [], function(i, row) { - if(row.purchase_receipt) frappe.model.clear_doc("Purchase Receipt", row.purchase_receipt) + $.each(this.frm.doc["items"] || [], function (i, row) { + if (row.purchase_receipt) frappe.model.clear_doc("Purchase Receipt", row.purchase_receipt) }) } @@ -456,33 +519,33 @@ function hide_fields(doc) { var item_fields_stock = ['warehouse_section', 'received_qty', 'rejected_qty']; cur_frm.fields_dict['items'].grid.set_column_disp(item_fields_stock, - (cint(doc.update_stock)==1 || cint(doc.is_return)==1 ? true : false)); + (cint(doc.update_stock) == 1 || cint(doc.is_return) == 1 ? true : false)); } -cur_frm.cscript.update_stock = function(doc, dt, dn) { +cur_frm.cscript.update_stock = function (doc, dt, dn) { hide_fields(doc, dt, dn); - this.frm.fields_dict.items.grid.toggle_reqd("item_code", doc.update_stock? true: false) + this.frm.fields_dict.items.grid.toggle_reqd("item_code", doc.update_stock ? true : false) } -cur_frm.fields_dict.cash_bank_account.get_query = function(doc) { +cur_frm.fields_dict.cash_bank_account.get_query = function (doc) { return { filters: [ ["Account", "account_type", "in", ["Cash", "Bank"]], - ["Account", "is_group", "=",0], + ["Account", "is_group", "=", 0], ["Account", "company", "=", doc.company], ["Account", "report_type", "=", "Balance Sheet"] ] } } -cur_frm.fields_dict['items'].grid.get_field("item_code").get_query = function(doc, cdt, cdn) { +cur_frm.fields_dict['items'].grid.get_field("item_code").get_query = function (doc, cdt, cdn) { return { query: "erpnext.controllers.queries.item_query", - filters: {'is_purchase_item': 1} + filters: { 'is_purchase_item': 1 } } } -cur_frm.fields_dict['credit_to'].get_query = function(doc) { +cur_frm.fields_dict['credit_to'].get_query = function (doc) { // filter on Account return { filters: { @@ -494,33 +557,33 @@ cur_frm.fields_dict['credit_to'].get_query = function(doc) { } // Get Print Heading -cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) { +cur_frm.fields_dict['select_print_heading'].get_query = function (doc, cdt, cdn) { return { - filters:[ + filters: [ ['Print Heading', 'docstatus', '!=', 2] ] } } -cur_frm.set_query("expense_account", "items", function(doc) { +cur_frm.set_query("expense_account", "items", function (doc) { return { query: "erpnext.controllers.queries.get_expense_account", - filters: {'company': doc.company } + filters: { 'company': doc.company } } }); -cur_frm.cscript.expense_account = function(doc, cdt, cdn){ +cur_frm.cscript.expense_account = function (doc, cdt, cdn) { var d = locals[cdt][cdn]; - if(d.idx == 1 && d.expense_account){ + if (d.idx == 1 && d.expense_account) { var cl = doc.items || []; - for(var i = 0; i < cl.length; i++){ - if(!cl[i].expense_account) cl[i].expense_account = d.expense_account; + for (var i = 0; i < cl.length; i++) { + if (!cl[i].expense_account) cl[i].expense_account = d.expense_account; } } refresh_field('items'); } -cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function(doc) { +cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function (doc) { return { filters: { 'company': doc.company, @@ -530,16 +593,16 @@ cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function( } } -cur_frm.fields_dict['items'].grid.get_field('project').get_query = function(doc, cdt, cdn) { - return{ - filters:[ +cur_frm.fields_dict['items'].grid.get_field('project').get_query = function (doc, cdt, cdn) { + return { + filters: [ ['Project', 'status', 'not in', 'Completed, Cancelled'] ] } } frappe.ui.form.on("Purchase Invoice", { - setup: function(frm) { + setup: function (frm) { frm.custom_make_buttons = { 'Purchase Invoice': 'Return / Debit Note', 'Payment Entry': 'Payment', @@ -548,7 +611,7 @@ frappe.ui.form.on("Purchase Invoice", { 'Payment Request': 'Payment Request', } - frm.fields_dict['items'].grid.get_field('deferred_expense_account').get_query = function(doc) { + frm.fields_dict['items'].grid.get_field('deferred_expense_account').get_query = function (doc) { return { filters: { 'root_type': 'Asset', @@ -558,7 +621,7 @@ frappe.ui.form.on("Purchase Invoice", { } } - frm.set_query("cost_center", function() { + frm.set_query("cost_center", function () { return { filters: { company: frm.doc.company, @@ -568,23 +631,23 @@ frappe.ui.form.on("Purchase Invoice", { }); }, - onload: function(frm) { - if(frm.doc.__onload) { - if(frm.doc.supplier) { + onload: function (frm) { + if (frm.doc.__onload) { + if (frm.doc.supplier) { frm.doc.apply_tds = frm.doc.__onload.supplier_tds ? 1 : 0; } - if(!frm.doc.__onload.supplier_tds) { + if (!frm.doc.__onload.supplier_tds) { frm.set_df_property("apply_tds", "read_only", 1); me.frm.set_df_property("apply_tds", "hidden", 1); } } - erpnext.queries.setup_queries(frm, "Warehouse", function() { + erpnext.queries.setup_queries(frm, "Warehouse", function () { return erpnext.queries.warehouse(frm.doc); }); }, - is_subcontracted: function(frm) { + is_subcontracted: function (frm) { if (frm.doc.is_subcontracted) { erpnext.buying.get_default_bom(frm); } diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index 95467bd54bee..d2d0b7c975ab 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -105,6 +105,8 @@ "shipping_rule", "section_break_51", "taxes", + "section_break_idyjv", + "customs_tariff_tax", "sec_tax_breakup", "other_charges_calculation", "tax_exclusive_totals_section", @@ -1878,13 +1880,24 @@ "options": "Company:company:default_currency", "print_hide": 1, "read_only": 1 + }, + { + "fieldname": "section_break_idyjv", + "fieldtype": "Section Break" + }, + { + "depends_on": "eval:(doc.taxes || []).filter(d => d.charge_type == \"On HS Code\").length", + "fieldname": "customs_tariff_tax", + "fieldtype": "Table", + "label": "Customs Tariff Tax", + "options": "Customs Tariff Tax" } ], "icon": "fa fa-file-text", "idx": 204, "is_submittable": 1, "links": [], - "modified": "2024-02-12 16:23:06.891238", + "modified": "2024-08-12 18:36:30.556478", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 58f563e3b73f..3b6f88becdcc 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -6,6 +6,8 @@ from frappe.utils import cint, cstr, formatdate, flt, getdate, nowdate from frappe import _, throw import frappe.defaults +import json +from six import string_types from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account from erpnext.controllers.buying_controller import BuyingController @@ -1353,3 +1355,29 @@ def make_inter_company_sales_invoice(source_name, target_doc=None): def on_doctype_update(): frappe.db.add_index("Purchase Invoice", ["supplier", "is_return", "return_against"]) + +@frappe.whitelist() +def get_item_details(item_list, account_head): + if isinstance(item_list, string_types): + item_list = json.loads(item_list) + + + out = frappe._dict({ + "customs_tariff_tax": [], + }) + + for item_data in item_list: + if isinstance(item_data, dict) and item_data.get('customs_tariff_number'): + customs_tariff_number = item_data['customs_tariff_number'] + account_head_value = account_head + + item_dict = frappe._dict() + item_dict.customs_tariff_number = customs_tariff_number + item_dict.account_head = account_head_value + item_dict.amount = 0 + + out.customs_tariff_tax.append(item_dict) + + print(out) + + return out \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json index 47cf067b7287..c240ff052858 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json @@ -65,7 +65,7 @@ "label": "Type", "oldfieldname": "charge_type", "oldfieldtype": "Select", - "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total\nOn Item Quantity\nWeighted Distribution\nManual", + "options": "\nActual\nOn HS Code\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total\nOn Item Quantity\nWeighted Distribution\nManual", "reqd": 1 }, { @@ -265,7 +265,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2023-08-23 13:59:40.617093", + "modified": "2024-07-18 17:44:27.705739", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Taxes and Charges", diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 76e467b4a550..4c273fe5420e 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -547,6 +547,23 @@ def set_cumulative_total(self, row_idx, tax): def get_current_tax_amount(self, item, tax, item_tax_map, weighted_distrubution_tax_on_net_total): tax_rate = self._get_tax_rate(tax, item_tax_map) current_tax_amount = 0.0 + items_net_total = [] + + if len(self.doc.get("customs_tariff_tax", [])) > 0: + for item in self.doc.get("items", []): + index = -1 + for i, d in enumerate(items_net_total): + if d["customs_tariff_no"] == item.customs_tariff_no: + index = i + break + + if index != -1: + items_net_total[index]["total"] += item.amount + else: + items_net_total.append({ + "customs_tariff_no": item.customs_tariff_no, + "total": item.amount, + }) if tax.charge_type in ["Actual", "Weighted Distribution"]: # distribute the tax amount proportionally to each item row @@ -583,6 +600,16 @@ def get_current_tax_amount(self, item, tax, item_tax_map, weighted_distrubution_ current_tax_amount = (tax_rate / 100.0) * taxable_amount elif tax.charge_type == "On Item Quantity": current_tax_amount = tax_rate * item.qty + elif tax.charge_type == "On HS Code": + print(item.customs_tariff_no) + + for tariff_tax_table in self.doc.get("customs_tariff_tax", []): + if tariff_tax_table.account_head == tax.account_head and item.customs_tariff_no == tariff_tax_table.customs_tariff_no: + for i, d in enumerate(items_net_total): + if d["customs_tariff_no"] == item.customs_tariff_no: + current_tax_amount = (tariff_tax_table.amount / items_net_total[i]["total"]) * item.amount + break + self.set_item_wise_tax(item, tax, tax_rate, current_tax_amount) diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index 14486f9ae57e..00675bd97765 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -168,13 +168,16 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) { args: { account_head: d.account_head }, - callback: function(r) { + callback: (r) => { if (r.message) { frappe.model.set_value(cdt, cdn, "description", r.message.account_name); frappe.model.set_value(cdt, cdn, "exclude_from_item_tax_amount", cint(r.message.exclude_from_item_tax_amount)); if (["Actual", "Manual"].includes(d.charge_type)) { frappe.model.set_value(cdt, cdn, "rate", flt(r.message.tax_rate) || 0); + } else if (d.charge_type == "On HS Code") { + this.update_customs_tariff_table(); + frappe.model.set_value(cdt, cdn, "rate", 0); } else { frappe.model.set_value(cdt, cdn, "rate", 0); } @@ -184,6 +187,100 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) { } } +// cur_frm.cscript.amount = function(doc, cdt, cdn){ +// // let row = frappe.get_doc(cdt, cdn); +// // let tariff_tax_table = doc.customs_tariff_tax || []; +// // let sum = 0; +// // for (let i = 0; i < tariff_tax_table.length; i++){ +// // if (tariff_tax_table[i].account_head == row.account_head){ +// // let Index = doc.taxes.findIndex(item => item.account_head === tariff_tax_table[i].account_head && item.charge_type === "On HS Code"); +// // sum = sum + tariff_tax_table[i].amount; +// // doc.taxes[Index].tax_amount = sum; +// // cur_frm.debounced_refresh_fields(); +// // } +// // } + +// _calculate_taxes_and_totals(); +// console.log("called"); +// } + + +// function update_customs_tariff_table(doc) { +// let filteredTaxes = doc.taxes.filter(tax => tax.charge_type === "On HS Code"); +// let uniqueTaxes = Array.from(new Map(filteredTaxes.map(tax => [tax.account_head, tax])).values()); +// let tariff_tax_table = doc.customs_tariff_tax || []; + +// if (tariff_tax_table.length < uniqueTaxes.length * doc.items.length) { +// for (let i = 0; i < uniqueTaxes.length; i++) { +// for (let j = 0; j < doc.items.length; j++) { +// if (tariff_tax_table.find(item => item.account_head === uniqueTaxes[i].account_head) === undefined || tariff_tax_table.find(item => item.customs_tariff_number === doc.items[j].customs_tariff_no) === undefined) { +// cur_frm.toggle_display('customs_tariff_tax', true); +// let rows = cur_frm.add_child('customs_tariff_tax', { +// account_head: uniqueTaxes[i].account_head, +// customs_tariff_number: doc.items[j].customs_tariff_no +// }); +// } +// } +// } +// cur_frm.debounced_refresh_fields(); +// } else if (tariff_tax_table.length > uniqueTaxes.length * doc.items.length) { +// for (let i = 0; i < doc.customs_tariff_tax.length; i++) { +// if (uniqueTaxes.find(item => item.account_head === doc.customs_tariff_tax[i].account_head) === undefined) { +// console.log((uniqueTaxes.find(item => item.account_head === "GST - N") )); +// cur_frm.doc.customs_tariff_tax = cur_frm.doc.customs_tariff_tax.filter(item => item.account_head !== doc.customs_tariff_tax[i].account_head); +// } +// } +// } +// cur_frm.debounced_refresh_fields(); + +// } + + +cur_frm.cscript.update_customs_tariff_table = function() { + let account_heads = (this.frm.doc.taxes || []).filter(tax => tax.charge_type === "On HS Code" && tax.account_head).map(tax => tax.account_head); + account_heads = [...new Set(account_heads)]; + + let customs_tariff_nos = (this.frm.doc.items || []).filter(d => d.customs_tariff_no).map(d => d.customs_tariff_no); + customs_tariff_nos = [...new Set(customs_tariff_nos)]; + + let item_account_tariff_nos = []; + for (let account_head of account_heads) { + for (let customs_tariff_no of customs_tariff_nos) { + item_account_tariff_nos.push({ + account_head: account_head, + customs_tariff_no: customs_tariff_no, + }); + } + } + + let ui_account_tariff_nos = []; + for (let d of this.frm.doc.customs_tariff_tax || []) { + if (d.customs_tariff_no && d.account_head) { + ui_account_tariff_nos.push({ + account_head: d.account_head, + customs_tariff_no: d.customs_tariff_no, + }); + } + } + + // Add missing + for (let item_data of item_account_tariff_nos) { + if (!ui_account_tariff_nos.find(ui_data => ui_data.account_head == item_data.account_head && ui_data.customs_tariff_no == item_data.customs_tariff_no)) { + let row = this.frm.add_child('customs_tariff_tax'); + row.account_head = item_data.account_head; + row.customs_tariff_no = item_data.customs_tariff_no + this.frm.refresh_field('customs_tariff_tax'); + } + } + + // Remove extra + this.frm.doc.customs_tariff_tax = (this.frm.doc.customs_tariff_tax || []).filter(ui_data => { + return item_account_tariff_nos.find(item_data => ui_data.account_head == item_data.account_head && ui_data.customs_tariff_no == item_data.customs_tariff_no); + }); + + this.frm.refresh_field("customs_tariff_tax"); +} + cur_frm.cscript.validate_taxes_and_charges = function(cdt, cdn) { var d = locals[cdt][cdn]; var msg = ""; diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 4e2928081c42..3156085eb7ff 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -2,7 +2,7 @@ // License: GNU General Public License v3. See license.txt erpnext.taxes_and_totals_hooks = []; - + erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { apply_pricing_rule_on_item(item) { let effective_item_rate = item.price_list_rate; @@ -658,6 +658,22 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { get_current_tax_amount(item, tax, item_tax_map, weighted_distrubution_tax_on_net_total) { var tax_rate = this._get_tax_rate(tax, item_tax_map); var current_tax_amount = 0.0; + var items_net_total = [] + + if ((this.frm.doc["customs_tariff_tax"] || []).length > 0) { + (this.frm.doc["items"] || []).forEach((item) => { + let index = items_net_total.findIndex(d => d.customs_tariff_no === item.customs_tariff_no); + + if (index !== -1) { + items_net_total[index].total += item.amount; + } else { + items_net_total.push({ + customs_tariff_no: item.customs_tariff_no, + total: item.amount, + }); + } + }); + } if(tax.charge_type == "Actual" || tax.charge_type == "Weighted Distribution") { // distribute the tax amount proportionally to each item row @@ -696,6 +712,16 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { current_tax_amount = (tax_rate / 100.0) * taxable_amount; } else if (tax.charge_type == "On Item Quantity") { current_tax_amount = tax_rate * item.qty; + } else if (tax.charge_type == "On HS Code") { + console.log(item.customs_tariff_no); + $.each(this.frm.doc["customs_tariff_tax"] || [], function(j, tariff_tax_table) { + if (tariff_tax_table.account_head == tax.account_head && item.customs_tariff_no == tariff_tax_table.customs_tariff_no) { + current_tax_amount = (tariff_tax_table.amount / items_net_total[items_net_total.findIndex(d => d.customs_tariff_no == item.customs_tariff_no)].total) * item.amount; + } + }); + this.frm.refresh_field("taxes"); + this.frm.refresh_field("total_taxes_and_charges"); + } this.set_item_wise_tax(item, tax, tax_rate, current_tax_amount); @@ -703,6 +729,10 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { return current_tax_amount; } + amount = function(doc, cdt, cdn) { + this._calculate_taxes_and_totals(); + } + set_item_wise_tax(item, tax, tax_rate, current_tax_amount) { // store tax breakup for each item if (!item.item_tax_detail.hasOwnProperty(tax.name)) { @@ -825,6 +855,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { this.frm.doc.total_taxes_and_charges = this.frm.doc.total_after_taxes - this.frm.doc.taxable_total - flt(this.frm.doc.rounding_adjustment); if (this.should_round_transaction_currency()) { this.frm.doc.total_taxes_and_charges = flt(this.frm.doc.total_taxes_and_charges, precision("total_taxes_and_charges")); + } this.set_in_company_currency(this.frm.doc, ["total_taxes_and_charges", "rounding_adjustment"], diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 2aa1cbd5f3a6..34d06f8f2576 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -143,8 +143,9 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe frappe.ui.form.on(this.frm.cscript.tax_table, { taxes_remove: function(frm, cdt, cdn) { - cur_frm.cscript.set_dynamic_labels(); - cur_frm.cscript.calculate_taxes_and_totals(); + frm.cscript.set_dynamic_labels(); + frm.cscript.update_customs_tariff_table(); + frm.cscript.calculate_taxes_and_totals(); } }); @@ -201,6 +202,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe }, items_remove: function (frm) { + frm.cscript.update_customs_tariff_table(); frm.cscript.calculate_taxes_and_totals(); }, @@ -775,7 +777,8 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe let key = item.name; me.apply_rule_on_other_items({key: item}); } - } + }, + () => me.update_customs_tariff_table(), ]); } } diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index 2b82ccb3709f..414b2a0b4dd3 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -1357,7 +1357,7 @@ "idx": 2, "image_field": "image", "links": [], - "modified": "2024-02-12 17:40:34.456453", + "modified": "2024-07-23 12:33:43.656041", "modified_by": "Administrator", "module": "Stock", "name": "Item", diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 19c6885522b1..94cbfa60d6b2 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -251,6 +251,7 @@ def get_basic_details(args, item, overwrite_warehouse=True): "has_serial_no": item.has_serial_no, "has_batch_no": item.has_batch_no, "is_vehicle": item.is_vehicle, + "customs_tariff_number": item.customs_tariff_number, "batch_no": args.get("batch_no") if args.get("batch_no") and frappe.db.get_value("Batch", args.get("batch_no"), 'item') == item.name else "", "stock_uom": item.stock_uom, "uom": default_uom, From 176114bc983b0b8b94bb50a546c31b5a68039c15 Mon Sep 17 00:00:00 2001 From: zainkizilbash Date: Mon, 26 Aug 2024 11:51:18 +0500 Subject: [PATCH 2/6] feat: tariff tax implementation --- .../customs_tariff_tax.json | 6 +- .../purchase_invoice/purchase_invoice.js | 63 ------------------ .../purchase_invoice/purchase_invoice.py | 28 -------- .../purchase_invoice_item.json | 2 +- erpnext/controllers/taxes_and_totals.py | 42 ++++++------ erpnext/public/js/controllers/accounts.js | 65 +++---------------- .../public/js/controllers/taxes_and_totals.js | 39 +++++------ 7 files changed, 53 insertions(+), 192 deletions(-) diff --git a/erpnext/accounts/doctype/customs_tariff_tax/customs_tariff_tax.json b/erpnext/accounts/doctype/customs_tariff_tax/customs_tariff_tax.json index 0c79819e7693..abb41fbd3e4b 100644 --- a/erpnext/accounts/doctype/customs_tariff_tax/customs_tariff_tax.json +++ b/erpnext/accounts/doctype/customs_tariff_tax/customs_tariff_tax.json @@ -6,7 +6,7 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ - "customs_tariff_no", + "customs_tariff_number", "account_head", "amount" ], @@ -27,7 +27,7 @@ "options": "currency" }, { - "fieldname": "customs_tariff_no", + "fieldname": "customs_tariff_number", "fieldtype": "Link", "in_list_view": 1, "label": "Customs Tariff Number", @@ -38,7 +38,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-08-13 13:35:13.118862", + "modified": "2024-08-20 18:22:06.460326", "modified_by": "Administrator", "module": "Accounts", "name": "Customs Tariff Tax", diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index f537e114da6e..0fd04cc5b333 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -20,69 +20,6 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. } } - // item_code(doc, cdt, cdn) { - // let row = frappe.get_doc(cdt, cdn); - // console.log(row.customs_tariff_no); - // // this.get_item_details(row); - - // } - - // charge_type(doc, cdt, cdn) { - // let row = frappe.get_doc(cdt, cdn); - // this.populate_customs_tariff_number_table(cdt,cdn) - // } - - // account_head(doc,cdt,cdn){ - // let row = frappe.get_doc(cdt, cdn); - // this.populate_customs_tariff_number_table(cdt,cdn) - // } - - // before_taxes_remove(doc, cdt, cdn){ - // console.log("hello"); - // let row = frappe.get_doc(cdt, cdn); - // console.log(row.account_head); - // this.delete_rows(cdt, cdn) - // } - - - - - populate_customs_tariff_number_table(cdt, cdn) { - let numberOfItems = this.frm.doc.items.length; - console.log(numberOfItems); // Output the number of items to the console - console.log(this.frm.doc.items[0]) - let row = frappe.get_doc(cdt, cdn) - let customs_tariff_no = this.frm.doc.items[0].customs_tariff_no; - console.log(customs_tariff_no); - if (row.charge_type == "On HS Code" && row.account_head!==undefined && customs_tariff_no!==undefined){ - for (let i = 0; i < this.frm.doc.items.length; i++){ - console.log(i); - this.frm.toggle_display('customs_tariff_tax', true); - let rows = this.frm.add_child('customs_tariff_tax', { - account_head: row.account_head, - customs_tariff_number: this.frm.doc.items[i].customs_tariff_no - }); - } - this.frm.debounced_refresh_fields(); - } - } - - // amount(doc, cdt, cdn){ - // console.log("hello amount"); - // let row = frappe.get_doc(cdt, cdn); - // let total_cost = this.frm.doc.items[0].amount; - // let qty = this.frm.doc.items[0].qty; - // this.frm.doc.total_taxes_and_charges = (row.amount/total_cost)*qty; - // console.log(this.frm.doc.total_taxes_and_charges) - // } - - - - // this -> controller class - // this.frm -> form object - // this.frm.doc -> document object (data model) - - refresh(doc) { const me = this; super.refresh(); diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 3b6f88becdcc..58f563e3b73f 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -6,8 +6,6 @@ from frappe.utils import cint, cstr, formatdate, flt, getdate, nowdate from frappe import _, throw import frappe.defaults -import json -from six import string_types from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account from erpnext.controllers.buying_controller import BuyingController @@ -1355,29 +1353,3 @@ def make_inter_company_sales_invoice(source_name, target_doc=None): def on_doctype_update(): frappe.db.add_index("Purchase Invoice", ["supplier", "is_return", "return_against"]) - -@frappe.whitelist() -def get_item_details(item_list, account_head): - if isinstance(item_list, string_types): - item_list = json.loads(item_list) - - - out = frappe._dict({ - "customs_tariff_tax": [], - }) - - for item_data in item_list: - if isinstance(item_data, dict) and item_data.get('customs_tariff_number'): - customs_tariff_number = item_data['customs_tariff_number'] - account_head_value = account_head - - item_dict = frappe._dict() - item_dict.customs_tariff_number = customs_tariff_number - item_dict.account_head = account_head_value - item_dict.amount = 0 - - out.customs_tariff_tax.append(item_dict) - - print(out) - - return out \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json index d04ca85283d8..3032a2bbbb25 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -1370,7 +1370,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2024-03-21 17:07:25.008634", + "modified": "2024-08-22 13:44:44.886527", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice Item", diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 4c273fe5420e..28d593677371 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -547,23 +547,6 @@ def set_cumulative_total(self, row_idx, tax): def get_current_tax_amount(self, item, tax, item_tax_map, weighted_distrubution_tax_on_net_total): tax_rate = self._get_tax_rate(tax, item_tax_map) current_tax_amount = 0.0 - items_net_total = [] - - if len(self.doc.get("customs_tariff_tax", [])) > 0: - for item in self.doc.get("items", []): - index = -1 - for i, d in enumerate(items_net_total): - if d["customs_tariff_no"] == item.customs_tariff_no: - index = i - break - - if index != -1: - items_net_total[index]["total"] += item.amount - else: - items_net_total.append({ - "customs_tariff_no": item.customs_tariff_no, - "total": item.amount, - }) if tax.charge_type in ["Actual", "Weighted Distribution"]: # distribute the tax amount proportionally to each item row @@ -601,12 +584,29 @@ def get_current_tax_amount(self, item, tax, item_tax_map, weighted_distrubution_ elif tax.charge_type == "On Item Quantity": current_tax_amount = tax_rate * item.qty elif tax.charge_type == "On HS Code": - print(item.customs_tariff_no) + items_net_total = [] + #totalling of items prices based on their HS codes + if len(self.doc.get("customs_tariff_tax", [])) > 0: + for items in self.doc.get("items", []): + index = -1 + for i, sel_item in enumerate(items_net_total): + if sel_item["customs_tariff_number"] == items.customs_tariff_number: + index = i + break + + if index != -1: + items_net_total[index]["total"] += items.amount + else: + items_net_total.append({ + "customs_tariff_number": items.customs_tariff_number, + "total": items.amount, + }) + #tax distribution according to the item qty & HS code for tariff_tax_table in self.doc.get("customs_tariff_tax", []): - if tariff_tax_table.account_head == tax.account_head and item.customs_tariff_no == tariff_tax_table.customs_tariff_no: - for i, d in enumerate(items_net_total): - if d["customs_tariff_no"] == item.customs_tariff_no: + if tariff_tax_table.account_head == tax.account_head and item.customs_tariff_number == tariff_tax_table.customs_tariff_number: + for i, sel_item in enumerate(items_net_total): + if sel_item["customs_tariff_number"] == item.customs_tariff_number: current_tax_amount = (tariff_tax_table.amount / items_net_total[i]["total"]) * item.amount break diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index 00675bd97765..ae3c073d8249 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -187,95 +187,46 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) { } } -// cur_frm.cscript.amount = function(doc, cdt, cdn){ -// // let row = frappe.get_doc(cdt, cdn); -// // let tariff_tax_table = doc.customs_tariff_tax || []; -// // let sum = 0; -// // for (let i = 0; i < tariff_tax_table.length; i++){ -// // if (tariff_tax_table[i].account_head == row.account_head){ -// // let Index = doc.taxes.findIndex(item => item.account_head === tariff_tax_table[i].account_head && item.charge_type === "On HS Code"); -// // sum = sum + tariff_tax_table[i].amount; -// // doc.taxes[Index].tax_amount = sum; -// // cur_frm.debounced_refresh_fields(); -// // } -// // } - -// _calculate_taxes_and_totals(); -// console.log("called"); -// } - - -// function update_customs_tariff_table(doc) { -// let filteredTaxes = doc.taxes.filter(tax => tax.charge_type === "On HS Code"); -// let uniqueTaxes = Array.from(new Map(filteredTaxes.map(tax => [tax.account_head, tax])).values()); -// let tariff_tax_table = doc.customs_tariff_tax || []; - -// if (tariff_tax_table.length < uniqueTaxes.length * doc.items.length) { -// for (let i = 0; i < uniqueTaxes.length; i++) { -// for (let j = 0; j < doc.items.length; j++) { -// if (tariff_tax_table.find(item => item.account_head === uniqueTaxes[i].account_head) === undefined || tariff_tax_table.find(item => item.customs_tariff_number === doc.items[j].customs_tariff_no) === undefined) { -// cur_frm.toggle_display('customs_tariff_tax', true); -// let rows = cur_frm.add_child('customs_tariff_tax', { -// account_head: uniqueTaxes[i].account_head, -// customs_tariff_number: doc.items[j].customs_tariff_no -// }); -// } -// } -// } -// cur_frm.debounced_refresh_fields(); -// } else if (tariff_tax_table.length > uniqueTaxes.length * doc.items.length) { -// for (let i = 0; i < doc.customs_tariff_tax.length; i++) { -// if (uniqueTaxes.find(item => item.account_head === doc.customs_tariff_tax[i].account_head) === undefined) { -// console.log((uniqueTaxes.find(item => item.account_head === "GST - N") )); -// cur_frm.doc.customs_tariff_tax = cur_frm.doc.customs_tariff_tax.filter(item => item.account_head !== doc.customs_tariff_tax[i].account_head); -// } -// } -// } -// cur_frm.debounced_refresh_fields(); - -// } - - cur_frm.cscript.update_customs_tariff_table = function() { let account_heads = (this.frm.doc.taxes || []).filter(tax => tax.charge_type === "On HS Code" && tax.account_head).map(tax => tax.account_head); account_heads = [...new Set(account_heads)]; - let customs_tariff_nos = (this.frm.doc.items || []).filter(d => d.customs_tariff_no).map(d => d.customs_tariff_no); + let customs_tariff_nos = (this.frm.doc.items || []).filter(d => d.customs_tariff_number).map(d => d.customs_tariff_number); customs_tariff_nos = [...new Set(customs_tariff_nos)]; let item_account_tariff_nos = []; for (let account_head of account_heads) { - for (let customs_tariff_no of customs_tariff_nos) { + for (let customs_tariff_number of customs_tariff_nos) { item_account_tariff_nos.push({ account_head: account_head, - customs_tariff_no: customs_tariff_no, + customs_tariff_number: customs_tariff_number, }); } } let ui_account_tariff_nos = []; for (let d of this.frm.doc.customs_tariff_tax || []) { - if (d.customs_tariff_no && d.account_head) { + if (d.customs_tariff_number && d.account_head) { ui_account_tariff_nos.push({ account_head: d.account_head, - customs_tariff_no: d.customs_tariff_no, + customs_tariff_number: d.customs_tariff_number, }); } } // Add missing for (let item_data of item_account_tariff_nos) { - if (!ui_account_tariff_nos.find(ui_data => ui_data.account_head == item_data.account_head && ui_data.customs_tariff_no == item_data.customs_tariff_no)) { + if (!ui_account_tariff_nos.find(ui_data => ui_data.account_head == item_data.account_head && ui_data.customs_tariff_number == item_data.customs_tariff_number)) { let row = this.frm.add_child('customs_tariff_tax'); row.account_head = item_data.account_head; - row.customs_tariff_no = item_data.customs_tariff_no + row.customs_tariff_number = item_data.customs_tariff_number this.frm.refresh_field('customs_tariff_tax'); } } // Remove extra this.frm.doc.customs_tariff_tax = (this.frm.doc.customs_tariff_tax || []).filter(ui_data => { - return item_account_tariff_nos.find(item_data => ui_data.account_head == item_data.account_head && ui_data.customs_tariff_no == item_data.customs_tariff_no); + return item_account_tariff_nos.find(item_data => ui_data.account_head == item_data.account_head && ui_data.customs_tariff_number == item_data.customs_tariff_number); }); this.frm.refresh_field("customs_tariff_tax"); diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 3156085eb7ff..b231f1fb9c2a 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -658,22 +658,6 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { get_current_tax_amount(item, tax, item_tax_map, weighted_distrubution_tax_on_net_total) { var tax_rate = this._get_tax_rate(tax, item_tax_map); var current_tax_amount = 0.0; - var items_net_total = [] - - if ((this.frm.doc["customs_tariff_tax"] || []).length > 0) { - (this.frm.doc["items"] || []).forEach((item) => { - let index = items_net_total.findIndex(d => d.customs_tariff_no === item.customs_tariff_no); - - if (index !== -1) { - items_net_total[index].total += item.amount; - } else { - items_net_total.push({ - customs_tariff_no: item.customs_tariff_no, - total: item.amount, - }); - } - }); - } if(tax.charge_type == "Actual" || tax.charge_type == "Weighted Distribution") { // distribute the tax amount proportionally to each item row @@ -713,10 +697,27 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { } else if (tax.charge_type == "On Item Quantity") { current_tax_amount = tax_rate * item.qty; } else if (tax.charge_type == "On HS Code") { - console.log(item.customs_tariff_no); + let items_net_total = []; + // totalling of items prices based on their HS codes + if ((this.frm.doc["customs_tariff_tax"] || []).length > 0) { + (this.frm.doc["items"] || []).forEach((item) => { + let index = items_net_total.findIndex(d => d.customs_tariff_number === item.customs_tariff_number); + + if (index !== -1) { + items_net_total[index].total += item.amount; + } else { + items_net_total.push({ + customs_tariff_number: item.customs_tariff_number, + total: item.amount, + }); + } + }); + } + + // tax distribution according to the item qty & HS code $.each(this.frm.doc["customs_tariff_tax"] || [], function(j, tariff_tax_table) { - if (tariff_tax_table.account_head == tax.account_head && item.customs_tariff_no == tariff_tax_table.customs_tariff_no) { - current_tax_amount = (tariff_tax_table.amount / items_net_total[items_net_total.findIndex(d => d.customs_tariff_no == item.customs_tariff_no)].total) * item.amount; + if (tariff_tax_table.account_head == tax.account_head && item.customs_tariff_number == tariff_tax_table.customs_tariff_number) { + current_tax_amount = (tariff_tax_table.amount / items_net_total[items_net_total.findIndex(d => d.customs_tariff_number == item.customs_tariff_number)].total) * item.amount; } }); this.frm.refresh_field("taxes"); From 65cc24896e17e0787803ac74bcb40f484b5d9fa2 Mon Sep 17 00:00:00 2001 From: zainkizilbash Date: Thu, 5 Sep 2024 16:10:13 +0500 Subject: [PATCH 3/6] chore: break long line --- erpnext/controllers/taxes_and_totals.py | 4 +++- erpnext/public/js/controllers/taxes_and_totals.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 28d593677371..35d6a3f7e850 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -607,7 +607,9 @@ def get_current_tax_amount(self, item, tax, item_tax_map, weighted_distrubution_ if tariff_tax_table.account_head == tax.account_head and item.customs_tariff_number == tariff_tax_table.customs_tariff_number: for i, sel_item in enumerate(items_net_total): if sel_item["customs_tariff_number"] == item.customs_tariff_number: - current_tax_amount = (tariff_tax_table.amount / items_net_total[i]["total"]) * item.amount + HS_code_tax_amount = tariff_tax_table.amount + HS_code_net_total = items_net_total[i]["total"] + current_tax_amount = (HS_code_tax_amount / HS_code_net_total) * item.amount break diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index b231f1fb9c2a..10a614b56d1a 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -717,7 +717,9 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { // tax distribution according to the item qty & HS code $.each(this.frm.doc["customs_tariff_tax"] || [], function(j, tariff_tax_table) { if (tariff_tax_table.account_head == tax.account_head && item.customs_tariff_number == tariff_tax_table.customs_tariff_number) { - current_tax_amount = (tariff_tax_table.amount / items_net_total[items_net_total.findIndex(d => d.customs_tariff_number == item.customs_tariff_number)].total) * item.amount; + let HS_code_tax_amount = tariff_tax_table.amount; + let HS_code_net_total = items_net_total[items_net_total.findIndex(d => d.customs_tariff_number == item.customs_tariff_number)].total + current_tax_amount = (HS_code_tax_amount / HS_code_net_total) * item.amount; } }); this.frm.refresh_field("taxes"); From fc05b31feea89fd8ab6463fdf65fcc792815acba Mon Sep 17 00:00:00 2001 From: zainkizilbash Date: Thu, 5 Sep 2024 16:18:30 +0500 Subject: [PATCH 4/6] chore: revert Item.json --- erpnext/stock/doctype/item/item.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index 65ecb0c10fe5..4b23a94af371 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -1168,7 +1168,7 @@ "idx": 2, "image_field": "image", "links": [], - "modified": "2024-07-30 01:07:57.420619", + "modified": "2024-07-30 01:07:57.420618", "modified_by": "Administrator", "module": "Stock", "name": "Item", @@ -1278,4 +1278,4 @@ "states": [], "title_field": "item_name", "track_changes": 1 -} +} \ No newline at end of file From e52b80a596e1212a76fbf06e2515c8b0bdfd9380 Mon Sep 17 00:00:00 2001 From: zainkizilbash Date: Thu, 5 Sep 2024 16:34:29 +0500 Subject: [PATCH 5/6] chore: revert unnecessary changes --- .../purchase_invoice/purchase_invoice.js | 120 +++++++++--------- .../purchase_invoice_item.json | 2 +- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 0fd04cc5b333..1b166bcf8e0c 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -12,9 +12,9 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. onload() { super.onload(); - if (!this.frm.doc.__islocal) { + if(!this.frm.doc.__islocal) { // show credit_to in print format - if (!this.frm.doc.supplier && this.frm.doc.credit_to) { + if(!this.frm.doc.supplier && this.frm.doc.credit_to) { this.frm.set_df_property("credit_to", "print_hide", 0); } } @@ -48,19 +48,19 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. ); this.frm.add_custom_button( __('Unblock Invoice'), - function () { me.unblock_invoice() }, + function() {me.unblock_invoice()}, __('Hold Invoice') ); } else if (!doc.on_hold) { this.frm.add_custom_button( __('Block Invoice'), - function () { me.block_invoice() }, + function() {me.block_invoice()}, __('Hold Invoice') ); } } - if ( + if( doc.docstatus == 1 && doc.outstanding_amount != 0 && !(doc.is_return && doc.return_against) @@ -71,7 +71,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. this.frm.page.set_inner_btn_group_as_primary(__('Create')); } - if (!doc.is_return && doc.docstatus == 1) { + if (!doc.is_return && doc.docstatus==1) { if ( (doc.outstanding_amount >= 0 || Math.abs(flt(doc.outstanding_amount)) < flt(doc.grand_total)) && frappe.model.can_create("Purchase Invoice") @@ -86,19 +86,19 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. } if (!doc.auto_repeat && frappe.model.can_create("Auto Repeat")) { - this.frm.add_custom_button(__('Subscription'), function () { + this.frm.add_custom_button(__('Subscription'), function() { erpnext.utils.make_subscription(doc.doctype, doc.name) }, __('Create')) } } if (doc.outstanding_amount > 0 && !cint(doc.is_return) && frappe.model.can_create("Payment Request")) { - this.frm.add_custom_button(__('Payment Request'), function () { + this.frm.add_custom_button(__('Payment Request'), function() { me.make_payment_request() }, __('Create')); } - if (doc.docstatus === 0) { + if (doc.docstatus===0) { if (frappe.model.can_read("Purchase Receipt")) { this.frm.add_custom_button(__('Purchase Receipt'), function () { erpnext.utils.map_current_doc({ @@ -173,7 +173,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. if (doc.docstatus == 1 && !doc.inter_company_reference) { if (me.frm.doc.__onload?.is_internal_supplier) { - me.frm.add_custom_button("Inter Company Invoice", function () { + me.frm.add_custom_button("Inter Company Invoice", function() { me.make_inter_company_invoice(me.frm); }, __('Create')); } @@ -190,7 +190,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. const me = this; frappe.call({ 'method': 'erpnext.accounts.doctype.purchase_invoice.purchase_invoice.unblock_invoice', - 'args': { 'name': me.frm.doc.name }, + 'args': {'name': me.frm.doc.name}, 'callback': (r) => me.frm.reload_doc() }); } @@ -218,12 +218,12 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. var dialog = new frappe.ui.Dialog({ title: __("Customer"), fields: [ - { "fieldtype": "Link", "label": __("Customer"), "fieldname": "customer", "options": "Customer", "mandatory": true }, - { "fieldtype": "Button", "label": __("Make Sales Order"), "fieldname": "make_sales_order", "cssClass": "btn-primary" }, + {"fieldtype": "Link", "label": __("Customer"), "fieldname": "customer", "options":"Customer", "mandatory":true}, + {"fieldtype": "Button", "label": __("Make Sales Order"), "fieldname": "make_sales_order", "cssClass": "btn-primary"}, ] }); - dialog.fields_dict.make_sales_order.$input.click(function () { + dialog.fields_dict.make_sales_order.$input.click(function() { var args = dialog.get_values(); dialog.hide(); return frappe.call({ @@ -234,8 +234,8 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. "source_name": me.frm.doc.name }, freeze: true, - callback: function (r) { - if (!r.exc) { + callback: function(r) { + if(!r.exc) { var doc = frappe.model.sync(r.message); frappe.set_route("Form", r.message.doctype, r.message.name); } @@ -253,7 +253,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. { fieldname: 'release_date', read_only: 0, - fieldtype: 'Date', + fieldtype:'Date', label: __('Release Date'), default: me.frm.doc.release_date, reqd: 1 @@ -261,7 +261,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. { fieldname: 'hold_comment', read_only: 0, - fieldtype: 'Small Text', + fieldtype:'Small Text', label: __('Reason For Putting On Hold'), default: "" }, @@ -272,7 +272,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. fields: fields }); - this.dialog.set_primary_action(__('Save'), function () { + this.dialog.set_primary_action(__('Save'), function() { const dialog_data = me.dialog.get_values(); frappe.call({ 'method': 'erpnext.accounts.doctype.purchase_invoice.purchase_invoice.block_invoice', @@ -297,7 +297,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. { fieldname: 'release_date', read_only: 0, - fieldtype: 'Date', + fieldtype:'Date', label: __('Release Date'), default: me.frm.doc.release_date }, @@ -308,9 +308,9 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. fields: fields }); - this.dialog.set_primary_action(__('Save'), function () { + this.dialog.set_primary_action(__('Save'), function() { me.dialog_data = me.dialog.get_values(); - if (me.can_change_release_date(me.dialog_data.release_date)) { + if(me.can_change_release_date(me.dialog_data.release_date)) { me.dialog_data.name = me.frm.doc.name; me.set_release_date(me.dialog_data); me.dialog.hide(); @@ -337,7 +337,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. } set_party_details() { - if (this.frm.updating_party_details) + if(this.frm.updating_party_details) return; var me = this; @@ -350,7 +350,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. letter_of_credit: this.frm.doc.letter_of_credit, account: this.frm.doc.credit_to, price_list: this.frm.doc.buying_price_list - }, function () { + }, function() { me.apply_pricing_rule(); me.frm.doc.apply_tds = me.frm.supplier_tds ? 1 : 0; me.frm.doc.tax_withholding_category = me.frm.supplier_tds; @@ -374,7 +374,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. credit_to() { var me = this; - if (this.frm.doc.credit_to) { + if(this.frm.doc.credit_to) { me.frm.call({ method: "frappe.client.get_value", args: { @@ -382,8 +382,8 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. fieldname: "account_currency", filters: { name: me.frm.doc.credit_to }, }, - callback: function (r, rt) { - if (r.message) { + callback: function(r, rt) { + if(r.message) { me.frm.set_value("party_account_currency", r.message.account_currency); me.set_dynamic_labels(); } @@ -400,9 +400,9 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. } is_paid() { - if (cint(this.frm.doc.is_paid)) { + if(cint(this.frm.doc.is_paid)) { this.frm.set_value("allocate_advances_automatically", 0); - if (!this.frm.doc.company) { + if(!this.frm.doc.company) { this.frm.set_value("is_paid", 0) frappe.msgprint(__("Please specify Company to proceed")); } @@ -435,8 +435,8 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. } on_submit() { - $.each(this.frm.doc["items"] || [], function (i, row) { - if (row.purchase_receipt) frappe.model.clear_doc("Purchase Receipt", row.purchase_receipt) + $.each(this.frm.doc["items"] || [], function(i, row) { + if(row.purchase_receipt) frappe.model.clear_doc("Purchase Receipt", row.purchase_receipt) }) } @@ -456,33 +456,33 @@ function hide_fields(doc) { var item_fields_stock = ['warehouse_section', 'received_qty', 'rejected_qty']; cur_frm.fields_dict['items'].grid.set_column_disp(item_fields_stock, - (cint(doc.update_stock) == 1 || cint(doc.is_return) == 1 ? true : false)); + (cint(doc.update_stock)==1 || cint(doc.is_return)==1 ? true : false)); } -cur_frm.cscript.update_stock = function (doc, dt, dn) { +cur_frm.cscript.update_stock = function(doc, dt, dn) { hide_fields(doc, dt, dn); - this.frm.fields_dict.items.grid.toggle_reqd("item_code", doc.update_stock ? true : false) + this.frm.fields_dict.items.grid.toggle_reqd("item_code", doc.update_stock? true: false) } -cur_frm.fields_dict.cash_bank_account.get_query = function (doc) { +cur_frm.fields_dict.cash_bank_account.get_query = function(doc) { return { filters: [ ["Account", "account_type", "in", ["Cash", "Bank"]], - ["Account", "is_group", "=", 0], + ["Account", "is_group", "=",0], ["Account", "company", "=", doc.company], ["Account", "report_type", "=", "Balance Sheet"] ] } } -cur_frm.fields_dict['items'].grid.get_field("item_code").get_query = function (doc, cdt, cdn) { +cur_frm.fields_dict['items'].grid.get_field("item_code").get_query = function(doc, cdt, cdn) { return { query: "erpnext.controllers.queries.item_query", - filters: { 'is_purchase_item': 1 } + filters: {'is_purchase_item': 1} } } -cur_frm.fields_dict['credit_to'].get_query = function (doc) { +cur_frm.fields_dict['credit_to'].get_query = function(doc) { // filter on Account return { filters: { @@ -494,33 +494,33 @@ cur_frm.fields_dict['credit_to'].get_query = function (doc) { } // Get Print Heading -cur_frm.fields_dict['select_print_heading'].get_query = function (doc, cdt, cdn) { +cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) { return { - filters: [ + filters:[ ['Print Heading', 'docstatus', '!=', 2] ] } } -cur_frm.set_query("expense_account", "items", function (doc) { +cur_frm.set_query("expense_account", "items", function(doc) { return { query: "erpnext.controllers.queries.get_expense_account", - filters: { 'company': doc.company } + filters: {'company': doc.company } } }); -cur_frm.cscript.expense_account = function (doc, cdt, cdn) { +cur_frm.cscript.expense_account = function(doc, cdt, cdn){ var d = locals[cdt][cdn]; - if (d.idx == 1 && d.expense_account) { + if(d.idx == 1 && d.expense_account){ var cl = doc.items || []; - for (var i = 0; i < cl.length; i++) { - if (!cl[i].expense_account) cl[i].expense_account = d.expense_account; + for(var i = 0; i < cl.length; i++){ + if(!cl[i].expense_account) cl[i].expense_account = d.expense_account; } } refresh_field('items'); } -cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function (doc) { +cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function(doc) { return { filters: { 'company': doc.company, @@ -530,16 +530,16 @@ cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function } } -cur_frm.fields_dict['items'].grid.get_field('project').get_query = function (doc, cdt, cdn) { - return { - filters: [ +cur_frm.fields_dict['items'].grid.get_field('project').get_query = function(doc, cdt, cdn) { + return{ + filters:[ ['Project', 'status', 'not in', 'Completed, Cancelled'] ] } } frappe.ui.form.on("Purchase Invoice", { - setup: function (frm) { + setup: function(frm) { frm.custom_make_buttons = { 'Purchase Invoice': 'Return / Debit Note', 'Payment Entry': 'Payment', @@ -548,7 +548,7 @@ frappe.ui.form.on("Purchase Invoice", { 'Payment Request': 'Payment Request', } - frm.fields_dict['items'].grid.get_field('deferred_expense_account').get_query = function (doc) { + frm.fields_dict['items'].grid.get_field('deferred_expense_account').get_query = function(doc) { return { filters: { 'root_type': 'Asset', @@ -558,7 +558,7 @@ frappe.ui.form.on("Purchase Invoice", { } } - frm.set_query("cost_center", function () { + frm.set_query("cost_center", function() { return { filters: { company: frm.doc.company, @@ -568,23 +568,23 @@ frappe.ui.form.on("Purchase Invoice", { }); }, - onload: function (frm) { - if (frm.doc.__onload) { - if (frm.doc.supplier) { + onload: function(frm) { + if(frm.doc.__onload) { + if(frm.doc.supplier) { frm.doc.apply_tds = frm.doc.__onload.supplier_tds ? 1 : 0; } - if (!frm.doc.__onload.supplier_tds) { + if(!frm.doc.__onload.supplier_tds) { frm.set_df_property("apply_tds", "read_only", 1); me.frm.set_df_property("apply_tds", "hidden", 1); } } - erpnext.queries.setup_queries(frm, "Warehouse", function () { + erpnext.queries.setup_queries(frm, "Warehouse", function() { return erpnext.queries.warehouse(frm.doc); }); }, - is_subcontracted: function (frm) { + is_subcontracted: function(frm) { if (frm.doc.is_subcontracted) { erpnext.buying.get_default_bom(frm); } diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json index 3032a2bbbb25..d04ca85283d8 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -1370,7 +1370,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2024-08-22 13:44:44.886527", + "modified": "2024-03-21 17:07:25.008634", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice Item", From 8613aac6c57d689d0057587209794028ea341352 Mon Sep 17 00:00:00 2001 From: zainkizilbash Date: Thu, 5 Sep 2024 16:34:51 +0500 Subject: [PATCH 6/6] fix(Purchase Taxes and Charges): move On HS Code down --- .../purchase_taxes_and_charges.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json index c240ff052858..8b7097488660 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json @@ -65,7 +65,7 @@ "label": "Type", "oldfieldname": "charge_type", "oldfieldtype": "Select", - "options": "\nActual\nOn HS Code\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total\nOn Item Quantity\nWeighted Distribution\nManual", + "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total\nOn Item Quantity\nOn HS Code\nWeighted Distribution\nManual", "reqd": 1 }, { @@ -265,7 +265,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2024-07-18 17:44:27.705739", + "modified": "2024-09-05 16:27:52.880423", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Taxes and Charges",