From e7679703cfda039948adbfc5b12c5e94ae82f6bb Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 20 Feb 2015 14:40:35 +0530 Subject: [PATCH 01/13] Taxes and totals calculation in party currency --- .../sales_taxes_and_charges.json | 279 +-- .../sales_taxes_and_charges_master.js | 8 +- .../supplier_quotation.json | 1101 +++++------ erpnext/controllers/taxes_and_totals.py | 217 +-- .../public/js/controllers/taxes_and_totals.js | 269 +-- erpnext/public/js/controllers/transaction.js | 18 - .../selling/doctype/quotation/quotation.js | 6 +- .../selling/doctype/quotation/quotation.json | 1628 +++++++++-------- .../quotation_item/quotation_item.json | 654 +++---- .../stock_ledger_entry/stock_ledger_entry.py | 2 +- 10 files changed, 2146 insertions(+), 2036 deletions(-) diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json index 06c981fe4f..2a0f506188 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json +++ b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json @@ -1,156 +1,183 @@ { - "autoname": "hash", - "creation": "2013-04-24 11:39:32", - "docstatus": 0, - "doctype": "DocType", + "autoname": "hash", + "creation": "2013-04-24 11:39:32", + "docstatus": 0, + "doctype": "DocType", "fields": [ { - "fieldname": "charge_type", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Type", - "oldfieldname": "charge_type", - "oldfieldtype": "Select", - "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total", - "permlevel": 0, + "fieldname": "charge_type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Type", + "oldfieldname": "charge_type", + "oldfieldtype": "Select", + "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total", + "permlevel": 0, "reqd": 1 - }, + }, { - "depends_on": "eval:[\"On Previous Row Amount\", \"On Previous Row Total\"].indexOf(doc.charge_type)!==-1", - "fieldname": "row_id", - "fieldtype": "Data", - "hidden": 0, - "label": "Reference Row #", - "oldfieldname": "row_id", - "oldfieldtype": "Data", + "depends_on": "eval:[\"On Previous Row Amount\", \"On Previous Row Total\"].indexOf(doc.charge_type)!==-1", + "fieldname": "row_id", + "fieldtype": "Data", + "hidden": 0, + "label": "Reference Row #", + "oldfieldname": "row_id", + "oldfieldtype": "Data", "permlevel": 0 - }, + }, { - "fieldname": "description", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "permlevel": 0, - "print_width": "300px", - "reqd": 1, + "fieldname": "description", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "300px", + "reqd": 1, "width": "300px" - }, + }, { - "fieldname": "col_break_1", - "fieldtype": "Column Break", - "permlevel": 0, + "fieldname": "col_break_1", + "fieldtype": "Column Break", + "permlevel": 0, "width": "50%" - }, + }, { - "fieldname": "account_head", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Account Head", - "oldfieldname": "account_head", - "oldfieldtype": "Link", - "options": "Account", - "permlevel": 0, - "reqd": 1, + "fieldname": "account_head", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Account Head", + "oldfieldname": "account_head", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "reqd": 1, "search_index": 1 - }, + }, { - "default": ":Company", - "fieldname": "cost_center", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Cost Center", - "oldfieldname": "cost_center_other_charges", - "oldfieldtype": "Link", - "options": "Cost Center", + "default": ":Company", + "fieldname": "cost_center", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Cost Center", + "oldfieldname": "cost_center_other_charges", + "oldfieldtype": "Link", + "options": "Cost Center", "permlevel": 0 - }, + }, { - "fieldname": "rate", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "rate", - "oldfieldtype": "Currency", - "permlevel": 0, + "fieldname": "rate", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "rate", + "oldfieldtype": "Currency", + "permlevel": 0, "reqd": 1 - }, + }, { - "fieldname": "tax_amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "tax_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "read_only": 1, + "fieldname": "tax_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "options": "currency", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "base_tax_amount", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Amount (Company Currency)", + "oldfieldname": "tax_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1, "reqd": 0 - }, + }, { - "fieldname": "total", - "fieldtype": "Currency", - "label": "Total", - "oldfieldname": "total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, + "fieldname": "total", + "fieldtype": "Currency", + "label": "Total", + "options": "currency", + "permlevel": 0, + "precision": "", "read_only": 1 - }, + }, { - "allow_on_submit": 0, - "description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount", - "fieldname": "included_in_print_rate", - "fieldtype": "Check", - "label": "Is this Tax included in Basic Rate?", - "no_copy": 0, - "permlevel": 0, - "print_hide": 1, - "print_width": "150px", - "report_hide": 1, + "fieldname": "base_total", + "fieldtype": "Currency", + "label": "Total (Company Currency)", + "oldfieldname": "total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "allow_on_submit": 0, + "description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount", + "fieldname": "included_in_print_rate", + "fieldtype": "Check", + "label": "Is this Tax included in Basic Rate?", + "no_copy": 0, + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "report_hide": 1, "width": "150px" - }, + }, { - "depends_on": "eval:parent.discount_amount", - "fieldname": "tax_amount_after_discount_amount", - "fieldtype": "Currency", - "hidden": 0, - "label": "Tax Amount After Discount Amount", - "options": "Company:company:default_currency", - "permlevel": 0, + "fieldname": "tax_amount_after_discount_amount", + "fieldtype": "Currency", + "label": "Tax Amount After Discount Amount", + "options": "currency", + "permlevel": 0, + "precision": "", "read_only": 1 - }, + }, { - "fieldname": "item_wise_tax_detail", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Item Wise Tax Detail", - "oldfieldname": "item_wise_tax_detail", - "oldfieldtype": "Small Text", - "permlevel": 0, + "depends_on": "eval:parent.discount_amount", + "fieldname": "base_tax_amount_after_discount_amount", + "fieldtype": "Currency", + "hidden": 0, + "label": "Tax Amount After Discount Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, "read_only": 1 - }, + }, { - "fieldname": "parenttype", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "label": "Parenttype", - "oldfieldname": "parenttype", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 1, + "fieldname": "item_wise_tax_detail", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Item Wise Tax Detail", + "oldfieldname": "item_wise_tax_detail", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "parenttype", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "label": "Parenttype", + "oldfieldname": "parenttype", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, "search_index": 1 } - ], - "hide_heading": 1, - "idx": 1, - "istable": 1, - "modified": "2015-02-19 01:07:02.165094", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Sales Taxes and Charges", - "owner": "Administrator", + ], + "hide_heading": 1, + "idx": 1, + "istable": 1, + "modified": "2015-02-19 17:00:07.949352", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Sales Taxes and Charges", + "owner": "Administrator", "permissions": [] -} \ No newline at end of file +} diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js index af744e9f8e..8fd8f0123b 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js @@ -165,10 +165,10 @@ cur_frm.cscript.tax_amount = function(doc, cdt, cdn) { msgprint(__("Please select Charge Type first")); d.tax_amount = ''; } - else if(d.charge_type && d.tax_amount) { - msgprint(__("Cannot directly set amount. For 'Actual' charge type, use the rate field")); - d.tax_amount = ''; - } + // else if(d.charge_type && d.tax_amount) { + // msgprint(__("Cannot directly set amount. For 'Actual' charge type, use the rate field")); + // d.tax_amount = ''; + // } validated = false; refresh_field('tax_amount', d.name, 'taxes'); }; diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json index 99471ca2d3..352178f18e 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json @@ -1,680 +1,681 @@ { - "allow_import": 1, - "autoname": "naming_series:", - "creation": "2013-05-21 16:16:45", - "docstatus": 0, - "doctype": "DocType", - "document_type": "Transaction", + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-05-21 16:16:45", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", "fields": [ { - "fieldname": "supplier_section", - "fieldtype": "Section Break", - "label": "Supplier", - "options": "icon-user", + "fieldname": "supplier_section", + "fieldtype": "Section Break", + "label": "Supplier", + "options": "icon-user", "permlevel": 0 - }, + }, { - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "SQTN-", - "permlevel": 0, - "print_hide": 1, + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "SQTN-", + "permlevel": 0, + "print_hide": 1, "reqd": 1 - }, + }, { - "description": "Supplier (vendor) name as entered in supplier master", - "fieldname": "supplier", - "fieldtype": "Link", - "in_filter": 1, - "label": "Supplier", - "oldfieldname": "supplier", - "oldfieldtype": "Link", - "options": "Supplier", - "permlevel": 0, - "print_hide": 1, - "reqd": 1, + "description": "Supplier (vendor) name as entered in supplier master", + "fieldname": "supplier", + "fieldtype": "Link", + "in_filter": 1, + "label": "Supplier", + "oldfieldname": "supplier", + "oldfieldtype": "Link", + "options": "Supplier", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, "search_index": 1 - }, + }, { - "fieldname": "supplier_name", - "fieldtype": "Data", - "hidden": 0, - "in_list_view": 0, - "label": "Name", - "permlevel": 0, + "fieldname": "supplier_name", + "fieldtype": "Data", + "hidden": 0, + "in_list_view": 0, + "label": "Name", + "permlevel": 0, "read_only": 1 - }, + }, { - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Address", - "permlevel": 0, + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Address", + "permlevel": 0, "read_only": 1 - }, + }, { - "fieldname": "contact_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact", - "permlevel": 0, + "fieldname": "contact_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact", + "permlevel": 0, "read_only": 1 - }, + }, { - "fieldname": "contact_mobile", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Mobile No", - "permlevel": 0, + "fieldname": "contact_mobile", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Mobile No", + "permlevel": 0, "read_only": 1 - }, + }, { - "fieldname": "contact_email", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact Email", - "permlevel": 0, - "print_hide": 1, + "fieldname": "contact_email", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact Email", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "permlevel": 0, - "print_hide": 0, - "print_width": "50%", + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 0, + "print_width": "50%", "width": "50%" - }, + }, { - "fieldname": "transaction_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Date", - "oldfieldname": "transaction_date", - "oldfieldtype": "Date", - "permlevel": 0, - "reqd": 1, + "fieldname": "transaction_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Date", + "oldfieldname": "transaction_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1, "search_index": 1 - }, + }, { - "fieldname": "amended_from", - "fieldtype": "Link", - "hidden": 1, - "ignore_user_permissions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "options": "Supplier Quotation", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "amended_from", + "fieldtype": "Link", + "hidden": 1, + "ignore_user_permissions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "options": "Supplier Quotation", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "report_hide": 0 - }, + }, { - "description": "", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "no_copy": 0, - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "permlevel": 0, - "print_hide": 1, - "reqd": 1, + "description": "", + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "no_copy": 0, + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, "search_index": 1 - }, + }, { - "fieldname": "currency_and_price_list", - "fieldtype": "Section Break", - "label": "", - "options": "icon-tag", + "fieldname": "currency_and_price_list", + "fieldtype": "Section Break", + "label": "", + "options": "icon-tag", "permlevel": 0 - }, + }, { - "fieldname": "currency", - "fieldtype": "Link", - "label": "Currency", - "no_copy": 0, - "oldfieldname": "currency", - "oldfieldtype": "Select", - "options": "Currency", - "permlevel": 0, - "print_hide": 1, + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "no_copy": 0, + "oldfieldname": "currency", + "oldfieldtype": "Select", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, "reqd": 1 - }, + }, { - "description": "Rate at which supplier's currency is converted to company's base currency", - "fieldname": "conversion_rate", - "fieldtype": "Float", - "hidden": 0, - "label": "Exchange Rate", - "no_copy": 0, - "oldfieldname": "conversion_rate", - "oldfieldtype": "Currency", - "permlevel": 0, - "print_hide": 1, + "description": "Rate at which supplier's currency is converted to company's base currency", + "fieldname": "conversion_rate", + "fieldtype": "Float", + "hidden": 0, + "label": "Exchange Rate", + "no_copy": 0, + "oldfieldname": "conversion_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, "reqd": 1 - }, + }, { - "fieldname": "cb_price_list", - "fieldtype": "Column Break", - "permlevel": 0, - "print_width": "50%", + "fieldname": "cb_price_list", + "fieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", "width": "50%" - }, + }, { - "fieldname": "buying_price_list", - "fieldtype": "Link", - "label": "Price List", - "options": "Price List", - "permlevel": 0, + "fieldname": "buying_price_list", + "fieldtype": "Link", + "label": "Price List", + "options": "Price List", + "permlevel": 0, "print_hide": 1 - }, + }, { - "depends_on": "buying_price_list", - "fieldname": "price_list_currency", - "fieldtype": "Link", - "label": "Price List Currency", - "options": "Currency", - "permlevel": 0, - "print_hide": 1, + "depends_on": "buying_price_list", + "fieldname": "price_list_currency", + "fieldtype": "Link", + "label": "Price List Currency", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "depends_on": "buying_price_list", - "fieldname": "plc_conversion_rate", - "fieldtype": "Float", - "label": "Price List Exchange Rate", - "permlevel": 0, + "depends_on": "buying_price_list", + "fieldname": "plc_conversion_rate", + "fieldtype": "Float", + "label": "Price List Exchange Rate", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "ignore_pricing_rule", - "fieldtype": "Check", - "label": "Ignore Pricing Rule", - "no_copy": 1, - "permlevel": 1, + "fieldname": "ignore_pricing_rule", + "fieldtype": "Check", + "label": "Ignore Pricing Rule", + "no_copy": 1, + "permlevel": 1, "print_hide": 1 - }, + }, { - "fieldname": "items_section", - "fieldtype": "Section Break", - "label": "", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart", + "fieldname": "items_section", + "fieldtype": "Section Break", + "label": "", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", "permlevel": 0 - }, + }, { - "allow_on_submit": 1, - "fieldname": "items", - "fieldtype": "Table", - "label": "Items", - "no_copy": 0, - "oldfieldname": "po_details", - "oldfieldtype": "Table", - "options": "Supplier Quotation Item", + "allow_on_submit": 1, + "fieldname": "items", + "fieldtype": "Table", + "label": "Items", + "no_copy": 0, + "oldfieldname": "po_details", + "oldfieldtype": "Table", + "options": "Supplier Quotation Item", "permlevel": 0 - }, + }, { - "fieldname": "section_break_22", - "fieldtype": "Section Break", + "fieldname": "section_break_22", + "fieldtype": "Section Break", "permlevel": 0 - }, + }, { - "fieldname": "base_net_total", - "fieldtype": "Currency", - "label": "Net Total (Company Currency)", - "no_copy": 1, - "oldfieldname": "net_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "base_net_total", + "fieldtype": "Currency", + "label": "Net Total (Company Currency)", + "no_copy": 1, + "oldfieldname": "net_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "reqd": 0 - }, + }, { - "fieldname": "column_break_24", - "fieldtype": "Column Break", + "fieldname": "column_break_24", + "fieldtype": "Column Break", "permlevel": 0 - }, + }, { - "fieldname": "net_total", - "fieldtype": "Currency", - "label": "Net Total", - "no_copy": 0, - "oldfieldname": "net_total_import", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 0, + "fieldname": "net_total", + "fieldtype": "Currency", + "label": "Net Total", + "no_copy": 0, + "oldfieldname": "net_total_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, "read_only": 1 - }, + }, { - "fieldname": "taxes_section", - "fieldtype": "Section Break", - "label": "Taxes and Charges", - "oldfieldtype": "Section Break", - "options": "icon-money", + "fieldname": "taxes_section", + "fieldtype": "Section Break", + "label": "Taxes and Charges", + "oldfieldtype": "Section Break", + "options": "icon-money", "permlevel": 0 - }, + }, { - "description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.", - "fieldname": "taxes_and_charges", - "fieldtype": "Link", - "label": "Taxes and Charges", - "no_copy": 1, - "oldfieldname": "purchase_other_charges", - "oldfieldtype": "Link", - "options": "Purchase Taxes and Charges Master", - "permlevel": 0, + "description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.", + "fieldname": "taxes_and_charges", + "fieldtype": "Link", + "label": "Taxes and Charges", + "no_copy": 1, + "oldfieldname": "purchase_other_charges", + "oldfieldtype": "Link", + "options": "Purchase Taxes and Charges Master", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "taxes", - "fieldtype": "Table", - "label": "Purchase Taxes and Charges", - "no_copy": 0, - "oldfieldname": "purchase_tax_details", - "oldfieldtype": "Table", - "options": "Purchase Taxes and Charges", + "fieldname": "taxes", + "fieldtype": "Table", + "label": "Purchase Taxes and Charges", + "no_copy": 0, + "oldfieldname": "purchase_tax_details", + "oldfieldtype": "Table", + "options": "Purchase Taxes and Charges", "permlevel": 0 - }, + }, { - "fieldname": "other_charges_calculation", - "fieldtype": "HTML", - "label": "Taxes and Charges Calculation", - "no_copy": 1, - "oldfieldtype": "HTML", - "permlevel": 0, + "fieldname": "other_charges_calculation", + "fieldtype": "HTML", + "label": "Taxes and Charges Calculation", + "no_copy": 1, + "oldfieldtype": "HTML", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "totals", - "fieldtype": "Section Break", - "label": "", - "oldfieldtype": "Section Break", - "options": "icon-money", + "fieldname": "totals", + "fieldtype": "Section Break", + "label": "", + "oldfieldtype": "Section Break", + "options": "icon-money", "permlevel": 0 - }, + }, { - "fieldname": "base_taxes_and_charges_added", - "fieldtype": "Currency", - "label": "Taxes and Charges Added (Company Currency)", - "no_copy": 0, - "oldfieldname": "other_charges_added", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, + "fieldname": "base_taxes_and_charges_added", + "fieldtype": "Currency", + "label": "Taxes and Charges Added (Company Currency)", + "no_copy": 0, + "oldfieldname": "other_charges_added", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "base_taxes_and_charges_deducted", - "fieldtype": "Currency", - "label": "Taxes and Charges Deducted (Company Currency)", - "no_copy": 0, - "oldfieldname": "other_charges_deducted", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, + "fieldname": "base_taxes_and_charges_deducted", + "fieldtype": "Currency", + "label": "Taxes and Charges Deducted (Company Currency)", + "no_copy": 0, + "oldfieldname": "other_charges_deducted", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "base_total_taxes_and_charges", - "fieldtype": "Currency", - "label": "Total Taxes and Charges (Company Currency)", - "no_copy": 1, - "oldfieldname": "total_tax", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, + "fieldname": "base_total_taxes_and_charges", + "fieldtype": "Currency", + "label": "Total Taxes and Charges (Company Currency)", + "no_copy": 1, + "oldfieldname": "total_tax", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "base_grand_total", - "fieldtype": "Currency", - "label": "Grand Total (Company Currency)", - "no_copy": 1, - "oldfieldname": "grand_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, + "fieldname": "base_grand_total", + "fieldtype": "Currency", + "label": "Grand Total (Company Currency)", + "no_copy": 1, + "oldfieldname": "grand_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "base_rounded_total", - "fieldtype": "Currency", - "label": "Rounded Total (Company Currency)", - "oldfieldname": "rounded_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, + "fieldname": "base_rounded_total", + "fieldtype": "Currency", + "label": "Rounded Total (Company Currency)", + "oldfieldname": "rounded_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "description": "In Words will be visible once you save the Purchase Order.", - "fieldname": "base_in_words", - "fieldtype": "Data", - "label": "In Words (Company Currency)", - "oldfieldname": "in_words", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 1, + "description": "In Words will be visible once you save the Purchase Order.", + "fieldname": "base_in_words", + "fieldtype": "Data", + "label": "In Words (Company Currency)", + "oldfieldname": "in_words", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "column_break4", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "permlevel": 0, + "fieldname": "column_break4", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, "print_hide": 0 - }, + }, { - "fieldname": "taxes_and_charges_added", - "fieldtype": "Currency", - "label": "Taxes and Charges Added", - "no_copy": 0, - "oldfieldname": "other_charges_added_import", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "taxes_and_charges_added", + "fieldtype": "Currency", + "label": "Taxes and Charges Added", + "no_copy": 0, + "oldfieldname": "other_charges_added_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "report_hide": 0 - }, + }, { - "fieldname": "taxes_and_charges_deducted", - "fieldtype": "Currency", - "label": "Taxes and Charges Deducted", - "no_copy": 0, - "oldfieldname": "other_charges_deducted_import", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "taxes_and_charges_deducted", + "fieldtype": "Currency", + "label": "Taxes and Charges Deducted", + "no_copy": 0, + "oldfieldname": "other_charges_deducted_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "report_hide": 0 - }, + }, { - "fieldname": "total_taxes_and_charges", - "fieldtype": "Currency", - "label": "Total Taxes and Charges", - "options": "currency", - "permlevel": 0, - "precision": "" - }, - { - "fieldname": "grand_total", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Grand Total", - "no_copy": 0, - "oldfieldname": "grand_total_import", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 0, - "read_only": 1, - "report_hide": 0 - }, - { - "fieldname": "in_words", - "fieldtype": "Data", - "label": "In Words", - "oldfieldname": "in_words_import", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 0, + "fieldname": "total_taxes_and_charges", + "fieldtype": "Currency", + "label": "Total Taxes and Charges", + "options": "currency", + "permlevel": 0, + "precision": "", "read_only": 1 - }, + }, { - "fieldname": "fold", - "fieldtype": "Fold", + "fieldname": "grand_total", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Grand Total", + "no_copy": 0, + "oldfieldname": "grand_total_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "report_hide": 0 + }, + { + "fieldname": "in_words", + "fieldtype": "Data", + "label": "In Words", + "oldfieldname": "in_words_import", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "fold", + "fieldtype": "Fold", "permlevel": 0 - }, + }, { - "fieldname": "terms_section_break", - "fieldtype": "Section Break", - "label": "Terms and Conditions", - "oldfieldtype": "Section Break", - "options": "icon-legal", + "fieldname": "terms_section_break", + "fieldtype": "Section Break", + "label": "Terms and Conditions", + "oldfieldtype": "Section Break", + "options": "icon-legal", "permlevel": 0 - }, + }, { - "allow_on_submit": 1, - "fieldname": "letter_head", - "fieldtype": "Link", - "label": "Letter Head", - "oldfieldname": "letter_head", - "oldfieldtype": "Select", - "options": "Letter Head", - "permlevel": 0, + "allow_on_submit": 1, + "fieldname": "letter_head", + "fieldtype": "Link", + "label": "Letter Head", + "oldfieldname": "letter_head", + "oldfieldtype": "Select", + "options": "Letter Head", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "tc_name", - "fieldtype": "Link", - "label": "Terms", - "oldfieldname": "tc_name", - "oldfieldtype": "Link", - "options": "Terms and Conditions", - "permlevel": 0, + "fieldname": "tc_name", + "fieldtype": "Link", + "label": "Terms", + "oldfieldname": "tc_name", + "oldfieldtype": "Link", + "options": "Terms and Conditions", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "get_terms", - "fieldtype": "Button", - "label": "Get Terms and Conditions", - "oldfieldtype": "Button", + "fieldname": "get_terms", + "fieldtype": "Button", + "label": "Get Terms and Conditions", + "oldfieldtype": "Button", "permlevel": 0 - }, + }, { - "fieldname": "terms", - "fieldtype": "Text Editor", - "label": "Terms and Conditions", - "oldfieldname": "terms", - "oldfieldtype": "Text Editor", + "fieldname": "terms", + "fieldtype": "Text Editor", + "label": "Terms and Conditions", + "oldfieldname": "terms", + "oldfieldtype": "Text Editor", "permlevel": 0 - }, + }, { - "depends_on": "supplier", - "fieldname": "contact_section", - "fieldtype": "Section Break", - "label": "Contact Info", - "options": "icon-bullhorn", + "depends_on": "supplier", + "fieldname": "contact_section", + "fieldtype": "Section Break", + "label": "Contact Info", + "options": "icon-bullhorn", "permlevel": 0 - }, + }, { - "fieldname": "supplier_address", - "fieldtype": "Link", - "in_filter": 1, - "label": "Supplier Address", - "options": "Address", - "permlevel": 0, + "fieldname": "supplier_address", + "fieldtype": "Link", + "in_filter": 1, + "label": "Supplier Address", + "options": "Address", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "contact_person", - "fieldtype": "Link", - "in_filter": 1, - "label": "Contact Person", - "options": "Contact", - "permlevel": 0, + "fieldname": "contact_person", + "fieldtype": "Link", + "in_filter": 1, + "label": "Contact Person", + "options": "Contact", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text", + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", "permlevel": 0 - }, + }, { - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nDraft\nSubmitted\nStopped\nCancelled", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, - "reqd": 1, + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "\nDraft\nSubmitted\nStopped\nCancelled", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1, "search_index": 1 - }, + }, { - "default": "No", - "fieldname": "is_subcontracted", - "fieldtype": "Select", - "label": "Is Subcontracted", - "options": "\nYes\nNo", - "permlevel": 0, + "default": "No", + "fieldname": "is_subcontracted", + "fieldtype": "Select", + "label": "Is Subcontracted", + "options": "\nYes\nNo", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "column_break_57", - "fieldtype": "Column Break", + "fieldname": "column_break_57", + "fieldtype": "Column Break", "permlevel": 0 - }, + }, { - "fieldname": "fiscal_year", - "fieldtype": "Link", - "in_filter": 1, - "label": "Fiscal Year", - "no_copy": 0, - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "Fiscal Year", - "permlevel": 0, - "print_hide": 1, - "reqd": 1, + "fieldname": "fiscal_year", + "fieldtype": "Link", + "in_filter": 1, + "label": "Fiscal Year", + "no_copy": 0, + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, "search_index": 1 - }, + }, { - "allow_on_submit": 1, - "fieldname": "select_print_heading", - "fieldtype": "Link", - "label": "Print Heading", - "no_copy": 1, - "oldfieldname": "select_print_heading", - "oldfieldtype": "Link", - "options": "Print Heading", - "permlevel": 0, - "print_hide": 1, + "allow_on_submit": 1, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "label": "Print Heading", + "no_copy": 1, + "oldfieldname": "select_print_heading", + "oldfieldtype": "Link", + "options": "Print Heading", + "permlevel": 0, + "print_hide": 1, "report_hide": 1 } - ], - "icon": "icon-shopping-cart", - "idx": 1, - "is_submittable": 1, - "modified": "2015-02-20 05:16:21.307774", - "modified_by": "Administrator", - "module": "Buying", - "name": "Supplier Quotation", - "owner": "Administrator", + ], + "icon": "icon-shopping-cart", + "idx": 1, + "is_submittable": 1, + "modified": "2015-02-20 05:16:21.307774", + "modified_by": "Administrator", + "module": "Buying", + "name": "Supplier Quotation", + "owner": "Administrator", "permissions": [ { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Manufacturing Manager", - "share": 1, - "submit": 1, + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Manufacturing Manager", + "share": 1, + "submit": 1, "write": 1 - }, + }, { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Purchase Manager", - "share": 1, - "submit": 1, + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Manager", + "share": 1, + "submit": 1, "write": 1 - }, + }, { - "amend": 1, - "apply_user_permissions": 1, - "cancel": 0, - "create": 1, - "delete": 0, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Purchase User", - "share": 1, - "submit": 0, + "amend": 1, + "apply_user_permissions": 1, + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User", + "share": 1, + "submit": 0, "write": 1 - }, + }, { - "amend": 0, - "apply_user_permissions": 1, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Material User", - "submit": 0, + "amend": 0, + "apply_user_permissions": 1, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 0, "write": 0 - }, + }, { - "amend": 0, - "apply_user_permissions": 1, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Supplier", - "submit": 0, + "amend": 0, + "apply_user_permissions": 1, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Supplier", + "submit": 0, "write": 0 - }, + }, { - "permlevel": 1, - "read": 1, - "role": "Purchase Manager", + "permlevel": 1, + "read": 1, + "role": "Purchase Manager", "write": 1 } - ], - "read_only_onload": 1, - "search_fields": "status, transaction_date, supplier,base_grand_total", - "sort_field": "modified", - "sort_order": "DESC", + ], + "read_only_onload": 1, + "search_fields": "status, transaction_date, supplier,grand_total", + "sort_field": "modified", + "sort_order": "DESC", "title_field": "supplier_name" -} \ No newline at end of file +} diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index d9bac98f36..504c446fe9 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -11,7 +11,6 @@ from erpnext.controllers.accounts_controller import validate_conversion_rate class calculate_taxes_and_totals(object): def __init__(self, doc): self.doc = doc - self.calculate() def calculate(self): @@ -25,6 +24,15 @@ class calculate_taxes_and_totals(object): self.calculate_total_advance() def _calculate(self): + self.calculate_item_values() + self.initialize_taxes() + self.determine_exclusive_rate() + self.calculate_net_total() + self.calculate_taxes() + self.calculate_totals() + self._cleanup() + + def validate_conversion_rate(self): # validate conversion rate company_currency = get_company_currency(self.doc.company) if not self.doc.currency or self.doc.currency == company_currency: @@ -36,17 +44,6 @@ class calculate_taxes_and_totals(object): self.doc.conversion_rate = flt(self.doc.conversion_rate) - self.calculate_item_values() - self.initialize_taxes() - - if self.doc.doctype in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]: - self.determine_exclusive_rate() - - self.calculate_net_total() - self.calculate_taxes() - self.calculate_totals() - self._cleanup() - def calculate_item_values(self): if not self.discount_amount_applied: for item in self.doc.get("items"): @@ -55,21 +52,22 @@ class calculate_taxes_and_totals(object): if item.discount_percentage == 100: item.rate = 0.0 elif not item.rate: - item.rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)), - self.doc.precision("rate", item)) + item.rate = flt(item.price_list_rate * + (1.0 - (item.discount_percentage / 100.0)), item.precision("rate")) - item.amount = flt(item.rate * item.qty, self.doc.precision("amount", item)) - item.item_tax_amount = 0.0; + item.net_rate = item.rate + item.amount = flt(item.rate * item.qty, item.precision("amount")) + item.net_amount = item.amount - self._set_in_company_currency(item, "price_list_rate", "base_price_list_rate") - self._set_in_company_currency(item, "rate", "base_rate") - self._set_in_company_currency(item, "amount", "base_amount") + self._set_in_company_currency(item, ["price_list_rate", "rate", "net_rate", "amount", "net_amount"]) - def _set_in_company_currency(self, item, print_field, base_field): + item.item_tax_amount = 0.0 + + def _set_in_company_currency(self, doc, fields): """set values in base currency""" - value_in_company_currency = flt(self.doc.conversion_rate * - flt(item.get(print_field), self.doc.precision(print_field, item)), self.doc.precision(base_field, item)) - item.set(base_field, value_in_company_currency) + for f in fields: + val = flt(flt(doc.get(f), doc.precision(f)) * self.doc.conversion_rate, doc.precision("base_" + f)) + doc.set("base_" + f, val) def initialize_taxes(self): for tax in self.doc.get("taxes"): @@ -116,9 +114,9 @@ class calculate_taxes_and_totals(object): _on_previous_row_error("1 - %d" % (tax.row_id,)) def determine_exclusive_rate(self): - if not any((cint(tax.included_in_print_rate) for tax in self.doc.get("taxes"))): - # no inclusive tax - return + if not any((cint(tax.included_in_print_rate) for tax in self.doc.get("taxes"))) or \ + self.doc.doctype not in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]: + return for item in self.doc.get("items"): item_tax_map = self._load_item_tax_rate(item.item_tax_rate) @@ -136,18 +134,24 @@ class calculate_taxes_and_totals(object): cumulated_tax_fraction += tax.tax_fraction_for_current_item if cumulated_tax_fraction and not self.discount_amount_applied and item.qty: - item.base_amount = flt((item.amount * self.doc.conversion_rate) / - (1 + cumulated_tax_fraction), self.doc.precision("base_amount", item)) + item.net_amount = flt(item.amount / (1 + cumulated_tax_fraction), item.precision("net_amount")) + item.net_rate = flt(item.net_amount / item.qty, item.precision("net_rate")) + item.discount_percentage = flt(item.discount_percentage, item.precision("discount_percentage")) - item.base_rate = flt(item.base_amount / item.qty, self.doc.precision("base_rate", item)) - item.discount_percentage = flt(item.discount_percentage, self.doc.precision("discount_percentage", item)) - if item.discount_percentage == 100: - item.base_price_list_rate = item.base_rate - item.base_rate = 0.0 - else: - item.base_price_list_rate = flt(item.base_rate / (1 - (item.discount_percentage / 100.0)), - self.doc.precision("base_price_list_rate", item)) + self._set_in_company_currency(item, ["net_rate", "net_amount"]) + + # below part need to be fixed??? + + # if item.discount_percentage == 100: + # item.price_list_rate = item.net_rate + # item.base_price_list_rate = flt(item.price_list_rate*self.doc.conversion_rate, + # self.doc.precision("base_price_list_rate", item)) + # item.rate = item.base_rate = item.net_rate = item.base_net_rate = 0.0 + # else: + # item.base_price_list_rate = flt(item.net_rate / (1 - (item.discount_percentage / 100.0)), + # self.doc.precision("price_list_rate", item)) + def _load_item_tax_rate(self, item_tax_rate): return json.loads(item_tax_rate) if item_tax_rate else {} @@ -182,17 +186,19 @@ class calculate_taxes_and_totals(object): return tax.rate def calculate_net_total(self): - self.doc.base_net_total = self.doc.net_total = 0.0 + self.doc.print_total = self.doc.base_print_total = self.doc.net_total = self.doc.base_net_total = 0.0 for item in self.doc.get("items"): - self.doc.base_net_total += item.base_amount - self.doc.net_total += item.amount + self.doc.print_total += item.amount + self.doc.base_print_total += item.base_amount + self.doc.net_total += item.net_amount + self.doc.base_net_total += item.base_net_amount - self.doc.round_floats_in(self.doc, ["base_net_total", "net_total"]) + self.doc.round_floats_in(self.doc, ["print_total", "base_print_total", "net_total", "base_net_total"]) def calculate_taxes(self): # maintain actual tax rate based on idx - actual_tax_dict = dict([[tax.idx, flt(tax.rate, self.doc.precision("tax_amount", tax))] + actual_tax_dict = dict([[tax.idx, flt(tax.tax_amount, tax.precision("tax_amount"))] for tax in self.doc.get("taxes") if tax.charge_type == "Actual"]) for n, item in enumerate(self.doc.get("items")): @@ -230,12 +236,10 @@ class calculate_taxes_and_totals(object): # note: grand_total_for_current_item contains the contribution of # item's amount, previously applied tax and the current tax on that item if i==0: - tax.grand_total_for_current_item = flt(item.base_amount + current_tax_amount, - self.doc.precision("total", tax)) + tax.grand_total_for_current_item = flt(item.net_amount + current_tax_amount) else: tax.grand_total_for_current_item = \ - flt(self.doc.get("taxes")[i-1].grand_total_for_current_item + - current_tax_amount, self.doc.precision("total", tax)) + self.doc.get("taxes")[i-1].grand_total_for_current_item + current_tax_amount # in tax.total, accumulate grand total of each item tax.total += tax.grand_total_for_current_item @@ -254,12 +258,11 @@ class calculate_taxes_and_totals(object): if tax.charge_type == "Actual": # distribute the tax amount proportionally to each item row - actual = flt(tax.rate, self.doc.precision("tax_amount", tax)) - current_tax_amount = (self.doc.base_net_total - and ((item.base_amount / self.doc.base_net_total) * actual) - or 0) + actual = flt(tax.tax_amount, tax.precision("tax_amount")) + current_tax_amount = item.net_amount*actual / self.doc.net_total if self.doc.net_total else 0.0 + elif tax.charge_type == "On Net Total": - current_tax_amount = (tax_rate / 100.0) * item.base_amount + current_tax_amount = (tax_rate / 100.0) * item.net_amount elif tax.charge_type == "On Previous Row Amount": current_tax_amount = (tax_rate / 100.0) * \ self.doc.get("taxes")[cint(tax.row_id) - 1].tax_amount_for_current_item @@ -267,72 +270,66 @@ class calculate_taxes_and_totals(object): current_tax_amount = (tax_rate / 100.0) * \ self.doc.get("taxes")[cint(tax.row_id) - 1].grand_total_for_current_item - current_tax_amount = flt(current_tax_amount, self.doc.precision("tax_amount", tax)) + # current_tax_amount = flt(current_tax_amount, tax.precision("tax_amount", tax)) - # store tax breakup for each item - key = item.item_code or item.item_name - if tax.item_wise_tax_detail.get(key): - item_wise_tax_amount = tax.item_wise_tax_detail[key][1] + current_tax_amount - tax.item_wise_tax_detail[key] = [tax_rate,item_wise_tax_amount] - else: - tax.item_wise_tax_detail[key] = [tax_rate,current_tax_amount] + self.set_item_wise_tax(item, tax, tax_rate, current_tax_amount) return current_tax_amount + def set_item_wise_tax(self, item, tax, tax_rate, current_tax_amount): + # store tax breakup for each item + key = item.item_code or item.item_name + item_wise_tax_amount = current_tax_amount*self.doc.conversion_rate + if tax.item_wise_tax_detail.get(key): + item_wise_tax_amount += tax.item_wise_tax_detail[key][1] + + tax.item_wise_tax_detail[key] = [tax_rate,flt(item_wise_tax_amount, tax.precision("base_tax_amount"))] + def round_off_totals(self, tax): - tax.total = flt(tax.total, self.doc.precision("total", tax)) - tax.tax_amount = flt(tax.tax_amount, self.doc.precision("tax_amount", tax)) - tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, - self.doc.precision("tax_amount", tax)) + tax.total = flt(tax.total, tax.precision("total")) + tax.tax_amount = flt(tax.tax_amount, tax.precision("tax_amount")) + tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, tax.precision("tax_amount")) def adjust_discount_amount_loss(self, tax): - discount_amount_loss = self.doc.base_grand_total - flt(self.doc.base_discount_amount) - tax.total + discount_amount_loss = self.doc.grand_total - flt(self.doc.discount_amount) - tax.total tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount + discount_amount_loss, self.doc.precision("tax_amount", tax)) tax.total = flt(tax.total + discount_amount_loss, self.doc.precision("total", tax)) def calculate_totals(self): - self.doc.base_grand_total = flt(self.doc.get("taxes")[-1].total - if self.doc.get("taxes") else self.doc.base_net_total) - - self.doc.base_total_taxes_and_charges = flt(self.doc.base_grand_total - self.doc.base_net_total, - self.doc.precision("base_total_taxes_and_charges")) + self.doc.grand_total = flt(self.doc.get("taxes")[-1].total + if self.doc.get("taxes") else self.doc.net_total) if self.doc.doctype in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]: - self.doc.grand_total = flt(self.doc.base_grand_total / self.doc.conversion_rate) \ - if (self.doc.base_total_taxes_and_charges or self.doc.discount_amount) else self.doc.net_total - - self.doc.total_taxes_and_charges = flt(self.doc.grand_total - self.doc.net_total + - flt(self.doc.discount_amount), self.doc.precision("total_taxes_and_charges")) + self.doc.base_grand_total = flt(self.doc.grand_total * self.doc.conversion_rate) \ + if self.doc.total_taxes_and_charges else self.doc.base_net_total else: - self.doc.base_taxes_and_charges_added, self.doc.base_taxes_and_charges_deducted = 0.0, 0.0 + self.doc.taxes_and_charges_added, self.taxes_and_charges_deducted = 0.0, 0.0 for tax in self.doc.get("taxes"): if tax.category in ["Valuation and Total", "Total"]: if tax.add_deduct_tax == "Add": - self.doc.base_taxes_and_charges_added += flt(tax.tax_amount) + self.doc.taxes_and_charges_added += flt(tax.tax_amount) else: - self.doc.base_taxes_and_charges_deducted += flt(tax.tax_amount) + self.doc.taxes_and_charges_deducted += flt(tax.tax_amount) - self.doc.round_floats_in(self.doc, ["base_taxes_and_charges_added", "base_taxes_and_charges_deducted"]) + self.doc.round_floats_in(self.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"]) - self.doc.grand_total = flt(self.doc.base_grand_total / self.doc.conversion_rate) \ - if (self.doc.base_taxes_and_charges_added or self.doc.base_taxes_and_charges_deducted) else self.doc.net_total + self.doc.base_grand_total = flt(self.doc.grand_total * self.doc.conversion_rate) \ + if (self.doc.taxes_and_charges_added or self.doc.taxes_and_charges_deducted) \ + else self.doc.base_net_total - self.doc.total_taxes_and_charges = flt(self.doc.grand_total - self.doc.net_total, - self.doc.precision("total_taxes_and_charges")) + self._set_in_company_currency(self.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"]) - self.doc.taxes_and_charges_added = flt(self.doc.base_taxes_and_charges_added / self.doc.conversion_rate, - self.doc.precision("taxes_and_charges_added")) - self.doc.taxes_and_charges_deducted = flt(self.doc.base_taxes_and_charges_deducted / self.doc.conversion_rate, - self.doc.precision("taxes_and_charges_deducted")) + self.doc.total_taxes_and_charges = flt(self.doc.grand_total - self.doc.net_total, + self.doc.precision("total_taxes_and_charges")) - self.doc.base_grand_total = flt(self.doc.base_grand_total, self.doc.precision("base_grand_total")) - self.doc.grand_total = flt(self.doc.grand_total, self.doc.precision("grand_total")) + self._set_in_company_currency(self.doc, ["total_taxes_and_charges"]) + self.doc.round_floats_in(self.doc, ["grand_total", "base_grand_total"]) - if self.doc.meta.get_field("base_rounded_total"): - self.doc.base_rounded_total = rounded(self.doc.base_grand_total) if self.doc.meta.get_field("rounded_total"): self.doc.rounded_total = rounded(self.doc.grand_total) + if self.doc.meta.get_field("base_rounded_total"): + self.doc.base_rounded_total = rounded(self.doc.base_grand_total) def _cleanup(self): for tax in self.doc.get("taxes"): @@ -343,40 +340,44 @@ class calculate_taxes_and_totals(object): self.doc.base_discount_amount = flt(self.doc.discount_amount * self.doc.conversion_rate, self.doc.precision("base_discount_amount")) - grand_total_for_discount_amount = self.get_grand_total_for_discount_amount() + total_for_discount_amount = self.get_total_for_discount_amount() - if grand_total_for_discount_amount: + if total_for_discount_amount: # calculate item amount after Discount Amount for item in self.doc.get("items"): - distributed_amount = flt(self.doc.base_discount_amount) * item.base_amount / grand_total_for_discount_amount - item.base_amount = flt(item.base_amount - distributed_amount, self.doc.precision("base_amount", item)) + distributed_amount = flt(self.doc.discount_amount) * item.net_amount / total_for_discount_amount + item.net_amount = flt(item.net_amount - distributed_amount, item.precision("net_amount")) + item.net_rate = flt(item.net_amount / item.qty, item.precision("net_rate")) + + self._set_in_company_currency(item, ["net_rate", "net_amount"]) self.discount_amount_applied = True self._calculate() else: self.doc.base_discount_amount = 0 - def get_grand_total_for_discount_amount(self): - actual_taxes_dict = {} + def get_total_for_discount_amount(self): + if self.doc.apply_discount_on == "Print Total": + return self.net_total + else: + actual_taxes_dict = {} - for tax in self.doc.get("taxes"): - if tax.charge_type == "Actual": - actual_taxes_dict.setdefault(tax.idx, tax.tax_amount) - elif tax.row_id in actual_taxes_dict: - actual_tax_amount = flt(actual_taxes_dict.get(tax.row_id, 0)) * flt(tax.rate) / 100 - actual_taxes_dict.setdefault(tax.idx, actual_tax_amount) + for tax in self.doc.get("taxes"): + if tax.charge_type == "Actual": + actual_taxes_dict.setdefault(tax.idx, tax.tax_amount) + elif tax.row_id in actual_taxes_dict: + actual_tax_amount = flt(actual_taxes_dict.get(tax.row_id, 0)) * flt(tax.rate) / 100 + actual_taxes_dict.setdefault(tax.idx, actual_tax_amount) - grand_total_for_discount_amount = flt(self.doc.base_grand_total - sum(actual_taxes_dict.values()), - self.doc.precision("base_grand_total")) - return grand_total_for_discount_amount + return flt(self.doc.grand_total - sum(actual_taxes_dict.values()), self.doc.precision("grand_total")) - def calculate_total_advance(self): - if self.doc.docstatus < 2: - sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.doc.precision("allocated_amount", adv)) + def calculate_total_advance(self, parenttype, advance_parentfield): + if self.docstatus < 2: + total_allocated_amount = sum([flt(adv.allocated_amount, adv.precision("allocated_amount")) for adv in self.doc.get("advances")]) - self.doc.total_advance = flt(sum_of_allocated_amount, self.doc.precision("total_advance")) + self.doc.total_advance = flt(total_allocated_amount, self.doc.precision("total_advance")) if self.doc.docstatus == 0: self.calculate_outstanding_amount() diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 663f6ab603..d9e3e43a5a 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -38,22 +38,46 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ this.show_item_wise_taxes(); }, + validate_conversion_rate: function() { + this.frm.doc.conversion_rate = flt(this.frm.doc.conversion_rate, precision("conversion_rate")); + var conversion_rate_label = frappe.meta.get_label(this.frm.doc.doctype, "conversion_rate", + this.frm.doc.name); + var company_currency = this.get_company_currency(); + + if(!this.frm.doc.conversion_rate) { + frappe.throw(repl('%(conversion_rate_label)s' + + __(' is mandatory. Maybe Currency Exchange record is not created for ') + + '%(from_currency)s' + __(" to ") + '%(to_currency)s', + { + "conversion_rate_label": conversion_rate_label, + "from_currency": this.frm.doc.currency, + "to_currency": company_currency + })); + } + }, + calculate_item_values: function() { var me = this; if (!this.discount_amount_applied) { $.each(this.frm.doc["items"] || [], function(i, item) { frappe.model.round_floats_in(item); + item.net_rate = item.rate; item.amount = flt(item.rate * item.qty, precision("amount", item)); + item.net_amount = item.amount; item.item_tax_amount = 0.0; - $.each(["price_list_rate", "rate", "amount"], function(i, f) { - item["base_" + f] = flt(item[f] * me.frm.doc.conversion_rate, precision("base_" + f, item)); - }) + this.set_in_company_currency(item, ["price_list_rate", "rate", "amount", "net_rate", "net_amount"]); }); } }, + set_in_company_currency: function(doc, fields) { + $.each(fields, function(i, f) { + doc["base_"+f] = flt(flt(doc[f], precision(f, doc)) * me.frm.doc.conversion_rate, precision("base_" + f, doc)); + }) + } + initialize_taxes: function() { var me = this; @@ -75,7 +99,12 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ }, determine_exclusive_rate: function() { - if(!in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) return; + var has_inclusive_tax = false; + $.each(me.frm.doc["taxes"] || [], function(i, row) { + if(cint(row.included_in_print_rate)) has_inclusive_tax = true; + }) + if(has_inclusive_tax==false || !in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) + return; var me = this; $.each(me.frm.doc["items"] || [], function(n, item) { @@ -97,19 +126,21 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ }); if(cumulated_tax_fraction && !me.discount_amount_applied) { - item.base_amount = flt( + item.net_amount = flt( (item.amount * me.frm.doc.conversion_rate) / (1 + cumulated_tax_fraction), - precision("base_amount", item)); + precision("net_amount", item)); - item.base_rate = flt(item.base_amount / item.qty, precision("base_rate", item)); + item.net_rate = flt(item.net_amount / item.qty, precision("net_rate", item)); - if(item.discount_percentage == 100) { - item.base_price_list_rate = item.base_rate; - item.base_rate = 0.0; - } else { - item.base_price_list_rate = flt(item.base_rate / (1 - item.discount_percentage / 100.0), - precision("base_price_list_rate", item)); - } + this.set_in_company_currency(item, ["net_rate", "net_amount"]); + + // if(item.discount_percentage == 100) { + // item.base_price_list_rate = item.base_rate; + // item.base_rate = 0.0; + // } else { + // item.base_price_list_rate = flt(item.base_rate / (1 - item.discount_percentage / 100.0), + // precision("base_price_list_rate", item)); + // } } }); }, @@ -140,20 +171,21 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ _get_tax_rate: function(tax, item_tax_map) { return (keys(item_tax_map).indexOf(tax.account_head) != -1) ? - flt(item_tax_map[tax.account_head], precision("rate", tax)) : - tax.rate; + flt(item_tax_map[tax.account_head], precision("rate", tax)) : tax.rate; }, calculate_net_total: function() { var me = this; - this.frm.doc.base_net_total = this.frm.doc.net_total = 0.0; + this.frm.doc.print_total = this.frm.doc.base_print_total = this.frm.doc.net_total = this.frm.doc.base_net_total = 0.0; $.each(this.frm.doc["items"] || [], function(i, item) { - me.frm.doc.base_net_total += item.base_amount; - me.frm.doc.net_total += item.amount; + me.frm.doc.print_total += item.amount; + me.frm.doc.base_print_total += item.base_amount; + me.frm.doc.net_total += item.net_amount; + me.frm.doc.base_net_total += item.base_net_amount; }); - frappe.model.round_floats_in(this.frm.doc, ["base_net_total", "net_total"]); + frappe.model.round_floats_in(this.frm.doc, ["print_total", "base_print_total", "net_total", "base_net_total"]); }, calculate_taxes: function() { @@ -163,7 +195,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ // maintain actual tax rate based on idx $.each(this.frm.doc["taxes"] || [], function(i, tax) { if (tax.charge_type == "Actual") { - actual_tax_dict[tax.idx] = flt(tax.rate, precision("tax_amount", tax)); + actual_tax_dict[tax.idx] = flt(tax.tax_amount, precision("tax_amount", tax)); } }); @@ -205,12 +237,10 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ // note: grand_total_for_current_item contains the contribution of // item's amount, previously applied tax and the current tax on that item if(i==0) { - tax.grand_total_for_current_item = flt(item.base_amount + current_tax_amount, - precision("total", tax)); + tax.grand_total_for_current_item = flt(item.base_amount + current_tax_amount); } else { tax.grand_total_for_current_item = - flt(me.frm.doc["taxes"][i-1].grand_total_for_current_item + current_tax_amount, - precision("total", tax)); + flt(me.frm.doc["taxes"][i-1].grand_total_for_current_item + current_tax_amount); } // in tax.total, accumulate grand total for each item @@ -238,12 +268,12 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ if(tax.charge_type == "Actual") { // distribute the tax amount proportionally to each item row - var actual = flt(tax.rate, precision("tax_amount", tax)); - current_tax_amount = this.frm.doc.base_net_total ? - ((item.base_amount / this.frm.doc.base_net_total) * actual) : 0.0; + var actual = flt(tax.tax_amount, precision("tax_amount", tax)); + current_tax_amount = this.frm.doc.net_total ? + ((item.net_amount / this.frm.doc.net_total) * actual) : 0.0; } else if(tax.charge_type == "On Net Total") { - current_tax_amount = (tax_rate / 100.0) * item.base_amount; + current_tax_amount = (tax_rate / 100.0) * item.net_amount; } else if(tax.charge_type == "On Previous Row Amount") { current_tax_amount = (tax_rate / 100.0) * @@ -254,14 +284,24 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ this.frm.doc["taxes"][cint(tax.row_id) - 1].grand_total_for_current_item; } - current_tax_amount = flt(current_tax_amount, precision("tax_amount", tax)); + // current_tax_amount = flt(current_tax_amount, precision("tax_amount", tax)); - // store tax breakup for each item - tax.item_wise_tax_detail[item.item_code || item.item_name] = [tax_rate, current_tax_amount]; + this.set_item_wise_tax(item, tax, tax_rate, current_tax_amount); return current_tax_amount; }, + set_item_wise_tax: function(item, tax, tax_rate, current_tax_amount) { + // store tax breakup for each item + var key = item.item_code || item.item_name; + var item_wise_tax_amount = current_tax_amount * this.frm.doc.conversion_rate; + if (tax.item_wise_tax_detail.get(key)) + item_wise_tax_amount += tax.item_wise_tax_detail[key][1] + + tax.item_wise_tax_detail[key] = [tax_rate,flt(item_wise_tax_amount, precision("base_tax_amount", tax))] + + }, + round_off_totals: function(tax) { tax.total = flt(tax.total, precision("total", tax)); tax.tax_amount = flt(tax.tax_amount, precision("tax_amount", tax)); @@ -276,9 +316,55 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ tax.total = flt(tax.total + discount_amount_loss, precision("total", tax)); }, + calculate_totals: function() { + // Changing sequence can cause roundiing issue and on-screen discrepency + var me = this; + var tax_count = this.frm.doc["taxes"] ? this.frm.doc["taxes"].length : 0; + this.frm.doc.grand_total = flt(tax_count ? this.frm.doc["taxes"][tax_count - 1].total : this.frm.doc.net_total); + + if(in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) { + this.frm.doc.base_grand_total = (this.frm.doc.base_total_taxes_and_charges) ? + flt(this.frm.doc.grand_total * this.frm.doc.conversion_rate) : this.frm.doc.base_net_total; + } else { + // other charges added/deducted + this.frm.doc.taxes_and_charges_added = this.frm.doc.taxes_and_charges_deducted = 0.0; + if(tax_count) { + $.each(this.frm.doc["taxes"] || [], function(i, tax) { + if in_list(["Valuation and Total", "Total"], tax.category) { + if(tax.add_deduct_tax == "Add") { + me.frm.doc.taxes_and_charges_added += flt(tax.tax_amount); + } else { + me.frm.doc.taxes_and_charges_deducted += flt(tax.tax_amount); + } + } + }) + + frappe.model.round_floats_in(this.frm.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"]); + } + + this.frm.doc.grand_total = flt((this.frm.doc.taxes_and_charges_added || this.frm.doc.taxes_and_charges_deducted) ? + flt(this.frm.doc.grand_total * this.frm.doc.conversion_rate) : this.frm.doc.base_net_total); + + this.set_in_company_currency(this.frm.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"]); + } + + this.frm.doc.total_taxes_and_charges = flt(this.frm.doc.grand_total - this.frm.doc.net_total, + precision("total_taxes_and_charges")); + + // Round grand total as per precision + frappe.model.round_floats_in(this.frm.doc, ["grand_total", "base_grand_total"]); + + // rounded totals + if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total", this.frm.doc.name)) { + this.frm.doc.rounded_total = Math.round(this.frm.doc.grand_total); + } + if(frappe.meta.get_docfield(this.frm.doc.doctype, "base_rounded_total", this.frm.doc.name)) { + this.frm.doc.base_rounded_total = Math.round(this.frm.doc.base_grand_total); + } + }, _cleanup: function() { - this.frm.doc.base_in_words = this.frm.doc.in_words = this.frm.doc.in_words = ""; + this.frm.doc.base_in_words = this.frm.doc.in_words = ""; if(this.frm.doc["items"] && this.frm.doc["items"].length) { if(!frappe.meta.get_docfield(this.frm.doc["items"][0].doctype, "item_tax_amount", this.frm.doctype)) { @@ -288,7 +374,6 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ } } - if(this.frm.doc["taxes"] && this.frm.doc["taxes"].length) { var temporary_fields = ["tax_amount_for_current_item", "grand_total_for_current_item", "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"] @@ -307,65 +392,6 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ } }, - calculate_totals: function() { - // Changing sequence can cause roundiing issue and on-screen discrepency - - var tax_count = this.frm.doc["taxes"] ? this.frm.doc["taxes"].length : 0; - this.frm.doc.base_grand_total = flt(tax_count ? this.frm.doc["taxes"][tax_count - 1].total : this.frm.doc.base_net_total); - - this.frm.doc.base_total_taxes_and_charges = flt(this.frm.doc.base_grand_total - this.frm.doc.base_net_total, - precision("base_total_taxes_and_charges")); - - if(in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) { - this.frm.doc.grand_total = (this.frm.doc.base_total_taxes_and_charges || this.frm.doc.discount_amount) ? - flt(this.frm.doc.base_grand_total / this.frm.doc.conversion_rate) : this.frm.doc.net_total; - - this.frm.doc.total_taxes_and_charges = flt(this.frm.doc.grand_total - this.frm.doc.net_total - + flt(this.frm.doc.discount_amount), precision("total_taxes_and_charges")); - } else { - // other charges added/deducted - this.frm.doc.base_taxes_and_charges_added = 0.0 - this.frm.doc.base_taxes_and_charges_deducted = 0.0 - if(tax_count) { - this.frm.doc.base_taxes_and_charges_added = frappe.utils.sum($.map(this.frm.doc["taxes"], - function(tax) { return (tax.add_deduct_tax == "Add" - && in_list(["Valuation and Total", "Total"], tax.category)) ? - tax.tax_amount : 0.0; })); - - this.frm.doc.base_taxes_and_charges_deducted = frappe.utils.sum($.map(this.frm.doc["taxes"], - function(tax) { return (tax.add_deduct_tax == "Deduct" - && in_list(["Valuation and Total", "Total"], tax.category)) ? - tax.tax_amount : 0.0; })); - - frappe.model.round_floats_in(this.frm.doc, - ["base_taxes_and_charges_added", "base_taxes_and_charges_deducted"]); - } - - this.frm.doc.grand_total = flt((this.frm.doc.base_taxes_and_charges_added || this.frm.doc.base_taxes_and_charges_deducted) ? - flt(this.frm.doc.base_grand_total / this.frm.doc.conversion_rate) : this.frm.doc.net_total); - - this.frm.doc.total_taxes_and_charges = flt(this.frm.doc.grand_total - this.frm.doc.net_total, - precision("total_taxes_and_charges")); - - this.frm.doc.taxes_and_charges_added = flt(this.frm.doc.base_taxes_and_charges_added / - this.frm.doc.conversion_rate, precision("taxes_and_charges_added")); - this.frm.doc.taxes_and_charges_deducted = flt(this.frm.doc.base_taxes_and_charges_deducted / - this.frm.doc.conversion_rate, precision("taxes_and_charges_deducted")); - } - - // Round grand total as per precision - this.frm.doc.base_grand_total = flt(this.frm.doc.base_grand_total, precision("base_grand_total")); - this.frm.doc.grand_total = flt(this.frm.doc.grand_total, precision("grand_total")); - - // rounded totals - if(frappe.meta.get_docfield(this.frm.doc.doctype, "base_rounded_total", this.frm.doc.name)) { - this.frm.doc.base_rounded_total = Math.round(this.frm.doc.base_grand_total); - } - if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total", this.frm.doc.name)) { - this.frm.doc.rounded_total = Math.round(this.frm.doc.grand_total); - } - }, - apply_discount_amount: function() { var me = this; var distributed_amount = 0.0; @@ -374,12 +400,15 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ this.frm.set_value("base_discount_amount", flt(this.frm.doc.discount_amount * this.frm.doc.conversion_rate, precision("base_discount_amount"))) - var grand_total_for_discount_amount = this.get_grand_total_for_discount_amount(); + var total_for_discount_amount = this.get_total_for_discount_amount(); // calculate item amount after Discount Amount - if (grand_total_for_discount_amount) { + if (total_for_discount_amount) { $.each(this.frm.doc["items"] || [], function(i, item) { - distributed_amount = flt(me.frm.doc.base_discount_amount) * item.base_amount / grand_total_for_discount_amount; - item.base_amount = flt(item.base_amount - distributed_amount, precision("base_amount", item)); + distributed_amount = flt(me.frm.doc.discount_amount) * item.net_amount / total_for_discount_amount; + item.base_amount = flt(item.net_amount - distributed_amount, precision("base_amount", item)); + item.net_rate = flt(item.net_amount / item.qty, precision("net_rate", item)); + + me.set_in_company_currency(item, ["net_rate", "net_amount"]); }); this.discount_amount_applied = true; @@ -390,34 +419,38 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ } }, - get_grand_total_for_discount_amount: function() { + get_total_for_discount_amount: function() { var me = this; - var total_actual_tax = 0.0; - var actual_taxes_dict = {}; - $.each(this.frm.doc["taxes"] || [], function(i, tax) { - if (tax.charge_type == "Actual") - actual_taxes_dict[tax.idx] = tax.tax_amount; - else if (actual_taxes_dict[tax.row_id] !== null) { - actual_tax_amount = flt(actual_taxes_dict[tax.row_id]) * flt(tax.rate) / 100; - actual_taxes_dict[tax.idx] = actual_tax_amount; - } - }); + if(this.apply_discount_amount == "Print Total") { + return this.net_total + } else { + var total_actual_tax = 0.0; + var actual_taxes_dict = {}; - $.each(actual_taxes_dict, function(key, value) { - if (value) - total_actual_tax += value; - }); + $.each(this.frm.doc["taxes"] || [], function(i, tax) { + if (tax.charge_type == "Actual") + actual_taxes_dict[tax.idx] = tax.tax_amount; + else if (actual_taxes_dict[tax.row_id] !== null) { + actual_tax_amount = flt(actual_taxes_dict[tax.row_id]) * flt(tax.rate) / 100; + actual_taxes_dict[tax.idx] = actual_tax_amount; + } + }); - grand_total_for_discount_amount = flt(this.frm.doc.base_grand_total - total_actual_tax, - precision("base_grand_total")); - return grand_total_for_discount_amount; + $.each(actual_taxes_dict, function(key, value) { + if (value) + total_actual_tax += value; + }); + + return flt(this.frm.doc.grand_total - total_actual_tax, precision("grand_total")); + } }, calculate_total_advance: function(update_paid_amount) { - this.frm.doc.total_advance = flt(frappe.utils.sum( - $.map(this.frm.doc["advances"] || [], function(adv) { return adv.allocated_amount }) - ), precision("total_advance")); + var total_allocated_amount = frappe.utils.sum($.map(this.frm.doc["advances"] || [], function(adv) { + return flt(adv.allocated_amount, precision("allocated_amount", adv)) + })); + this.frm.doc.total_advance = flt(total_allocated_amount, precision("total_advance")); this.calculate_outstanding_amount(update_paid_amount); } diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 1dca8372a7..6e6ea23af2 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -560,24 +560,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ return valid; }, - validate_conversion_rate: function() { - this.frm.doc.conversion_rate = flt(this.frm.doc.conversion_rate, precision("conversion_rate")); - var conversion_rate_label = frappe.meta.get_label(this.frm.doc.doctype, "conversion_rate", - this.frm.doc.name); - var company_currency = this.get_company_currency(); - - if(!this.frm.doc.conversion_rate) { - frappe.throw(repl('%(conversion_rate_label)s' + - __(' is mandatory. Maybe Currency Exchange record is not created for ') + - '%(from_currency)s' + __(" to ") + '%(to_currency)s', - { - "conversion_rate_label": conversion_rate_label, - "from_currency": this.frm.doc.currency, - "to_currency": company_currency - })); - } - }, - get_terms: function() { var me = this; if(this.frm.doc.tc_name) { diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 665710072c..c63939dbf9 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -25,7 +25,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ cur_frm.add_custom_button(__('Set as Lost'), cur_frm.cscript['Declare Order Lost'], "icon-exclamation", "btn-default"); } - + } if (this.frm.doc.docstatus===0) { @@ -159,4 +159,6 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { cur_frm.email_doc(frappe.boot.notification_settings.quotation_message); } - +frappe.ui.form.on("Quotation Item", "items_on_form_rendered", function(frm, cdt, cdn) { + // enable tax_amount field if Actual +}) diff --git a/erpnext/selling/doctype/quotation/quotation.json b/erpnext/selling/doctype/quotation/quotation.json index 14bce048a9..d90f1072ef 100644 --- a/erpnext/selling/doctype/quotation/quotation.json +++ b/erpnext/selling/doctype/quotation/quotation.json @@ -1,946 +1,974 @@ { - "allow_import": 1, - "autoname": "naming_series:", - "creation": "2013-05-24 19:29:08", - "docstatus": 0, - "doctype": "DocType", - "document_type": "Transaction", + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-05-24 19:29:08", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", "fields": [ { - "fieldname": "customer_section", - "fieldtype": "Section Break", - "label": "", - "options": "icon-user", + "fieldname": "customer_section", + "fieldtype": "Section Break", + "label": "", + "options": "icon-user", "permlevel": 0 - }, + }, { - "fieldname": "column_break0", - "fieldtype": "Column Break", - "permlevel": 0, - "read_only": 0, + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, "width": "50%" - }, + }, { - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "QTN-", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "QTN-", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, "reqd": 1 - }, + }, { - "default": "Customer", - "fieldname": "quotation_to", - "fieldtype": "Select", - "in_filter": 1, - "label": "Quotation To", - "oldfieldname": "quotation_to", - "oldfieldtype": "Select", - "options": "\nLead\nCustomer", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, - "report_hide": 0, + "default": "Customer", + "fieldname": "quotation_to", + "fieldtype": "Select", + "in_filter": 1, + "label": "Quotation To", + "oldfieldname": "quotation_to", + "oldfieldtype": "Select", + "options": "\nLead\nCustomer", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, "reqd": 1 - }, + }, { - "depends_on": "eval:doc.quotation_to == \"Customer\"", - "fieldname": "customer", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Customer", - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, + "depends_on": "eval:doc.quotation_to == \"Customer\"", + "fieldname": "customer", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Customer", + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, "search_index": 1 - }, + }, { - "depends_on": "eval:doc.quotation_to == \"Lead\"", - "fieldname": "lead", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Lead", - "oldfieldname": "lead", - "oldfieldtype": "Link", - "options": "Lead", - "permlevel": 0, - "print_hide": 1, + "depends_on": "eval:doc.quotation_to == \"Lead\"", + "fieldname": "lead", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Lead", + "oldfieldname": "lead", + "oldfieldtype": "Link", + "options": "Lead", + "permlevel": 0, + "print_hide": 1, "read_only": 0 - }, + }, { - "fieldname": "customer_name", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Customer / Lead Name", - "permlevel": 0, + "fieldname": "customer_name", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Customer / Lead Name", + "permlevel": 0, "read_only": 1 - }, + }, { - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "in_filter": 0, - "label": "Address", - "oldfieldname": "customer_address", - "oldfieldtype": "Small Text", - "permlevel": 0, - "print_hide": 0, - "read_only": 1, - "reqd": 0, + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "in_filter": 0, + "label": "Address", + "oldfieldname": "customer_address", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "reqd": 0, "search_index": 0 - }, + }, { - "fieldname": "contact_display", - "fieldtype": "Small Text", - "hidden": 1, - "in_filter": 0, - "label": "Contact", - "permlevel": 0, - "print_hide": 0, + "fieldname": "contact_display", + "fieldtype": "Small Text", + "hidden": 1, + "in_filter": 0, + "label": "Contact", + "permlevel": 0, + "print_hide": 0, "read_only": 1 - }, + }, { - "fieldname": "contact_mobile", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Mobile No", - "permlevel": 0, - "print_hide": 0, + "fieldname": "contact_mobile", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Mobile No", + "permlevel": 0, + "print_hide": 0, "read_only": 1 - }, + }, { - "fieldname": "contact_email", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact Email", - "permlevel": 0, - "print_hide": 1, + "fieldname": "contact_email", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact Email", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "permlevel": 0, - "read_only": 0, + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, "width": "50%" - }, + }, { - "fieldname": "amended_from", - "fieldtype": "Link", - "ignore_user_permissions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "options": "Quotation", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "amended_from", + "fieldtype": "Link", + "ignore_user_permissions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "options": "Quotation", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "width": "150px" - }, + }, { - "description": "", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 0, + "description": "", + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 0, "width": "150px" - }, + }, { - "default": "Today", - "fieldname": "transaction_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Date", - "no_copy": 1, - "oldfieldname": "transaction_date", - "oldfieldtype": "Date", - "permlevel": 0, - "read_only": 0, - "reqd": 1, - "search_index": 1, + "default": "Today", + "fieldname": "transaction_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Date", + "no_copy": 1, + "oldfieldname": "transaction_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "search_index": 1, "width": "100px" - }, + }, { - "default": "Sales", - "fieldname": "order_type", - "fieldtype": "Select", - "in_filter": 1, - "label": "Order Type", - "oldfieldname": "order_type", - "oldfieldtype": "Select", - "options": "\nSales\nMaintenance\nShopping Cart", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, - "reqd": 1, + "default": "Sales", + "fieldname": "order_type", + "fieldtype": "Select", + "in_filter": 1, + "label": "Order Type", + "oldfieldname": "order_type", + "oldfieldtype": "Select", + "options": "\nSales\nMaintenance\nShopping Cart", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, "search_index": 0 - }, + }, { - "fieldname": "currency_and_price_list", - "fieldtype": "Section Break", - "label": "", - "options": "icon-tag", - "permlevel": 0, + "fieldname": "currency_and_price_list", + "fieldtype": "Section Break", + "label": "", + "options": "icon-tag", + "permlevel": 0, "read_only": 0 - }, + }, { - "fieldname": "currency", - "fieldtype": "Link", - "in_filter": 1, - "label": "Currency", - "oldfieldname": "currency", - "oldfieldtype": "Select", - "options": "Currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 0, + "fieldname": "currency", + "fieldtype": "Link", + "in_filter": 1, + "label": "Currency", + "oldfieldname": "currency", + "oldfieldtype": "Select", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 0, "width": "100px" - }, + }, { - "description": "Rate at which customer's currency is converted to company's base currency", - "fieldname": "conversion_rate", - "fieldtype": "Float", - "label": "Exchange Rate", - "oldfieldname": "conversion_rate", - "oldfieldtype": "Currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, - "reqd": 1, + "description": "Rate at which customer's currency is converted to company's base currency", + "fieldname": "conversion_rate", + "fieldtype": "Float", + "label": "Exchange Rate", + "oldfieldname": "conversion_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, "width": "100px" - }, + }, { - "fieldname": "column_break2", - "fieldtype": "Column Break", - "permlevel": 0, - "read_only": 0, + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, "width": "50%" - }, + }, { - "fieldname": "selling_price_list", - "fieldtype": "Link", - "in_filter": 1, - "label": "Price List", - "oldfieldname": "price_list_name", - "oldfieldtype": "Select", - "options": "Price List", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 0, + "fieldname": "selling_price_list", + "fieldtype": "Link", + "in_filter": 1, + "label": "Price List", + "oldfieldname": "price_list_name", + "oldfieldtype": "Select", + "options": "Price List", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 0, "width": "100px" - }, + }, { - "fieldname": "price_list_currency", - "fieldtype": "Link", - "label": "Price List Currency", - "options": "Currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "price_list_currency", + "fieldtype": "Link", + "label": "Price List Currency", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "reqd": 1 - }, + }, { - "description": "Rate at which Price list currency is converted to company's base currency", - "fieldname": "plc_conversion_rate", - "fieldtype": "Float", - "label": "Price List Exchange Rate", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, + "description": "Rate at which Price list currency is converted to company's base currency", + "fieldname": "plc_conversion_rate", + "fieldtype": "Float", + "label": "Price List Exchange Rate", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, "reqd": 1 - }, + }, { - "fieldname": "ignore_pricing_rule", - "fieldtype": "Check", - "label": "Ignore Pricing Rule", - "no_copy": 1, - "permlevel": 1, + "fieldname": "ignore_pricing_rule", + "fieldtype": "Check", + "label": "Ignore Pricing Rule", + "no_copy": 1, + "permlevel": 1, "print_hide": 1 - }, + }, { - "fieldname": "items_section", - "fieldtype": "Section Break", - "label": "", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart", - "permlevel": 0, - "print_hide": 0, - "read_only": 0, + "fieldname": "items_section", + "fieldtype": "Section Break", + "label": "", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, "search_index": 0 - }, + }, { - "allow_on_submit": 1, - "fieldname": "items", - "fieldtype": "Table", - "label": "Items", - "oldfieldname": "quotation_details", - "oldfieldtype": "Table", - "options": "Quotation Item", - "permlevel": 0, - "read_only": 0, - "reqd": 0, + "allow_on_submit": 1, + "fieldname": "items", + "fieldtype": "Table", + "label": "Items", + "oldfieldname": "quotation_details", + "oldfieldtype": "Table", + "options": "Quotation Item", + "permlevel": 0, + "read_only": 0, + "reqd": 0, "width": "40px" - }, + }, { - "fieldname": "sec_break23", - "fieldtype": "Section Break", - "permlevel": 0, + "fieldname": "sec_break23", + "fieldtype": "Section Break", + "permlevel": 0, "read_only": 0 - }, + }, { - "fieldname": "base_net_total", - "fieldtype": "Currency", - "label": "Net Total (Company Currency)", - "no_copy": 0, - "oldfieldname": "net_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, - "reqd": 0, + "fieldname": "base_print_total", + "fieldtype": "Currency", + "label": "Print Total (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "base_net_total", + "fieldtype": "Currency", + "label": "Net Total (Company Currency)", + "no_copy": 0, + "oldfieldname": "net_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 0, "width": "100px" - }, + }, { - "fieldname": "column_break_28", - "fieldtype": "Column Break", + "fieldname": "column_break_28", + "fieldtype": "Column Break", "permlevel": 0 - }, + }, { - "fieldname": "net_total", - "fieldtype": "Currency", - "label": "Net Total", - "options": "currency", - "permlevel": 0, + "fieldname": "print_total", + "fieldtype": "Currency", + "label": "Print Total", + "options": "currency", + "permlevel": 0, + "precision": "", "read_only": 1 - }, + }, { - "fieldname": "taxes_section", - "fieldtype": "Section Break", - "label": "Taxes and Charges", - "oldfieldtype": "Section Break", - "options": "icon-money", - "permlevel": 0, - "read_only": 0 - }, - { - "fieldname": "taxes_and_charges", - "fieldtype": "Link", - "hidden": 0, - "label": "Taxes and Charges", - "oldfieldname": "charge", - "oldfieldtype": "Link", - "options": "Sales Taxes and Charges Master", - "permlevel": 0, - "print_hide": 1, - "read_only": 0 - }, - { - "fieldname": "column_break_34", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "fieldname": "shipping_rule", - "fieldtype": "Link", - "hidden": 0, - "label": "Shipping Rule", - "oldfieldtype": "Button", - "options": "Shipping Rule", - "permlevel": 0, - "print_hide": 1, - "read_only": 0 - }, - { - "fieldname": "section_break_36", - "fieldtype": "Section Break", - "permlevel": 0 - }, - { - "fieldname": "taxes", - "fieldtype": "Table", - "label": "Sales Taxes and Charges", - "oldfieldname": "other_charges", - "oldfieldtype": "Table", - "options": "Sales Taxes and Charges", - "permlevel": 0, - "read_only": 0 - }, - { - "fieldname": "other_charges_calculation", - "fieldtype": "HTML", - "label": "Taxes and Charges Calculation", - "oldfieldtype": "HTML", - "permlevel": 0, - "print_hide": 1, - "read_only": 0 - }, - { - "fieldname": "section_break_39", - "fieldtype": "Section Break", - "permlevel": 0 - }, - { - "fieldname": "total_taxes_and_charges", - "fieldtype": "Currency", - "label": "Total Taxes and Charges", - "options": "currency", - "permlevel": 0, - "print_hide": 1, + "fieldname": "net_total", + "fieldtype": "Currency", + "label": "Net Total", + "options": "currency", + "permlevel": 0, "read_only": 1 - }, + }, { - "fieldname": "base_total_taxes_and_charges", - "fieldtype": "Currency", - "label": "Total Taxes and Charges (Company Currency)", - "oldfieldname": "other_charges_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1 - }, - { - "fieldname": "column_break_42", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "fieldname": "discount_amount", - "fieldtype": "Currency", - "label": "Discount Amount", - "options": "currency", - "permlevel": 0 - }, - { - "fieldname": "base_discount_amount", - "fieldtype": "Currency", - "label": "Discount Amount (Company Currency)", - "options": "Company:company:default_currency", - "permlevel": 0, - "precision": "", - "print_hide": 1, - "read_only": 1 - }, - { - "fieldname": "totals", - "fieldtype": "Section Break", - "label": "", - "oldfieldtype": "Section Break", - "options": "icon-money", - "permlevel": 0, - "print_hide": 1, + "fieldname": "taxes_section", + "fieldtype": "Section Break", + "label": "Taxes and Charges", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, "read_only": 0 - }, + }, { - "fieldname": "base_grand_total", - "fieldtype": "Currency", - "label": "Grand Total (Company Currency)", - "no_copy": 0, - "oldfieldname": "grand_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, - "reqd": 0, + "fieldname": "taxes_and_charges", + "fieldtype": "Link", + "hidden": 0, + "label": "Taxes and Charges", + "oldfieldname": "charge", + "oldfieldtype": "Link", + "options": "Sales Taxes and Charges Master", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "column_break_34", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "shipping_rule", + "fieldtype": "Link", + "hidden": 0, + "label": "Shipping Rule", + "oldfieldtype": "Button", + "options": "Shipping Rule", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "section_break_36", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "taxes", + "fieldtype": "Table", + "label": "Sales Taxes and Charges", + "oldfieldname": "other_charges", + "oldfieldtype": "Table", + "options": "Sales Taxes and Charges", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "other_charges_calculation", + "fieldtype": "HTML", + "label": "Taxes and Charges Calculation", + "oldfieldtype": "HTML", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "section_break_39", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "total_taxes_and_charges", + "fieldtype": "Currency", + "label": "Total Taxes and Charges", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "base_total_taxes_and_charges", + "fieldtype": "Currency", + "label": "Total Taxes and Charges (Company Currency)", + "oldfieldname": "other_charges_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_42", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "default": "Grand Total", + "fieldname": "apply_discount_on", + "fieldtype": "Select", + "label": "Apply Discount On", + "options": "\nGrand Total\nPrint Total", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount", + "options": "currency", + "permlevel": 0 + }, + { + "fieldname": "base_discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "totals", + "fieldtype": "Section Break", + "label": "", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "base_grand_total", + "fieldtype": "Currency", + "label": "Grand Total (Company Currency)", + "no_copy": 0, + "oldfieldname": "grand_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 0, "width": "200px" - }, + }, { - "fieldname": "base_rounded_total", - "fieldtype": "Currency", - "label": "Rounded Total (Company Currency)", - "no_copy": 0, - "oldfieldname": "rounded_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "base_rounded_total", + "fieldtype": "Currency", + "label": "Rounded Total (Company Currency)", + "no_copy": 0, + "oldfieldname": "rounded_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "width": "200px" - }, + }, { - "description": "In Words will be visible once you save the Quotation.", - "fieldname": "base_in_words", - "fieldtype": "Data", - "label": "In Words (Company Currency)", - "no_copy": 0, - "oldfieldname": "in_words", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "description": "In Words will be visible once you save the Quotation.", + "fieldname": "base_in_words", + "fieldtype": "Data", + "label": "In Words (Company Currency)", + "no_copy": 0, + "oldfieldname": "in_words", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "width": "200px" - }, + }, { - "fieldname": "column_break3", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, + "fieldname": "column_break3", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, "width": "50%" - }, + }, { - "fieldname": "grand_total", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Grand Total", - "no_copy": 0, - "oldfieldname": "grand_total_export", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 0, - "read_only": 1, - "reqd": 0, + "fieldname": "grand_total", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Grand Total", + "no_copy": 0, + "oldfieldname": "grand_total_export", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "reqd": 0, "width": "200px" - }, + }, { - "fieldname": "rounded_total", - "fieldtype": "Currency", - "label": "Rounded Total", - "no_copy": 0, - "oldfieldname": "rounded_total_export", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 0, - "read_only": 1, - "reqd": 0, + "fieldname": "rounded_total", + "fieldtype": "Currency", + "label": "Rounded Total", + "no_copy": 0, + "oldfieldname": "rounded_total_export", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "reqd": 0, "width": "200px" - }, + }, { - "fieldname": "in_words", - "fieldtype": "Data", - "label": "In Words", - "no_copy": 0, - "oldfieldname": "in_words_export", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 0, - "read_only": 1, + "fieldname": "in_words", + "fieldtype": "Data", + "label": "In Words", + "no_copy": 0, + "oldfieldname": "in_words_export", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, "width": "200px" - }, + }, { - "fieldname": "fold", - "fieldtype": "Fold", - "label": "Fold", + "fieldname": "fold", + "fieldtype": "Fold", + "label": "Fold", "permlevel": 0 - }, + }, { - "fieldname": "terms_section_break", - "fieldtype": "Section Break", - "label": "Terms and Conditions", - "oldfieldtype": "Section Break", - "options": "icon-legal", - "permlevel": 0, - "print_hide": 0, + "fieldname": "terms_section_break", + "fieldtype": "Section Break", + "label": "Terms and Conditions", + "oldfieldtype": "Section Break", + "options": "icon-legal", + "permlevel": 0, + "print_hide": 0, "read_only": 0 - }, + }, { - "fieldname": "tc_name", - "fieldtype": "Link", - "label": "Terms", - "oldfieldname": "tc_name", - "oldfieldtype": "Link", - "options": "Terms and Conditions", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, + "fieldname": "tc_name", + "fieldtype": "Link", + "label": "Terms", + "oldfieldname": "tc_name", + "oldfieldtype": "Link", + "options": "Terms and Conditions", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, "report_hide": 1 - }, + }, { - "fieldname": "terms", - "fieldtype": "Text Editor", - "label": "Term Details", - "oldfieldname": "terms", - "oldfieldtype": "Text Editor", - "permlevel": 0, + "fieldname": "terms", + "fieldtype": "Text Editor", + "label": "Term Details", + "oldfieldname": "terms", + "oldfieldtype": "Text Editor", + "permlevel": 0, "read_only": 0 - }, + }, { - "fieldname": "contact_section", - "fieldtype": "Section Break", - "label": "Contact Info", - "options": "icon-bullhorn", - "permlevel": 0, + "fieldname": "contact_section", + "fieldtype": "Section Break", + "label": "Contact Info", + "options": "icon-bullhorn", + "permlevel": 0, "read_only": 0 - }, + }, { - "description": "", - "fieldname": "territory", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Territory", - "options": "Territory", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, - "reqd": 1, + "description": "", + "fieldname": "territory", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Territory", + "options": "Territory", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, "search_index": 0 - }, + }, { - "depends_on": "customer", - "description": "", - "fieldname": "customer_group", - "fieldtype": "Link", - "in_filter": 1, - "label": "Customer Group", - "oldfieldname": "customer_group", - "oldfieldtype": "Link", - "options": "Customer Group", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, - "reqd": 0, + "depends_on": "customer", + "description": "", + "fieldname": "customer_group", + "fieldtype": "Link", + "in_filter": 1, + "label": "Customer Group", + "oldfieldname": "customer_group", + "oldfieldtype": "Link", + "options": "Customer Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0, "search_index": 0 - }, + }, { - "fieldname": "shipping_address_name", - "fieldtype": "Link", - "hidden": 0, - "label": "Shipping Address", - "options": "Address", - "permlevel": 0, + "fieldname": "shipping_address_name", + "fieldtype": "Link", + "hidden": 0, + "label": "Shipping Address", + "options": "Address", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "shipping_address", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Shipping Address", - "permlevel": 0, - "print_hide": 1, + "fieldname": "shipping_address", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Shipping Address", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "depends_on": "customer", - "fieldname": "col_break98", - "fieldtype": "Column Break", - "permlevel": 0, - "read_only": 0, + "depends_on": "customer", + "fieldname": "col_break98", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, "width": "50%" - }, + }, { - "fieldname": "customer_address", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Customer Address", - "options": "Address", - "permlevel": 0, - "print_hide": 1, + "fieldname": "customer_address", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Customer Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1, "read_only": 0 - }, + }, { - "depends_on": "eval:doc.customer", - "fieldname": "contact_person", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Contact Person", - "oldfieldname": "contact_person", - "oldfieldtype": "Link", - "options": "Contact", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, + "depends_on": "eval:doc.customer", + "fieldname": "contact_person", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Contact Person", + "oldfieldname": "contact_person", + "oldfieldtype": "Link", + "options": "Contact", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, "reqd": 0 - }, + }, { - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text", - "permlevel": 0, - "print_hide": 1, + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0, + "print_hide": 1, "read_only": 0 - }, + }, { - "fieldname": "campaign", - "fieldtype": "Link", - "hidden": 0, - "label": "Campaign", - "no_copy": 0, - "oldfieldname": "campaign", - "oldfieldtype": "Link", - "options": "Campaign", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, + "fieldname": "campaign", + "fieldtype": "Link", + "hidden": 0, + "label": "Campaign", + "no_copy": 0, + "oldfieldname": "campaign", + "oldfieldtype": "Link", + "options": "Campaign", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, "report_hide": 0 - }, + }, { - "fieldname": "source", - "fieldtype": "Select", - "hidden": 0, - "label": "Source", - "no_copy": 0, - "oldfieldname": "source", - "oldfieldtype": "Select", - "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, + "fieldname": "source", + "fieldtype": "Select", + "hidden": 0, + "label": "Source", + "no_copy": 0, + "oldfieldname": "source", + "oldfieldtype": "Select", + "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, "report_hide": 0 - }, + }, { - "allow_on_submit": 0, - "default": "Draft", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "Draft\nSubmitted\nOrdered\nLost\nCancelled\nOpen\nReplied", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, - "reqd": 1, + "allow_on_submit": 0, + "default": "Draft", + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "Draft\nSubmitted\nOrdered\nLost\nCancelled\nOpen\nReplied", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1, "search_index": 0 - }, + }, { - "allow_on_submit": 1, - "fieldname": "order_lost_reason", - "fieldtype": "Small Text", - "label": "Quotation Lost Reason", - "no_copy": 1, - "oldfieldname": "order_lost_reason", - "oldfieldtype": "Small Text", - "permlevel": 0, - "print_hide": 1, + "allow_on_submit": 1, + "fieldname": "order_lost_reason", + "fieldtype": "Small Text", + "label": "Quotation Lost Reason", + "no_copy": 1, + "oldfieldname": "order_lost_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, "read_only": 0 - }, + }, { - "fieldname": "column_break4", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, + "fieldname": "column_break4", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, "width": "50%" - }, + }, { - "allow_on_submit": 1, - "fieldname": "letter_head", - "fieldtype": "Link", - "label": "Letter Head", - "oldfieldname": "letter_head", - "oldfieldtype": "Select", - "options": "Letter Head", - "permlevel": 0, - "print_hide": 1, + "allow_on_submit": 1, + "fieldname": "letter_head", + "fieldtype": "Link", + "label": "Letter Head", + "oldfieldname": "letter_head", + "oldfieldtype": "Select", + "options": "Letter Head", + "permlevel": 0, + "print_hide": 1, "read_only": 0 - }, + }, { - "allow_on_submit": 1, - "fieldname": "select_print_heading", - "fieldtype": "Link", - "label": "Print Heading", - "no_copy": 1, - "oldfieldname": "select_print_heading", - "oldfieldtype": "Link", - "options": "Print Heading", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, + "allow_on_submit": 1, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "label": "Print Heading", + "no_copy": 1, + "oldfieldname": "select_print_heading", + "oldfieldtype": "Link", + "options": "Print Heading", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, "report_hide": 1 - }, + }, { - "fieldname": "fiscal_year", - "fieldtype": "Link", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "Fiscal Year", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, - "reqd": 1, + "fieldname": "fiscal_year", + "fieldtype": "Link", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, "search_index": 0 - }, + }, { - "fieldname": "enq_det", - "fieldtype": "Text", - "hidden": 1, - "label": "Opportunity Item", - "no_copy": 0, - "oldfieldname": "enq_det", - "oldfieldtype": "Text", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "enq_det", + "fieldtype": "Text", + "hidden": 1, + "label": "Opportunity Item", + "no_copy": 0, + "oldfieldname": "enq_det", + "oldfieldtype": "Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "report_hide": 0 } - ], - "hide_toolbar": 0, - "icon": "icon-shopping-cart", - "idx": 1, - "is_submittable": 1, - "max_attachments": 1, - "modified": "2015-02-20 05:16:20.664025", - "modified_by": "Administrator", - "module": "Selling", - "name": "Quotation", - "owner": "Administrator", + ], + "hide_toolbar": 0, + "icon": "icon-shopping-cart", + "idx": 1, + "is_submittable": 1, + "max_attachments": 1, + "modified": "2015-02-20 05:16:20.664025", + "modified_by": "Administrator", + "module": "Selling", + "name": "Quotation", + "owner": "Administrator", "permissions": [ { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Sales User", - "share": 1, - "submit": 1, + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "share": 1, + "submit": 1, "write": 1 - }, + }, { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "match": "", - "permlevel": 1, - "read": 1, - "report": 1, - "role": "Sales User", - "submit": 0, + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "match": "", + "permlevel": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, "write": 0 - }, + }, { - "cancel": 0, - "delete": 0, - "email": 1, - "match": "", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, + "cancel": 0, + "delete": 0, + "email": 1, + "match": "", + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, "role": "Customer" - }, + }, { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "match": "", - "permlevel": 1, - "read": 1, - "report": 1, - "role": "Sales Manager", - "submit": 0, + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "match": "", + "permlevel": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "submit": 0, "write": 0 - }, + }, { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Sales Manager", - "share": 1, - "submit": 1, + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "share": 1, + "submit": 1, "write": 1 - }, + }, { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Maintenance Manager", - "share": 1, - "submit": 1, + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Maintenance Manager", + "share": 1, + "submit": 1, "write": 1 - }, + }, { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "match": "", - "permlevel": 1, - "read": 1, - "report": 1, - "role": "Maintenance Manager", + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "match": "", + "permlevel": 1, + "read": 1, + "report": 1, + "role": "Maintenance Manager", "submit": 0 - }, + }, { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Maintenance User", - "share": 1, - "submit": 1, + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Maintenance User", + "share": 1, + "submit": 1, "write": 1 - }, + }, { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "match": "", - "permlevel": 1, - "read": 1, - "report": 1, - "role": "Maintenance User", + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "match": "", + "permlevel": 1, + "read": 1, + "report": 1, + "role": "Maintenance User", "submit": 0 } - ], - "read_only_onload": 1, - "search_fields": "status,transaction_date,customer,lead,order_type", - "sort_field": "modified", - "sort_order": "DESC", + ], + "read_only_onload": 1, + "search_fields": "status,transaction_date,customer,lead,order_type", + "sort_field": "modified", + "sort_order": "DESC", "title_field": "customer_name" -} \ No newline at end of file +} diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.json b/erpnext/selling/doctype/quotation_item/quotation_item.json index 23b0b18591..b2f9307be2 100644 --- a/erpnext/selling/doctype/quotation_item/quotation_item.json +++ b/erpnext/selling/doctype/quotation_item/quotation_item.json @@ -1,360 +1,396 @@ { - "autoname": "hash", - "creation": "2013-03-07 11:42:57", - "docstatus": 0, - "doctype": "DocType", + "autoname": "hash", + "creation": "2013-03-07 11:42:57", + "docstatus": 0, + "doctype": "DocType", "fields": [ { - "fieldname": "item_code", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "permlevel": 0, - "print_hide": 0, - "print_width": "150px", - "read_only": 0, - "reqd": 1, - "search_index": 1, + "fieldname": "item_code", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "print_hide": 0, + "print_width": "150px", + "read_only": 0, + "reqd": 1, + "search_index": 1, "width": "150px" - }, + }, { - "fieldname": "customer_item_code", - "fieldtype": "Data", - "hidden": 1, - "label": "Customer's Item Code", - "permlevel": 0, - "print_hide": 1, + "fieldname": "customer_item_code", + "fieldtype": "Data", + "hidden": 1, + "label": "Customer's Item Code", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "item_name", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 1, - "print_width": "150px", - "read_only": 0, - "reqd": 1, - "search_index": 1, + "fieldname": "item_name", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 0, + "reqd": 1, + "search_index": 1, "width": "150px" - }, + }, { - "fieldname": "col_break1", - "fieldtype": "Column Break", + "fieldname": "col_break1", + "fieldtype": "Column Break", "permlevel": 0 - }, + }, { - "fieldname": "description", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "permlevel": 0, - "print_hide": 0, - "print_width": "300px", - "read_only": 0, - "reqd": 1, + "fieldname": "description", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 0, + "print_width": "300px", + "read_only": 0, + "reqd": 1, "width": "300px" - }, + }, { - "fieldname": "image", - "fieldtype": "Attach", - "hidden": 1, - "label": "Image", - "permlevel": 0, - "precision": "", + "fieldname": "image", + "fieldtype": "Attach", + "hidden": 1, + "label": "Image", + "permlevel": 0, + "precision": "", "print_hide": 1 - }, + }, { - "fieldname": "image_view", - "fieldtype": "Image", - "label": "Image View", - "options": "image", - "permlevel": 0, + "fieldname": "image_view", + "fieldtype": "Image", + "label": "Image View", + "options": "image", + "permlevel": 0, "precision": "" - }, + }, { - "fieldname": "quantity_and_rate", - "fieldtype": "Section Break", - "label": "Quantity and Rate", + "fieldname": "quantity_and_rate", + "fieldtype": "Section Break", + "label": "Quantity and Rate", "permlevel": 0 - }, + }, { - "fieldname": "qty", - "fieldtype": "Float", - "in_filter": 0, - "in_list_view": 1, - "label": "Quantity", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "permlevel": 0, - "print_hide": 0, - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "search_index": 0, + "fieldname": "qty", + "fieldtype": "Float", + "in_filter": 0, + "in_list_view": 1, + "label": "Quantity", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "search_index": 0, "width": "100px" - }, + }, { - "fieldname": "price_list_rate", - "fieldtype": "Currency", - "label": "Price List Rate", - "oldfieldname": "ref_rate", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 0, + "fieldname": "price_list_rate", + "fieldtype": "Currency", + "label": "Price List Rate", + "oldfieldname": "ref_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 0, "width": "100px" - }, + }, { - "fieldname": "discount_percentage", - "fieldtype": "Percent", - "in_list_view": 1, - "label": "Discount (%)", - "oldfieldname": "adj_rate", - "oldfieldtype": "Float", - "permlevel": 0, - "print_hide": 1, - "print_width": "100px", - "read_only": 0, + "fieldname": "discount_percentage", + "fieldtype": "Percent", + "in_list_view": 1, + "label": "Discount (%)", + "oldfieldname": "adj_rate", + "oldfieldtype": "Float", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, "width": "100px" - }, + }, { - "fieldname": "col_break2", - "fieldtype": "Column Break", + "fieldname": "col_break2", + "fieldtype": "Column Break", "permlevel": 0 - }, + }, { - "fieldname": "stock_uom", - "fieldtype": "Link", - "in_list_view": 1, - "label": "UOM", - "oldfieldname": "stock_uom", - "oldfieldtype": "Data", - "options": "UOM", - "permlevel": 0, - "print_hide": 0, - "print_width": "100px", - "read_only": 1, - "reqd": 0, + "fieldname": "stock_uom", + "fieldtype": "Link", + "in_list_view": 1, + "label": "UOM", + "oldfieldname": "stock_uom", + "oldfieldtype": "Data", + "options": "UOM", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "read_only": 1, + "reqd": 0, "width": "100px" - }, + }, { - "fieldname": "base_price_list_rate", - "fieldtype": "Currency", - "label": "Price List Rate (Company Currency)", - "oldfieldname": "base_ref_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "print_width": "100px", - "read_only": 1, + "fieldname": "base_price_list_rate", + "fieldtype": "Currency", + "label": "Price List Rate (Company Currency)", + "oldfieldname": "base_ref_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, "width": "100px" - }, + }, { - "fieldname": "Section_break1", - "fieldtype": "Section Break", + "fieldname": "Section_break1", + "fieldtype": "Section Break", "permlevel": 0 - }, + }, { - "fieldname": "rate", - "fieldtype": "Currency", - "in_filter": 0, - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "export_rate", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 0, - "print_width": "100px", - "read_only": 0, - "reqd": 0, - "search_index": 0, + "fieldname": "rate", + "fieldtype": "Currency", + "in_filter": 0, + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "export_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 0, + "search_index": 0, "width": "100px" - }, + }, { - "fieldname": "amount", - "fieldtype": "Currency", - "in_filter": 0, - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "export_amount", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 0, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "search_index": 0, - "width": "100px" - }, - { - "fieldname": "col_break3", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "fieldname": "base_rate", - "fieldtype": "Currency", - "in_filter": 0, - "label": "Basic Rate (Company Currency)", - "oldfieldname": "basic_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "search_index": 0, - "width": "100px" - }, - { - "fieldname": "base_amount", - "fieldtype": "Currency", - "in_filter": 0, - "label": "Amount (Company Currency)", - "oldfieldname": "amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "search_index": 0, - "width": "100px" - }, - { - "fieldname": "pricing_rule", - "fieldtype": "Link", - "label": "Pricing Rule", - "options": "Pricing Rule", - "permlevel": 0, + "fieldname": "net_rate", + "fieldtype": "Currency", + "label": "Net Rate", + "permlevel": 0, + "precision": "", "read_only": 1 - }, + }, { - "fieldname": "reference", - "fieldtype": "Section Break", - "label": "Reference", + "fieldname": "amount", + "fieldtype": "Currency", + "in_filter": 0, + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "export_amount", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "search_index": 0, + "width": "100px" + }, + { + "fieldname": "net_amount", + "fieldtype": "Currency", + "label": "Net Amount", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", "permlevel": 0 - }, + }, { - "fieldname": "prevdoc_doctype", - "fieldtype": "Data", - "hidden": 1, - "label": "Against Doctype", - "no_copy": 1, - "oldfieldname": "prevdoc_doctype", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "report_hide": 0, - "width": "150px" - }, + "fieldname": "base_rate", + "fieldtype": "Currency", + "in_filter": 0, + "label": "Rate (Company Currency)", + "oldfieldname": "basic_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "search_index": 0, + "width": "100px" + }, { - "fieldname": "prevdoc_docname", - "fieldtype": "Data", - "label": "Against Docname", - "no_copy": 1, - "oldfieldname": "prevdoc_docname", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "report_hide": 0, - "width": "150px" - }, + "fieldname": "base_net_rate", + "fieldtype": "Currency", + "label": "Net Rate (Company Currency)", + "permlevel": 0, + "precision": "", + "read_only": 1 + }, { - "fieldname": "item_tax_rate", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Item Tax Rate", - "oldfieldname": "item_tax_rate", - "oldfieldtype": "Small Text", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, - "report_hide": 1 - }, + "fieldname": "base_amount", + "fieldtype": "Currency", + "in_filter": 0, + "label": "Amount (Company Currency)", + "oldfieldname": "amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "search_index": 0, + "width": "100px" + }, { - "fieldname": "col_break4", - "fieldtype": "Column Break", + "fieldname": "base_net_amount", + "fieldtype": "Currency", + "label": "Net Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "pricing_rule", + "fieldtype": "Link", + "label": "Pricing Rule", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "reference", + "fieldtype": "Section Break", + "label": "Reference", "permlevel": 0 - }, + }, { - "allow_on_submit": 1, - "fieldname": "page_break", - "fieldtype": "Check", - "hidden": 0, - "label": "Page Break", - "no_copy": 1, - "oldfieldname": "page_break", - "oldfieldtype": "Check", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, + "fieldname": "prevdoc_doctype", + "fieldtype": "Data", + "hidden": 1, + "label": "Against Doctype", + "no_copy": 1, + "oldfieldname": "prevdoc_doctype", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "report_hide": 0, + "width": "150px" + }, + { + "fieldname": "prevdoc_docname", + "fieldtype": "Data", + "label": "Against Docname", + "no_copy": 1, + "oldfieldname": "prevdoc_docname", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "report_hide": 0, + "width": "150px" + }, + { + "fieldname": "item_tax_rate", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Item Tax Rate", + "oldfieldname": "item_tax_rate", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "report_hide": 1 - }, + }, { - "description": "", - "fieldname": "item_group", - "fieldtype": "Link", - "hidden": 1, - "in_filter": 1, - "label": "Item Group", - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "col_break4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "page_break", + "fieldtype": "Check", + "hidden": 0, + "label": "Page Break", + "no_copy": 1, + "oldfieldname": "page_break", + "oldfieldtype": "Check", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + }, + { + "description": "", + "fieldname": "item_group", + "fieldtype": "Link", + "hidden": 1, + "in_filter": 1, + "label": "Item Group", + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "search_index": 1 - }, + }, { - "fieldname": "brand", - "fieldtype": "Link", - "hidden": 1, - "in_filter": 1, - "label": "Brand", - "oldfieldname": "brand", - "oldfieldtype": "Link", - "options": "Brand", - "permlevel": 0, - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "search_index": 1, + "fieldname": "brand", + "fieldtype": "Link", + "hidden": 1, + "in_filter": 1, + "label": "Brand", + "oldfieldname": "brand", + "oldfieldtype": "Link", + "options": "Brand", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "search_index": 1, "width": "150px" } - ], - "idx": 1, - "istable": 1, - "modified": "2015-02-19 01:07:01.742936", - "modified_by": "Administrator", - "module": "Selling", - "name": "Quotation Item", - "owner": "Administrator", - "permissions": [], - "sort_field": "modified", + ], + "idx": 1, + "istable": 1, + "modified": "2015-02-19 15:08:25.451407", + "modified_by": "Administrator", + "module": "Selling", + "name": "Quotation Item", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", "sort_order": "DESC" -} \ No newline at end of file +} diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index a6abe7cae1..8009b40262 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -53,7 +53,7 @@ class StockLedgerEntry(Document): def validate_item(self): item_det = frappe.db.sql("""select name, has_batch_no, docstatus, - is_stock_item, has_variants + is_stock_item, has_variants, stock_uom from tabItem where name=%s""", self.item_code, as_dict=True)[0] if item_det.is_stock_item != 'Yes': From ce24512ed75e79f22eb15dc754ce67b132dfa8b3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sun, 22 Feb 2015 20:14:49 +0530 Subject: [PATCH 02/13] Commonified sales/purchase taxes and charges master.js code --- .../purchase_taxes_and_charges_master.js | 168 +----------------- .../sales_taxes_and_charges_master.js | 167 +---------------- .../purchase_common/purchase_common.js | 19 +- erpnext/controllers/taxes_and_totals.py | 2 + erpnext/projects/doctype/time_log/time_log.js | 1 - erpnext/public/js/controllers/accounts.js | 144 ++++++++++++++- .../public/js/controllers/taxes_and_totals.js | 19 +- erpnext/public/js/controllers/transaction.js | 16 +- .../selling/doctype/quotation/quotation.js | 1 - erpnext/selling/sales_common.js | 18 +- 10 files changed, 185 insertions(+), 370 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js index 4f91c56a48..4493d5288e 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js @@ -1,80 +1,11 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt +cur_frm.cscript.tax_table = "Purchase Taxes and Charges"; + {% include "public/js/controllers/accounts.js" %} -cur_frm.cscript.refresh = function(doc, cdt, cdn) { - cur_frm.set_footnote(frappe.markdown(cur_frm.meta.description)); -} - -// For customizing print -cur_frm.pformat.net_total = function(doc) { - return ''; -} - -cur_frm.pformat.grand_total = function(doc) { - return ''; -} - -cur_frm.pformat.in_words = function(doc) { - return ''; -} - -cur_frm.pformat.taxes= function(doc) { - - //function to make row of table - var make_row = function(title, val, bold) { - var bstart = ''; var bend = ''; - return '' + (bold?bstart:'') + title + (bold?bend:'') + '' - + '' - + '' + format_currency(val, doc.currency) + '' - + ''; - } - - function convert_rate(val) { - var new_val = flt(val)/flt(doc.conversion_rate); - return new_val; - } - - function print_hide(fieldname) { - var doc_field = frappe.meta.get_docfield(doc.doctype, fieldname, doc.name); - return doc_field.print_hide; - } - - var cl = doc.taxes || []; - - // outer table - var out='
\ -
'; - - // main table - out +=''; - if(!print_hide('net_total')) - out += make_row('Net Total', doc.net_total, 1); - - // add rows - if(cl.length){ - for(var i=0; i'; - } - - out +='
'; - return out; -} - -cur_frm.cscript.add_deduct_tax = function(doc, cdt, cdn) { +frappe.ui.form.on("Purchase Taxes and Charges", "add_deduct_tax", function(doc, cdt, cdn) { var d = locals[cdt][cdn]; if(!d.category && d.add_deduct_tax) { @@ -85,96 +16,5 @@ cur_frm.cscript.add_deduct_tax = function(doc, cdt, cdn) { msgprint(__("Cannot deduct when category is for 'Valuation' or 'Valuation and Total'")); d.add_deduct_tax = ''; } -} - -cur_frm.cscript.charge_type = function(doc, cdt, cdn) { - var d = locals[cdt][cdn]; - - if(!d.category && d.charge_type) { - msgprint(__("Please select Category first")); - d.charge_type = ''; - } - else if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')) { - msgprint(__("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row")); - d.charge_type = ''; - } - else if((d.category == 'Valuation' || d.category == 'Valuation and Total') && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')) { - msgprint(__("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for valuation. You can select only 'Total' option for previous row amount or previous row total")); - d.charge_type = ''; - } - - validated = false; - refresh_field('charge_type', d.name, 'taxes'); - - cur_frm.cscript.row_id(doc, cdt, cdn); - cur_frm.cscript.rate(doc, cdt, cdn); - cur_frm.cscript.tax_amount(doc, cdt, cdn); -} - - -cur_frm.cscript.row_id = function(doc, cdt, cdn) { - var d = locals[cdt][cdn]; - - if(!d.charge_type && d.row_id) { - msgprint(__("Please select charge type first")); - d.row_id = ''; - } - else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) { - msgprint(__("Can refer row only if the charge type is 'On Previous Row Amount' or 'Previous Row Total'")); - d.row_id = ''; - } - else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id) { - if(d.row_id >= d.idx){ - msgprint(__("Cannot refer row number greater than or equal to current row number for this Charge type")); - d.row_id = ''; - } - } - validated = false; - refresh_field('row_id', d.name, 'taxes'); -} - -cur_frm.set_query("account_head", "taxes", function(doc) { - return { - query: "erpnext.controllers.queries.tax_account_query", - filters: { - "account_type": ["Tax", "Chargeable", "Expense Account"], - "company": doc.company - } - } -}); - -cur_frm.fields_dict['taxes'].grid.get_field("cost_center").get_query = function(doc) { - return { - filters: { - 'company': doc.company, - 'group_or_ledger': "Ledger" - } - } -} - -cur_frm.cscript.rate = function(doc, cdt, cdn) { - var d = locals[cdt][cdn]; - - if(!d.charge_type && d.rate) { - msgprint(__("Please select Charge Type first")); - d.rate = ''; - } - validated = false; - refresh_field('rate', d.name, 'taxes'); -} - -cur_frm.cscript.tax_amount = function(doc, cdt, cdn) { - var d = locals[cdt][cdn]; - - if(!d.charge_type && d.tax_amount) { - msgprint(__("Please select Charge Type first")); - d.tax_amount = ''; - } - else if(d.charge_type && d.tax_amount) { - msgprint(__("Cannot directly set amount. For 'Actual' charge type, use the rate field")); - d.tax_amount = ''; - } - - validated = false; - refresh_field('tax_amount', d.name, 'taxes'); + refresh_field('add_deduct_tax', d.name, 'taxes'); } diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js index 8fd8f0123b..58a80a8314 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js @@ -1,174 +1,11 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt +cur_frm.cscript.tax_table = "Sales Taxes and Charges"; + {% include "public/js/controllers/accounts.js" %} cur_frm.cscript.onload = function(doc, cdt, cdn) { if(doc.doctype === "Sales Taxes and Charges Master") erpnext.add_applicable_territory(); } - -cur_frm.cscript.refresh = function(doc, cdt, cdn) { - cur_frm.set_footnote(frappe.markdown(cur_frm.meta.description)); -} - -// For customizing print -cur_frm.pformat.net_total = function(doc) { - return ''; -} - -cur_frm.pformat.discount_amount = function(doc) { - return ''; -} - -cur_frm.pformat.grand_total = function(doc) { - return ''; -} - -cur_frm.pformat.rounded_total = function(doc) { - return ''; -} - -cur_frm.pformat.in_words = function(doc) { - return ''; -} - -cur_frm.pformat.taxes= function(doc){ - //function to make row of table - var make_row = function(title, val, bold){ - var bstart = ''; var bend = ''; - return '' + (bold?bstart:'') + title + (bold?bend:'') + '' - + '' + format_currency(val, doc.currency) + '' - + ''; - } - - function convert_rate(val) { - var new_val = flt(val)/flt(doc.conversion_rate); - return new_val; - } - - function print_hide(fieldname) { - var doc_field = frappe.meta.get_docfield(doc.doctype, fieldname, doc.name); - return doc_field.print_hide; - } - - out =''; - if (!doc.print_without_amount) { - var cl = doc.taxes || []; - - // outer table - var out='
'; - - // main table - - out +=''; - - if(!print_hide('net_total')) { - out += make_row('Net Total', doc.net_total, 1); - } - - // add rows - if(cl.length){ - for(var i=0;i'; - } - out += '
'; - } - return out; -} - -cur_frm.cscript.charge_type = function(doc, cdt, cdn) { - var d = locals[cdt][cdn]; - if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')) { - msgprint(__("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row")); - d.charge_type = ''; - } - validated = false; - refresh_field('charge_type', d.name, 'taxes'); - cur_frm.cscript.row_id(doc, cdt, cdn); - cur_frm.cscript.rate(doc, cdt, cdn); - cur_frm.cscript.tax_amount(doc, cdt, cdn); -} - -cur_frm.cscript.row_id = function(doc, cdt, cdn) { - var d = locals[cdt][cdn]; - if(!d.charge_type && d.row_id) { - msgprint(__("Please select Charge Type first")); - d.row_id = ''; - } - else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) { - msgprint(__("Can refer row only if the charge type is 'On Previous Row Amount' or 'Previous Row Total'")); - d.row_id = ''; - } - else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id) { - if(d.row_id >= d.idx){ - msgprint(__("Cannot refer row number greater than or equal to current row number for this Charge type")); - d.row_id = ''; - } - } - validated = false; - refresh_field('row_id', d.name, 'taxes'); -} - -/*---------------------- Get rate if account_head has account_type as TAX or CHARGEABLE-------------------------------------*/ - -cur_frm.fields_dict['taxes'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) { - return{ - query: "erpnext.controllers.queries.tax_account_query", - filters: { - "account_type": ["Tax", "Chargeable", "Income Account"], - "company": doc.company - } - } -} - -cur_frm.fields_dict['taxes'].grid.get_field("cost_center").get_query = function(doc) { - return{ - 'company': doc.company, - 'group_or_ledger': "Ledger" - } -} - -cur_frm.cscript.rate = function(doc, cdt, cdn) { - var d = locals[cdt][cdn]; - if(!d.charge_type && d.rate) { - msgprint(__("Please select Charge Type first")); - d.rate = ''; - } - validated = false; - refresh_field('rate', d.name, 'taxes'); -} - -cur_frm.cscript.tax_amount = function(doc, cdt, cdn) { - var d = locals[cdt][cdn]; - if(!d.charge_type && d.tax_amount) { - msgprint(__("Please select Charge Type first")); - d.tax_amount = ''; - } - // else if(d.charge_type && d.tax_amount) { - // msgprint(__("Cannot directly set amount. For 'Actual' charge type, use the rate field")); - // d.tax_amount = ''; - // } - validated = false; - refresh_field('tax_amount', d.name, 'taxes'); -}; diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index 6759550e99..f98dab783d 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -90,20 +90,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ this.price_list_rate(doc, cdt, cdn); }, - rate: function(doc, cdt, cdn) { - var item = frappe.get_doc(cdt, cdn); - frappe.model.round_floats_in(item, ["rate", "discount_percentage"]); - - if(item.price_list_rate) { - item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0, - precision("discount_percentage", item)); - } else { - item.discount_percentage = 0.0; - } - - this.calculate_taxes_and_totals(); - }, - uom: function(doc, cdt, cdn) { var me = this; var item = frappe.get_doc(cdt, cdn); @@ -293,3 +279,8 @@ erpnext.buying.get_default_bom = function(frm) { } }); } + + +frappe.ui.form.on("Purchase Taxes and Charges", "rate", function(frm, cdt, cdn) { + cur_frm.cscript.calculate_taxes_and_totals(); +}) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 504c446fe9..7d19fde6e1 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -290,6 +290,8 @@ class calculate_taxes_and_totals(object): tax.tax_amount = flt(tax.tax_amount, tax.precision("tax_amount")) tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, tax.precision("tax_amount")) + self._set_in_company_currency(tax, ["total", "tax_amount", "tax_amount_after_discount_amount"]); + def adjust_discount_amount_loss(self, tax): discount_amount_loss = self.doc.grand_total - flt(self.doc.discount_amount) - tax.total tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount + diff --git a/erpnext/projects/doctype/time_log/time_log.js b/erpnext/projects/doctype/time_log/time_log.js index 5f7e84615f..eb2e1a01f7 100644 --- a/erpnext/projects/doctype/time_log/time_log.js +++ b/erpnext/projects/doctype/time_log/time_log.js @@ -77,7 +77,6 @@ $.extend(cur_frm.cscript, { }, callback: function(r) { if(!r.exc) { - console.log(r.message) cur_frm.set_value("workstation", r.message) } } diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index 03e1890b8b..4b1581180a 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -1,3 +1,9 @@ +// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +// License: GNU General Public License v3. See license.txt + +frappe.ui.form.on(cur_frm.doctype, "refresh", function(frm) { + frm.set_footnote(frappe.markdown(frm.meta.description)); +} // get tax rate cur_frm.cscript.account_head = function(doc, cdt, cdn) { @@ -8,7 +14,7 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) { } else if(d.account_head && d.charge_type!=="Actual") { frappe.call({ type:"GET", - method: "erpnext.controllers.accounts_controller.get_tax_rate", + method: "erpnext.controllers.accounts_controller.get_tax_rate", args: {"account_head":d.account_head}, callback: function(r) { frappe.model.set_value(cdt, cdn, "rate", r.message || 0); @@ -16,3 +22,139 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) { }) } } + + +var validate_taxes_and_charges = function(cdt, cdn) { + var d = locals[cdt][cdn]; + if(!d.charge_type && (d.row_id || d.rate || d.tax_amount)) { + msgprint(__("Please select Charge Type first")); + d.row_id = "" + d.rate = d.tax_amount = 0.0 + } else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) { + msgprint(__("Can refer row only if the charge type is 'On Previous Row Amount' or 'Previous Row Total'")); + d.row_id = ""; + } else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id) { + if (d.idx == 1) { + msgprint(__("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row")); + d.charge_type = ''; + } else if (d.row_i && d.row_id >= d.idx) { + msgprint(__("Cannot refer row number greater than or equal to current row number for this Charge type")); + d.row_id = ""; + } + } + validated = false; + refresh_field('row_id', d.name, 'taxes'); +} + +frappe.ui.form.on(cur_frm.cscript.tax_table, "row_id", function(frm, cdt, cdn) { + validate_taxes_and_charges(cdt, cdn); +}) + +frappe.ui.form.on(cur_frm.cscript.tax_table, "rate", function(frm, cdt, cdn) { + validate_taxes_and_charges(cdt, cdn); +}) + +frappe.ui.form.on(cur_frm.cscript.tax_table, "tax_amount", function(frm, cdt, cdn) { + validate_taxes_and_charges(cdt, cdn); +}) + +frappe.ui.form.on(cur_frm.cscript.tax_table, "charge_type", function(frm, cdt, cdn) { + validate_taxes_and_charges(cdt, cdn); +}) + + +cur_frm.set_query("account_head", "taxes", function(doc) { + if(cur_frm.cscript.tax_table == "Sales Taxes and Charges") { + var account_type = ["Tax", "Chargeable", "Expense Account"]; + } else { + var account_type = ["Tax", "Chargeable", "Income Account"]; + } + + return { + query: "erpnext.controllers.queries.tax_account_query", + filters: { + "account_type": account_type, + "company": doc.company + } + } +}); + +cur_frm.set_query("cost_center", "taxes", function(doc) { + return { + filters: { + 'company': doc.company, + 'group_or_ledger': "Ledger" + } + } +} + +// For customizing print +cur_frm.pformat.print_total = function(doc) { return ''; } +cur_frm.pformat.discount_amount = function(doc) { return ''; } +cur_frm.pformat.grand_total = function(doc) { return ''; } +cur_frm.pformat.rounded_total = function(doc) { return ''; } +cur_frm.pformat.in_words = function(doc) { return ''; } + +cur_frm.pformat.taxes= function(doc){ + //function to make row of table + var make_row = function(title, val, bold){ + var bstart = ''; var bend = ''; + return '' + (bold?bstart:'') + title + (bold?bend:'') + '' + + '' + format_currency(val, doc.currency) + '' + + ''; + } + + function convert_rate(val) { + var new_val = flt(val)/flt(doc.conversion_rate); + return new_val; + } + + function print_hide(fieldname) { + var doc_field = frappe.meta.get_docfield(doc.doctype, fieldname, doc.name); + return doc_field.print_hide; + } + + out =''; + if (!doc.print_without_amount) { + var cl = doc.taxes || []; + + // outer table + var out='
'; + + // main table + + out +=''; + + if(!print_hide('print_total')) { + out += make_row('Net Total', doc.print_total, 1); + } + + // add rows + if(cl.length){ + for(var i=0;i'; + } + out += '
'; + } + return out; +} diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index d9e3e43a5a..f5307c79bd 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -67,16 +67,17 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ item.net_amount = item.amount; item.item_tax_amount = 0.0; - this.set_in_company_currency(item, ["price_list_rate", "rate", "amount", "net_rate", "net_amount"]); + me.set_in_company_currency(item, ["price_list_rate", "rate", "amount", "net_rate", "net_amount"]); }); } }, set_in_company_currency: function(doc, fields) { + var me = this; $.each(fields, function(i, f) { doc["base_"+f] = flt(flt(doc[f], precision(f, doc)) * me.frm.doc.conversion_rate, precision("base_" + f, doc)); }) - } + }, initialize_taxes: function() { var me = this; @@ -99,6 +100,8 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ }, determine_exclusive_rate: function() { + var me = this; + var has_inclusive_tax = false; $.each(me.frm.doc["taxes"] || [], function(i, row) { if(cint(row.included_in_print_rate)) has_inclusive_tax = true; @@ -106,7 +109,6 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ if(has_inclusive_tax==false || !in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) return; - var me = this; $.each(me.frm.doc["items"] || [], function(n, item) { var item_tax_map = me._load_item_tax_rate(item.item_tax_rate); var cumulated_tax_fraction = 0.0; @@ -132,7 +134,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ item.net_rate = flt(item.net_amount / item.qty, precision("net_rate", item)); - this.set_in_company_currency(item, ["net_rate", "net_amount"]); + me.set_in_company_currency(item, ["net_rate", "net_amount"]); // if(item.discount_percentage == 100) { // item.base_price_list_rate = item.base_rate; @@ -295,7 +297,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ // store tax breakup for each item var key = item.item_code || item.item_name; var item_wise_tax_amount = current_tax_amount * this.frm.doc.conversion_rate; - if (tax.item_wise_tax_detail.get(key)) + if (tax.item_wise_tax_detail && tax.item_wise_tax_detail[key]) item_wise_tax_amount += tax.item_wise_tax_detail[key][1] tax.item_wise_tax_detail[key] = [tax_rate,flt(item_wise_tax_amount, precision("base_tax_amount", tax))] @@ -305,8 +307,9 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ round_off_totals: function(tax) { tax.total = flt(tax.total, precision("total", tax)); tax.tax_amount = flt(tax.tax_amount, precision("tax_amount", tax)); - tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, - precision("tax_amount", tax)); + tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, precision("tax_amount", tax)); + + this.set_in_company_currency(tax, ["total", "tax_amount", "tax_amount_after_discount_amount"]); }, adjust_discount_amount_loss: function(tax) { @@ -330,7 +333,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ this.frm.doc.taxes_and_charges_added = this.frm.doc.taxes_and_charges_deducted = 0.0; if(tax_count) { $.each(this.frm.doc["taxes"] || [], function(i, tax) { - if in_list(["Valuation and Total", "Total"], tax.category) { + if (in_list(["Valuation and Total", "Total"], tax.category)) { if(tax.add_deduct_tax == "Add") { me.frm.doc.taxes_and_charges_added += flt(tax.tax_amount); } else { diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 6e6ea23af2..519b04cb09 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -274,8 +274,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ this.apply_pricing_rule(frappe.get_doc(cdt, cdn), true); }, - // tax rate - rate: function(doc, cdt, cdn) { + tax_amount: function(doc, cdt, cdn) { this.calculate_taxes_and_totals(); }, @@ -638,3 +637,16 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } } }); + +frappe.ui.form.on(cur_frm.doctype + "Item", "rate", function(frm, cdt, cdn) { + var item = frappe.get_doc(cdt, cdn); + frappe.model.round_floats_in(item, ["rate", "price_list_rate"]); + + if(item.price_list_rate) { + item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0, precision("discount_percentage", item)); + } else { + item.discount_percentage = 0.0; + } + + cur_frm.cscript.calculate_taxes_and_totals(); +}) diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index c63939dbf9..570c16aac9 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -151,7 +151,6 @@ cur_frm.cscript['Declare Order Lost'] = function(){ }) }); dialog.show(); - } cur_frm.cscript.on_submit = function(doc, cdt, cdn) { diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 3a01ca035d..13796c6a2e 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -154,20 +154,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ } }, - rate: function(doc, cdt, cdn) { - var item = frappe.get_doc(cdt, cdn); - frappe.model.round_floats_in(item, ["rate", "price_list_rate"]); - - if(item.price_list_rate) { - item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0, - precision("discount_percentage", item)); - } else { - item.discount_percentage = 0.0; - } - - this.calculate_taxes_and_totals(); - }, - discount_amount: function() { this.calculate_taxes_and_totals(); }, @@ -432,3 +418,7 @@ frappe.ui.form.on(cur_frm.doctype,"project_name", function(frm) { }) } }) + +frappe.ui.form.on("Sales Taxes and Charges", "rate", function(frm, cdt, cdn) { + cur_frm.cscript.calculate_taxes_and_totals(); +}) From 2b019ed4302f407aa89d7588692bbf65471cef3d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sun, 22 Feb 2015 23:03:07 +0530 Subject: [PATCH 03/13] Fixes for discount amount --- erpnext/controllers/taxes_and_totals.py | 11 ++++---- .../v4_0/set_naming_series_property_setter.py | 1 - erpnext/public/js/controllers/accounts.js | 18 +++++-------- .../public/js/controllers/taxes_and_totals.js | 26 ++++++++++--------- .../selling/doctype/quotation/quotation.js | 1 + erpnext/setup/doctype/company/test_company.py | 15 +++++------ 6 files changed, 34 insertions(+), 38 deletions(-) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 7d19fde6e1..640bcea4a5 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -76,7 +76,7 @@ class calculate_taxes_and_totals(object): "tax_amount_for_current_item", "grand_total_for_current_item", "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"] - if not self.discount_amount_applied: + if tax.charge_type != "Actual" and not self.discount_amount_applied: tax_fields.append("tax_amount") for fieldname in tax_fields: @@ -214,14 +214,15 @@ class calculate_taxes_and_totals(object): if n == len(self.doc.get("items")) - 1: current_tax_amount += actual_tax_dict[tax.idx] + # accumulate tax amount into tax.tax_amount + if tax.charge_type != "Actual" and not self.discount_amount_applied: + tax.tax_amount += current_tax_amount + # store tax_amount for current item as it will be used for # charge type = 'On Previous Row Amount' tax.tax_amount_for_current_item = current_tax_amount - # accumulate tax amount into tax.tax_amount - if not self.discount_amount_applied: - tax.tax_amount += current_tax_amount - + # set tax after discount tax.tax_amount_after_discount_amount += current_tax_amount if getattr(tax, "category", None): diff --git a/erpnext/patches/v4_0/set_naming_series_property_setter.py b/erpnext/patches/v4_0/set_naming_series_property_setter.py index bd4ed91a3e..ff241ae5c0 100644 --- a/erpnext/patches/v4_0/set_naming_series_property_setter.py +++ b/erpnext/patches/v4_0/set_naming_series_property_setter.py @@ -35,7 +35,6 @@ doctype_series_map = { def execute(): series_to_set = get_series_to_set() for doctype, opts in series_to_set.items(): - print "Setting naming series", doctype, opts set_series(doctype, opts["options"], opts["default"]) def set_series(doctype, options, default): diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index 4b1581180a..652350ac80 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -1,10 +1,6 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.ui.form.on(cur_frm.doctype, "refresh", function(frm) { - frm.set_footnote(frappe.markdown(frm.meta.description)); -} - // get tax rate cur_frm.cscript.account_head = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; @@ -28,8 +24,8 @@ var validate_taxes_and_charges = function(cdt, cdn) { var d = locals[cdt][cdn]; if(!d.charge_type && (d.row_id || d.rate || d.tax_amount)) { msgprint(__("Please select Charge Type first")); - d.row_id = "" - d.rate = d.tax_amount = 0.0 + d.row_id = ""; + d.rate = d.tax_amount = 0.0; } else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) { msgprint(__("Can refer row only if the charge type is 'On Previous Row Amount' or 'Previous Row Total'")); d.row_id = ""; @@ -48,19 +44,19 @@ var validate_taxes_and_charges = function(cdt, cdn) { frappe.ui.form.on(cur_frm.cscript.tax_table, "row_id", function(frm, cdt, cdn) { validate_taxes_and_charges(cdt, cdn); -}) +}); frappe.ui.form.on(cur_frm.cscript.tax_table, "rate", function(frm, cdt, cdn) { validate_taxes_and_charges(cdt, cdn); -}) +}); frappe.ui.form.on(cur_frm.cscript.tax_table, "tax_amount", function(frm, cdt, cdn) { validate_taxes_and_charges(cdt, cdn); -}) +}); frappe.ui.form.on(cur_frm.cscript.tax_table, "charge_type", function(frm, cdt, cdn) { validate_taxes_and_charges(cdt, cdn); -}) +}); cur_frm.set_query("account_head", "taxes", function(doc) { @@ -86,7 +82,7 @@ cur_frm.set_query("cost_center", "taxes", function(doc) { 'group_or_ledger': "Ledger" } } -} +}); // For customizing print cur_frm.pformat.print_total = function(doc) { return ''; } diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index f5307c79bd..e30099c8e7 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -88,7 +88,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ "tax_amount_for_current_item", "grand_total_for_current_item", "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"] - if (!me.discount_amount_applied) + if (cstr(tax.charge_type) != "Actual" && !me.discount_amount_applied) tax_fields.push("tax_amount"); $.each(tax_fields, function(i, fieldname) { tax[fieldname] = 0.0 }); @@ -216,14 +216,15 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ } } + // accumulate tax amount into tax.tax_amount + if (tax.charge_type != "Actual" && !me.discount_amount_applied) + tax.tax_amount += current_tax_amount; + // store tax_amount for current item as it will be used for // charge type = 'On Previous Row Amount' tax.tax_amount_for_current_item = current_tax_amount; - // accumulate tax amount into tax.tax_amount - if (!me.discount_amount_applied) - tax.tax_amount += current_tax_amount; - + // tax amount after discount amount tax.tax_amount_after_discount_amount += current_tax_amount; // for buying @@ -239,7 +240,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ // note: grand_total_for_current_item contains the contribution of // item's amount, previously applied tax and the current tax on that item if(i==0) { - tax.grand_total_for_current_item = flt(item.base_amount + current_tax_amount); + tax.grand_total_for_current_item = flt(item.net_amount + current_tax_amount); } else { tax.grand_total_for_current_item = flt(me.frm.doc["taxes"][i-1].grand_total_for_current_item + current_tax_amount); @@ -313,7 +314,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ }, adjust_discount_amount_loss: function(tax) { - var discount_amount_loss = this.frm.doc.base_grand_total - flt(this.frm.doc.base_discount_amount) - tax.total; + var discount_amount_loss = this.frm.doc.grand_total - flt(this.frm.doc.discount_amount) - tax.total; tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount + discount_amount_loss, precision("tax_amount", tax)); tax.total = flt(tax.total + discount_amount_loss, precision("total", tax)); @@ -326,7 +327,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ this.frm.doc.grand_total = flt(tax_count ? this.frm.doc["taxes"][tax_count - 1].total : this.frm.doc.net_total); if(in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) { - this.frm.doc.base_grand_total = (this.frm.doc.base_total_taxes_and_charges) ? + this.frm.doc.base_grand_total = (this.frm.doc.total_taxes_and_charges) ? flt(this.frm.doc.grand_total * this.frm.doc.conversion_rate) : this.frm.doc.base_net_total; } else { // other charges added/deducted @@ -345,7 +346,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ frappe.model.round_floats_in(this.frm.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"]); } - this.frm.doc.grand_total = flt((this.frm.doc.taxes_and_charges_added || this.frm.doc.taxes_and_charges_deducted) ? + this.frm.doc.base_grand_total = flt((this.frm.doc.taxes_and_charges_added || this.frm.doc.taxes_and_charges_deducted) ? flt(this.frm.doc.grand_total * this.frm.doc.conversion_rate) : this.frm.doc.base_net_total); this.set_in_company_currency(this.frm.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"]); @@ -354,6 +355,8 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ this.frm.doc.total_taxes_and_charges = flt(this.frm.doc.grand_total - this.frm.doc.net_total, precision("total_taxes_and_charges")); + this.set_in_company_currency(this.frm.doc, ["total_taxes_and_charges"]); + // Round grand total as per precision frappe.model.round_floats_in(this.frm.doc, ["grand_total", "base_grand_total"]); @@ -408,7 +411,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ if (total_for_discount_amount) { $.each(this.frm.doc["items"] || [], function(i, item) { distributed_amount = flt(me.frm.doc.discount_amount) * item.net_amount / total_for_discount_amount; - item.base_amount = flt(item.net_amount - distributed_amount, precision("base_amount", item)); + item.net_amount = flt(item.net_amount - distributed_amount, precision("base_amount", item)); item.net_rate = flt(item.net_amount / item.qty, precision("net_rate", item)); me.set_in_company_currency(item, ["net_rate", "net_amount"]); @@ -441,8 +444,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ }); $.each(actual_taxes_dict, function(key, value) { - if (value) - total_actual_tax += value; + if (value) total_actual_tax += value; }); return flt(this.frm.doc.grand_total - total_actual_tax, precision("grand_total")); diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 570c16aac9..c63939dbf9 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -151,6 +151,7 @@ cur_frm.cscript['Declare Order Lost'] = function(){ }) }); dialog.show(); + } cur_frm.cscript.on_submit = function(doc, cdt, cdn) { diff --git a/erpnext/setup/doctype/company/test_company.py b/erpnext/setup/doctype/company/test_company.py index 06db121531..32d0b0e7a1 100644 --- a/erpnext/setup/doctype/company/test_company.py +++ b/erpnext/setup/doctype/company/test_company.py @@ -8,11 +8,8 @@ import unittest class TestCompany(unittest.TestCase): def atest_coa(self): - for country, chart_name in frappe.db.sql("""select country, chart_name + for country, chart_name in frappe.db.sql("""select country, chart_name from `tabChart of Accounts` where name = 'Deutscher Kontenplan SKR03'""", as_list=1): - print "Country: ", country - print "Chart Name: ", chart_name - company_doc = frappe.get_doc({ "doctype": "Company", "company_name": "_Test Company 2", @@ -23,10 +20,10 @@ class TestCompany(unittest.TestCase): }) company_doc.insert() - self.assertTrue(frappe.db.sql("""select count(*) from tabAccount + self.assertTrue(frappe.db.sql("""select count(*) from tabAccount where company='_Test Company 2'""")[0][0] > 10) - - frappe.delete_doc("Company", "_Test Company 2") - -test_records = frappe.get_test_records('Company') \ No newline at end of file + frappe.delete_doc("Company", "_Test Company 2") + + +test_records = frappe.get_test_records('Company') From de9c8a90287a99cf46fb07a1fd4a96a662753d44 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Feb 2015 01:06:00 +0530 Subject: [PATCH 04/13] discount calculation and in print view --- erpnext/controllers/buying_controller.py | 2 +- erpnext/controllers/selling_controller.py | 2 +- erpnext/controllers/taxes_and_totals.py | 21 +- erpnext/public/js/controllers/accounts.js | 16 +- .../public/js/controllers/taxes_and_totals.js | 16 +- .../selling/doctype/quotation/quotation.json | 1706 +++++++++-------- .../quotation_item/quotation_item.json | 655 +++---- erpnext/selling/sales_common.js | 4 + .../delivery_note_item.json | 13 +- .../print_formats/includes/taxes.html | 18 + 10 files changed, 1241 insertions(+), 1212 deletions(-) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 5e27b3a69a..4e4e507cae 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -14,7 +14,7 @@ from erpnext.controllers.stock_controller import StockController class BuyingController(StockController): def __setup__(self): - if hasattr(self, "items"): + if hasattr(self, "taxes"): self.print_templates = { "taxes": "templates/print_formats/includes/taxes.html" } diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index e6ec2af385..9cee5832b4 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -12,7 +12,7 @@ from erpnext.controllers.stock_controller import StockController class SellingController(StockController): def __setup__(self): - if hasattr(self, "items"): + if hasattr(self, "taxes"): self.print_templates = { "taxes": "templates/print_formats/includes/taxes.html" } diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 640bcea4a5..1b1527b7eb 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -76,8 +76,9 @@ class calculate_taxes_and_totals(object): "tax_amount_for_current_item", "grand_total_for_current_item", "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"] - if tax.charge_type != "Actual" and not self.discount_amount_applied: - tax_fields.append("tax_amount") + if tax.charge_type != "Actual" and \ + not (self.discount_amount_applied and self.doc.apply_discount_on=="Grand Total"): + tax_fields.append("tax_amount") for fieldname in tax_fields: tax.set(fieldname, 0.0) @@ -215,8 +216,9 @@ class calculate_taxes_and_totals(object): current_tax_amount += actual_tax_dict[tax.idx] # accumulate tax amount into tax.tax_amount - if tax.charge_type != "Actual" and not self.discount_amount_applied: - tax.tax_amount += current_tax_amount + if tax.charge_type != "Actual" and \ + not (self.discount_amount_applied and self.doc.apply_discount_on=="Grand Total"): + tax.tax_amount += current_tax_amount # store tax_amount for current item as it will be used for # charge type = 'On Previous Row Amount' @@ -250,8 +252,9 @@ class calculate_taxes_and_totals(object): self.round_off_totals(tax) # adjust Discount Amount loss in last tax iteration - if i == (len(self.doc.get("taxes")) - 1) and self.discount_amount_applied: - self.adjust_discount_amount_loss(tax) + if i == (len(self.doc.get("taxes")) - 1) and self.discount_amount_applied \ + and self.doc.apply_discount_on == "Grand Total": + self.adjust_discount_amount_loss(tax) def get_current_tax_amount(self, item, tax, item_tax_map): tax_rate = self._get_tax_rate(tax, item_tax_map) @@ -291,7 +294,7 @@ class calculate_taxes_and_totals(object): tax.tax_amount = flt(tax.tax_amount, tax.precision("tax_amount")) tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, tax.precision("tax_amount")) - self._set_in_company_currency(tax, ["total", "tax_amount", "tax_amount_after_discount_amount"]); + self._set_in_company_currency(tax, ["total", "tax_amount", "tax_amount_after_discount_amount"]) def adjust_discount_amount_loss(self, tax): discount_amount_loss = self.doc.grand_total - flt(self.doc.discount_amount) - tax.total @@ -360,8 +363,8 @@ class calculate_taxes_and_totals(object): self.doc.base_discount_amount = 0 def get_total_for_discount_amount(self): - if self.doc.apply_discount_on == "Print Total": - return self.net_total + if self.doc.apply_discount_on == "Net Total": + return self.doc.net_total else: actual_taxes_dict = {} diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index 652350ac80..21ad71fc5d 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -93,11 +93,11 @@ cur_frm.pformat.in_words = function(doc) { return ''; } cur_frm.pformat.taxes= function(doc){ //function to make row of table - var make_row = function(title, val, bold){ + var make_row = function(title, val, bold, is_negative) { var bstart = ''; var bend = ''; return '' + (bold?bstart:'') + title + (bold?bend:'') + '' - + '' + format_currency(val, doc.currency) + '' - + ''; + + '' + (is_negative ? '- ' : '') + + format_currency(val, doc.currency) + ''; } function convert_rate(val) { @@ -125,6 +125,10 @@ cur_frm.pformat.taxes= function(doc){ out += make_row('Net Total', doc.print_total, 1); } + // Discount Amount on net total + if(!print_hide('discount_amount') && doc.apply_discount_on == "Net Total" && doc.discount_amount) + out += make_row('Discount Amount', doc.discount_amount, 0, 1); + // add rows if(cl.length){ for(var i=0;i +
+
+
+ - {{ doc.get_formatted("discount_amount", doc) }} +
+ + {%- endif -%} +{%- endmacro -%} +
+ {%- if doc.apply_discount_on == "Net Total" -%} + {{ render_discount_amount(doc) }} + {%- endif -%} {%- for charge in data -%} {%- if not charge.included_in_print_rate -%}
@@ -13,5 +28,8 @@
{%- endif -%} {%- endfor -%} + {%- if doc.apply_discount_on == "Grand Total" -%} + {{ render_discount_amount(doc) }} + {%- endif -%}
From 755ff60313e577d87b3035e37d7265c2feb4e8f1 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Feb 2015 01:12:09 +0530 Subject: [PATCH 05/13] tax amount conversion in client side printing --- erpnext/public/js/controllers/accounts.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index 21ad71fc5d..c8bb86cfaa 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -100,11 +100,6 @@ cur_frm.pformat.taxes= function(doc){ + format_currency(val, doc.currency) + ''; } - function convert_rate(val) { - var new_val = flt(val)/flt(doc.conversion_rate); - return new_val; - } - function print_hide(fieldname) { var doc_field = frappe.meta.get_docfield(doc.doctype, fieldname, doc.name); return doc_field.print_hide; @@ -132,8 +127,8 @@ cur_frm.pformat.taxes= function(doc){ // add rows if(cl.length){ for(var i=0;i Date: Mon, 23 Feb 2015 01:40:01 +0530 Subject: [PATCH 06/13] Renamed Net total to Total and dynamic label --- erpnext/controllers/taxes_and_totals.py | 8 ++--- erpnext/public/js/controllers/accounts.js | 6 ++-- .../public/js/controllers/taxes_and_totals.js | 8 ++--- .../selling/doctype/quotation/quotation.json | 10 +++--- erpnext/selling/sales_common.js | 33 ++++++++++++------- 5 files changed, 38 insertions(+), 27 deletions(-) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 1b1527b7eb..0b32d47cd5 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -187,15 +187,15 @@ class calculate_taxes_and_totals(object): return tax.rate def calculate_net_total(self): - self.doc.print_total = self.doc.base_print_total = self.doc.net_total = self.doc.base_net_total = 0.0 + self.doc.total = self.doc.base_total = self.doc.net_total = self.doc.base_net_total = 0.0 for item in self.doc.get("items"): - self.doc.print_total += item.amount - self.doc.base_print_total += item.base_amount + self.doc.total += item.amount + self.doc.base_total += item.base_amount self.doc.net_total += item.net_amount self.doc.base_net_total += item.base_net_amount - self.doc.round_floats_in(self.doc, ["print_total", "base_print_total", "net_total", "base_net_total"]) + self.doc.round_floats_in(self.doc, ["total", "base_total", "net_total", "base_net_total"]) def calculate_taxes(self): # maintain actual tax rate based on idx diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index c8bb86cfaa..8911832016 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -85,7 +85,7 @@ cur_frm.set_query("cost_center", "taxes", function(doc) { }); // For customizing print -cur_frm.pformat.print_total = function(doc) { return ''; } +cur_frm.pformat.total = function(doc) { return ''; } cur_frm.pformat.discount_amount = function(doc) { return ''; } cur_frm.pformat.grand_total = function(doc) { return ''; } cur_frm.pformat.rounded_total = function(doc) { return ''; } @@ -116,8 +116,8 @@ cur_frm.pformat.taxes= function(doc){ out +=''; - if(!print_hide('print_total')) { - out += make_row('Net Total', doc.print_total, 1); + if(!print_hide('total')) { + out += make_row('Total', doc.total, 1); } // Discount Amount on net total diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 603b147a00..4018742c3d 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -179,16 +179,16 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ calculate_net_total: function() { var me = this; - this.frm.doc.print_total = this.frm.doc.base_print_total = this.frm.doc.net_total = this.frm.doc.base_net_total = 0.0; + this.frm.doc.total = this.frm.doc.base_total = this.frm.doc.net_total = this.frm.doc.base_net_total = 0.0; $.each(this.frm.doc["items"] || [], function(i, item) { - me.frm.doc.print_total += item.amount; - me.frm.doc.base_print_total += item.base_amount; + me.frm.doc.total += item.amount; + me.frm.doc.base_total += item.base_amount; me.frm.doc.net_total += item.net_amount; me.frm.doc.base_net_total += item.base_net_amount; }); - frappe.model.round_floats_in(this.frm.doc, ["print_total", "base_print_total", "net_total", "base_net_total"]); + frappe.model.round_floats_in(this.frm.doc, ["total", "base_total", "net_total", "base_net_total"]); }, calculate_taxes: function() { diff --git a/erpnext/selling/doctype/quotation/quotation.json b/erpnext/selling/doctype/quotation/quotation.json index 7a00237c9f..675e6b0fd7 100644 --- a/erpnext/selling/doctype/quotation/quotation.json +++ b/erpnext/selling/doctype/quotation/quotation.json @@ -313,9 +313,9 @@ "read_only": 0 }, { - "fieldname": "base_print_total", + "fieldname": "base_total", "fieldtype": "Currency", - "label": "Print Total (Company Currency)", + "label": "Total (Company Currency)", "options": "Company:company:default_currency", "permlevel": 0, "precision": "", @@ -343,9 +343,9 @@ "permlevel": 0 }, { - "fieldname": "print_total", + "fieldname": "total", "fieldtype": "Currency", - "label": "Print Total", + "label": "Total", "options": "currency", "permlevel": 0, "precision": "", @@ -844,7 +844,7 @@ "idx": 1, "is_submittable": 1, "max_attachments": 1, - "modified": "2015-02-23 00:55:17.519474", + "modified": "2015-02-23 01:18:17.421144", "modified_by": "Administrator", "module": "Selling", "name": "Quotation", diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 2c520f6edd..1414912dfd 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -326,12 +326,12 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ } }); }; - setup_field_label_map(["base_net_total", "base_total_taxes_and_charges", "base_discount_amount", "base_grand_total", - "base_rounded_total", "base_in_words", + setup_field_label_map(["base_total", "base_net_total", "base_total_taxes_and_charges", + "base_discount_amount", "base_grand_total", "base_rounded_total", "base_in_words", "outstanding_amount", "total_advance", "paid_amount", "write_off_amount"], company_currency); - setup_field_label_map(["net_total", "total_taxes_and_charges", "discount_amount", "grand_total", + setup_field_label_map(["total", "net_total", "total_taxes_and_charges", "discount_amount", "grand_total", "rounded_total", "in_words"], this.frm.doc.currency); cur_frm.set_df_property("conversion_rate", "description", "1 " + this.frm.doc.currency @@ -343,7 +343,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ } // toggle fields - this.frm.toggle_display(["conversion_rate", "base_net_total", "base_total_taxes_and_charges", + this.frm.toggle_display(["conversion_rate", "base_total", "base_net_total", "base_total_taxes_and_charges", "base_grand_total", "base_rounded_total", "base_in_words", "base_discount_amount"], this.frm.doc.currency != company_currency); @@ -372,13 +372,15 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }); } - setup_field_label_map(["base_rate", "base_price_list_rate", "base_amount"], + setup_field_label_map(["base_rate", "base_net_rate", "base_price_list_rate", "base_amount", "base_net_amount"], company_currency, "items"); - setup_field_label_map(["rate", "price_list_rate", "amount"], + setup_field_label_map(["rate", "net_rate", "price_list_rate", "amount", "net_amount"], this.frm.doc.currency, "items"); - setup_field_label_map(["tax_amount", "total"], company_currency, "taxes"); + setup_field_label_map(["tax_amount", "total", "tax_amount_after_discount"], this.frm.doc.currency, "taxes"); + + setup_field_label_map(["base_tax_amount", "base_total", "base_tax_amount_after_discount"], company_currency, "taxes"); if(this.frm.fields_dict["advances"]) { setup_field_label_map(["advance_amount", "allocated_amount"], company_currency, @@ -387,15 +389,24 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ // toggle columns var item_grid = this.frm.fields_dict["items"].grid; - var show = (this.frm.doc.currency != company_currency) || - ((cur_frm.doc.taxes || []).filter( - function(d) { return d.included_in_print_rate===1}).length); - $.each(["base_rate", "base_price_list_rate", "base_amount"], function(i, fname) { + if(frappe.meta.get_docfield(item_grid.doctype, fname)) + item_grid.set_column_disp(fname, this.frm.doc.currency != company_currency); + }); + + var show = (cint(cur_frm.doc.discount_amount)) || + ((cur_frm.doc.taxes || []).filter(function(d) {return d.included_in_print_rate===1}).length); + + $.each(["net_rate", "net_amount"], function(i, fname) { if(frappe.meta.get_docfield(item_grid.doctype, fname)) item_grid.set_column_disp(fname, show); }); + $.each(["base_net_rate", "base_net_amount"], function(i, fname) { + if(frappe.meta.get_docfield(item_grid.doctype, fname)) + item_grid.set_column_disp(fname, (show && (this.frm.doc.currency != company_currency))); + }); + // set labels var $wrapper = $(this.frm.wrapper); $.each(field_label_map, function(fname, label) { From e9eec93be7d6d7d3f11373cafc57a51d2d4071fe Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Feb 2015 01:47:08 +0530 Subject: [PATCH 07/13] minor fix --- erpnext/selling/sales_common.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 1414912dfd..c153f94ab8 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -391,7 +391,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ var item_grid = this.frm.fields_dict["items"].grid; $.each(["base_rate", "base_price_list_rate", "base_amount"], function(i, fname) { if(frappe.meta.get_docfield(item_grid.doctype, fname)) - item_grid.set_column_disp(fname, this.frm.doc.currency != company_currency); + item_grid.set_column_disp(fname, me.frm.doc.currency != company_currency); }); var show = (cint(cur_frm.doc.discount_amount)) || @@ -404,7 +404,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ $.each(["base_net_rate", "base_net_amount"], function(i, fname) { if(frappe.meta.get_docfield(item_grid.doctype, fname)) - item_grid.set_column_disp(fname, (show && (this.frm.doc.currency != company_currency))); + item_grid.set_column_disp(fname, (show && (me.frm.doc.currency != company_currency))); }); // set labels From 34afcfb4a13cd8bff16433022fe08903d50e4ef6 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Feb 2015 02:11:04 +0530 Subject: [PATCH 08/13] Print without amount in delivery note --- erpnext/stock/doctype/delivery_note/delivery_note.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index 2743ffcdfa..51afa2c805 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -25,7 +25,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend( cur_frm.add_custom_button(__('Make Installation Note'), this.make_installation_note); if (doc.docstatus==1) { - + this.show_stock_ledger(); this.show_general_ledger(); } @@ -131,6 +131,7 @@ erpnext.stock.delivery_note.set_print_hide = function(doc, cdt, cdn){ dn_item_fields['discount_percentage'].print_hide = 1; dn_item_fields['price_list_rate'].print_hide = 1; dn_item_fields['amount'].print_hide = 1; + dn_fields['taxes'].print_hide = 1; } else { if (dn_fields_copy['currency'].print_hide != 1) dn_fields['currency'].print_hide = 0; @@ -138,6 +139,8 @@ erpnext.stock.delivery_note.set_print_hide = function(doc, cdt, cdn){ dn_item_fields['rate'].print_hide = 0; if (dn_item_fields_copy['amount'].print_hide != 1) dn_item_fields['amount'].print_hide = 0; + if (dn_fields_copy['taxes'].print_hide != 1) + dn_fields['taxes'].print_hide = 0; } } From 613d081a60b33262073dd050571e24dc1b423f4f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Feb 2015 11:58:15 +0530 Subject: [PATCH 09/13] Validate taxes and charges input, commonified --- .../purchase_invoice/purchase_invoice.js | 1 - .../purchase_taxes_and_charges_master.py | 7 +- .../doctype/sales_invoice/sales_invoice.js | 1 - .../sales_taxes_and_charges_master.js | 2 - .../sales_taxes_and_charges_master.py | 7 +- .../purchase_common/purchase_common.js | 101 +-------- .../doctype/purchase_order/purchase_order.js | 1 - .../supplier_quotation/supplier_quotation.js | 1 - erpnext/controllers/accounts_controller.py | 33 ++- erpnext/controllers/taxes_and_totals.py | 36 +--- erpnext/public/js/controllers/accounts.js | 75 +++++-- .../public/js/controllers/taxes_and_totals.js | 7 +- erpnext/public/js/controllers/transaction.js | 194 +++++++++++------- .../selling/doctype/quotation/quotation.js | 1 - .../doctype/sales_order/sales_order.js | 1 - erpnext/selling/sales_common.js | 112 +--------- .../doctype/delivery_note/delivery_note.js | 1 - .../purchase_receipt/purchase_receipt.js | 1 - 18 files changed, 242 insertions(+), 340 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 6f16dcde46..8040c41ee5 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -3,7 +3,6 @@ frappe.provide("erpnext.accounts"); {% include 'buying/doctype/purchase_common/purchase_common.js' %}; -{% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ onload: function() { diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py index e93c57263f..b004a2e148 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py @@ -2,8 +2,11 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document +from erpnext.controllers.accounts_controller import validate_taxes_and_charges, validate_inclusive_tax class PurchaseTaxesandChargesMaster(Document): - pass + def validate(self): + for tax in self.get("taxes"): + validate_taxes_and_charges(tax) + validate_inclusive_tax(tax, self) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index bbc0dd21f1..4670303e2e 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -5,7 +5,6 @@ cur_frm.pformat.print_heading = 'Invoice'; {% include 'selling/sales_common.js' %}; -{% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} frappe.provide("erpnext.accounts"); erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({ diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js index 58a80a8314..b5dc38f803 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js @@ -1,8 +1,6 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.cscript.tax_table = "Sales Taxes and Charges"; - {% include "public/js/controllers/accounts.js" %} cur_frm.cscript.onload = function(doc, cdt, cdn) { diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py index 6ab5ab2745..4317f2ab8c 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py @@ -3,8 +3,8 @@ from __future__ import unicode_literals import frappe -from frappe.utils import cint from frappe.model.document import Document +from erpnext.controllers.accounts_controller import validate_taxes_and_charges, validate_inclusive_tax class SalesTaxesandChargesMaster(Document): def validate(self): @@ -15,3 +15,8 @@ class SalesTaxesandChargesMaster(Document): # at least one territory self.validate_table_has_rows("territories") + + for tax in self.get("taxes"): + validate_taxes_and_charges(tax) + validate_inclusive_tax(tax, self) + diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index f98dab783d..dc3b3a32be 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -1,11 +1,12 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt +cur_frm.cscript.tax_table = "Purchase Taxes and Charges"; +{% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} + frappe.provide("erpnext.buying"); frappe.require("assets/erpnext/js/controllers/transaction.js"); -{% include "public/js/controllers/accounts.js" %}; - cur_frm.email_field = "contact_email"; erpnext.buying.BuyingController = erpnext.TransactionController.extend({ @@ -166,97 +167,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ this.frm.doc.outstanding_amount = flt(this.frm.doc.total_amount_to_pay - this.frm.doc.total_advance, precision("outstanding_amount")); } - }, - - change_form_labels: function(company_currency) { - var me = this; - var field_label_map = {}; - - var setup_field_label_map = function(fields_list, currency) { - $.each(fields_list, function(i, fname) { - var docfield = frappe.meta.docfield_map[me.frm.doc.doctype][fname]; - if(docfield) { - var label = __(docfield.label || "").replace(/\([^\)]*\)/g, ""); - field_label_map[fname] = label.trim() + " (" + currency + ")"; - } - }); - }; - - - setup_field_label_map(["base_net_total", "base_total_taxes_and_charges", "base_grand_total", "base_in_words", - "base_taxes_and_charges_added", "base_taxes_and_charges_deducted", - "outstanding_amount", "total_advance", "total_amount_to_pay", "base_rounded_total"], - company_currency); - - setup_field_label_map(["net_total", "grand_total", "in_words", - "taxes_and_charges_added", "taxes_and_charges_deducted"], this.frm.doc.currency); - - cur_frm.set_df_property("conversion_rate", "description", "1 " + this.frm.doc.currency - + " = [?] " + company_currency); - - if(this.frm.doc.price_list_currency && this.frm.doc.price_list_currency!=company_currency) { - cur_frm.set_df_property("plc_conversion_rate", "description", "1 " + this.frm.doc.price_list_currency - + " = [?] " + company_currency); - } - - // toggle fields - this.frm.toggle_display(["conversion_rate", "base_net_total", "base_grand_total", - "base_in_words", "base_taxes_and_charges_added", "base_taxes_and_charges_deducted"], - this.frm.doc.currency !== company_currency); - - this.frm.toggle_display(["plc_conversion_rate", "price_list_currency"], - this.frm.doc.price_list_currency !== company_currency); - - // set labels - $.each(field_label_map, function(fname, label) { - me.frm.fields_dict[fname].set_label(label); - }); - - }, - - change_grid_labels: function(company_currency) { - var me = this; - var field_label_map = {}; - - var setup_field_label_map = function(fields_list, currency, parentfield) { - var grid_doctype = me.frm.fields_dict[parentfield].grid.doctype; - $.each(fields_list, function(i, fname) { - var docfield = frappe.meta.docfield_map[grid_doctype][fname]; - if(docfield) { - var label = __(docfield.label || "").replace(/\([^\)]*\)/g, ""); - field_label_map[grid_doctype + "-" + fname] = - label.trim() + " (" + currency + ")"; - } - }); - }; - - setup_field_label_map(["base_rate", "base_price_list_rate", "base_amount", "base_rate"], - company_currency, "items"); - - setup_field_label_map(["rate", "price_list_rate", "amount"], this.frm.doc.currency, "items"); - - if(this.frm.fields_dict["taxes"]) { - setup_field_label_map(["tax_amount", "total"], company_currency, "taxes"); - } - - if(this.frm.fields_dict["advances"]) { - setup_field_label_map(["advance_amount", "allocated_amount"], company_currency, - "advances"); - } - - // toggle columns - var item_grid = this.frm.fields_dict["items"].grid; - var fieldnames = $.map(["base_rate", "base_price_list_rate", "base_amount", "base_rate"], function(fname) { - return frappe.meta.get_docfield(item_grid.doctype, fname, me.frm.docname) ? fname : null; - }); - - item_grid.set_column_disp(fieldnames, this.frm.doc.currency != company_currency); - - // set labels - var $wrapper = $(this.frm.wrapper); - $.each(field_label_map, function(fname, label) { - $wrapper.find('[data-grid-fieldname="'+fname+'"]').text(label); - }); } }); cur_frm.add_fetch('project_name', 'cost_center', 'cost_center'); @@ -279,8 +189,3 @@ erpnext.buying.get_default_bom = function(frm) { } }); } - - -frappe.ui.form.on("Purchase Taxes and Charges", "rate", function(frm, cdt, cdn) { - cur_frm.cscript.calculate_taxes_and_totals(); -}) diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index b1eee0ed99..27ea0d4dd2 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -4,7 +4,6 @@ frappe.provide("erpnext.buying"); {% include 'buying/doctype/purchase_common/purchase_common.js' %}; -{% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({ refresh: function(doc, cdt, cdn) { diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js index 9c2bbed2f8..ecd9185c0e 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js @@ -3,7 +3,6 @@ // attach required files {% include 'buying/doctype/purchase_common/purchase_common.js' %}; -{% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({ refresh: function() { diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index c0a63cd9e9..1765fbf7f2 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe from frappe import _, throw -from frappe.utils import today, flt +from frappe.utils import today, flt, cint from erpnext.setup.utils import get_company_currency, get_exchange_rate from erpnext.accounts.utils import get_fiscal_year, validate_fiscal_year from erpnext.utilities.transaction_base import TransactionBase @@ -357,3 +357,34 @@ def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, c if not conversion_rate: throw(_("{0} is mandatory. Maybe Currency Exchange record is not created for {1} to {2}.").format( conversion_rate_label, currency, company_currency)) + +def validate_taxes_and_charges(tax): + if not tax.charge_type and (tax.row_id or tax.rate or tax.tax_amount): + frappe.throw(_("Please select Charge Type first")) + elif tax.charge_type in ['Actual', 'On Net Total'] and tax.row_id: + frappe.throw(_("Can refer row only if the charge type is 'On Previous Row Amount' or 'Previous Row Total'")) + elif tax.charge_type in ['On Previous Row Amount', 'On Previous Row Total'] and tax.row_id: + if cint(tax.idx) == 1: + frappe.throw(_("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row")) + elif not tax.row_id: + frappe.throw(_("Please specify a valid Row ID for row {0} in table {1}".format(tax.idx, _(tax.doctype)))) + elif tax.row_id and cint(tax.row_id) >= cint(tax.idx): + frappe.throw(_("Cannot refer row number greater than or equal to current row number for this Charge type")) + +def validate_inclusive_tax(tax, doc): + def _on_previous_row_error(row_range): + throw(_("To include tax in row {0} in Item rate, taxes in rows {1} must also be included").format(tax.idx, + row_range)) + + if cint(getattr(tax, "included_in_print_rate", None)): + if tax.charge_type == "Actual": + # inclusive tax cannot be of type Actual + throw(_("Charge of type 'Actual' in row {0} cannot be included in Item Rate").format(tax.idx)) + elif tax.charge_type == "On Previous Row Amount" and \ + not cint(doc.get("taxes")[cint(tax.row_id) - 1].included_in_print_rate): + # referred row should also be inclusive + _on_previous_row_error(tax.row_id) + elif tax.charge_type == "On Previous Row Total" and \ + not all([cint(t.included_in_print_rate) for t in doc.get("taxes")[:cint(tax.row_id) - 1]]): + # all rows about the reffered tax should be inclusive + _on_previous_row_error("1 - %d" % (tax.row_id,)) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 0b32d47cd5..eb397f8c55 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -3,10 +3,10 @@ from __future__ import unicode_literals import json -from frappe import _, throw from frappe.utils import cint, flt, rounded from erpnext.setup.utils import get_company_currency -from erpnext.controllers.accounts_controller import validate_conversion_rate +from erpnext.controllers.accounts_controller import validate_conversion_rate, \ + validate_taxes_and_charges, validate_inclusive_tax class calculate_taxes_and_totals(object): def __init__(self, doc): @@ -71,6 +71,9 @@ class calculate_taxes_and_totals(object): def initialize_taxes(self): for tax in self.doc.get("taxes"): + validate_taxes_and_charges(tax) + validate_inclusive_tax(tax, self.doc) + tax.item_wise_tax_detail = {} tax_fields = ["total", "tax_amount_after_discount_amount", "tax_amount_for_current_item", "grand_total_for_current_item", @@ -83,37 +86,8 @@ class calculate_taxes_and_totals(object): for fieldname in tax_fields: tax.set(fieldname, 0.0) - self.validate_on_previous_row(tax) - self.validate_inclusive_tax(tax) self.doc.round_floats_in(tax) - def validate_on_previous_row(self, tax): - """ - validate if a valid row id is mentioned in case of - On Previous Row Amount and On Previous Row Total - """ - if tax.charge_type in ["On Previous Row Amount", "On Previous Row Total"] and \ - (not tax.row_id or cint(tax.row_id) >= tax.idx): - throw(_("Please specify a valid Row ID for {0} in row {1}").format(_(tax.doctype), tax.idx)) - - def validate_inclusive_tax(self, tax): - def _on_previous_row_error(row_range): - throw(_("To include tax in row {0} in Item rate, taxes in rows {1} must also be included").format(tax.idx, - row_range)) - - if cint(getattr(tax, "included_in_print_rate", None)): - if tax.charge_type == "Actual": - # inclusive tax cannot be of type Actual - throw(_("Charge of type 'Actual' in row {0} cannot be included in Item Rate").format(tax.idx)) - elif tax.charge_type == "On Previous Row Amount" and \ - not cint(self.doc.get("taxes")[cint(tax.row_id) - 1].included_in_print_rate): - # referred row should also be inclusive - _on_previous_row_error(tax.row_id) - elif tax.charge_type == "On Previous Row Total" and \ - not all([cint(t.included_in_print_rate) for t in self.doc.get("taxes")[:cint(tax.row_id) - 1]]): - # all rows about the reffered tax should be inclusive - _on_previous_row_error("1 - %d" % (tax.row_id,)) - def determine_exclusive_rate(self): if not any((cint(tax.included_in_print_rate) for tax in self.doc.get("taxes"))) or \ self.doc.doctype not in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]: diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index 8911832016..d0f27bcedf 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -19,45 +19,94 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) { } } - -var validate_taxes_and_charges = function(cdt, cdn) { +cur_frm.cscript.validate_taxes_and_charges = function(cdt, cdn) { var d = locals[cdt][cdn]; + var msg = ""; if(!d.charge_type && (d.row_id || d.rate || d.tax_amount)) { - msgprint(__("Please select Charge Type first")); + msg = __("Please select Charge Type first"); d.row_id = ""; d.rate = d.tax_amount = 0.0; } else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) { - msgprint(__("Can refer row only if the charge type is 'On Previous Row Amount' or 'Previous Row Total'")); + msg = __("Can refer row only if the charge type is 'On Previous Row Amount' or 'Previous Row Total'"); d.row_id = ""; } else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id) { if (d.idx == 1) { - msgprint(__("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row")); + msg = __("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row"); d.charge_type = ''; - } else if (d.row_i && d.row_id >= d.idx) { - msgprint(__("Cannot refer row number greater than or equal to current row number for this Charge type")); + } else if (!d.row_id) { + msg = __("Please specify a valid Row ID for row {0} in table {1}", [d.idx, __(d.doctype)]); + d.row_id = ""; + } else if(d.row_id && d.row_id >= d.idx) { + msg = __("Cannot refer row number greater than or equal to current row number for this Charge type"); d.row_id = ""; } } - validated = false; - refresh_field('row_id', d.name, 'taxes'); + if(msg) { + validated = false; + refresh_field("taxes"); + frappe.throw(msg); + } + +} + +cur_frm.cscript.validate_inclusive_tax = function(tax) { + var actual_type_error = function() { + var msg = __("Actual type tax cannot be included in Item rate in row {0}", [tax.idx]) + frappe.throw(msg); + }; + + var on_previous_row_error = function(row_range) { + var msg = __("For row {0} in {1}. To include {2} in Item rate, rows {3} must also be included", + [tax.idx, __(tax.doctype), tax.charge_type, row_range]) + frappe.throw(msg); + }; + + if(cint(tax.included_in_print_rate)) { + if(tax.charge_type == "Actual") { + // inclusive tax cannot be of type Actual + actual_type_error(); + } else if(tax.charge_type == "On Previous Row Amount" && + !cint(this.frm.doc["taxes"][tax.row_id - 1].included_in_print_rate)) { + // referred row should also be an inclusive tax + on_previous_row_error(tax.row_id); + } else if(tax.charge_type == "On Previous Row Total") { + var taxes_not_included = $.map(this.frm.doc["taxes"].slice(0, tax.row_id), + function(t) { return cint(t.included_in_print_rate) ? null : t; }); + if(taxes_not_included.length > 0) { + // all rows above this tax should be inclusive + on_previous_row_error(tax.row_id == 1 ? "1" : "1 - " + tax.row_id); + } + } + } } frappe.ui.form.on(cur_frm.cscript.tax_table, "row_id", function(frm, cdt, cdn) { - validate_taxes_and_charges(cdt, cdn); + cur_frm.cscript.validate_taxes_and_charges(cdt, cdn); }); frappe.ui.form.on(cur_frm.cscript.tax_table, "rate", function(frm, cdt, cdn) { - validate_taxes_and_charges(cdt, cdn); + cur_frm.cscript.validate_taxes_and_charges(cdt, cdn); }); frappe.ui.form.on(cur_frm.cscript.tax_table, "tax_amount", function(frm, cdt, cdn) { - validate_taxes_and_charges(cdt, cdn); + cur_frm.cscript.validate_taxes_and_charges(cdt, cdn); }); frappe.ui.form.on(cur_frm.cscript.tax_table, "charge_type", function(frm, cdt, cdn) { - validate_taxes_and_charges(cdt, cdn); + cur_frm.cscript.validate_taxes_and_charges(cdt, cdn); }); +frappe.ui.form.on(cur_frm.cscript.tax_table, "included_in_print_rate", function(frm, cdt, cdn) { + var tax = frappe.get_doc(cdt, cdn); + try { + cur_frm.cscript.validate_taxes_and_charges(cdt, cdn); + cur_frm.cscript.validate_inclusive_tax(tax); + } catch(e) { + tax.included_in_print_rate = 0; + refresh_field("included_in_print_rate", tax.name, tax.parentfield); + throw e; + } +}); cur_frm.set_query("account_head", "taxes", function(doc) { if(cur_frm.cscript.tax_table == "Sales Taxes and Charges") { diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 4018742c3d..466839869a 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -94,7 +94,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ $.each(tax_fields, function(i, fieldname) { tax[fieldname] = 0.0 }); - me.validate_on_previous_row(tax); + cur_frm.cscript.validate_taxes_and_charges(tax.doctype, tax.name); me.validate_inclusive_tax(tax); frappe.model.round_floats_in(tax); }); @@ -129,10 +129,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ }); if(cumulated_tax_fraction && !me.discount_amount_applied) { - item.net_amount = flt( - (item.amount * me.frm.doc.conversion_rate) / (1 + cumulated_tax_fraction), - precision("net_amount", item)); - + item.net_amount = flt(item.amount / (1 + cumulated_tax_fraction), precision("net_amount", item)); item.net_rate = flt(item.net_amount / item.qty, precision("net_rate", item)); me.set_in_company_currency(item, ["net_rate", "net_amount"]); diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 519b04cb09..88b4ac4956 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -274,22 +274,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ this.apply_pricing_rule(frappe.get_doc(cdt, cdn), true); }, - tax_amount: function(doc, cdt, cdn) { - this.calculate_taxes_and_totals(); - }, - - row_id: function(doc, cdt, cdn) { - var tax = frappe.get_doc(cdt, cdn); - try { - this.validate_on_previous_row(tax); - this.calculate_taxes_and_totals(); - } catch(e) { - tax.row_id = null; - refresh_field("row_id", tax.name, tax.parentfield); - throw e; - } - }, - set_dynamic_labels: function() { // What TODO? should we make price list system non-mandatory? this.frm.toggle_reqd("plc_conversion_rate", @@ -301,6 +285,114 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ this.frm.refresh_fields(); }, + + change_form_labels: function(company_currency) { + var me = this; + var field_label_map = {}; + + var setup_field_label_map = function(fields_list, currency) { + $.each(fields_list, function(i, fname) { + var docfield = frappe.meta.docfield_map[me.frm.doc.doctype][fname]; + if(docfield) { + var label = __(docfield.label || "").replace(/\([^\)]*\)/g, ""); + field_label_map[fname] = label.trim() + " (" + currency + ")"; + } + }); + }; + setup_field_label_map(["base_total", "base_net_total", "base_total_taxes_and_charges", + "base_discount_amount", "base_grand_total", "base_rounded_total", "base_in_words", + "base_taxes_and_charges_added", "base_taxes_and_charges_deducted", "total_amount_to_pay", + "outstanding_amount", "total_advance", "paid_amount", "write_off_amount"], + company_currency); + + setup_field_label_map(["total", "net_total", "total_taxes_and_charges", "discount_amount", + "grand_total", "taxes_and_charges_added", "taxes_and_charges_deducted", + "rounded_total", "in_words"], this.frm.doc.currency); + + cur_frm.set_df_property("conversion_rate", "description", "1 " + this.frm.doc.currency + + " = [?] " + company_currency) + + if(this.frm.doc.price_list_currency && this.frm.doc.price_list_currency!=company_currency) { + cur_frm.set_df_property("plc_conversion_rate", "description", "1 " + this.frm.doc.price_list_currency + + " = [?] " + company_currency) + } + + // toggle fields + this.frm.toggle_display(["conversion_rate", "base_total", "base_net_total", "base_total_taxes_and_charges", + "base_taxes_and_charges_added", "base_taxes_and_charges_deducted", + "base_grand_total", "base_rounded_total", "base_in_words", "base_discount_amount"], + this.frm.doc.currency != company_currency); + + this.frm.toggle_display(["plc_conversion_rate", "price_list_currency"], + this.frm.doc.price_list_currency != company_currency); + + // set labels + $.each(field_label_map, function(fname, label) { + me.frm.fields_dict[fname].set_label(label); + }); + }, + + change_grid_labels: function(company_currency) { + var me = this; + var field_label_map = {}; + + var setup_field_label_map = function(fields_list, currency, parentfield) { + var grid_doctype = me.frm.fields_dict[parentfield].grid.doctype; + $.each(fields_list, function(i, fname) { + var docfield = frappe.meta.docfield_map[grid_doctype][fname]; + if(docfield) { + var label = __(docfield.label || "").replace(/\([^\)]*\)/g, ""); + field_label_map[grid_doctype + "-" + fname] = + label.trim() + " (" + currency + ")"; + } + }); + } + + setup_field_label_map(["base_rate", "base_net_rate", "base_price_list_rate", "base_amount", "base_net_amount"], + company_currency, "items"); + + setup_field_label_map(["rate", "net_rate", "price_list_rate", "amount", "net_amount"], + this.frm.doc.currency, "items"); + + if(this.frm.fields_dict["taxes"]) { + setup_field_label_map(["tax_amount", "total", "tax_amount_after_discount"], this.frm.doc.currency, "taxes"); + + setup_field_label_map(["base_tax_amount", "base_total", "base_tax_amount_after_discount"], company_currency, "taxes"); + } + + if(this.frm.fields_dict["advances"]) { + setup_field_label_map(["advance_amount", "allocated_amount"], company_currency, "advances"); + } + + // toggle columns + var item_grid = this.frm.fields_dict["items"].grid; + $.each(["base_rate", "base_price_list_rate", "base_amount"], function(i, fname) { + if(frappe.meta.get_docfield(item_grid.doctype, fname)) + item_grid.set_column_disp(fname, me.frm.doc.currency != company_currency); + }); + + var show = (cint(cur_frm.doc.discount_amount)) || + ((cur_frm.doc.taxes || []).filter(function(d) {return d.included_in_print_rate===1}).length); + + $.each(["net_rate", "net_amount"], function(i, fname) { + if(frappe.meta.get_docfield(item_grid.doctype, fname)) + item_grid.set_column_disp(fname, show); + }); + + $.each(["base_net_rate", "base_net_amount"], function(i, fname) { + if(frappe.meta.get_docfield(item_grid.doctype, fname)) + item_grid.set_column_disp(fname, (show && (me.frm.doc.currency != company_currency))); + }); + + // set labels + var $wrapper = $(this.frm.wrapper); + $.each(field_label_map, function(fname, label) { + fname = fname.split("-"); + var df = frappe.meta.get_docfield(fname[0], fname[1], me.frm.doc.name); + if(df) df.label = label; + }); + }, + recalculate: function() { this.calculate_taxes_and_totals(); }, @@ -426,60 +518,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }); }, - included_in_print_rate: function(doc, cdt, cdn) { - var tax = frappe.get_doc(cdt, cdn); - try { - this.validate_on_previous_row(tax); - this.validate_inclusive_tax(tax); - this.calculate_taxes_and_totals(); - } catch(e) { - tax.included_in_print_rate = 0; - refresh_field("included_in_print_rate", tax.name, tax.parentfield); - throw e; - } - }, - - validate_on_previous_row: function(tax) { - // validate if a valid row id is mentioned in case of - // On Previous Row Amount and On Previous Row Total - if((["On Previous Row Amount", "On Previous Row Total"].indexOf(tax.charge_type) != -1) && - (!tax.row_id || cint(tax.row_id) >= tax.idx)) { - var msg = __("Please specify a valid Row ID for row {0} in table {1}", [tax.idx, __(tax.doctype)]) - frappe.throw(msg); - } - }, - - validate_inclusive_tax: function(tax) { - var actual_type_error = function() { - var msg = __("Actual type tax cannot be included in Item rate in row {0}", [tax.idx]) - frappe.throw(msg); - }; - - var on_previous_row_error = function(row_range) { - var msg = __("For row {0} in {1}. To include {2} in Item rate, rows {3} must also be included", - [tax.idx, __(tax.doctype), tax.charge_type, row_range]) - frappe.throw(msg); - }; - - if(cint(tax.included_in_print_rate)) { - if(tax.charge_type == "Actual") { - // inclusive tax cannot be of type Actual - actual_type_error(); - } else if(tax.charge_type == "On Previous Row Amount" && - !cint(this.frm.doc["taxes"][tax.row_id - 1].included_in_print_rate)) { - // referred row should also be an inclusive tax - on_previous_row_error(tax.row_id); - } else if(tax.charge_type == "On Previous Row Total") { - var taxes_not_included = $.map(this.frm.doc["taxes"].slice(0, tax.row_id), - function(t) { return cint(t.included_in_print_rate) ? null : t; }); - if(taxes_not_included.length > 0) { - // all rows above this tax should be inclusive - on_previous_row_error(tax.row_id == 1 ? "1" : "1 - " + tax.row_id); - } - } - } - }, - get_item_wise_taxes_html: function() { var item_tax = {}; var tax_accounts = []; @@ -650,3 +688,19 @@ frappe.ui.form.on(cur_frm.doctype + "Item", "rate", function(frm, cdt, cdn) { cur_frm.cscript.calculate_taxes_and_totals(); }) + +frappe.ui.form.on(cur_frm.cscript.tax_table, "rate", function(frm, cdt, cdn) { + cur_frm.cscript.calculate_taxes_and_totals(); +}) + +frappe.ui.form.on(cur_frm.cscript.tax_table, "tax_amount", function(frm, cdt, cdn) { + cur_frm.cscript.calculate_taxes_and_totals(); +}) + +frappe.ui.form.on(cur_frm.cscript.tax_table, "row_id", function(frm, cdt, cdn) { + cur_frm.cscript.calculate_taxes_and_totals(); +}) + +frappe.ui.form.on(cur_frm.cscript.tax_table, "included_in_print_rate", function(frm, cdt, cdn) { + cur_frm.cscript.calculate_taxes_and_totals(); +}) diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index c63939dbf9..4767f510eb 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -3,7 +3,6 @@ {% include 'selling/sales_common.js' %} -{% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ onload: function(doc, dt, dn) { diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 15b0e39740..bc9d0d119a 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -2,7 +2,6 @@ // License: GNU General Public License v3. See license.txt {% include 'selling/sales_common.js' %} -{% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({ refresh: function(doc, dt, dn) { diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index c153f94ab8..5d49e2f29d 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -2,11 +2,12 @@ // License: GNU General Public License v3. See license.txt +cur_frm.cscript.tax_table = "Sales Taxes and Charges"; +{% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} + frappe.provide("erpnext.selling"); frappe.require("assets/erpnext/js/controllers/transaction.js"); -{% include "public/js/controllers/accounts.js" %}; - cur_frm.email_field = "contact_email"; erpnext.selling.SellingController = erpnext.TransactionController.extend({ @@ -311,109 +312,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ } } refresh_field('sales_bom_help'); - }, - - change_form_labels: function(company_currency) { - var me = this; - var field_label_map = {}; - - var setup_field_label_map = function(fields_list, currency) { - $.each(fields_list, function(i, fname) { - var docfield = frappe.meta.docfield_map[me.frm.doc.doctype][fname]; - if(docfield) { - var label = __(docfield.label || "").replace(/\([^\)]*\)/g, ""); - field_label_map[fname] = label.trim() + " (" + currency + ")"; - } - }); - }; - setup_field_label_map(["base_total", "base_net_total", "base_total_taxes_and_charges", - "base_discount_amount", "base_grand_total", "base_rounded_total", "base_in_words", - "outstanding_amount", "total_advance", "paid_amount", "write_off_amount"], - company_currency); - - setup_field_label_map(["total", "net_total", "total_taxes_and_charges", "discount_amount", "grand_total", - "rounded_total", "in_words"], this.frm.doc.currency); - - cur_frm.set_df_property("conversion_rate", "description", "1 " + this.frm.doc.currency - + " = [?] " + company_currency) - - if(this.frm.doc.price_list_currency && this.frm.doc.price_list_currency!=company_currency) { - cur_frm.set_df_property("plc_conversion_rate", "description", "1 " + this.frm.doc.price_list_currency - + " = [?] " + company_currency) - } - - // toggle fields - this.frm.toggle_display(["conversion_rate", "base_total", "base_net_total", "base_total_taxes_and_charges", - "base_grand_total", "base_rounded_total", "base_in_words", "base_discount_amount"], - this.frm.doc.currency != company_currency); - - this.frm.toggle_display(["plc_conversion_rate", "price_list_currency"], - this.frm.doc.price_list_currency != company_currency); - - // set labels - $.each(field_label_map, function(fname, label) { - me.frm.fields_dict[fname].set_label(label); - }); - }, - - change_grid_labels: function(company_currency) { - var me = this; - var field_label_map = {}; - - var setup_field_label_map = function(fields_list, currency, parentfield) { - var grid_doctype = me.frm.fields_dict[parentfield].grid.doctype; - $.each(fields_list, function(i, fname) { - var docfield = frappe.meta.docfield_map[grid_doctype][fname]; - if(docfield) { - var label = __(docfield.label || "").replace(/\([^\)]*\)/g, ""); - field_label_map[grid_doctype + "-" + fname] = - label.trim() + " (" + currency + ")"; - } - }); - } - - setup_field_label_map(["base_rate", "base_net_rate", "base_price_list_rate", "base_amount", "base_net_amount"], - company_currency, "items"); - - setup_field_label_map(["rate", "net_rate", "price_list_rate", "amount", "net_amount"], - this.frm.doc.currency, "items"); - - setup_field_label_map(["tax_amount", "total", "tax_amount_after_discount"], this.frm.doc.currency, "taxes"); - - setup_field_label_map(["base_tax_amount", "base_total", "base_tax_amount_after_discount"], company_currency, "taxes"); - - if(this.frm.fields_dict["advances"]) { - setup_field_label_map(["advance_amount", "allocated_amount"], company_currency, - "advances"); - } - - // toggle columns - var item_grid = this.frm.fields_dict["items"].grid; - $.each(["base_rate", "base_price_list_rate", "base_amount"], function(i, fname) { - if(frappe.meta.get_docfield(item_grid.doctype, fname)) - item_grid.set_column_disp(fname, me.frm.doc.currency != company_currency); - }); - - var show = (cint(cur_frm.doc.discount_amount)) || - ((cur_frm.doc.taxes || []).filter(function(d) {return d.included_in_print_rate===1}).length); - - $.each(["net_rate", "net_amount"], function(i, fname) { - if(frappe.meta.get_docfield(item_grid.doctype, fname)) - item_grid.set_column_disp(fname, show); - }); - - $.each(["base_net_rate", "base_net_amount"], function(i, fname) { - if(frappe.meta.get_docfield(item_grid.doctype, fname)) - item_grid.set_column_disp(fname, (show && (me.frm.doc.currency != company_currency))); - }); - - // set labels - var $wrapper = $(this.frm.wrapper); - $.each(field_label_map, function(fname, label) { - fname = fname.split("-"); - var df = frappe.meta.get_docfield(fname[0], fname[1], me.frm.doc.name); - if(df) df.label = label; - }); } }); @@ -433,7 +331,3 @@ frappe.ui.form.on(cur_frm.doctype,"project_name", function(frm) { }) } }) - -frappe.ui.form.on("Sales Taxes and Charges", "rate", function(frm, cdt, cdn) { - cur_frm.cscript.calculate_taxes_and_totals(); -}) diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index 51afa2c805..185c242eda 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -2,7 +2,6 @@ // License: GNU General Public License v3. See license.txt {% include 'selling/sales_common.js' %}; -{% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} frappe.provide("erpnext.stock"); frappe.provide("erpnext.stock.delivery_note"); diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index 50a1073dcf..a7e662055c 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -2,7 +2,6 @@ // License: GNU General Public License v3. See license.txt {% include 'buying/doctype/purchase_common/purchase_common.js' %}; -{% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} frappe.provide("erpnext.stock"); erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({ From 37b047d9a82f0900b6d6064d867aaaab7a97027f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Feb 2015 16:01:33 +0530 Subject: [PATCH 10/13] Fields added in all sales and purchase doctypes --- .../purchase_invoice/purchase_invoice.json | 130 +- .../purchase_invoice_item.json | 54 +- .../purchase_taxes_and_charges.json | 85 +- .../purchase_taxes_and_charges_master.js | 4 +- .../doctype/sales_invoice/sales_invoice.json | 46 +- .../sales_invoice_item.json | 54 +- .../sales_taxes_and_charges.json | 326 ++--- .../purchase_common/purchase_common.js | 3 +- .../purchase_order/purchase_order.json | 159 ++- .../purchase_order_item.json | 54 +- .../supplier_quotation.json | 1179 +++++++++-------- .../supplier_quotation_item.json | 53 +- erpnext/controllers/accounts_controller.py | 6 +- erpnext/controllers/taxes_and_totals.py | 10 +- .../public/js/controllers/taxes_and_totals.js | 6 +- erpnext/public/js/controllers/transaction.js | 22 +- .../doctype/sales_order/sales_order.json | 46 +- .../sales_order_item/sales_order_item.json | 802 +++++------ erpnext/selling/sales_common.js | 8 - .../doctype/delivery_note/delivery_note.json | 45 +- .../delivery_note_item.json | 54 +- .../purchase_receipt/purchase_receipt.json | 160 ++- .../purchase_receipt_item.json | 54 +- 23 files changed, 2109 insertions(+), 1251 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index eb756de221..bd8199c0fe 100755 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -263,6 +263,16 @@ "fieldtype": "Section Break", "permlevel": 0 }, + { + "fieldname": "base_total", + "fieldtype": "Currency", + "label": "Total (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "description": "Will be calculated automatically when you enter the details", "fieldname": "base_net_total", @@ -280,6 +290,17 @@ "fieldtype": "Column Break", "permlevel": 0 }, + { + "fieldname": "total", + "fieldtype": "Currency", + "hidden": 0, + "label": "Total", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "net_total", "fieldtype": "Currency", @@ -373,35 +394,10 @@ "read_only": 1 }, { - "fieldname": "base_grand_total", - "fieldtype": "Currency", - "label": "Grand Total (Company Currency)", - "oldfieldname": "grand_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1 - }, - { - "description": "In Words will be visible once you save the Purchase Invoice.", - "fieldname": "base_in_words", - "fieldtype": "Data", - "label": "In Words (Company Currency)", - "oldfieldname": "in_words", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 1, - "read_only": 1 - }, - { - "fieldname": "column_break8", + "fieldname": "column_break_40", "fieldtype": "Column Break", - "oldfieldtype": "Column Break", "permlevel": 0, - "print_hide": 1, - "read_only": 0, - "width": "50%" + "precision": "" }, { "fieldname": "taxes_and_charges_added", @@ -433,6 +429,84 @@ "permlevel": 0, "precision": "" }, + { + "fieldname": "section_break_44", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "default": "Grand Total", + "fieldname": "apply_discount_on", + "fieldtype": "Select", + "label": "Apply Discount On", + "options": "\nGrand Total\nNet Total", + "permlevel": 0, + "precision": "", + "print_hide": 1 + }, + { + "fieldname": "column_break_46", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1 + }, + { + "fieldname": "base_discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "section_break_49", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "base_grand_total", + "fieldtype": "Currency", + "label": "Grand Total (Company Currency)", + "oldfieldname": "grand_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "description": "In Words will be visible once you save the Purchase Invoice.", + "fieldname": "base_in_words", + "fieldtype": "Data", + "label": "In Words (Company Currency)", + "oldfieldname": "in_words", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break8", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "width": "50%" + }, { "fieldname": "grand_total", "fieldtype": "Currency", @@ -888,7 +962,7 @@ "icon": "icon-file-text", "idx": 1, "is_submittable": 1, - "modified": "2015-02-20 05:16:22.693978", + "modified": "2015-02-23 15:33:28.554922", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", 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 33ccb27f9d..54b633b2c7 100755 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -194,6 +194,58 @@ "permlevel": 0, "read_only": 1 }, + { + "fieldname": "section_break_22", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "net_rate", + "fieldtype": "Currency", + "label": "Net Rate", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "net_amount", + "fieldtype": "Currency", + "label": "Net Amount", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_25", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "base_net_rate", + "fieldtype": "Currency", + "label": "Net Rate (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "base_net_amount", + "fieldtype": "Currency", + "label": "Net Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "accounting", "fieldtype": "Section Break", @@ -399,7 +451,7 @@ ], "idx": 1, "istable": 1, - "modified": "2015-02-19 01:07:01.060411", + "modified": "2015-02-23 15:35:32.895515", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice Item", 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 8244d12e61..057383a9cd 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 @@ -53,17 +53,13 @@ "read_only": 0 }, { - "fieldname": "description", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", + "description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount", + "fieldname": "included_in_print_rate", + "fieldtype": "Check", + "label": "Is this Tax included in Basic Rate?", "permlevel": 0, - "print_width": "300px", - "read_only": 0, - "reqd": 1, - "width": "300px" + "precision": "", + "report_hide": 1 }, { "fieldname": "col_break1", @@ -94,6 +90,19 @@ "permlevel": 0, "read_only": 0 }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "300px", + "read_only": 0, + "reqd": 1, + "width": "300px" + }, { "fieldname": "rate", "fieldtype": "Float", @@ -105,6 +114,12 @@ "read_only": 0, "reqd": 0 }, + { + "fieldname": "section_break_9", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, { "fieldname": "tax_amount", "fieldtype": "Currency", @@ -112,19 +127,65 @@ "label": "Amount", "oldfieldname": "tax_amount", "oldfieldtype": "Currency", - "options": "Company:company:default_currency", + "options": "currency", "permlevel": 0, "read_only": 1, "reqd": 0 }, + { + "fieldname": "tax_amount_after_discount_amount", + "fieldtype": "Currency", + "label": "Tax Amount After Discount Amount", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "total", "fieldtype": "Currency", "label": "Total", "oldfieldname": "total", "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break_14", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "base_tax_amount", + "fieldtype": "Currency", + "label": "Amount (Company Currency)", "options": "Company:company:default_currency", "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "base_total", + "fieldtype": "Currency", + "hidden": 1, + "label": "Total (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1 + }, + { + "fieldname": "base_tax_amount_after_discount_amount", + "fieldtype": "Currency", + "label": "Tax Amount After Discount Amount", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, "read_only": 1 }, { @@ -155,7 +216,7 @@ "hide_heading": 1, "idx": 1, "istable": 1, - "modified": "2015-02-19 01:07:01.581115", + "modified": "2015-02-23 15:01:31.895131", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Taxes and Charges", diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js index 4493d5288e..09f2e8def8 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js @@ -1,8 +1,6 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.cscript.tax_table = "Purchase Taxes and Charges"; - {% include "public/js/controllers/accounts.js" %} frappe.ui.form.on("Purchase Taxes and Charges", "add_deduct_tax", function(doc, cdt, cdn) { @@ -17,4 +15,4 @@ frappe.ui.form.on("Purchase Taxes and Charges", "add_deduct_tax", function(doc, d.add_deduct_tax = ''; } refresh_field('add_deduct_tax', d.name, 'taxes'); -} +}); diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index 61eb191112..d7837a2e9d 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -331,6 +331,16 @@ "fieldtype": "Section Break", "permlevel": 0 }, + { + "fieldname": "base_total", + "fieldtype": "Currency", + "label": "Total (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "base_net_total", "fieldtype": "Currency", @@ -348,6 +358,16 @@ "fieldtype": "Column Break", "permlevel": 0 }, + { + "fieldname": "total", + "fieldtype": "Currency", + "label": "Total", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "net_total", "fieldtype": "Currency", @@ -431,6 +451,12 @@ "print_hide": 1, "read_only": 1 }, + { + "fieldname": "column_break_47", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, { "fieldname": "base_total_taxes_and_charges", "fieldtype": "Currency", @@ -443,7 +469,23 @@ "read_only": 1 }, { - "fieldname": "column_break_45", + "fieldname": "section_break_49", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "default": "Grand Total", + "fieldname": "apply_discount_on", + "fieldtype": "Select", + "label": "Apply Discount On", + "options": "\nGrand Total\nNet Total", + "permlevel": 0, + "precision": "", + "print_hide": 1 + }, + { + "fieldname": "column_break_51", "fieldtype": "Column Break", "permlevel": 0 }, @@ -1202,7 +1244,7 @@ "icon": "icon-file-text", "idx": 1, "is_submittable": 1, - "modified": "2015-02-20 05:16:19.256361", + "modified": "2015-02-23 15:53:37.894033", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json index b87c6322f6..e720f1b02b 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json @@ -201,6 +201,58 @@ "permlevel": 0, "read_only": 1 }, + { + "fieldname": "section_break_21", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "net_rate", + "fieldtype": "Currency", + "label": "Net Rate", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "net_amount", + "fieldtype": "Currency", + "label": "Net Amount", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_24", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "base_net_rate", + "fieldtype": "Currency", + "label": "Net Rate (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "base_net_amount", + "fieldtype": "Currency", + "label": "Net Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "accounting", "fieldtype": "Section Break", @@ -439,7 +491,7 @@ ], "idx": 1, "istable": 1, - "modified": "2015-02-19 01:07:01.862525", + "modified": "2015-02-23 15:55:23.143072", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice Item", diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json index 2a0f506188..23225505e9 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json +++ b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json @@ -1,183 +1,195 @@ { - "autoname": "hash", - "creation": "2013-04-24 11:39:32", - "docstatus": 0, - "doctype": "DocType", + "autoname": "INVTD.######", + "creation": "2013-04-24 11:39:32", + "docstatus": 0, + "doctype": "DocType", "fields": [ { - "fieldname": "charge_type", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Type", - "oldfieldname": "charge_type", - "oldfieldtype": "Select", - "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total", - "permlevel": 0, + "fieldname": "charge_type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Type", + "oldfieldname": "charge_type", + "oldfieldtype": "Select", + "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total", + "permlevel": 0, "reqd": 1 - }, + }, { - "depends_on": "eval:[\"On Previous Row Amount\", \"On Previous Row Total\"].indexOf(doc.charge_type)!==-1", - "fieldname": "row_id", - "fieldtype": "Data", - "hidden": 0, - "label": "Reference Row #", - "oldfieldname": "row_id", - "oldfieldtype": "Data", + "depends_on": "eval:[\"On Previous Row Amount\", \"On Previous Row Total\"].indexOf(doc.charge_type)!==-1", + "fieldname": "row_id", + "fieldtype": "Data", + "hidden": 0, + "label": "Reference Row #", + "oldfieldname": "row_id", + "oldfieldtype": "Data", "permlevel": 0 - }, + }, { - "fieldname": "description", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "permlevel": 0, - "print_width": "300px", - "reqd": 1, - "width": "300px" - }, - { - "fieldname": "col_break_1", - "fieldtype": "Column Break", - "permlevel": 0, - "width": "50%" - }, - { - "fieldname": "account_head", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Account Head", - "oldfieldname": "account_head", - "oldfieldtype": "Link", - "options": "Account", - "permlevel": 0, - "reqd": 1, + "fieldname": "account_head", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Account Head", + "oldfieldname": "account_head", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "reqd": 1, "search_index": 1 - }, + }, { - "default": ":Company", - "fieldname": "cost_center", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Cost Center", - "oldfieldname": "cost_center_other_charges", - "oldfieldtype": "Link", - "options": "Cost Center", + "default": ":Company", + "fieldname": "cost_center", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Cost Center", + "oldfieldname": "cost_center_other_charges", + "oldfieldtype": "Link", + "options": "Cost Center", "permlevel": 0 - }, + }, { - "fieldname": "rate", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "rate", - "oldfieldtype": "Currency", - "permlevel": 0, + "fieldname": "rate", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "rate", + "oldfieldtype": "Currency", + "permlevel": 0, "reqd": 1 - }, + }, { - "fieldname": "tax_amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "options": "currency", - "permlevel": 0, - "precision": "" - }, + "fieldname": "col_break_1", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, { - "fieldname": "base_tax_amount", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Amount (Company Currency)", - "oldfieldname": "tax_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "read_only": 1, - "reqd": 0 - }, + "fieldname": "description", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "300px", + "reqd": 1, + "width": "300px" + }, { - "fieldname": "total", - "fieldtype": "Currency", - "label": "Total", - "options": "currency", - "permlevel": 0, - "precision": "", - "read_only": 1 - }, - { - "fieldname": "base_total", - "fieldtype": "Currency", - "label": "Total (Company Currency)", - "oldfieldname": "total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "read_only": 1 - }, - { - "allow_on_submit": 0, - "description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount", - "fieldname": "included_in_print_rate", - "fieldtype": "Check", - "label": "Is this Tax included in Basic Rate?", - "no_copy": 0, - "permlevel": 0, - "print_hide": 1, - "print_width": "150px", - "report_hide": 1, + "allow_on_submit": 0, + "description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount", + "fieldname": "included_in_print_rate", + "fieldtype": "Check", + "label": "Is this Tax included in Basic Rate?", + "no_copy": 0, + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "report_hide": 1, "width": "150px" - }, + }, { - "fieldname": "tax_amount_after_discount_amount", - "fieldtype": "Currency", - "label": "Tax Amount After Discount Amount", - "options": "currency", - "permlevel": 0, - "precision": "", + "fieldname": "section_break_9", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "tax_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "options": "currency", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "total", + "fieldtype": "Currency", + "label": "Total", + "options": "currency", + "permlevel": 0, + "precision": "", "read_only": 1 - }, + }, { - "depends_on": "eval:parent.discount_amount", - "fieldname": "base_tax_amount_after_discount_amount", - "fieldtype": "Currency", - "hidden": 0, - "label": "Tax Amount After Discount Amount (Company Currency)", - "options": "Company:company:default_currency", - "permlevel": 0, + "fieldname": "tax_amount_after_discount_amount", + "fieldtype": "Currency", + "label": "Tax Amount After Discount Amount", + "options": "currency", + "permlevel": 0, + "precision": "", "read_only": 1 - }, + }, { - "fieldname": "item_wise_tax_detail", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Item Wise Tax Detail", - "oldfieldname": "item_wise_tax_detail", - "oldfieldtype": "Small Text", - "permlevel": 0, + "fieldname": "column_break_13", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "base_tax_amount", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Amount (Company Currency)", + "oldfieldname": "tax_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "base_total", + "fieldtype": "Currency", + "label": "Total (Company Currency)", + "oldfieldname": "total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, "read_only": 1 - }, + }, { - "fieldname": "parenttype", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "label": "Parenttype", - "oldfieldname": "parenttype", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 1, + "depends_on": "eval:parent.discount_amount", + "fieldname": "base_tax_amount_after_discount_amount", + "fieldtype": "Currency", + "hidden": 0, + "label": "Tax Amount After Discount Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "item_wise_tax_detail", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Item Wise Tax Detail", + "oldfieldname": "item_wise_tax_detail", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "parenttype", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "label": "Parenttype", + "oldfieldname": "parenttype", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, "search_index": 1 } - ], - "hide_heading": 1, - "idx": 1, - "istable": 1, - "modified": "2015-02-19 17:00:07.949352", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Sales Taxes and Charges", - "owner": "Administrator", + ], + "hide_heading": 1, + "idx": 1, + "istable": 1, + "modified": "2015-02-23 12:36:02.213508", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Sales Taxes and Charges", + "owner": "Administrator", "permissions": [] -} +} \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index dc3b3a32be..414134a4b6 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -1,10 +1,11 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt +frappe.provide("erpnext.buying"); + cur_frm.cscript.tax_table = "Purchase Taxes and Charges"; {% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} -frappe.provide("erpnext.buying"); frappe.require("assets/erpnext/js/controllers/transaction.js"); cur_frm.email_field = "contact_email"; diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json index 2698f24cb6..6776535713 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.json +++ b/erpnext/buying/doctype/purchase_order/purchase_order.json @@ -224,11 +224,29 @@ "options": "Purchase Order Item", "permlevel": 0 }, + { + "fieldname": "get_last_purchase_rate", + "fieldtype": "Button", + "label": "Get Last Purchase Rate", + "oldfieldtype": "Button", + "permlevel": 0, + "print_hide": 0 + }, { "fieldname": "sb_last_purchase", "fieldtype": "Section Break", "permlevel": 0 }, + { + "fieldname": "base_total", + "fieldtype": "Currency", + "label": "Total (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "base_net_total", "fieldtype": "Currency", @@ -247,6 +265,16 @@ "fieldtype": "Column Break", "permlevel": 0 }, + { + "fieldname": "total", + "fieldtype": "Currency", + "label": "Total", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "net_total", "fieldtype": "Currency", @@ -259,14 +287,6 @@ "print_hide": 0, "read_only": 1 }, - { - "fieldname": "get_last_purchase_rate", - "fieldtype": "Button", - "label": "Get Last Purchase Rate", - "oldfieldtype": "Button", - "permlevel": 0, - "print_hide": 0 - }, { "fieldname": "taxes_section", "fieldtype": "Section Break", @@ -351,6 +371,93 @@ "print_hide": 1, "read_only": 1 }, + { + "fieldname": "column_break_39", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "taxes_and_charges_added", + "fieldtype": "Currency", + "label": "Taxes and Charges Added", + "no_copy": 0, + "oldfieldname": "other_charges_added_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 0 + }, + { + "fieldname": "taxes_and_charges_deducted", + "fieldtype": "Currency", + "label": "Taxes and Charges Deducted", + "no_copy": 0, + "oldfieldname": "other_charges_deducted_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 0 + }, + { + "fieldname": "total_taxes_and_charges", + "fieldtype": "Currency", + "label": "Total Taxes and Charges", + "options": "currency", + "permlevel": 0, + "precision": "", + "read_only": 1 + }, + { + "fieldname": "discount_section", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "default": "Grand Total", + "fieldname": "apply_discount_on", + "fieldtype": "Select", + "label": "Apply Discount On", + "options": "\nGrand Total\nNet Total", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "column_break_45", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1 + }, + { + "fieldname": "base_discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "totals_section", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, { "fieldname": "base_grand_total", "fieldtype": "Currency", @@ -400,40 +507,6 @@ "permlevel": 0, "print_hide": 0 }, - { - "fieldname": "taxes_and_charges_added", - "fieldtype": "Currency", - "label": "Taxes and Charges Added", - "no_copy": 0, - "oldfieldname": "other_charges_added_import", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, - "report_hide": 0 - }, - { - "fieldname": "taxes_and_charges_deducted", - "fieldtype": "Currency", - "label": "Taxes and Charges Deducted", - "no_copy": 0, - "oldfieldname": "other_charges_deducted_import", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, - "report_hide": 0 - }, - { - "fieldname": "total_taxes_and_charges", - "fieldtype": "Currency", - "label": "Total Taxes and Charges", - "options": "currency", - "permlevel": 0, - "precision": "" - }, { "fieldname": "grand_total", "fieldtype": "Currency", @@ -783,7 +856,7 @@ "icon": "icon-file-text", "idx": 1, "is_submittable": 1, - "modified": "2015-02-20 05:16:19.990723", + "modified": "2015-02-23 15:10:05.156787", "modified_by": "Administrator", "module": "Buying", "name": "Purchase Order", diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json index b0ba316a40..58af0767cf 100755 --- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json +++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json @@ -281,6 +281,58 @@ "permlevel": 0, "read_only": 1 }, + { + "fieldname": "section_break_29", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "net_rate", + "fieldtype": "Currency", + "label": "Net Rate", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "net_amount", + "fieldtype": "Currency", + "label": "Net Amount", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_32", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "base_net_rate", + "fieldtype": "Currency", + "label": "Net Rate (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "base_net_amount", + "fieldtype": "Currency", + "label": "Net Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "warehouse_and_reference", "fieldtype": "Section Break", @@ -484,7 +536,7 @@ ], "idx": 1, "istable": 1, - "modified": "2015-02-19 01:07:01.224244", + "modified": "2015-02-23 12:21:53.399279", "modified_by": "Administrator", "module": "Buying", "name": "Purchase Order Item", diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json index 352178f18e..0ed60230d5 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json @@ -1,681 +1,754 @@ { - "allow_import": 1, - "autoname": "naming_series:", - "creation": "2013-05-21 16:16:45", - "docstatus": 0, - "doctype": "DocType", - "document_type": "Transaction", + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-05-21 16:16:45", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", "fields": [ { - "fieldname": "supplier_section", - "fieldtype": "Section Break", - "label": "Supplier", - "options": "icon-user", + "fieldname": "supplier_section", + "fieldtype": "Section Break", + "label": "Supplier", + "options": "icon-user", "permlevel": 0 - }, + }, { - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "SQTN-", - "permlevel": 0, - "print_hide": 1, + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "SQTN-", + "permlevel": 0, + "print_hide": 1, "reqd": 1 - }, + }, { - "description": "Supplier (vendor) name as entered in supplier master", - "fieldname": "supplier", - "fieldtype": "Link", - "in_filter": 1, - "label": "Supplier", - "oldfieldname": "supplier", - "oldfieldtype": "Link", - "options": "Supplier", - "permlevel": 0, - "print_hide": 1, - "reqd": 1, + "description": "Supplier (vendor) name as entered in supplier master", + "fieldname": "supplier", + "fieldtype": "Link", + "in_filter": 1, + "label": "Supplier", + "oldfieldname": "supplier", + "oldfieldtype": "Link", + "options": "Supplier", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, "search_index": 1 - }, + }, { - "fieldname": "supplier_name", - "fieldtype": "Data", - "hidden": 0, - "in_list_view": 0, - "label": "Name", - "permlevel": 0, + "fieldname": "supplier_name", + "fieldtype": "Data", + "hidden": 0, + "in_list_view": 0, + "label": "Name", + "permlevel": 0, "read_only": 1 - }, + }, { - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Address", - "permlevel": 0, + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Address", + "permlevel": 0, "read_only": 1 - }, + }, { - "fieldname": "contact_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact", - "permlevel": 0, + "fieldname": "contact_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact", + "permlevel": 0, "read_only": 1 - }, + }, { - "fieldname": "contact_mobile", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Mobile No", - "permlevel": 0, + "fieldname": "contact_mobile", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Mobile No", + "permlevel": 0, "read_only": 1 - }, + }, { - "fieldname": "contact_email", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact Email", - "permlevel": 0, - "print_hide": 1, + "fieldname": "contact_email", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact Email", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "permlevel": 0, - "print_hide": 0, - "print_width": "50%", + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 0, + "print_width": "50%", "width": "50%" - }, + }, { - "fieldname": "transaction_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Date", - "oldfieldname": "transaction_date", - "oldfieldtype": "Date", - "permlevel": 0, - "reqd": 1, + "fieldname": "transaction_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Date", + "oldfieldname": "transaction_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1, "search_index": 1 - }, + }, { - "fieldname": "amended_from", - "fieldtype": "Link", - "hidden": 1, - "ignore_user_permissions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "options": "Supplier Quotation", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "amended_from", + "fieldtype": "Link", + "hidden": 1, + "ignore_user_permissions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "options": "Supplier Quotation", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "report_hide": 0 - }, + }, { - "description": "", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "no_copy": 0, - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "permlevel": 0, - "print_hide": 1, - "reqd": 1, + "description": "", + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "no_copy": 0, + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, "search_index": 1 - }, + }, { - "fieldname": "currency_and_price_list", - "fieldtype": "Section Break", - "label": "", - "options": "icon-tag", + "fieldname": "currency_and_price_list", + "fieldtype": "Section Break", + "label": "", + "options": "icon-tag", "permlevel": 0 - }, + }, { - "fieldname": "currency", - "fieldtype": "Link", - "label": "Currency", - "no_copy": 0, - "oldfieldname": "currency", - "oldfieldtype": "Select", - "options": "Currency", - "permlevel": 0, - "print_hide": 1, + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "no_copy": 0, + "oldfieldname": "currency", + "oldfieldtype": "Select", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, "reqd": 1 - }, + }, { - "description": "Rate at which supplier's currency is converted to company's base currency", - "fieldname": "conversion_rate", - "fieldtype": "Float", - "hidden": 0, - "label": "Exchange Rate", - "no_copy": 0, - "oldfieldname": "conversion_rate", - "oldfieldtype": "Currency", - "permlevel": 0, - "print_hide": 1, + "description": "Rate at which supplier's currency is converted to company's base currency", + "fieldname": "conversion_rate", + "fieldtype": "Float", + "hidden": 0, + "label": "Exchange Rate", + "no_copy": 0, + "oldfieldname": "conversion_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, "reqd": 1 - }, + }, { - "fieldname": "cb_price_list", - "fieldtype": "Column Break", - "permlevel": 0, - "print_width": "50%", + "fieldname": "cb_price_list", + "fieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", "width": "50%" - }, + }, { - "fieldname": "buying_price_list", - "fieldtype": "Link", - "label": "Price List", - "options": "Price List", - "permlevel": 0, + "fieldname": "buying_price_list", + "fieldtype": "Link", + "label": "Price List", + "options": "Price List", + "permlevel": 0, "print_hide": 1 - }, + }, { - "depends_on": "buying_price_list", - "fieldname": "price_list_currency", - "fieldtype": "Link", - "label": "Price List Currency", - "options": "Currency", - "permlevel": 0, - "print_hide": 1, + "depends_on": "buying_price_list", + "fieldname": "price_list_currency", + "fieldtype": "Link", + "label": "Price List Currency", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "depends_on": "buying_price_list", - "fieldname": "plc_conversion_rate", - "fieldtype": "Float", - "label": "Price List Exchange Rate", - "permlevel": 0, + "depends_on": "buying_price_list", + "fieldname": "plc_conversion_rate", + "fieldtype": "Float", + "label": "Price List Exchange Rate", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "ignore_pricing_rule", - "fieldtype": "Check", - "label": "Ignore Pricing Rule", - "no_copy": 1, - "permlevel": 1, + "fieldname": "ignore_pricing_rule", + "fieldtype": "Check", + "label": "Ignore Pricing Rule", + "no_copy": 1, + "permlevel": 1, "print_hide": 1 - }, + }, { - "fieldname": "items_section", - "fieldtype": "Section Break", - "label": "", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart", + "fieldname": "items_section", + "fieldtype": "Section Break", + "label": "", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", "permlevel": 0 - }, + }, { - "allow_on_submit": 1, - "fieldname": "items", - "fieldtype": "Table", - "label": "Items", - "no_copy": 0, - "oldfieldname": "po_details", - "oldfieldtype": "Table", - "options": "Supplier Quotation Item", + "allow_on_submit": 1, + "fieldname": "items", + "fieldtype": "Table", + "label": "Items", + "no_copy": 0, + "oldfieldname": "po_details", + "oldfieldtype": "Table", + "options": "Supplier Quotation Item", "permlevel": 0 - }, + }, { - "fieldname": "section_break_22", - "fieldtype": "Section Break", + "fieldname": "section_break_22", + "fieldtype": "Section Break", "permlevel": 0 - }, + }, { - "fieldname": "base_net_total", - "fieldtype": "Currency", - "label": "Net Total (Company Currency)", - "no_copy": 1, - "oldfieldname": "net_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "base_total", + "fieldtype": "Currency", + "label": "Total (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "base_net_total", + "fieldtype": "Currency", + "label": "Net Total (Company Currency)", + "no_copy": 1, + "oldfieldname": "net_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "reqd": 0 - }, + }, { - "fieldname": "column_break_24", - "fieldtype": "Column Break", + "fieldname": "column_break_24", + "fieldtype": "Column Break", "permlevel": 0 - }, + }, { - "fieldname": "net_total", - "fieldtype": "Currency", - "label": "Net Total", - "no_copy": 0, - "oldfieldname": "net_total_import", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 0, + "fieldname": "total", + "fieldtype": "Currency", + "label": "Total", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "taxes_section", - "fieldtype": "Section Break", - "label": "Taxes and Charges", - "oldfieldtype": "Section Break", - "options": "icon-money", + "fieldname": "net_total", + "fieldtype": "Currency", + "label": "Net Total", + "no_copy": 0, + "oldfieldname": "net_total_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "taxes_section", + "fieldtype": "Section Break", + "label": "Taxes and Charges", + "oldfieldtype": "Section Break", + "options": "icon-money", "permlevel": 0 - }, + }, { - "description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.", - "fieldname": "taxes_and_charges", - "fieldtype": "Link", - "label": "Taxes and Charges", - "no_copy": 1, - "oldfieldname": "purchase_other_charges", - "oldfieldtype": "Link", - "options": "Purchase Taxes and Charges Master", - "permlevel": 0, + "description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.", + "fieldname": "taxes_and_charges", + "fieldtype": "Link", + "label": "Taxes and Charges", + "no_copy": 1, + "oldfieldname": "purchase_other_charges", + "oldfieldtype": "Link", + "options": "Purchase Taxes and Charges Master", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "taxes", - "fieldtype": "Table", - "label": "Purchase Taxes and Charges", - "no_copy": 0, - "oldfieldname": "purchase_tax_details", - "oldfieldtype": "Table", - "options": "Purchase Taxes and Charges", + "fieldname": "taxes", + "fieldtype": "Table", + "label": "Purchase Taxes and Charges", + "no_copy": 0, + "oldfieldname": "purchase_tax_details", + "oldfieldtype": "Table", + "options": "Purchase Taxes and Charges", "permlevel": 0 - }, + }, { - "fieldname": "other_charges_calculation", - "fieldtype": "HTML", - "label": "Taxes and Charges Calculation", - "no_copy": 1, - "oldfieldtype": "HTML", - "permlevel": 0, + "fieldname": "other_charges_calculation", + "fieldtype": "HTML", + "label": "Taxes and Charges Calculation", + "no_copy": 1, + "oldfieldtype": "HTML", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "totals", - "fieldtype": "Section Break", - "label": "", - "oldfieldtype": "Section Break", - "options": "icon-money", + "fieldname": "totals", + "fieldtype": "Section Break", + "label": "", + "oldfieldtype": "Section Break", + "options": "icon-money", "permlevel": 0 - }, + }, { - "fieldname": "base_taxes_and_charges_added", - "fieldtype": "Currency", - "label": "Taxes and Charges Added (Company Currency)", - "no_copy": 0, - "oldfieldname": "other_charges_added", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, + "fieldname": "base_taxes_and_charges_added", + "fieldtype": "Currency", + "label": "Taxes and Charges Added (Company Currency)", + "no_copy": 0, + "oldfieldname": "other_charges_added", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "base_taxes_and_charges_deducted", - "fieldtype": "Currency", - "label": "Taxes and Charges Deducted (Company Currency)", - "no_copy": 0, - "oldfieldname": "other_charges_deducted", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, + "fieldname": "base_taxes_and_charges_deducted", + "fieldtype": "Currency", + "label": "Taxes and Charges Deducted (Company Currency)", + "no_copy": 0, + "oldfieldname": "other_charges_deducted", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "base_total_taxes_and_charges", - "fieldtype": "Currency", - "label": "Total Taxes and Charges (Company Currency)", - "no_copy": 1, - "oldfieldname": "total_tax", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, + "fieldname": "base_total_taxes_and_charges", + "fieldtype": "Currency", + "label": "Total Taxes and Charges (Company Currency)", + "no_copy": 1, + "oldfieldname": "total_tax", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "base_grand_total", - "fieldtype": "Currency", - "label": "Grand Total (Company Currency)", - "no_copy": 1, - "oldfieldname": "grand_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, + "fieldname": "column_break_37", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "taxes_and_charges_added", + "fieldtype": "Currency", + "label": "Taxes and Charges Added", + "no_copy": 0, + "oldfieldname": "other_charges_added_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 0 + }, + { + "fieldname": "taxes_and_charges_deducted", + "fieldtype": "Currency", + "label": "Taxes and Charges Deducted", + "no_copy": 0, + "oldfieldname": "other_charges_deducted_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 0 + }, + { + "fieldname": "total_taxes_and_charges", + "fieldtype": "Currency", + "label": "Total Taxes and Charges", + "options": "currency", + "permlevel": 0, + "precision": "", "read_only": 1 - }, + }, { - "fieldname": "base_rounded_total", - "fieldtype": "Currency", - "label": "Rounded Total (Company Currency)", - "oldfieldname": "rounded_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, + "fieldname": "section_break_41", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "default": "Grand Total", + "fieldname": "apply_discount_on", + "fieldtype": "Select", + "label": "Apply Discount On", + "options": "\nGrand Total\nNet Total", + "permlevel": 0, + "precision": "", + "print_hide": 1 + }, + { + "fieldname": "column_break_43", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1 + }, + { + "fieldname": "base_discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, "read_only": 1 - }, + }, { - "description": "In Words will be visible once you save the Purchase Order.", - "fieldname": "base_in_words", - "fieldtype": "Data", - "label": "In Words (Company Currency)", - "oldfieldname": "in_words", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 1, + "fieldname": "section_break_46", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "base_grand_total", + "fieldtype": "Currency", + "label": "Grand Total (Company Currency)", + "no_copy": 1, + "oldfieldname": "grand_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "column_break4", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "permlevel": 0, + "description": "In Words will be visible once you save the Purchase Order.", + "fieldname": "base_in_words", + "fieldtype": "Data", + "label": "In Words (Company Currency)", + "oldfieldname": "in_words", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "base_rounded_total", + "fieldtype": "Currency", + "label": "Rounded Total (Company Currency)", + "oldfieldname": "rounded_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break4", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, "print_hide": 0 - }, + }, { - "fieldname": "taxes_and_charges_added", - "fieldtype": "Currency", - "label": "Taxes and Charges Added", - "no_copy": 0, - "oldfieldname": "other_charges_added_import", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "grand_total", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Grand Total", + "no_copy": 0, + "oldfieldname": "grand_total_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, "report_hide": 0 - }, + }, { - "fieldname": "taxes_and_charges_deducted", - "fieldtype": "Currency", - "label": "Taxes and Charges Deducted", - "no_copy": 0, - "oldfieldname": "other_charges_deducted_import", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, - "report_hide": 0 - }, - { - "fieldname": "total_taxes_and_charges", - "fieldtype": "Currency", - "label": "Total Taxes and Charges", - "options": "currency", - "permlevel": 0, - "precision": "", + "fieldname": "in_words", + "fieldtype": "Data", + "label": "In Words", + "oldfieldname": "in_words_import", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, "read_only": 1 - }, + }, { - "fieldname": "grand_total", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Grand Total", - "no_copy": 0, - "oldfieldname": "grand_total_import", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 0, - "read_only": 1, - "report_hide": 0 - }, - { - "fieldname": "in_words", - "fieldtype": "Data", - "label": "In Words", - "oldfieldname": "in_words_import", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 0, - "read_only": 1 - }, - { - "fieldname": "fold", - "fieldtype": "Fold", + "fieldname": "fold", + "fieldtype": "Fold", "permlevel": 0 - }, + }, { - "fieldname": "terms_section_break", - "fieldtype": "Section Break", - "label": "Terms and Conditions", - "oldfieldtype": "Section Break", - "options": "icon-legal", + "fieldname": "terms_section_break", + "fieldtype": "Section Break", + "label": "Terms and Conditions", + "oldfieldtype": "Section Break", + "options": "icon-legal", "permlevel": 0 - }, + }, { - "allow_on_submit": 1, - "fieldname": "letter_head", - "fieldtype": "Link", - "label": "Letter Head", - "oldfieldname": "letter_head", - "oldfieldtype": "Select", - "options": "Letter Head", - "permlevel": 0, + "allow_on_submit": 1, + "fieldname": "letter_head", + "fieldtype": "Link", + "label": "Letter Head", + "oldfieldname": "letter_head", + "oldfieldtype": "Select", + "options": "Letter Head", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "tc_name", - "fieldtype": "Link", - "label": "Terms", - "oldfieldname": "tc_name", - "oldfieldtype": "Link", - "options": "Terms and Conditions", - "permlevel": 0, + "fieldname": "tc_name", + "fieldtype": "Link", + "label": "Terms", + "oldfieldname": "tc_name", + "oldfieldtype": "Link", + "options": "Terms and Conditions", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "get_terms", - "fieldtype": "Button", - "label": "Get Terms and Conditions", - "oldfieldtype": "Button", + "fieldname": "get_terms", + "fieldtype": "Button", + "label": "Get Terms and Conditions", + "oldfieldtype": "Button", "permlevel": 0 - }, + }, { - "fieldname": "terms", - "fieldtype": "Text Editor", - "label": "Terms and Conditions", - "oldfieldname": "terms", - "oldfieldtype": "Text Editor", + "fieldname": "terms", + "fieldtype": "Text Editor", + "label": "Terms and Conditions", + "oldfieldname": "terms", + "oldfieldtype": "Text Editor", "permlevel": 0 - }, + }, { - "depends_on": "supplier", - "fieldname": "contact_section", - "fieldtype": "Section Break", - "label": "Contact Info", - "options": "icon-bullhorn", + "depends_on": "supplier", + "fieldname": "contact_section", + "fieldtype": "Section Break", + "label": "Contact Info", + "options": "icon-bullhorn", "permlevel": 0 - }, + }, { - "fieldname": "supplier_address", - "fieldtype": "Link", - "in_filter": 1, - "label": "Supplier Address", - "options": "Address", - "permlevel": 0, + "fieldname": "supplier_address", + "fieldtype": "Link", + "in_filter": 1, + "label": "Supplier Address", + "options": "Address", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "contact_person", - "fieldtype": "Link", - "in_filter": 1, - "label": "Contact Person", - "options": "Contact", - "permlevel": 0, + "fieldname": "contact_person", + "fieldtype": "Link", + "in_filter": 1, + "label": "Contact Person", + "options": "Contact", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text", + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", "permlevel": 0 - }, + }, { - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nDraft\nSubmitted\nStopped\nCancelled", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, - "reqd": 1, + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "\nDraft\nSubmitted\nStopped\nCancelled", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1, "search_index": 1 - }, + }, { - "default": "No", - "fieldname": "is_subcontracted", - "fieldtype": "Select", - "label": "Is Subcontracted", - "options": "\nYes\nNo", - "permlevel": 0, + "default": "No", + "fieldname": "is_subcontracted", + "fieldtype": "Select", + "label": "Is Subcontracted", + "options": "\nYes\nNo", + "permlevel": 0, "print_hide": 1 - }, + }, { - "fieldname": "column_break_57", - "fieldtype": "Column Break", + "fieldname": "column_break_57", + "fieldtype": "Column Break", "permlevel": 0 - }, + }, { - "fieldname": "fiscal_year", - "fieldtype": "Link", - "in_filter": 1, - "label": "Fiscal Year", - "no_copy": 0, - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "Fiscal Year", - "permlevel": 0, - "print_hide": 1, - "reqd": 1, + "fieldname": "fiscal_year", + "fieldtype": "Link", + "in_filter": 1, + "label": "Fiscal Year", + "no_copy": 0, + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, "search_index": 1 - }, + }, { - "allow_on_submit": 1, - "fieldname": "select_print_heading", - "fieldtype": "Link", - "label": "Print Heading", - "no_copy": 1, - "oldfieldname": "select_print_heading", - "oldfieldtype": "Link", - "options": "Print Heading", - "permlevel": 0, - "print_hide": 1, + "allow_on_submit": 1, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "label": "Print Heading", + "no_copy": 1, + "oldfieldname": "select_print_heading", + "oldfieldtype": "Link", + "options": "Print Heading", + "permlevel": 0, + "print_hide": 1, "report_hide": 1 } - ], - "icon": "icon-shopping-cart", - "idx": 1, - "is_submittable": 1, - "modified": "2015-02-20 05:16:21.307774", - "modified_by": "Administrator", - "module": "Buying", - "name": "Supplier Quotation", - "owner": "Administrator", + ], + "icon": "icon-shopping-cart", + "idx": 1, + "is_submittable": 1, + "modified": "2015-02-23 15:24:02.428061", + "modified_by": "Administrator", + "module": "Buying", + "name": "Supplier Quotation", + "owner": "Administrator", "permissions": [ { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Manufacturing Manager", - "share": 1, - "submit": 1, + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Manufacturing Manager", + "share": 1, + "submit": 1, "write": 1 - }, + }, { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Purchase Manager", - "share": 1, - "submit": 1, + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Manager", + "share": 1, + "submit": 1, "write": 1 - }, + }, { - "amend": 1, - "apply_user_permissions": 1, - "cancel": 0, - "create": 1, - "delete": 0, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Purchase User", - "share": 1, - "submit": 0, + "amend": 1, + "apply_user_permissions": 1, + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User", + "share": 1, + "submit": 0, "write": 1 - }, + }, { - "amend": 0, - "apply_user_permissions": 1, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Material User", - "submit": 0, + "amend": 0, + "apply_user_permissions": 1, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 0, "write": 0 - }, + }, { - "amend": 0, - "apply_user_permissions": 1, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Supplier", - "submit": 0, + "amend": 0, + "apply_user_permissions": 1, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Supplier", + "submit": 0, "write": 0 - }, + }, { - "permlevel": 1, - "read": 1, - "role": "Purchase Manager", + "permlevel": 1, + "read": 1, + "role": "Purchase Manager", "write": 1 } - ], - "read_only_onload": 1, - "search_fields": "status, transaction_date, supplier,grand_total", - "sort_field": "modified", - "sort_order": "DESC", + ], + "read_only_onload": 1, + "search_fields": "status, transaction_date, supplier,grand_total", + "sort_field": "modified", + "sort_order": "DESC", "title_field": "supplier_name" -} +} \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json index 4e736defcf..59e3da488c 100644 --- a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json +++ b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json @@ -225,6 +225,57 @@ "permlevel": 0, "read_only": 1 }, + { + "fieldname": "section_break_24", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "net_rate", + "fieldtype": "Currency", + "label": "Net Rate", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "net_amount", + "fieldtype": "Currency", + "label": "Net Amount", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_27", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "base_net_rate", + "fieldtype": "Currency", + "label": "Net Rate (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "base_net_amount", + "fieldtype": "Currency", + "label": "Net Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "warehouse_and_reference", "fieldtype": "Section Break", @@ -360,7 +411,7 @@ ], "idx": 1, "istable": 1, - "modified": "2015-02-19 01:07:02.403267", + "modified": "2015-02-23 15:28:03.712608", "modified_by": "Administrator", "module": "Buying", "name": "Supplier Quotation Item", diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 1765fbf7f2..e4869894ad 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -359,11 +359,9 @@ def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, c conversion_rate_label, currency, company_currency)) def validate_taxes_and_charges(tax): - if not tax.charge_type and (tax.row_id or tax.rate or tax.tax_amount): - frappe.throw(_("Please select Charge Type first")) - elif tax.charge_type in ['Actual', 'On Net Total'] and tax.row_id: + if tax.charge_type in ['Actual', 'On Net Total'] and tax.row_id: frappe.throw(_("Can refer row only if the charge type is 'On Previous Row Amount' or 'Previous Row Total'")) - elif tax.charge_type in ['On Previous Row Amount', 'On Previous Row Total'] and tax.row_id: + elif tax.charge_type in ['On Previous Row Amount', 'On Previous Row Total']: if cint(tax.idx) == 1: frappe.throw(_("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row")) elif not tax.row_id: diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index eb397f8c55..24ca3c6922 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -3,6 +3,8 @@ from __future__ import unicode_literals import json +import frappe +from frappe import _ from frappe.utils import cint, flt, rounded from erpnext.setup.utils import get_company_currency from erpnext.controllers.accounts_controller import validate_conversion_rate, \ @@ -89,9 +91,8 @@ class calculate_taxes_and_totals(object): self.doc.round_floats_in(tax) def determine_exclusive_rate(self): - if not any((cint(tax.included_in_print_rate) for tax in self.doc.get("taxes"))) or \ - self.doc.doctype not in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]: - return + if not any((cint(tax.included_in_print_rate) for tax in self.doc.get("taxes"))): + return for item in self.doc.get("items"): item_tax_map = self._load_item_tax_rate(item.item_tax_rate) @@ -317,6 +318,9 @@ class calculate_taxes_and_totals(object): def apply_discount_amount(self): if self.doc.discount_amount: + if not self.doc.apply_discount_on: + frappe.throw(_("Please select Apply Discount On")) + self.doc.base_discount_amount = flt(self.doc.discount_amount * self.doc.conversion_rate, self.doc.precision("base_discount_amount")) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 466839869a..a3fff91387 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -107,8 +107,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ $.each(me.frm.doc["taxes"] || [], function(i, row) { if(cint(row.included_in_print_rate)) has_inclusive_tax = true; }) - if(has_inclusive_tax==false || !in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) - return; + if(has_inclusive_tax==false) return; $.each(me.frm.doc["items"] || [], function(n, item) { var item_tax_map = me._load_item_tax_rate(item.item_tax_rate); @@ -402,6 +401,9 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ var distributed_amount = 0.0; if (this.frm.doc.discount_amount) { + if(!this.frm.doc.apply_discount_on) + frappe.throw(__("Please select Apply Discount On")); + this.frm.set_value("base_discount_amount", flt(this.frm.doc.discount_amount * this.frm.doc.conversion_rate, precision("base_discount_amount"))) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 88b4ac4956..3f9846f195 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -285,7 +285,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ this.frm.refresh_fields(); }, - change_form_labels: function(company_currency) { var me = this; var field_label_map = {}; @@ -302,8 +301,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ setup_field_label_map(["base_total", "base_net_total", "base_total_taxes_and_charges", "base_discount_amount", "base_grand_total", "base_rounded_total", "base_in_words", "base_taxes_and_charges_added", "base_taxes_and_charges_deducted", "total_amount_to_pay", - "outstanding_amount", "total_advance", "paid_amount", "write_off_amount"], - company_currency); + "outstanding_amount", "total_advance", "paid_amount", "write_off_amount"], company_currency); setup_field_label_map(["total", "net_total", "total_taxes_and_charges", "discount_amount", "grand_total", "taxes_and_charges_added", "taxes_and_charges_deducted", @@ -330,6 +328,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ $.each(field_label_map, function(fname, label) { me.frm.fields_dict[fname].set_label(label); }); + }, change_grid_labels: function(company_currency) { @@ -500,9 +499,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ apply_price_list: function(item) { var me = this; var args = this._get_args(item); - if(!args.item_list.length) { - return; - } + return this.frm.call({ method: "erpnext.stock.get_item_details.apply_price_list", args: { args: args }, @@ -512,7 +509,10 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ me.frm.set_value("price_list_currency", r.message.parent.price_list_currency); me.frm.set_value("plc_conversion_rate", r.message.parent.plc_conversion_rate); me.in_apply_price_list = false; - me._set_values_for_item_list(r.message.children); + + if(args.item_list.length) { + me._set_values_for_item_list(r.message.children); + } } } }); @@ -704,3 +704,11 @@ frappe.ui.form.on(cur_frm.cscript.tax_table, "row_id", function(frm, cdt, cdn) { frappe.ui.form.on(cur_frm.cscript.tax_table, "included_in_print_rate", function(frm, cdt, cdn) { cur_frm.cscript.calculate_taxes_and_totals(); }) + +frappe.ui.form.on(cur_frm.doctype, "apply_discount_on", function(frm) { + cur_frm.cscript.calculate_taxes_and_totals(); +}) + +frappe.ui.form.on(cur_frm.doctype, "discount_amount", function(frm) { + cur_frm.cscript.calculate_taxes_and_totals(); +}) diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json index 07649a2ba1..db7cc800f7 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.json +++ b/erpnext/selling/doctype/sales_order/sales_order.json @@ -325,6 +325,16 @@ "fieldtype": "Column Break", "permlevel": 0 }, + { + "fieldname": "base_total", + "fieldtype": "Currency", + "label": "Total (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "base_net_total", "fieldtype": "Currency", @@ -343,6 +353,16 @@ "fieldtype": "Column Break", "permlevel": 0 }, + { + "fieldname": "total", + "fieldtype": "Currency", + "label": "Total", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "net_total", "fieldtype": "Currency", @@ -420,6 +440,12 @@ "print_hide": 1, "read_only": 1 }, + { + "fieldname": "column_break_46", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, { "fieldname": "base_total_taxes_and_charges", "fieldtype": "Currency", @@ -433,7 +459,23 @@ "width": "150px" }, { - "fieldname": "column_break_46", + "fieldname": "section_break_48", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "default": "Grand Total", + "fieldname": "apply_discount_on", + "fieldtype": "Select", + "label": "Apply Discount On", + "options": "\nGrand Total\nNet Total", + "permlevel": 0, + "precision": "", + "print_hide": 1 + }, + { + "fieldname": "column_break_50", "fieldtype": "Column Break", "permlevel": 0 }, @@ -1034,7 +1076,7 @@ "idx": 1, "is_submittable": 1, "issingle": 0, - "modified": "2015-02-20 05:16:18.207123", + "modified": "2015-02-23 15:40:17.414233", "modified_by": "Administrator", "module": "Selling", "name": "Sales Order", diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.json b/erpnext/selling/doctype/sales_order_item/sales_order_item.json index 131ec4db7e..6ef423b723 100644 --- a/erpnext/selling/doctype/sales_order_item/sales_order_item.json +++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.json @@ -1,455 +1,507 @@ { - "autoname": "hash", - "creation": "2013-03-07 11:42:58", - "docstatus": 0, - "doctype": "DocType", + "autoname": "hash", + "creation": "2013-03-07 11:42:58", + "docstatus": 0, + "doctype": "DocType", "fields": [ { - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "permlevel": 0, - "print_width": "150px", - "read_only": 0, - "reqd": 1, - "search_index": 1, + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "print_width": "150px", + "read_only": 0, + "reqd": 1, + "search_index": 1, "width": "150px" - }, + }, { - "fieldname": "customer_item_code", - "fieldtype": "Data", - "hidden": 1, - "label": "Customer's Item Code", - "permlevel": 0, - "print_hide": 1, + "fieldname": "customer_item_code", + "fieldtype": "Data", + "hidden": 1, + "label": "Customer's Item Code", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "fieldname": "col_break1", - "fieldtype": "Column Break", + "fieldname": "col_break1", + "fieldtype": "Column Break", "permlevel": 0 - }, + }, { - "fieldname": "item_name", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 1, - "print_width": "150", - "read_only": 0, - "reqd": 1, + "fieldname": "item_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150", + "read_only": 0, + "reqd": 1, "width": "150" - }, + }, { - "fieldname": "section_break_5", - "fieldtype": "Section Break", - "permlevel": 0, + "fieldname": "section_break_5", + "fieldtype": "Section Break", + "permlevel": 0, "precision": "" - }, + }, { - "fieldname": "description", - "fieldtype": "Small Text", - "in_filter": 1, - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "permlevel": 0, - "print_width": "300px", - "read_only": 0, - "reqd": 1, - "search_index": 1, + "fieldname": "description", + "fieldtype": "Small Text", + "in_filter": 1, + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "300px", + "read_only": 0, + "reqd": 1, + "search_index": 1, "width": "300px" - }, + }, { - "fieldname": "column_break_7", - "fieldtype": "Column Break", - "permlevel": 0, + "fieldname": "column_break_7", + "fieldtype": "Column Break", + "permlevel": 0, "precision": "" - }, + }, { - "fieldname": "image", - "fieldtype": "Attach", - "hidden": 1, - "label": "Image", - "permlevel": 0, - "precision": "", + "fieldname": "image", + "fieldtype": "Attach", + "hidden": 1, + "label": "Image", + "permlevel": 0, + "precision": "", "print_hide": 1 - }, + }, { - "fieldname": "image_view", - "fieldtype": "Image", - "label": "Image View", - "options": "image", - "permlevel": 0, + "fieldname": "image_view", + "fieldtype": "Image", + "label": "Image View", + "options": "image", + "permlevel": 0, "precision": "" - }, + }, { - "fieldname": "quantity_and_rate", - "fieldtype": "Section Break", - "label": "Quantity and Rate", + "fieldname": "quantity_and_rate", + "fieldtype": "Section Break", + "label": "Quantity and Rate", "permlevel": 0 - }, + }, { - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Quantity", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "permlevel": 0, - "print_width": "100px", - "read_only": 0, - "reqd": 1, + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Quantity", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 1, "width": "100px" - }, + }, { - "fieldname": "price_list_rate", - "fieldtype": "Currency", - "label": "Price List Rate", - "oldfieldname": "ref_rate", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_hide": 1, - "print_width": "70px", - "read_only": 1, - "reqd": 0, + "fieldname": "price_list_rate", + "fieldtype": "Currency", + "label": "Price List Rate", + "oldfieldname": "ref_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "70px", + "read_only": 1, + "reqd": 0, "width": "70px" - }, + }, { - "fieldname": "discount_percentage", - "fieldtype": "Percent", - "in_list_view": 1, - "label": "Discount(%)", - "oldfieldname": "adj_rate", - "oldfieldtype": "Float", - "permlevel": 0, - "print_hide": 1, - "print_width": "70px", - "read_only": 0, + "fieldname": "discount_percentage", + "fieldtype": "Percent", + "in_list_view": 1, + "label": "Discount(%)", + "oldfieldname": "adj_rate", + "oldfieldtype": "Float", + "permlevel": 0, + "print_hide": 1, + "print_width": "70px", + "read_only": 0, "width": "70px" - }, + }, { - "fieldname": "col_break2", - "fieldtype": "Column Break", + "fieldname": "col_break2", + "fieldtype": "Column Break", "permlevel": 0 - }, + }, { - "fieldname": "stock_uom", - "fieldtype": "Link", - "hidden": 0, - "in_list_view": 1, - "label": "UOM", - "oldfieldname": "stock_uom", - "oldfieldtype": "Data", - "options": "UOM", - "permlevel": 0, - "print_width": "70px", - "read_only": 1, - "reqd": 0, + "fieldname": "stock_uom", + "fieldtype": "Link", + "hidden": 0, + "in_list_view": 1, + "label": "UOM", + "oldfieldname": "stock_uom", + "oldfieldtype": "Data", + "options": "UOM", + "permlevel": 0, + "print_width": "70px", + "read_only": 1, + "reqd": 0, "width": "70px" - }, + }, { - "fieldname": "base_price_list_rate", - "fieldtype": "Currency", - "label": "Price List Rate (Company Currency)", - "oldfieldname": "base_ref_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "print_width": "100px", - "read_only": 1, + "fieldname": "base_price_list_rate", + "fieldtype": "Currency", + "label": "Price List Rate (Company Currency)", + "oldfieldname": "base_ref_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, "width": "100px" - }, + }, { - "fieldname": "section_break_simple1", - "fieldtype": "Section Break", + "fieldname": "section_break_simple1", + "fieldtype": "Section Break", "permlevel": 0 - }, + }, { - "fieldname": "rate", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "export_rate", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_width": "100px", - "read_only": 0, - "reqd": 0, + "fieldname": "rate", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "export_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 0, "width": "100px" - }, + }, { - "fieldname": "amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "no_copy": 0, - "oldfieldname": "export_amount", - "oldfieldtype": "Currency", - "options": "currency", - "permlevel": 0, - "print_width": "100px", - "read_only": 1, - "reqd": 0, + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "no_copy": 0, + "oldfieldname": "export_amount", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_width": "100px", + "read_only": 1, + "reqd": 0, "width": "100px" - }, + }, { - "fieldname": "col_break3", - "fieldtype": "Column Break", + "fieldname": "col_break3", + "fieldtype": "Column Break", "permlevel": 0 - }, + }, { - "fieldname": "base_rate", - "fieldtype": "Currency", - "label": "Basic Rate (Company Currency)", - "oldfieldname": "basic_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 0, + "fieldname": "base_rate", + "fieldtype": "Currency", + "label": "Basic Rate (Company Currency)", + "oldfieldname": "basic_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 0, "width": "100px" - }, + }, { - "fieldname": "base_amount", - "fieldtype": "Currency", - "label": "Amount (Company Currency)", - "no_copy": 0, - "oldfieldname": "amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 0, + "fieldname": "base_amount", + "fieldtype": "Currency", + "label": "Amount (Company Currency)", + "no_copy": 0, + "oldfieldname": "amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 0, "width": "100px" - }, + }, { - "fieldname": "pricing_rule", - "fieldtype": "Link", - "label": "Pricing Rule", - "options": "Pricing Rule", - "permlevel": 0, + "fieldname": "pricing_rule", + "fieldtype": "Link", + "label": "Pricing Rule", + "options": "Pricing Rule", + "permlevel": 0, "read_only": 1 - }, + }, { - "fieldname": "warehouse_and_reference", - "fieldtype": "Section Break", - "label": "Warehouse and Reference", + "fieldname": "section_break_24", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "net_rate", + "fieldtype": "Currency", + "label": "Net Rate", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "net_amount", + "fieldtype": "Currency", + "label": "Net Amount", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_27", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "base_net_rate", + "fieldtype": "Currency", + "label": "Net Rate (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "base_net_amount", + "fieldtype": "Currency", + "label": "Net Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "warehouse_and_reference", + "fieldtype": "Section Break", + "label": "Warehouse and Reference", "permlevel": 0 - }, + }, { - "fieldname": "warehouse", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Reserved Warehouse", - "no_copy": 0, - "oldfieldname": "reserved_warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "permlevel": 0, - "print_hide": 1, - "print_width": "150px", - "read_only": 0, - "reqd": 0, + "fieldname": "warehouse", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Reserved Warehouse", + "no_copy": 0, + "oldfieldname": "reserved_warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 0, + "reqd": 0, "width": "150px" - }, + }, { - "fieldname": "prevdoc_docname", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Quotation", - "no_copy": 1, - "oldfieldname": "prevdoc_docname", - "oldfieldtype": "Link", - "options": "Quotation", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "prevdoc_docname", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Quotation", + "no_copy": 1, + "oldfieldname": "prevdoc_docname", + "oldfieldtype": "Link", + "options": "Quotation", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "search_index": 1 - }, + }, { - "fieldname": "brand", - "fieldtype": "Link", - "hidden": 1, - "in_filter": 1, - "label": "Brand Name", - "oldfieldname": "brand", - "oldfieldtype": "Link", - "options": "Brand", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "brand", + "fieldtype": "Link", + "hidden": 1, + "in_filter": 1, + "label": "Brand Name", + "oldfieldname": "brand", + "oldfieldtype": "Link", + "options": "Brand", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "search_index": 1 - }, + }, { - "description": "", - "fieldname": "item_group", - "fieldtype": "Link", - "hidden": 1, - "in_filter": 1, - "label": "Item Group", - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "description": "", + "fieldname": "item_group", + "fieldtype": "Link", + "hidden": 1, + "in_filter": 1, + "label": "Item Group", + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "search_index": 1 - }, + }, { - "allow_on_submit": 1, - "fieldname": "page_break", - "fieldtype": "Check", - "label": "Page Break", - "oldfieldname": "page_break", - "oldfieldtype": "Check", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, + "allow_on_submit": 1, + "fieldname": "page_break", + "fieldtype": "Check", + "label": "Page Break", + "oldfieldname": "page_break", + "oldfieldtype": "Check", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, "report_hide": 1 - }, + }, { - "fieldname": "col_break4", - "fieldtype": "Column Break", + "fieldname": "col_break4", + "fieldtype": "Column Break", "permlevel": 0 - }, + }, { - "allow_on_submit": 1, - "fieldname": "projected_qty", - "fieldtype": "Float", - "hidden": 0, - "label": "Projected Qty", - "no_copy": 1, - "oldfieldname": "projected_qty", - "oldfieldtype": "Currency", - "permlevel": 0, - "print_hide": 1, - "print_width": "70px", - "read_only": 1, + "allow_on_submit": 1, + "fieldname": "projected_qty", + "fieldtype": "Float", + "hidden": 0, + "label": "Projected Qty", + "no_copy": 1, + "oldfieldname": "projected_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "70px", + "read_only": 1, "width": "70px" - }, + }, { - "allow_on_submit": 1, - "fieldname": "actual_qty", - "fieldtype": "Float", - "label": "Actual Qty", - "no_copy": 1, - "permlevel": 0, - "print_hide": 1, - "print_width": "70px", - "read_only": 1, + "allow_on_submit": 1, + "fieldname": "actual_qty", + "fieldtype": "Float", + "label": "Actual Qty", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "print_width": "70px", + "read_only": 1, "width": "70px" - }, + }, { - "fieldname": "delivered_qty", - "fieldtype": "Float", - "hidden": 0, - "in_filter": 0, - "label": "Delivered Qty", - "no_copy": 1, - "oldfieldname": "delivered_qty", - "oldfieldtype": "Currency", - "permlevel": 0, - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "search_index": 0, + "fieldname": "delivered_qty", + "fieldtype": "Float", + "hidden": 0, + "in_filter": 0, + "label": "Delivered Qty", + "no_copy": 1, + "oldfieldname": "delivered_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "search_index": 0, "width": "100px" - }, + }, { - "fieldname": "billed_amt", - "fieldtype": "Currency", - "label": "Billed Amt", - "no_copy": 1, - "options": "currency", - "permlevel": 0, - "print_hide": 1, + "fieldname": "billed_amt", + "fieldtype": "Currency", + "label": "Billed Amt", + "no_copy": 1, + "options": "currency", + "permlevel": 0, + "print_hide": 1, "read_only": 1 - }, + }, { - "description": "For Production", - "fieldname": "planned_qty", - "fieldtype": "Float", - "hidden": 1, - "label": "Planned Quantity", - "no_copy": 1, - "oldfieldname": "planned_qty", - "oldfieldtype": "Currency", - "permlevel": 0, - "print_hide": 1, - "print_width": "50px", - "read_only": 1, - "report_hide": 1, + "description": "For Production", + "fieldname": "planned_qty", + "fieldtype": "Float", + "hidden": 1, + "label": "Planned Quantity", + "no_copy": 1, + "oldfieldname": "planned_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "50px", + "read_only": 1, + "report_hide": 1, "width": "50px" - }, + }, { - "description": "For Production", - "fieldname": "produced_qty", - "fieldtype": "Float", - "hidden": 1, - "label": "Produced Quantity", - "oldfieldname": "produced_qty", - "oldfieldtype": "Currency", - "permlevel": 0, - "print_hide": 1, - "print_width": "50px", - "read_only": 1, - "report_hide": 1, + "description": "For Production", + "fieldname": "produced_qty", + "fieldtype": "Float", + "hidden": 1, + "label": "Produced Quantity", + "oldfieldname": "produced_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "50px", + "read_only": 1, + "report_hide": 1, "width": "50px" - }, + }, { - "fieldname": "item_tax_rate", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Item Tax Rate", - "oldfieldname": "item_tax_rate", - "oldfieldtype": "Small Text", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, + "fieldname": "item_tax_rate", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Item Tax Rate", + "oldfieldname": "item_tax_rate", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, "report_hide": 1 - }, + }, { - "description": "Used for Production Plan", - "fieldname": "transaction_date", - "fieldtype": "Date", - "hidden": 1, - "in_filter": 0, - "label": "Sales Order Date", - "oldfieldname": "transaction_date", - "oldfieldtype": "Date", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, - "report_hide": 1, + "description": "Used for Production Plan", + "fieldname": "transaction_date", + "fieldtype": "Date", + "hidden": 1, + "in_filter": 0, + "label": "Sales Order Date", + "oldfieldname": "transaction_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 1, "search_index": 0 } - ], - "idx": 1, - "istable": 1, - "modified": "2015-02-19 01:07:02.025024", - "modified_by": "Administrator", - "module": "Selling", - "name": "Sales Order Item", - "owner": "Administrator", - "permissions": [], - "sort_field": "modified", + ], + "idx": 1, + "istable": 1, + "modified": "2015-02-23 15:43:08.156543", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Order Item", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", "sort_order": "DESC" -} +} \ No newline at end of file diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 5d49e2f29d..f73b7970c6 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -155,14 +155,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ } }, - apply_discount_on: function() { - this.calculate_taxes_and_totals(); - }, - - discount_amount: function() { - this.calculate_taxes_and_totals(); - }, - commission_rate: function() { this.calculate_commission(); refresh_field("total_commission"); diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json index 6c8881ee35..a68f8cb29d 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.json +++ b/erpnext/stock/doctype/delivery_note/delivery_note.json @@ -340,6 +340,16 @@ "fieldtype": "Section Break", "permlevel": 0 }, + { + "fieldname": "base_total", + "fieldtype": "Currency", + "label": "Total (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "base_net_total", "fieldtype": "Currency", @@ -360,6 +370,16 @@ "fieldtype": "Column Break", "permlevel": 0 }, + { + "fieldname": "total", + "fieldtype": "Currency", + "label": "Total", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "net_total", "fieldtype": "Currency", @@ -443,6 +463,12 @@ "print_hide": 1, "read_only": 1 }, + { + "fieldname": "column_break_47", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, { "fieldname": "base_total_taxes_and_charges", "fieldtype": "Currency", @@ -457,7 +483,22 @@ "width": "150px" }, { - "fieldname": "column_break_47", + "fieldname": "section_break_49", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "default": "Grand Total", + "fieldname": "apply_discount_on", + "fieldtype": "Select", + "label": "Apply Discount On", + "options": "\nGrand Total\nNet Total", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "column_break_51", "fieldtype": "Column Break", "permlevel": 0 }, @@ -1024,7 +1065,7 @@ "idx": 1, "in_create": 0, "is_submittable": 1, - "modified": "2015-02-20 05:16:21.997931", + "modified": "2015-02-23 15:49:10.972483", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note", diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json index ff13200cb7..adcf258a4c 100644 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json @@ -254,6 +254,58 @@ "permlevel": 0, "read_only": 1 }, + { + "fieldname": "section_break_25", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "net_rate", + "fieldtype": "Currency", + "label": "Net Rate", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "net_amount", + "fieldtype": "Currency", + "label": "Net Amount", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_28", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "base_net_rate", + "fieldtype": "Currency", + "label": "Net Rate (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "base_net_amount", + "fieldtype": "Currency", + "label": "Net Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "warehouse_and_reference", "fieldtype": "Section Break", @@ -456,7 +508,7 @@ ], "idx": 1, "istable": 1, - "modified": "2015-02-23 00:06:50.441413", + "modified": "2015-02-23 15:51:20.772564", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note Item", diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json index 947c94c0d2..7964dd2455 100755 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json @@ -222,12 +222,31 @@ "print_hide": 0, "reqd": 0 }, + { + "fieldname": "get_current_stock", + "fieldtype": "Button", + "label": "Get Current Stock", + "oldfieldtype": "Button", + "options": "get_current_stock", + "permlevel": 0, + "print_hide": 1 + }, { "fieldname": "section_break0", "fieldtype": "Section Break", "oldfieldtype": "Section Break", "permlevel": 0 }, + { + "fieldname": "base_total", + "fieldtype": "Currency", + "label": "Total (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "base_net_total", "fieldtype": "Currency", @@ -242,20 +261,22 @@ "reqd": 1, "width": "150px" }, - { - "fieldname": "get_current_stock", - "fieldtype": "Button", - "label": "Get Current Stock", - "oldfieldtype": "Button", - "options": "get_current_stock", - "permlevel": 0, - "print_hide": 1 - }, { "fieldname": "column_break_27", "fieldtype": "Column Break", "permlevel": 0 }, + { + "fieldname": "total", + "fieldtype": "Currency", + "hidden": 0, + "label": "Total", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "net_total", "fieldtype": "Currency", @@ -346,39 +367,6 @@ "print_hide": 1, "read_only": 1 }, - { - "fieldname": "base_grand_total", - "fieldtype": "Currency", - "label": "Grand Total (Company Currency)", - "oldfieldname": "grand_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1 - }, - { - "fieldname": "base_rounded_total", - "fieldtype": "Currency", - "label": "Rounded Total (Company Currency)", - "oldfieldname": "rounded_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 0, - "print_hide": 1, - "read_only": 1 - }, - { - "description": "In Words will be visible once you save the Purchase Receipt.", - "fieldname": "base_in_words", - "fieldtype": "Data", - "label": "In Words (Company Currency)", - "oldfieldname": "in_words", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 1, - "read_only": 1 - }, { "fieldname": "column_break3", "fieldtype": "Column Break", @@ -416,6 +404,92 @@ "permlevel": 0, "precision": "" }, + { + "fieldname": "section_break_42", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "default": "Grand Total", + "fieldname": "apply_discount_on", + "fieldtype": "Select", + "label": "Apply Discount On", + "options": "\nGrand Total\nNet Total", + "permlevel": 0, + "precision": "", + "print_hide": 1 + }, + { + "fieldname": "column_break_44", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "base_discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "read_only": 1 + }, + { + "fieldname": "section_break_46", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "base_grand_total", + "fieldtype": "Currency", + "label": "Grand Total (Company Currency)", + "oldfieldname": "grand_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "description": "In Words will be visible once you save the Purchase Receipt.", + "fieldname": "base_in_words", + "fieldtype": "Data", + "label": "In Words (Company Currency)", + "oldfieldname": "in_words", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "base_rounded_total", + "fieldtype": "Currency", + "label": "Rounded Total (Company Currency)", + "oldfieldname": "rounded_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_50", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, { "fieldname": "grand_total", "fieldtype": "Currency", @@ -775,7 +849,7 @@ "icon": "icon-truck", "idx": 1, "is_submittable": 1, - "modified": "2015-02-20 05:16:24.035630", + "modified": "2015-02-23 15:16:36.617354", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt", diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json index c29a270afb..e36686c82b 100755 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json @@ -283,6 +283,58 @@ "permlevel": 0, "read_only": 1 }, + { + "fieldname": "section_break_29", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "net_rate", + "fieldtype": "Currency", + "label": "Net Rate", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "net_amount", + "fieldtype": "Currency", + "label": "Net Amount", + "options": "currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_32", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "base_net_rate", + "fieldtype": "Currency", + "label": "Net Rate (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "base_net_amount", + "fieldtype": "Currency", + "label": "Net Amount (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "precision": "", + "print_hide": 1, + "read_only": 1 + }, { "fieldname": "warehouse_and_reference", "fieldtype": "Section Break", @@ -588,7 +640,7 @@ ], "idx": 1, "istable": 1, - "modified": "2015-02-19 01:07:01.405923", + "modified": "2015-02-23 15:19:26.294450", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt Item", From 82e3e25cdbb60581d53c9c49ba9a6ad02d2d9ce6 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Feb 2015 16:58:30 +0530 Subject: [PATCH 11/13] fixes for base_rate, base_amount, tax_amount: mass search and replace --- .../purchase_invoice/purchase_invoice.py | 14 ++--- .../doctype/sales_invoice/sales_invoice.py | 8 +-- .../report/gross_profit/gross_profit.py | 6 +-- .../item_wise_purchase_register.py | 10 ++-- .../item_wise_sales_register.py | 11 ++-- .../purchase_register/purchase_register.py | 4 +- .../report/sales_register/sales_register.py | 6 +-- .../purchase_analytics/purchase_analytics.js | 2 +- erpnext/controllers/buying_controller.py | 8 +-- erpnext/controllers/trends.py | 6 +-- .../project_wise_stock_tracking.py | 30 +++++------ erpnext/public/js/feature_setup.js | 52 +++++++++++++------ .../page/sales_analytics/sales_analytics.js | 2 +- ..._person_target_variance_item_group_wise.py | 4 +- .../sales_person_wise_transaction_summary.py | 6 +-- ...rritory_target_variance_item_group_wise.py | 5 +- erpnext/shopping_cart/cart.py | 2 +- erpnext/startup/report_data_map.py | 12 ++--- .../purchase_receipt/purchase_receipt.py | 14 ++--- erpnext/stock/get_item_details.py | 2 + 20 files changed, 113 insertions(+), 91 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 4e0570f9b9..a289c03ff8 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -275,36 +275,36 @@ class PurchaseInvoice(BuyingController): # tax table gl entries valuation_tax = {} for tax in self.get("taxes"): - if tax.category in ("Total", "Valuation and Total") and flt(tax.tax_amount): + if tax.category in ("Total", "Valuation and Total") and flt(tax.base_tax_amount_after_discount_amount): gl_entries.append( self.get_gl_dict({ "account": tax.account_head, "against": self.credit_to, - "debit": tax.add_deduct_tax == "Add" and tax.tax_amount or 0, - "credit": tax.add_deduct_tax == "Deduct" and tax.tax_amount or 0, + "debit": tax.add_deduct_tax == "Add" and tax.base_tax_amount_after_discount_amount or 0, + "credit": tax.add_deduct_tax == "Deduct" and tax.base_tax_amount_after_discount_amount or 0, "remarks": self.remarks, "cost_center": tax.cost_center }) ) # accumulate valuation tax - if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount): + if tax.category in ("Valuation", "Valuation and Total") and flt(tax.base_tax_amount_after_discount_amount): if auto_accounting_for_stock and not tax.cost_center: frappe.throw(_("Cost Center is required in row {0} in Taxes table for type {1}").format(tax.idx, _(tax.category))) valuation_tax.setdefault(tax.cost_center, 0) valuation_tax[tax.cost_center] += \ - (tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.tax_amount) + (tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.base_tax_amount_after_discount_amount) # item gl entries negative_expense_to_be_booked = 0.0 stock_items = self.get_stock_items() for item in self.get("items"): - if flt(item.base_amount): + if flt(item.base_net_amount): gl_entries.append( self.get_gl_dict({ "account": item.expense_account, "against": self.credit_to, - "debit": item.base_amount, + "debit": item.base_net_amount, "remarks": self.remarks, "cost_center": item.cost_center }) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index f3ff9e1517..3b901c4681 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -496,12 +496,12 @@ class SalesInvoice(SellingController): def make_tax_gl_entries(self, gl_entries): for tax in self.get("taxes"): - if flt(tax.tax_amount_after_discount_amount): + if flt(tax.base_tax_amount_after_discount_amount): gl_entries.append( self.get_gl_dict({ "account": tax.account_head, "against": self.debit_to, - "credit": flt(tax.tax_amount_after_discount_amount), + "credit": flt(tax.base_tax_amount_after_discount_amount), "remarks": self.remarks, "cost_center": tax.cost_center }) @@ -510,12 +510,12 @@ class SalesInvoice(SellingController): def make_item_gl_entries(self, gl_entries): # income account gl entries for item in self.get("items"): - if flt(item.base_amount): + if flt(item.base_net_amount): gl_entries.append( self.get_gl_dict({ "account": item.income_account, "against": self.debit_to, - "credit": item.base_amount, + "credit": item.base_net_amount, "remarks": self.remarks, "cost_center": item.cost_center }) diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index d2129654ab..7ea9af9ab2 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -95,7 +95,7 @@ class GrossProfitGenerator(object): if self.skip_row(row, self.sales_boms): continue - row.selling_amount = flt(row.base_amount) + row.selling_amount = flt(row.base_net_amount) sales_boms = self.sales_boms.get(row.parenttype, {}).get(row.name, frappe._dict()) @@ -175,7 +175,7 @@ class GrossProfitGenerator(object): # sorted by posting_date desc, posting_time desc if item_code in self.non_stock_items: # average purchasing rate for non-stock items - item_rate = frappe.db.sql("""select sum(base_amount) / sum(qty) + item_rate = frappe.db.sql("""select sum(base_net_amount) / sum(qty) from `tabPurchase Invoice Item` where item_code = %s and docstatus=1""", item_code) @@ -211,7 +211,7 @@ class GrossProfitGenerator(object): si.customer, si.customer_group, si.territory, item.item_code, item.item_name, item.description, item.warehouse, item.item_group, item.brand, item.dn_detail, item.delivery_note, - item.qty, item.base_rate, item.base_amount, item.name as "item_row", + item.qty, item.base_net_rate, item.base_net_amount, item.name as "item_row", sales.sales_person, sales.sales_designation, sales.allocated_amount, sales.incentives from `tabSales Invoice` si diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py index 27f1249b2e..4a8427e341 100644 --- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py +++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py @@ -28,13 +28,13 @@ def execute(filters=None): expense_account = d.expense_account or aii_account_map.get(d.company) row = [d.item_code, d.item_name, d.item_group, d.parent, d.posting_date, d.supplier, d.supplier_name, d.credit_to, d.project_name, d.company, d.purchase_order, - purchase_receipt, expense_account, d.qty, d.base_rate, d.base_amount] + purchase_receipt, expense_account, d.qty, d.base_net_rate, d.base_net_amount] for tax in tax_accounts: row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0)) total_tax = sum(row[last_col:]) - row += [total_tax, d.base_amount + total_tax] + row += [total_tax, d.base_net_amount + total_tax] data.append(row) @@ -70,7 +70,7 @@ def get_items(filters): return frappe.db.sql("""select pi_item.parent, pi.posting_date, pi.credit_to, pi.company, pi.supplier, pi.remarks, pi.base_net_total, pi_item.item_code, pi_item.item_name, pi_item.item_group, pi_item.project_name, pi_item.purchase_order, pi_item.purchase_receipt, pi_item.po_detail - pi_item.expense_account, pi_item.qty, pi_item.base_rate, pi_item.base_amount, pi.supplier_name + pi_item.expense_account, pi_item.qty, pi_item.base_net_rate, pi_item.base_net_amount, pi.supplier_name from `tabPurchase Invoice` pi, `tabPurchase Invoice Item` pi_item where pi.name = pi_item.parent and pi.docstatus = 1 %s %s order by pi.posting_date desc, pi_item.item_code desc""" % (conditions, match_conditions), filters, as_dict=1) @@ -86,7 +86,7 @@ def get_tax_accounts(item_list, columns): for d in item_list: invoice_wise_items.setdefault(d.parent, []).append(d) - tax_details = frappe.db.sql("""select parent, account_head, item_wise_tax_detail, charge_type, tax_amount + tax_details = frappe.db.sql("""select parent, account_head, item_wise_tax_detail, charge_type, base_tax_amount_after_discount_amount from `tabPurchase Taxes and Charges` where parenttype = 'Purchase Invoice' and docstatus = 1 and ifnull(account_head, '') != '' and category in ('Total', 'Valuation and Total') and parent in (%s)""" % ', '.join(['%s']*len(invoice_wise_items)), tuple(invoice_wise_items.keys())) @@ -107,7 +107,7 @@ def get_tax_accounts(item_list, columns): elif charge_type == "Actual" and tax_amount: for d in invoice_wise_items.get(parent, []): item_tax.setdefault(parent, {}).setdefault(d.item_code, {})[account_head] = \ - (tax_amount * d.base_amount) / d.base_net_total + (tax_amount * d.base_net_amount) / d.base_net_total tax_accounts.sort() columns += [account_head + ":Currency:80" for account_head in tax_accounts] diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py index fef397f924..524773e396 100644 --- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py +++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py @@ -26,13 +26,13 @@ def execute(filters=None): row = [d.item_code, d.item_name, d.item_group, d.parent, d.posting_date, d.customer, d.customer_name, d.customer_group, d.debit_to, d.territory, d.project_name, d.company, d.sales_order, - delivery_note, d.income_account, d.qty, d.base_rate, d.base_amount] + delivery_note, d.income_account, d.qty, d.base_net_rate, d.base_net_amount] for tax in tax_accounts: row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0)) total_tax = sum(row[last_col:]) - row += [total_tax, d.base_amount + total_tax] + row += [total_tax, d.base_net_amount + total_tax] data.append(row) @@ -69,7 +69,7 @@ def get_items(filters): return frappe.db.sql("""select si_item.parent, si.posting_date, si.debit_to, si.project_name, si.customer, si.remarks, si.territory, si.company, si.base_net_total, si_item.item_code, si_item.item_name, si_item.item_group, si_item.sales_order, si_item.delivery_note, si_item.income_account, - si_item.qty, si_item.base_rate, si_item.base_amount, si.customer_name, + si_item.qty, si_item.base_net_rate, si_item.base_net_amount, si.customer_name, si.customer_group, si_item.so_detail from `tabSales Invoice` si, `tabSales Invoice Item` si_item where si.name = si_item.parent and si.docstatus = 1 %s @@ -83,7 +83,8 @@ def get_tax_accounts(item_list, columns): for d in item_list: invoice_wise_items.setdefault(d.parent, []).append(d) - tax_details = frappe.db.sql("""select parent, account_head, item_wise_tax_detail, charge_type, tax_amount + tax_details = frappe.db.sql("""select parent, account_head, item_wise_tax_detail, + charge_type, base_tax_amount_after_discount_amount from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice' and docstatus = 1 and ifnull(account_head, '') != '' and parent in (%s)""" % ', '.join(['%s']*len(invoice_wise_items)), @@ -104,7 +105,7 @@ def get_tax_accounts(item_list, columns): elif charge_type == "Actual" and tax_amount: for d in invoice_wise_items.get(parent, []): item_tax.setdefault(parent, {}).setdefault(d.item_code, {})[account_head] = \ - flt((tax_amount * d.base_amount) / d.base_net_total) + flt((tax_amount * d.base_net_amount) / d.base_net_total) tax_accounts.sort() columns += [account_head + ":Currency:80" for account_head in tax_accounts] diff --git a/erpnext/accounts/report/purchase_register/purchase_register.py b/erpnext/accounts/report/purchase_register/purchase_register.py index 724b6781f9..1e9273321b 100644 --- a/erpnext/accounts/report/purchase_register/purchase_register.py +++ b/erpnext/accounts/report/purchase_register/purchase_register.py @@ -114,7 +114,7 @@ def get_invoices(filters): def get_invoice_expense_map(invoice_list): - expense_details = frappe.db.sql("""select parent, expense_account, sum(base_amount) as amount + expense_details = frappe.db.sql("""select parent, expense_account, sum(base_net_amount) as amount from `tabPurchase Invoice Item` where parent in (%s) group by parent, expense_account""" % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1) @@ -126,7 +126,7 @@ def get_invoice_expense_map(invoice_list): return invoice_expense_map def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts): - tax_details = frappe.db.sql("""select parent, account_head, sum(tax_amount) as tax_amount + tax_details = frappe.db.sql("""select parent, account_head, sum(base_tax_amount_after_discount_amount) as tax_amount from `tabPurchase Taxes and Charges` where parent in (%s) group by parent, account_head""" % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1) diff --git a/erpnext/accounts/report/sales_register/sales_register.py b/erpnext/accounts/report/sales_register/sales_register.py index 3bd82b690c..5fa03f75a8 100644 --- a/erpnext/accounts/report/sales_register/sales_register.py +++ b/erpnext/accounts/report/sales_register/sales_register.py @@ -78,7 +78,7 @@ def get_columns(invoice_list): tax_accounts = frappe.db.sql_list("""select distinct account_head from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice' - and docstatus = 1 and ifnull(tax_amount_after_discount_amount, 0) != 0 + and docstatus = 1 and ifnull(base_tax_amount_after_discount_amount, 0) != 0 and parent in (%s) order by account_head""" % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list])) @@ -113,7 +113,7 @@ def get_invoices(filters): conditions, filters, as_dict=1) def get_invoice_income_map(invoice_list): - income_details = frappe.db.sql("""select parent, income_account, sum(base_amount) as amount + income_details = frappe.db.sql("""select parent, income_account, sum(base_net_amount) as amount from `tabSales Invoice Item` where parent in (%s) group by parent, income_account""" % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1) @@ -126,7 +126,7 @@ def get_invoice_income_map(invoice_list): def get_invoice_tax_map(invoice_list, invoice_income_map, income_accounts): tax_details = frappe.db.sql("""select parent, account_head, - sum(tax_amount_after_discount_amount) as tax_amount + sum(base_tax_amount_after_discount_amount) as tax_amount from `tabSales Taxes and Charges` where parent in (%s) group by parent, account_head""" % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1) diff --git a/erpnext/buying/page/purchase_analytics/purchase_analytics.js b/erpnext/buying/page/purchase_analytics/purchase_analytics.js index 470e44c15c..6afad76705 100644 --- a/erpnext/buying/page/purchase_analytics/purchase_analytics.js +++ b/erpnext/buying/page/purchase_analytics/purchase_analytics.js @@ -209,7 +209,7 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({ if (posting_date >= from_date && posting_date <= to_date) { var item = me.item_by_name[tl[me.tree_grid.item_key]] || me.item_by_name['Not Set']; - item[me.column_map[tl.posting_date].field] += (is_val ? tl.base_amount : tl.qty); + item[me.column_map[tl.posting_date].field] += (is_val ? tl.base_net_amount : tl.qty); } } }); diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 4e4e507cae..7d01f81fef 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -94,16 +94,16 @@ class BuyingController(StockController): for d in self.get(parentfield): if d.item_code and d.item_code in stock_items: stock_items_qty += flt(d.qty) - stock_items_amount += flt(d.base_amount) + stock_items_amount += flt(d.base_net_amount) last_stock_item_idx = d.idx - total_valuation_amount = sum([flt(d.tax_amount) for d in self.get("taxes") + total_valuation_amount = sum([flt(d.base_tax_amount_after_discount_amount) for d in self.get("taxes") if d.category in ["Valuation", "Valuation and Total"]]) valuation_amount_adjustment = total_valuation_amount for i, item in enumerate(self.get(parentfield)): if item.item_code and item.qty and item.item_code in stock_items: - item_proportion = flt(item.base_amount) / stock_items_amount if stock_items_amount \ + item_proportion = flt(item.base_net_amount) / stock_items_amount if stock_items_amount \ else flt(item.qty) / stock_items_qty if i == (last_stock_item_idx - 1): @@ -124,7 +124,7 @@ class BuyingController(StockController): landed_cost_voucher_amount = flt(item.landed_cost_voucher_amount) \ if self.doctype == "Purchase Receipt" else 0.0 - item.valuation_rate = ((item.base_amount + item.item_tax_amount + rm_supp_cost + item.valuation_rate = ((item.base_net_amount + item.item_tax_amount + rm_supp_cost + landed_cost_voucher_amount) / qty_in_stock_uom) else: item.valuation_rate = 0.0 diff --git a/erpnext/controllers/trends.py b/erpnext/controllers/trends.py index c2d5e0090c..dc7039ed60 100644 --- a/erpnext/controllers/trends.py +++ b/erpnext/controllers/trends.py @@ -132,9 +132,9 @@ def period_wise_columns_query(filters, trans): else: pwc = [_(filters.get("fiscal_year")) + " ("+_("Qty") + "):Float:120", _(filters.get("fiscal_year")) + " ("+ _("Amt") + "):Currency:120"] - query_details = " SUM(t2.qty), SUM(t2.base_amount)," + query_details = " SUM(t2.qty), SUM(t2.base_net_amount)," - query_details += 'SUM(t2.qty), SUM(t2.base_amount)' + query_details += 'SUM(t2.qty), SUM(t2.base_net_amount)' return pwc, query_details def get_period_wise_columns(bet_dates, period, pwc): @@ -147,7 +147,7 @@ def get_period_wise_columns(bet_dates, period, pwc): def get_period_wise_query(bet_dates, trans_date, query_details): query_details += """SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.qty, NULL)), - SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.base_amount, NULL)), + SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.base_net_amount, NULL)), """ % {"trans_date": trans_date, "sd": bet_dates[0],"ed": bet_dates[1]} return query_details diff --git a/erpnext/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.py b/erpnext/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.py index 538b7edd45..9146e42cf1 100644 --- a/erpnext/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.py +++ b/erpnext/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.py @@ -13,19 +13,19 @@ def execute(filters=None): data = [] for project in proj_details: - data.append([project.name, pr_item_map.get(project.name, 0), - se_item_map.get(project.name, 0), dn_item_map.get(project.name, 0), - project.project_name, project.status, project.company, - project.customer, project.project_value, project.project_start_date, + data.append([project.name, pr_item_map.get(project.name, 0), + se_item_map.get(project.name, 0), dn_item_map.get(project.name, 0), + project.project_name, project.status, project.company, + project.customer, project.project_value, project.project_start_date, project.completion_date]) - return columns, data + return columns, data def get_columns(): return [_("Project Id") + ":Link/Project:140", _("Cost of Purchased Items") + ":Currency:160", - _("Cost of Issued Items") + ":Currency:160", _("Cost of Delivered Items") + ":Currency:160", - _("Project Name") + "::120", _("Project Status") + "::120", _("Company") + ":Link/Company:100", - _("Customer") + ":Link/Customer:140", _("Project Value") + ":Currency:120", + _("Cost of Issued Items") + ":Currency:160", _("Cost of Delivered Items") + ":Currency:160", + _("Project Name") + "::120", _("Project Status") + "::120", _("Company") + ":Link/Company:100", + _("Customer") + ":Link/Customer:140", _("Project Value") + ":Currency:120", _("Project Start Date") + ":Date:120", _("Completion Date") + ":Date:120"] def get_project_details(): @@ -33,8 +33,8 @@ def get_project_details(): project_start_date, completion_date from tabProject where docstatus < 2""", as_dict=1) def get_purchased_items_cost(): - pr_items = frappe.db.sql("""select project_name, sum(base_amount) as amount - from `tabPurchase Receipt Item` where ifnull(project_name, '') != '' + pr_items = frappe.db.sql("""select project_name, sum(base_net_amount) as amount + from `tabPurchase Receipt Item` where ifnull(project_name, '') != '' and docstatus = 1 group by project_name""", as_dict=1) pr_item_map = {} @@ -46,7 +46,7 @@ def get_purchased_items_cost(): def get_issued_items_cost(): se_items = frappe.db.sql("""select se.project_name, sum(se_item.amount) as amount from `tabStock Entry` se, `tabStock Entry Detail` se_item - where se.name = se_item.parent and se.docstatus = 1 and ifnull(se_item.t_warehouse, '') = '' + where se.name = se_item.parent and se.docstatus = 1 and ifnull(se_item.t_warehouse, '') = '' and ifnull(se.project_name, '') != '' group by se.project_name""", as_dict=1) se_item_map = {} @@ -56,14 +56,14 @@ def get_issued_items_cost(): return se_item_map def get_delivered_items_cost(): - dn_items = frappe.db.sql("""select dn.project_name, sum(dn_item.base_amount) as amount + dn_items = frappe.db.sql("""select dn.project_name, sum(dn_item.base_net_amount) as amount from `tabDelivery Note` dn, `tabDelivery Note Item` dn_item where dn.name = dn_item.parent and dn.docstatus = 1 and ifnull(dn.project_name, '') != '' group by dn.project_name""", as_dict=1) - si_items = frappe.db.sql("""select si.project_name, sum(si_item.base_amount) as amount + si_items = frappe.db.sql("""select si.project_name, sum(si_item.base_net_amount) as amount from `tabSales Invoice` si, `tabSales Invoice Item` si_item - where si.name = si_item.parent and si.docstatus = 1 and ifnull(si.update_stock, 0) = 1 + where si.name = si_item.parent and si.docstatus = 1 and ifnull(si.update_stock, 0) = 1 and ifnull(si.is_pos, 0) = 1 and ifnull(si.project_name, '') != '' group by si.project_name""", as_dict=1) @@ -75,4 +75,4 @@ def get_delivered_items_cost(): for item in si_items: dn_item_map.setdefault(item.project_name, item.amount) - return dn_item_map \ No newline at end of file + return dn_item_map diff --git a/erpnext/public/js/feature_setup.js b/erpnext/public/js/feature_setup.js index bb831703c6..259c2cf315 100644 --- a/erpnext/public/js/feature_setup.js +++ b/erpnext/public/js/feature_setup.js @@ -111,34 +111,54 @@ erpnext.feature_setup.feature_dict = { 'Sales Order': {'items':['page_break']} }, 'fs_exports': { - 'Delivery Note': {'fields':['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total'],'items':['base_price_list_rate','base_amount','base_rate']}, + 'Delivery Note': { + 'fields': ['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total', + 'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'], + 'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount'] + }, 'POS Setting': {'fields':['conversion_rate','currency']}, - 'Quotation': {'fields':['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total'],'items':['base_price_list_rate','base_amount','base_rate']}, - 'Sales Invoice': {'fields':['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total'],'items':['base_price_list_rate','base_amount','base_rate']}, + 'Quotation': { + 'fields': ['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total', + 'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'], + 'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount'] + }, + 'Sales Invoice': { + 'fields': ['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total', + 'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'], + 'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount'] + }, 'Sales BOM': {'fields':['currency']}, - 'Sales Order': {'fields':['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total'],'items':['base_price_list_rate','base_amount','base_rate']} + 'Sales Order': { + 'fields': ['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total', + 'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'], + 'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount'] + } }, 'fs_imports': { 'Purchase Invoice': { - 'fields': ['conversion_rate', 'currency', 'base_grand_total', - 'base_in_words', 'base_net_total', 'base_taxes_and_charges_added', - 'base_taxes_and_charges_deducted'], - 'items': ['base_price_list_rate', 'base_amount','base_rate'] + 'fields': ['conversion_rate', 'currency', 'base_grand_total', 'base_discount_amount', + 'base_in_words', 'base_total', 'base_net_total', 'base_taxes_and_charges_added', + 'base_taxes_and_charges_deducted', 'base_total_taxes_and_charges'], + 'items': ['base_price_list_rate', 'base_amount','base_rate', 'base_net_rate', 'base_net_amount'] }, 'Purchase Order': { - 'fields': ['conversion_rate','currency', 'base_grand_total', - 'base_in_words', 'base_net_total', 'base_taxes_and_charges_added', - 'base_taxes_and_charges_deducted'], - 'items': ['base_price_list_rate', 'base_amount','base_rate'] + 'fields': ['conversion_rate','currency', 'base_grand_total', 'base_discount_amount', + 'base_in_words', 'base_total', 'base_net_total', 'base_taxes_and_charges_added', + 'base_taxes_and_charges_deducted', 'base_total_taxes_and_charges'], + 'items': ['base_price_list_rate', 'base_amount','base_rate', 'base_net_rate', 'base_net_amount'] }, 'Purchase Receipt': { - 'fields': ['conversion_rate', 'currency','base_grand_total', 'base_in_words', - 'base_net_total', 'base_taxes_and_charges_added', 'base_taxes_and_charges_deducted'], - 'items': ['base_price_list_rate','base_amount','base_rate'] + 'fields': ['conversion_rate', 'currency','base_grand_total', 'base_in_words', 'base_total', + 'base_net_total', 'base_taxes_and_charges_added', 'base_taxes_and_charges_deducted', + 'base_total_taxes_and_charges', 'base_discount_amount'], + 'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount'] }, 'Supplier Quotation': { - 'fields':['conversion_rate','currency'] + 'fields': ['conversion_rate', 'currency','base_grand_total', 'base_in_words', 'base_total', + 'base_net_total', 'base_taxes_and_charges_added', 'base_taxes_and_charges_deducted', + 'base_total_taxes_and_charges', 'base_discount_amount'], + 'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount'] } }, diff --git a/erpnext/selling/page/sales_analytics/sales_analytics.js b/erpnext/selling/page/sales_analytics/sales_analytics.js index bbe69d7c3e..197b6aca42 100644 --- a/erpnext/selling/page/sales_analytics/sales_analytics.js +++ b/erpnext/selling/page/sales_analytics/sales_analytics.js @@ -204,7 +204,7 @@ erpnext.SalesAnalytics = frappe.views.TreeGridReport.extend({ if (posting_date >= from_date && posting_date <= to_date) { var item = me.item_by_name[tl[me.tree_grid.item_key]] || me.item_by_name['Not Set']; - item[me.column_map[tl.posting_date].field] += (is_val ? tl.base_amount : tl.qty); + item[me.column_map[tl.posting_date].field] += (is_val ? tl.base_net_amount : tl.qty); } } }); diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py index 7471317b97..93dd74c460 100644 --- a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py +++ b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py @@ -82,7 +82,7 @@ def get_target_distribution_details(filters): def get_achieved_details(filters): start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:] - item_details = frappe.db.sql("""select soi.item_code, soi.qty, soi.base_amount, so.transaction_date, + item_details = frappe.db.sql("""select soi.item_code, soi.qty, soi.base_net_amount, so.transaction_date, st.sales_person, MONTHNAME(so.transaction_date) as month_name from `tabSales Order Item` soi, `tabSales Order` so, `tabSales Team` st where soi.parent=so.name and so.docstatus=1 and @@ -125,7 +125,7 @@ def get_salesperson_item_month_map(filters): if (filters["target_on"] == "Amount"): tav_dict.target = flt(sd.target_amount) * month_percentage / 100 if ad.month_name == month: - tav_dict.achieved += ad.base_amount + tav_dict.achieved += ad.base_net_amount return sim_map diff --git a/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py b/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py index c970431bec..8cac80c14c 100644 --- a/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py +++ b/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py @@ -16,7 +16,7 @@ def execute(filters=None): data.append([ d.name, d.customer, d.territory, d.posting_date, d.item_code, item_details.get(d.item_code, {}).get("item_group"), item_details.get(d.item_code, {}).get("brand"), - d.qty, d.base_amount, d.sales_person, d.allocated_percentage, d.contribution_amt + d.qty, d.base_net_amount, d.sales_person, d.allocated_percentage, d.contribution_amt ]) return columns, data @@ -36,8 +36,8 @@ def get_entries(filters): date_field = filters["doc_type"] == "Sales Order" and "transaction_date" or "posting_date" conditions, items = get_conditions(filters, date_field) entries = frappe.db.sql("""select dt.name, dt.customer, dt.territory, dt.%s as posting_date, - dt_item.item_code, dt_item.qty, dt_item.base_amount, st.sales_person, - st.allocated_percentage, dt_item.base_amount*st.allocated_percentage/100 as contribution_amt + dt_item.item_code, dt_item.qty, dt_item.base_net_amount, st.sales_person, + st.allocated_percentage, dt_item.base_net_amount*st.allocated_percentage/100 as contribution_amt from `tab%s` dt, `tab%s Item` dt_item, `tabSales Team` st where st.parent = dt.name and dt.name = dt_item.parent and st.parenttype = %s and dt.docstatus = 1 %s order by st.sales_person, dt.name desc""" % diff --git a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py b/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py index 6c3a2c30f1..4f19c73147 100644 --- a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py +++ b/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe import _, msgprint from frappe.utils import flt -import time from erpnext.accounts.utils import get_fiscal_year from erpnext.controllers.trends import get_period_date_ranges, get_period_month_ranges @@ -81,7 +80,7 @@ def get_target_distribution_details(filters): def get_achieved_details(filters): start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:] - item_details = frappe.db.sql("""select soi.item_code, soi.qty, soi.base_amount, so.transaction_date, + item_details = frappe.db.sql("""select soi.item_code, soi.qty, soi.base_net_amount, so.transaction_date, so.territory, MONTHNAME(so.transaction_date) as month_name from `tabSales Order Item` soi, `tabSales Order` so where soi.parent=so.name and so.docstatus=1 and so.transaction_date>=%s and @@ -125,7 +124,7 @@ def get_territory_item_month_map(filters): if (filters["target_on"] == "Amount"): tav_dict.target = flt(td.target_amount) * month_percentage / 100 if ad.month_name == month: - tav_dict.achieved += ad.base_amount + tav_dict.achieved += ad.base_net_amount return tim_map diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py index 7b836166c5..754eccbe44 100644 --- a/erpnext/shopping_cart/cart.py +++ b/erpnext/shopping_cart/cart.py @@ -141,7 +141,7 @@ def decorate_quotation_doc(quotation_doc): d["formatted_amount"] = fmt_money(d.get("amount"), currency=doc.currency) for d in doc.get("taxes", []): - d["formatted_tax_amount"] = fmt_money(flt(d.get("tax_amount")) / doc.conversion_rate, + d["formatted_tax_amount"] = fmt_money(flt(d.get("tax_amount_after_discount_amount")), currency=doc.currency) doc.formatted_grand_total_export = fmt_money(doc.grand_total, diff --git a/erpnext/startup/report_data_map.py b/erpnext/startup/report_data_map.py index b864cbc9e7..4bd0afe8f8 100644 --- a/erpnext/startup/report_data_map.py +++ b/erpnext/startup/report_data_map.py @@ -174,7 +174,7 @@ data_map = { } }, "Sales Invoice Item": { - "columns": ["name", "parent", "item_code", "qty", "base_amount"], + "columns": ["name", "parent", "item_code", "qty", "base_net_amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -192,7 +192,7 @@ data_map = { } }, "Sales Order Item[Sales Analytics]": { - "columns": ["name", "parent", "item_code", "qty", "base_amount"], + "columns": ["name", "parent", "item_code", "qty", "base_net_amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -210,7 +210,7 @@ data_map = { } }, "Delivery Note Item[Sales Analytics]": { - "columns": ["name", "parent", "item_code", "qty", "base_amount"], + "columns": ["name", "parent", "item_code", "qty", "base_net_amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -242,7 +242,7 @@ data_map = { } }, "Purchase Invoice Item": { - "columns": ["name", "parent", "item_code", "qty", "base_amount"], + "columns": ["name", "parent", "item_code", "qty", "base_net_amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -260,7 +260,7 @@ data_map = { } }, "Purchase Order Item[Purchase Analytics]": { - "columns": ["name", "parent", "item_code", "qty", "base_amount"], + "columns": ["name", "parent", "item_code", "qty", "base_net_amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -278,7 +278,7 @@ data_map = { } }, "Purchase Receipt Item[Purchase Analytics]": { - "columns": ["name", "parent", "item_code", "qty", "base_amount"], + "columns": ["name", "parent", "item_code", "qty", "base_net_amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index 9395e84fcf..2785cc13a2 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -295,7 +295,7 @@ class PurchaseReceipt(BuyingController): "cost_center": d.cost_center, "remarks": self.get("remarks") or _("Accounting Entry for Stock"), "debit": flt(flt(d.valuation_rate, val_rate_db_precision) * flt(d.qty) * flt(d.conversion_factor), - self.precision("base_amount", d)) + self.precision("base_net_amount", d)) })) # stock received but not billed @@ -304,7 +304,7 @@ class PurchaseReceipt(BuyingController): "against": warehouse_account[d.warehouse], "cost_center": d.cost_center, "remarks": self.get("remarks") or _("Accounting Entry for Stock"), - "credit": flt(d.base_amount, self.precision("base_amount", d)) + "credit": flt(d.base_net_amount, self.precision("base_net_amount", d)) })) negative_expense_to_be_booked += flt(d.item_tax_amount) @@ -332,12 +332,12 @@ class PurchaseReceipt(BuyingController): # divisional loss adjustment if not self.get("other_charges"): sle_valuation_amount = flt(flt(d.valuation_rate, val_rate_db_precision) * flt(d.qty) * flt(d.conversion_factor), - self.precision("base_amount", d)) + self.precision("base_net_amount", d)) - distributed_amount = flt(flt(d.base_amount, self.precision("base_amount", d))) + \ + distributed_amount = flt(flt(d.base_net_amount, self.precision("base_net_amount", d))) + \ flt(d.landed_cost_voucher_amount) + flt(d.rm_supp_cost) - divisional_loss = flt(distributed_amount - sle_valuation_amount, self.precision("base_amount", d)) + divisional_loss = flt(distributed_amount - sle_valuation_amount, self.precision("base_net_amount", d)) if divisional_loss: gl_entries.append(self.get_gl_dict({ "account": stock_rbnb, @@ -354,12 +354,12 @@ class PurchaseReceipt(BuyingController): # Cost center-wise amount breakup for other charges included for valuation valuation_tax = {} for tax in self.get("taxes"): - if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount): + if tax.category in ("Valuation", "Valuation and Total") and flt(tax.base_tax_amount_after_discount_amount): if not tax.cost_center: frappe.throw(_("Cost Center is required in row {0} in Taxes table for type {1}").format(tax.idx, _(tax.category))) valuation_tax.setdefault(tax.cost_center, 0) valuation_tax[tax.cost_center] += \ - (tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.tax_amount) + (tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.base_tax_amount_after_discount_amount) if negative_expense_to_be_booked and valuation_tax: # Backward compatibility: diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index d7ace2fe1d..44f60d7836 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -170,6 +170,8 @@ def get_basic_details(args, item): "base_rate": 0.0, "amount": 0.0, "base_amount": 0.0, + "net_rate": 0.0, + "net_amount": 0.0, "discount_percentage": 0.0 }) From 6dfbc2465b702ab4d98a09b7ba077a017fa73200 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Feb 2015 20:00:17 +0530 Subject: [PATCH 12/13] Patch: taxes and totals in party currency --- erpnext/patches.txt | 3 +- ...ds_in_custom_scripts_and_print_formats.py} | 9 ++- .../taxes_and_totals_in_party_currency.py | 66 +++++++++++++++++++ 3 files changed, 74 insertions(+), 4 deletions(-) rename erpnext/patches/v5_0/{replace_renamed_fields_in_custom_script_and_print_formats.py => replace_renamed_fields_in_custom_scripts_and_print_formats.py} (88%) create mode 100644 erpnext/patches/v5_0/taxes_and_totals_in_party_currency.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 05b92b1684..f6ac86007e 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -112,7 +112,6 @@ erpnext.patches.v5_0.remove_birthday_events erpnext.patches.v5_0.update_item_name_in_bom erpnext.patches.v5_0.rename_customer_issue erpnext.patches.v5_0.rename_total_fields -erpnext.patches.v5_0.replace_renamed_fields_in_custom_script_and_print_formats erpnext.patches.v5_0.new_crm_module erpnext.patches.v5_0.rename_customer_issue erpnext.patches.v5_0.update_material_transfer_for_manufacture @@ -124,3 +123,5 @@ erpnext.patches.v5_0.convert_stock_reconciliation erpnext.patches.v5_0.update_projects erpnext.patches.v5_0.item_patches erpnext.patches.v5_0.update_journal_entry_title +erpnext.patches.v5_0.taxes_and_totals_in_party_currency +erpnext.patches.v5_0.replace_renamed_fields_in_custom_scripts_and_print_formats diff --git a/erpnext/patches/v5_0/replace_renamed_fields_in_custom_script_and_print_formats.py b/erpnext/patches/v5_0/replace_renamed_fields_in_custom_scripts_and_print_formats.py similarity index 88% rename from erpnext/patches/v5_0/replace_renamed_fields_in_custom_script_and_print_formats.py rename to erpnext/patches/v5_0/replace_renamed_fields_in_custom_scripts_and_print_formats.py index f8775c12f3..7fe775b005 100644 --- a/erpnext/patches/v5_0/replace_renamed_fields_in_custom_script_and_print_formats.py +++ b/erpnext/patches/v5_0/replace_renamed_fields_in_custom_scripts_and_print_formats.py @@ -21,9 +21,10 @@ def get_all_renamed_fields(): from erpnext.patches.v5_0.rename_table_fieldnames import rename_map renamed_fields = ( + ("base_amount", "base_net_amount"), ("net_total", "base_net_total"), - ("net_total_export", "net_total"), - ("net_total_import", "net_total"), + ("net_total_export", "total"), + ("net_total_import", "total"), ("other_charges_total", "base_total_taxes_and_charges"), ("other_charges_total_export", "total_taxes_and_charges"), ("other_charges_added", "base_taxes_and_charges_added"), @@ -39,7 +40,9 @@ def get_all_renamed_fields(): ("rounded_total_import", "rounded_total"), ("in_words", "base_in_words"), ("in_words_export", "in_words"), - ("in_words_import", "in_words") + ("in_words_import", "in_words"), + ("tax_amount", "base_tax_amount"), + ("tax_amount_after_discount_amount", "base_tax_amount_after_discount_amount"), ) for fields in rename_map.values(): diff --git a/erpnext/patches/v5_0/taxes_and_totals_in_party_currency.py b/erpnext/patches/v5_0/taxes_and_totals_in_party_currency.py new file mode 100644 index 0000000000..b588971407 --- /dev/null +++ b/erpnext/patches/v5_0/taxes_and_totals_in_party_currency.py @@ -0,0 +1,66 @@ + +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +import frappe + +def execute(): + selling_doctypes = ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"] + buying_doctypes = ["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"] + + for dt in selling_doctypes: + update_values(dt, "Sales Taxes and Charges") + + for dt in buying_doctypes: + update_values(dt, "Purchase Taxes and Charges") + +def update_values(dt, tax_table): + frappe.reload_doctype(dt) + frappe.reload_doctype(dt + " Item") + frappe.reload_doctype(tax_table) + + # update net_total, discount_on + frappe.db.sql(""" + UPDATE + `tab{0}` + SET + total = net_total, + base_total = net_total*conversion_rate, + net_total = base_net_total / conversion_rate, + apply_discount_on = "Grand Total" + WHERE + docstatus < 2 + """.format(dt)) + + + # update net_amount + frappe.db.sql(""" + UPDATE + `tab{0}` par, `tab{1}` item + SET + item.base_net_amount = item.base_amount, + item.base_net_rate = item.base_rate, + item.net_amount = item.base_net_amount / par.conversion_rate, + item.net_rate = item.base_net_rate / par.conversion_rate, + item.base_amount = item.amount * par.conversion_rate, + item.base_rate = item.rate * par.conversion_rate + WHERE + par.name = item.parent + and par.docstatus < 2 + """.format(dt, dt + " Item")) + + # update tax in party currency + frappe.db.sql(""" + UPDATE + `tab{0}` par, `tab{1}` tax + SET + tax.base_tax_amount = tax.tax_amount, + tax.tax_amount = tax.base_tax_amount / par.conversion_rate, + tax.base_total = tax.total, + tax.total = tax.base_total / conversion_rate, + tax.base_tax_amount_after_discount_amount = tax.tax_amount_after_discount_amount, + tax.tax_amount_after_discount_amount = tax.base_tax_amount_after_discount_amount / conversion_rate + WHERE + par.name = tax.parent + and par.docstatus < 2 + """.format(dt, tax_table)) From 7b19b9ed02e1cbb0b5e7d217544229daa68b9ae3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 24 Feb 2015 09:42:24 +0530 Subject: [PATCH 13/13] minor fixes --- erpnext/controllers/taxes_and_totals.py | 4 ++-- erpnext/selling/sales_common.js | 4 ---- erpnext/stock/doctype/purchase_receipt/purchase_receipt.py | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 24ca3c6922..c786d2ab20 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -356,8 +356,8 @@ class calculate_taxes_and_totals(object): return flt(self.doc.grand_total - sum(actual_taxes_dict.values()), self.doc.precision("grand_total")) - def calculate_total_advance(self, parenttype, advance_parentfield): - if self.docstatus < 2: + def calculate_total_advance(self): + if self.doc.docstatus < 2: total_allocated_amount = sum([flt(adv.allocated_amount, adv.precision("allocated_amount")) for adv in self.doc.get("advances")]) diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index f73b7970c6..85f4f73baf 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -17,10 +17,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ this.toggle_editable_price_list_rate(); }, - onload_post_render: function() { - cur_frm.get_field("items").grid.set_multiple_add("item_code", "qty"); - }, - setup_queries: function() { var me = this; diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index 2785cc13a2..48fbb15fca 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -330,7 +330,7 @@ class PurchaseReceipt(BuyingController): })) # divisional loss adjustment - if not self.get("other_charges"): + if not self.get("taxes"): sle_valuation_amount = flt(flt(d.valuation_rate, val_rate_db_precision) * flt(d.qty) * flt(d.conversion_factor), self.precision("base_net_amount", d))