From 1eb560130a0df27d2725e3de5512d956d945b1f3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 10 Feb 2014 19:20:15 +0530 Subject: [PATCH] Rename fields: amount related fields --- .../purchase_invoice/purchase_invoice.py | 14 +++++----- .../purchase_invoice/test_purchase_invoice.py | 8 +++--- erpnext/accounts/doctype/sales_invoice/pos.js | 8 +++--- .../doctype/sales_invoice/sales_invoice.py | 14 +++++----- .../sales_invoice/test_sales_invoice.py | 28 +++++++++---------- .../report/gross_profit/gross_profit.py | 8 +++--- .../item_wise_purchase_register.py | 6 ++-- .../item_wise_sales_register.py | 6 ++-- .../purchase_register/purchase_register.py | 2 +- .../report/sales_register/sales_register.py | 2 +- .../purchase_common/purchase_common.js | 14 +++++----- .../doctype/purchase_order/purchase_order.py | 12 ++++---- .../purchase_order/test_purchase_order.py | 2 +- .../test_supplier_quotation.py | 2 +- erpnext/controllers/accounts_controller.py | 6 ++-- erpnext/controllers/buying_controller.py | 16 +++++------ erpnext/controllers/selling_controller.py | 20 ++++++------- .../project_wise_stock_tracking.py | 6 ++-- erpnext/public/js/feature_setup.js | 14 +++++----- erpnext/public/js/transaction.js | 6 ++-- .../doctype/quotation/test_quotation.py | 2 +- .../doctype/sales_order/sales_order.py | 12 ++++---- .../doctype/sales_order/test_sales_order.py | 2 +- ..._person_target_variance_item_group_wise.py | 4 +-- .../sales_person_wise_transaction_summary.py | 4 +-- ...rritory_target_variance_item_group_wise.py | 4 +-- erpnext/selling/sales_common.js | 26 ++++++++--------- erpnext/startup/report_data_map.py | 12 ++++---- .../doctype/delivery_note/delivery_note.js | 6 ++-- .../doctype/delivery_note/delivery_note.py | 2 +- .../delivery_note/test_delivery_note.py | 6 ++-- .../purchase_receipt/test_purchase_receipt.py | 6 ++-- 32 files changed, 140 insertions(+), 140 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index c702c92c2f..ab7b5b1094 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -27,8 +27,8 @@ class DocType(BuyingController): 'target_field': 'billed_amt', 'target_parent_dt': 'Purchase Order', 'target_parent_field': 'per_billed', - 'target_ref_field': 'import_amount', - 'source_field': 'import_amount', + 'target_ref_field': 'amount', + 'source_field': 'amount', 'percent_join_field': 'purchase_order', }] @@ -54,7 +54,7 @@ class DocType(BuyingController): self.validate_write_off_account() self.update_raw_material_cost() self.update_valuation_rate("entries") - self.validate_multiple_billing("Purchase Receipt", "pr_detail", "import_amount", + self.validate_multiple_billing("Purchase Receipt", "pr_detail", "amount", "purchase_receipt_details") def set_missing_values(self, for_validate=False): @@ -342,8 +342,8 @@ class DocType(BuyingController): # expense will be booked in sales invoice stock_item_and_auto_accounting_for_stock = True - valuation_amt = flt(item.amount + item.item_tax_amount + item.rm_supp_cost, - self.precision("amount", item)) + valuation_amt = flt(item.base_amount + item.item_tax_amount + item.rm_supp_cost, + self.precision("base_amount", item)) gl_entries.append( self.get_gl_dict({ @@ -354,13 +354,13 @@ class DocType(BuyingController): }) ) - elif flt(item.amount): + elif flt(item.base_amount): # if not a stock item or auto inventory accounting disabled, book the expense gl_entries.append( self.get_gl_dict({ "account": item.expense_account, "against": self.doc.credit_to, - "debit": item.amount, + "debit": item.base_amount, "remarks": self.doc.remarks, "cost_center": item.cost_center }) diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index 0c6ac44166..ed5d1b5cbb 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -230,9 +230,9 @@ test_records = [ "item_name": "_Test Item Home Desktop 100", "qty": 10, "rate": 50, - "import_amount": 500, - "base_rate": 50, "amount": 500, + "base_rate": 50, + "base_amount": 500, "uom": "_Test UOM", "item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}), "expense_account": "_Test Account Cost for Goods Sold - _TC", @@ -247,9 +247,9 @@ test_records = [ "item_name": "_Test Item Home Desktop 200", "qty": 5, "rate": 150, - "import_amount": 750, - "base_rate": 150, "amount": 750, + "base_rate": 150, + "base_amount": 750, "uom": "_Test UOM", "expense_account": "_Test Account Cost for Goods Sold - _TC", "cost_center": "_Test Cost Center - _TC", diff --git a/erpnext/accounts/doctype/sales_invoice/pos.js b/erpnext/accounts/doctype/sales_invoice/pos.js index 1a4d018f3d..673b35b789 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.js +++ b/erpnext/accounts/doctype/sales_invoice/pos.js @@ -131,8 +131,8 @@ erpnext.POS = Class.extend({ this.sales_or_purchase = (party == "Customer" ? "Sales" : "Purchase"); this.net_total = "net_total_" + export_or_import; this.grand_total = "grand_total_" + export_or_import; - this.amount = export_or_import + "_amount"; - this.rate = export_or_import + "_rate"; + // this.amount = export_or_import + "_amount"; + // this.rate = export_or_import + "_rate"; }, call_function: function(class_name, fn, event_name) { this.wrapper.find("." + class_name).on(event_name || "click", fn); @@ -401,8 +401,8 @@ erpnext.POS = Class.extend({ item_code: d.item_code, item_name: d.item_name===d.item_code ? "" : ("
" + d.item_name), qty: d.qty, - rate: format_currency(d[me.rate], me.frm.doc.currency), - amount: format_currency(d[me.amount], me.frm.doc.currency) + rate: format_currency(d.rate, me.frm.doc.currency), + amount: format_currency(d.amount, me.frm.doc.currency) } )).appendTo($items); }); diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 7dd1a6ade3..209aa60476 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -29,12 +29,12 @@ class DocType(SellingController): self.status_updater = [{ 'source_dt': 'Sales Invoice Item', 'target_field': 'billed_amt', - 'target_ref_field': 'export_amount', + 'target_ref_field': 'amount', 'target_dt': 'Sales Order Item', 'join_field': 'so_detail', 'target_parent_dt': 'Sales Order', 'target_parent_field': 'per_billed', - 'source_field': 'export_amount', + 'source_field': 'amount', 'join_field': 'so_detail', 'percent_join_field': 'sales_order', 'status_field': 'billing_status', @@ -73,7 +73,7 @@ class DocType(SellingController): self.validate_c_form() self.validate_time_logs_are_submitted() self.validate_recurring_invoice() - self.validate_multiple_billing("Delivery Note", "dn_detail", "export_amount", + self.validate_multiple_billing("Delivery Note", "dn_detail", "amount", "delivery_note_details") def on_submit(self): @@ -522,12 +522,12 @@ class DocType(SellingController): def make_item_gl_entries(self, gl_entries): # income account gl entries for item in self.doclist.get({"parentfield": "entries"}): - if flt(item.amount): + if flt(item.base_amount): gl_entries.append( self.get_gl_dict({ "account": item.income_account, "against": self.doc.debit_to, - "credit": item.amount, + "credit": item.base_amount, "remarks": self.doc.remarks, "cost_center": item.cost_center }) @@ -805,9 +805,9 @@ def make_delivery_note(source_name, target_doclist=None): bean.run_method("onload_post_render") def update_item(source_doc, target_doc, source_parent): - target_doc.amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \ + target_doc.base_amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \ flt(source_doc.base_rate) - target_doc.export_amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \ + target_doc.amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \ flt(source_doc.rate) target_doc.qty = flt(source_doc.qty) - flt(source_doc.delivered_qty) diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index d1d87efd76..d2aac03ea5 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -47,8 +47,8 @@ class TestSalesInvoice(unittest.TestCase): si.insert() expected_values = { - "keys": ["price_list_rate", "discount_percentage", "rate", "export_amount", - "base_price_list_rate", "base_rate", "amount"], + "keys": ["price_list_rate", "discount_percentage", "rate", "amount", + "base_price_list_rate", "base_rate", "base_amount"], "_Test Item Home Desktop 100": [50, 0, 50, 500, 50, 50, 500], "_Test Item Home Desktop 200": [150, 0, 150, 750, 150, 150, 750], } @@ -97,8 +97,8 @@ class TestSalesInvoice(unittest.TestCase): si.insert() expected_values = { - "keys": ["price_list_rate", "discount_percentage", "rate", "export_amount", - "base_price_list_rate", "base_rate", "amount"], + "keys": ["price_list_rate", "discount_percentage", "rate", "amount", + "base_price_list_rate", "base_rate", "base_amount"], "_Test Item Home Desktop 100": [1, 0, 1, 10, 50, 50, 500], "_Test Item Home Desktop 200": [3, 0, 3, 15, 150, 150, 750], } @@ -153,8 +153,8 @@ class TestSalesInvoice(unittest.TestCase): si.insert() expected_values = { - "keys": ["price_list_rate", "discount_percentage", "rate", "export_amount", - "base_price_list_rate", "base_rate", "amount"], + "keys": ["price_list_rate", "discount_percentage", "rate", "amount", + "base_price_list_rate", "base_rate", "base_amount"], "_Test Item Home Desktop 100": [62.5, 0, 62.5, 625.0, 50, 50, 465.37], "_Test Item Home Desktop 200": [190.66, 0, 190.66, 953.3, 150, 150, 698.08], } @@ -266,8 +266,8 @@ class TestSalesInvoice(unittest.TestCase): si.insert() expected_values = { - "keys": ["price_list_rate", "discount_percentage", "rate", "export_amount", - "base_price_list_rate", "base_rate", "amount"], + "keys": ["price_list_rate", "discount_percentage", "rate", "amount", + "base_price_list_rate", "base_rate", "base_amount"], "_Test Item Home Desktop 100": [62.5, 0, 62.5, 625.0, 50, 50, 499.98], "_Test Item Home Desktop 200": [190.66, 0, 190.66, 953.3, 150, 150, 750], } @@ -319,8 +319,8 @@ class TestSalesInvoice(unittest.TestCase): si.insert() expected_values = { - "keys": ["price_list_rate", "discount_percentage", "rate", "export_amount", - "base_price_list_rate", "base_rate", "amount"], + "keys": ["price_list_rate", "discount_percentage", "rate", "amount", + "base_price_list_rate", "base_rate", "base_amount"], "_Test Item Home Desktop 100": [55.56, 10, 50, 500, 2222.11, 1999.9, 19999.04], "_Test Item Home Desktop 200": [187.5, 20, 150, 750, 7375.66, 5900.53, 29502.66], } @@ -889,11 +889,11 @@ test_records = [ "territory": "_Test Territory" }, { - "amount": 500.0, + "base_amount": 500.0, "base_rate": 500.0, "description": "138-CMS Shoe", "doctype": "Sales Invoice Item", - "export_amount": 500.0, + "amount": 500.0, "rate": 500.0, "income_account": "Sales - _TC", "cost_center": "_Test Cost Center - _TC", @@ -960,9 +960,9 @@ test_records = [ "parentfield": "entries", "qty": 1.0, "base_rate": 500.0, - "amount": 500.0, + "base_amount": 500.0, "price_list_rate": 500.0, - "export_amount": 500.0, + "amount": 500.0, "income_account": "Sales - _TC", "expense_account": "_Test Account Cost for Goods Sold - _TC", "cost_center": "_Test Cost Center - _TC", diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index f36255f628..800f0b9077 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -20,7 +20,7 @@ def execute(filters=None): "Gross Profit:Currency", "Gross Profit %:Percent", "Project:Link/Project"] data = [] for row in source: - selling_amount = flt(row.amount) + selling_amount = flt(row.base_amount) item_sales_bom_map = item_sales_bom.get(row.parenttype, {}).get(row.name, webnotes._dict()) @@ -43,7 +43,7 @@ def execute(filters=None): % ("/".join(["#Form", row.parenttype, row.name]),) data.append([row.name, icon, row.posting_date, row.posting_time, row.item_code, row.item_name, row.description, row.warehouse, row.qty, row.base_rate, - row.qty and (buying_amount / row.qty) or 0, row.amount, buying_amount, + row.qty and (buying_amount / row.qty) or 0, row.base_amount, buying_amount, gross_profit, gross_profit_percent, row.project]) return columns, data @@ -93,7 +93,7 @@ def get_source_data(filters): delivery_note_items = webnotes.conn.sql("""select item.parenttype, dn.name, dn.posting_date, dn.posting_time, dn.project_name, item.item_code, item.item_name, item.description, item.warehouse, - item.qty, item.base_rate, item.amount, item.name as "item_row", + item.qty, item.base_rate, item.base_amount, item.name as "item_row", timestamp(dn.posting_date, dn.posting_time) as posting_datetime from `tabDelivery Note` dn, `tabDelivery Note Item` item where item.parent = dn.name and dn.docstatus = 1 %s @@ -102,7 +102,7 @@ def get_source_data(filters): sales_invoice_items = webnotes.conn.sql("""select item.parenttype, si.name, si.posting_date, si.posting_time, si.project_name, item.item_code, item.item_name, item.description, item.warehouse, - item.qty, item.base_rate, item.amount, item.name as "item_row", + item.qty, item.base_rate, item.base_amount, item.name as "item_row", timestamp(si.posting_date, si.posting_time) as posting_datetime from `tabSales Invoice` si, `tabSales Invoice Item` item where item.parent = si.name and si.docstatus = 1 %s 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 22e2cafd03..d70e28e6ff 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 @@ -20,12 +20,12 @@ 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_name, d.credit_to, d.project_name, d.company, d.purchase_order, - d.purchase_receipt, expense_account, d.qty, d.base_rate, d.amount] + d.purchase_receipt, expense_account, d.qty, d.base_rate, d.base_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.amount + total_tax] + row += [total_tax, d.base_amount + total_tax] data.append(row) @@ -60,7 +60,7 @@ def get_items(filters): return webnotes.conn.sql("""select pi_item.parent, pi.posting_date, pi.credit_to, pi.company, pi.supplier, pi.remarks, 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.expense_account, pi_item.qty, pi_item.base_rate, pi_item.amount, pi.supplier_name + pi_item.expense_account, pi_item.qty, pi_item.base_rate, pi_item.base_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) 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 b8f2f4db04..0eb6761649 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 @@ -18,13 +18,13 @@ def execute(filters=None): for d in item_list: row = [d.item_code, d.item_name, d.item_group, d.parent, d.posting_date, d.customer_name, d.debit_to, d.territory, d.project_name, d.company, d.sales_order, - d.delivery_note, d.income_account, d.qty, d.base_rate, d.amount] + d.delivery_note, d.income_account, d.qty, d.base_rate, d.base_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.amount + total_tax] + row += [total_tax, d.base_amount + total_tax] data.append(row) @@ -58,7 +58,7 @@ def get_items(filters): return webnotes.conn.sql("""select si_item.parent, si.posting_date, si.debit_to, si.project_name, si.customer, si.remarks, si.territory, si.company, 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.amount, si.customer_name + si_item.qty, si_item.base_rate, si_item.base_amount, si.customer_name from `tabSales Invoice` si, `tabSales Invoice Item` si_item where si.name = si_item.parent and si.docstatus = 1 %s order by si.posting_date desc, si_item.item_code desc""" % conditions, filters, as_dict=1) diff --git a/erpnext/accounts/report/purchase_register/purchase_register.py b/erpnext/accounts/report/purchase_register/purchase_register.py index d191cbafee..a3f42dae20 100644 --- a/erpnext/accounts/report/purchase_register/purchase_register.py +++ b/erpnext/accounts/report/purchase_register/purchase_register.py @@ -116,7 +116,7 @@ def get_invoices(filters): def get_invoice_expense_map(invoice_list): - expense_details = webnotes.conn.sql("""select parent, expense_account, sum(amount) as amount + expense_details = webnotes.conn.sql("""select parent, expense_account, sum(base_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) diff --git a/erpnext/accounts/report/sales_register/sales_register.py b/erpnext/accounts/report/sales_register/sales_register.py index 8fab6a9d97..4ed1cdd274 100644 --- a/erpnext/accounts/report/sales_register/sales_register.py +++ b/erpnext/accounts/report/sales_register/sales_register.py @@ -114,7 +114,7 @@ def get_invoices(filters): conditions, filters, as_dict=1) def get_invoice_income_map(invoice_list): - income_details = webnotes.conn.sql("""select parent, income_account, sum(amount) as amount + income_details = webnotes.conn.sql("""select parent, income_account, sum(base_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) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index c5456c3983..6f72e73c8f 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -221,12 +221,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ $.each(this.frm.item_doclist, function(i, item) { wn.model.round_floats_in(item); - item.import_amount = flt(item.rate * item.qty, precision("import_amount", item)); + item.amount = flt(item.rate * item.qty, precision("amount", item)); item.item_tax_amount = 0.0; me._set_in_company_currency(item, "price_list_rate", "base_price_list_rate"); me._set_in_company_currency(item, "rate", "base_rate"); - me._set_in_company_currency(item, "import_amount", "amount"); + me._set_in_company_currency(item, "amount", "base_amount"); }); }, @@ -236,8 +236,8 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ this.frm.doc.net_total = this.frm.doc.net_total_import = 0.0; $.each(this.frm.item_doclist, function(i, item) { - me.frm.doc.net_total += item.amount; - me.frm.doc.net_total_import += item.import_amount; + me.frm.doc.net_total += item.base_amount; + me.frm.doc.net_total_import += item.amount; }); wn.model.round_floats_in(this.frm.doc, ["net_total", "net_total_import"]); @@ -391,10 +391,10 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ }); }; - setup_field_label_map(["base_rate", "base_price_list_rate", "amount", "base_rate"], + setup_field_label_map(["base_rate", "base_price_list_rate", "base_amount", "base_rate"], company_currency, this.fname); - setup_field_label_map(["rate", "price_list_rate", "import_amount"], + setup_field_label_map(["rate", "price_list_rate", "amount"], this.frm.doc.currency, this.fname); if(this.frm.fields_dict[this.other_fname]) { @@ -408,7 +408,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ // toggle columns var item_grid = this.frm.fields_dict[this.fname].grid; - var fieldnames = $.map(["base_rate", "base_price_list_rate", "amount", "base_rate"], function(fname) { + var fieldnames = $.map(["base_rate", "base_price_list_rate", "base_amount", "base_rate"], function(fname) { return wn.meta.get_docfield(item_grid.doctype, fname, me.frm.docname) ? fname : null; }); diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index bbdf21e17f..b35b388547 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -190,8 +190,8 @@ def make_purchase_receipt(source_name, target_doclist=None): def update_item(obj, target, source_parent): target.qty = flt(obj.qty) - flt(obj.received_qty) target.stock_qty = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.conversion_factor) - target.import_amount = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.rate) - target.amount = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.base_rate) + target.amount = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.rate) + target.base_amount = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.base_rate) doclist = get_mapped_doclist("Purchase Order", source_name, { "Purchase Order": { @@ -227,10 +227,10 @@ def make_purchase_invoice(source_name, target_doclist=None): bean.run_method("set_missing_values") def update_item(obj, target, source_parent): - target.import_amount = flt(obj.import_amount) - flt(obj.billed_amt) - target.amount = target.import_amount * flt(source_parent.conversion_rate) + target.amount = flt(obj.amount) - flt(obj.billed_amt) + target.base_amount = target.amount * flt(source_parent.conversion_rate) if flt(obj.base_rate): - target.qty = target.amount / flt(obj.base_rate) + target.qty = target.base_amount / flt(obj.base_rate) doclist = get_mapped_doclist("Purchase Order", source_name, { "Purchase Order": { @@ -246,7 +246,7 @@ def make_purchase_invoice(source_name, target_doclist=None): "parent": "purchase_order", }, "postprocess": update_item, - "condition": lambda doc: doc.amount==0 or doc.billed_amt < doc.import_amount + "condition": lambda doc: doc.base_amount==0 or doc.billed_amt < doc.amount }, "Purchase Taxes and Charges": { "doctype": "Purchase Taxes and Charges", diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py index 1412ce182e..8e47e577b7 100644 --- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py @@ -139,7 +139,7 @@ test_records = [ "parentfield": "po_details", "qty": 10.0, "rate": 500.0, - "amount": 5000.0, + "base_amount": 5000.0, "warehouse": "_Test Warehouse - _TC", "stock_uom": "_Test UOM", "uom": "_Test UOM", diff --git a/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py index 7aed5def1b..d0edff4861 100644 --- a/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py @@ -56,7 +56,7 @@ test_records = [ "parentfield": "quotation_items", "qty": 10.0, "rate": 500.0, - "amount": 5000.0, + "base_amount": 5000.0, "warehouse": "_Test Warehouse - _TC", "uom": "_Test UOM", } diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index bdbf8c6b51..3cc100ae0e 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -276,7 +276,7 @@ class AccountsController(TransactionBase): # 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.amount + current_tax_amount, + tax.grand_total_for_current_item = flt(item.base_amount + current_tax_amount, self.precision("total", tax)) else: tax.grand_total_for_current_item = \ @@ -314,10 +314,10 @@ class AccountsController(TransactionBase): # distribute the tax amount proportionally to each item row actual = flt(tax.rate, self.precision("tax_amount", tax)) current_tax_amount = (self.doc.net_total - and ((item.amount / self.doc.net_total) * actual) + and ((item.base_amount / self.doc.net_total) * actual) or 0) elif tax.charge_type == "On Net Total": - current_tax_amount = (tax_rate / 100.0) * item.amount + current_tax_amount = (tax_rate / 100.0) * item.base_amount elif tax.charge_type == "On Previous Row Amount": current_tax_amount = (tax_rate / 100.0) * \ self.tax_doclist[cint(tax.row_id) - 1].tax_amount_for_current_item diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 119ac2863c..2563e609fd 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -88,11 +88,11 @@ class BuyingController(StockController): item.rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)), self.precision("rate", item)) - item.import_amount = flt(item.rate * item.qty, - self.precision("import_amount", item)) + item.amount = flt(item.rate * item.qty, + self.precision("amount", item)) item.item_tax_amount = 0.0; - self._set_in_company_currency(item, "import_amount", "amount") + self._set_in_company_currency(item, "amount", "base_amount") self._set_in_company_currency(item, "price_list_rate", "base_price_list_rate") self._set_in_company_currency(item, "rate", "base_rate") @@ -101,8 +101,8 @@ class BuyingController(StockController): self.doc.net_total = self.doc.net_total_import = 0.0 for item in self.item_doclist: - self.doc.net_total += item.amount - self.doc.net_total_import += item.import_amount + self.doc.net_total += item.base_amount + self.doc.net_total_import += item.amount self.round_floats_in(self.doc, ["net_total", "net_total_import"]) @@ -175,7 +175,7 @@ class BuyingController(StockController): for d in self.doclist.get({"parentfield": parentfield}): if d.item_code and d.item_code in stock_items: stock_items_qty += flt(d.qty) - stock_items_amount += flt(d.amount) + stock_items_amount += flt(d.base_amount) last_stock_item_idx = d.idx total_valuation_amount = sum([flt(d.tax_amount) for d in @@ -186,7 +186,7 @@ class BuyingController(StockController): valuation_amount_adjustment = total_valuation_amount for i, item in enumerate(self.doclist.get({"parentfield": parentfield})): if item.item_code and item.qty and item.item_code in stock_items: - item_proportion = flt(item.amount) / stock_items_amount if stock_items_amount \ + item_proportion = flt(item.base_amount) / stock_items_amount if stock_items_amount \ else flt(item.qty) / stock_items_qty if i == (last_stock_item_idx - 1): @@ -203,7 +203,7 @@ class BuyingController(StockController): "UOM Conversion Detail", {"parent": item.item_code, "uom": item.uom}, "conversion_factor")) or 1 qty_in_stock_uom = flt(item.qty * item.conversion_factor) - item.valuation_rate = ((item.amount + item.item_tax_amount + item.rm_supp_cost) + item.valuation_rate = ((item.base_amount + item.item_tax_amount + item.rm_supp_cost) / qty_in_stock_uom) else: item.valuation_rate = 0.0 diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index eb7ad316fe..174dc28237 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -112,10 +112,10 @@ class SellingController(StockController): cumulated_tax_fraction += tax.tax_fraction_for_current_item if cumulated_tax_fraction and not self.discount_amount_applied: - item.amount = flt((item.export_amount * self.doc.conversion_rate) / - (1 + cumulated_tax_fraction), self.precision("amount", item)) + item.base_amount = flt((item.amount * self.doc.conversion_rate) / + (1 + cumulated_tax_fraction), self.precision("base_amount", item)) - item.base_rate = flt(item.amount / item.qty, self.precision("base_rate", item)) + item.base_rate = flt(item.base_amount / item.qty, self.precision("base_rate", item)) if item.discount_percentage == 100: item.base_price_list_rate = item.base_rate @@ -158,19 +158,19 @@ class SellingController(StockController): item.rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)), self.precision("rate", item)) - item.export_amount = flt(item.rate * item.qty, - self.precision("export_amount", item)) + item.amount = flt(item.rate * item.qty, + self.precision("amount", item)) 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, "export_amount", "amount") + self._set_in_company_currency(item, "amount", "base_amount") def calculate_net_total(self): self.doc.net_total = self.doc.net_total_export = 0.0 for item in self.item_doclist: - self.doc.net_total += item.amount - self.doc.net_total_export += item.export_amount + self.doc.net_total += item.base_amount + self.doc.net_total_export += item.amount self.round_floats_in(self.doc, ["net_total", "net_total_export"]) @@ -197,8 +197,8 @@ class SellingController(StockController): if grand_total_for_discount_amount: # calculate item amount after Discount Amount for item in self.item_doclist: - distributed_amount = flt(self.doc.discount_amount) * item.amount / grand_total_for_discount_amount - item.amount = flt(item.amount - distributed_amount, self.precision("amount", item)) + distributed_amount = flt(self.doc.discount_amount) * item.base_amount / grand_total_for_discount_amount + item.base_amount = flt(item.base_amount - distributed_amount, self.precision("base_amount", item)) self.discount_amount_applied = True self._calculate_taxes_and_totals() 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 e4b11fcf3c..d21bf3d821 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 @@ -32,7 +32,7 @@ def get_project_details(): project_start_date, completion_date from tabProject where docstatus < 2""", as_dict=1) def get_purchased_items_cost(): - pr_items = webnotes.conn.sql("""select project_name, sum(amount) as amount + pr_items = webnotes.conn.sql("""select project_name, sum(base_amount) as amount from `tabPurchase Receipt Item` where ifnull(project_name, '') != '' and docstatus = 1 group by project_name""", as_dict=1) @@ -55,12 +55,12 @@ def get_issued_items_cost(): return se_item_map def get_delivered_items_cost(): - dn_items = webnotes.conn.sql("""select dn.project_name, sum(dn_item.amount) as amount + dn_items = webnotes.conn.sql("""select dn.project_name, sum(dn_item.base_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 = webnotes.conn.sql("""select si.project_name, sum(si_item.amount) as amount + si_items = webnotes.conn.sql("""select si.project_name, sum(si_item.base_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 and ifnull(si.is_pos, 0) = 1 and ifnull(si.project_name, '') != '' diff --git a/erpnext/public/js/feature_setup.js b/erpnext/public/js/feature_setup.js index 6a58173b4b..f3545d131f 100644 --- a/erpnext/public/js/feature_setup.js +++ b/erpnext/public/js/feature_setup.js @@ -114,12 +114,12 @@ pscript.feature_dict = { 'Sales Order': {'sales_order_details':['page_break']} }, 'fs_exports': { - 'Delivery Note': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'delivery_note_details':['base_price_list_rate','amount','base_rate']}, + 'Delivery Note': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'delivery_note_details':['base_price_list_rate','base_amount','base_rate']}, 'POS Setting': {'fields':['conversion_rate','currency']}, - 'Quotation': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'quotation_details':['base_price_list_rate','amount','base_rate']}, - 'Sales Invoice': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'entries':['base_price_list_rate','amount','base_rate']}, + 'Quotation': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'quotation_details':['base_price_list_rate','base_amount','base_rate']}, + 'Sales Invoice': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'entries':['base_price_list_rate','base_amount','base_rate']}, 'Sales BOM': {'fields':['currency']}, - 'Sales Order': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'sales_order_details':['base_price_list_rate','amount','base_rate']} + 'Sales Order': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'sales_order_details':['base_price_list_rate','base_amount','base_rate']} }, 'fs_imports': { @@ -127,18 +127,18 @@ pscript.feature_dict = { 'fields': ['conversion_rate', 'currency', 'grand_total', 'in_words', 'net_total', 'other_charges_added', 'other_charges_deducted'], - 'entries': ['base_price_list_rate', 'amount','rate'] + 'entries': ['base_price_list_rate', 'base_amount','base_rate'] }, 'Purchase Order': { 'fields': ['conversion_rate','currency', 'grand_total', 'in_words', 'net_total', 'other_charges_added', 'other_charges_deducted'], - 'po_details': ['base_price_list_rate', 'amount','base_rate'] + 'po_details': ['base_price_list_rate', 'base_amount','base_rate'] }, 'Purchase Receipt': { 'fields': ['conversion_rate', 'currency','grand_total', 'in_words', 'net_total', 'other_charges_added', 'other_charges_deducted'], - 'purchase_receipt_details': ['base_price_list_rate','amount','base_rate'] + 'purchase_receipt_details': ['base_price_list_rate','base_amount','base_rate'] }, 'Supplier Quotation': { 'fields':['conversion_rate','currency'] diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index 24fc332202..6d570e49e9 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -599,7 +599,7 @@ erpnext.TransactionController = 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.amount + current_tax_amount, + tax.grand_total_for_current_item = flt(item.base_amount + current_tax_amount, precision("total", tax)); } else { tax.grand_total_for_current_item = @@ -644,11 +644,11 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ // distribute the tax amount proportionally to each item row var actual = flt(tax.rate, precision("tax_amount", tax)); current_tax_amount = this.frm.doc.net_total ? - ((item.amount / this.frm.doc.net_total) * actual) : + ((item.base_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.amount; + current_tax_amount = (tax_rate / 100.0) * item.base_amount; } else if(tax.charge_type == "On Previous Row Amount") { current_tax_amount = (tax_rate / 100.0) * diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py index 1b6aa1e454..5bdc4d58dc 100644 --- a/erpnext/selling/doctype/quotation/test_quotation.py +++ b/erpnext/selling/doctype/quotation/test_quotation.py @@ -62,7 +62,7 @@ test_records = [ "qty": 10.0, "base_rate": 100.0, "rate": 100.0, - "amount": 1000.0, + "base_amount": 1000.0, } ], ] \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 0119513d1d..c6751d3dd6 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -281,8 +281,8 @@ def make_material_request(source_name, target_doclist=None): @webnotes.whitelist() def make_delivery_note(source_name, target_doclist=None): def update_item(obj, target, source_parent): - target.amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.base_rate) - target.export_amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.rate) + target.base_amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.base_rate) + target.amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.rate) target.qty = flt(obj.qty) - flt(obj.delivered_qty) doclist = get_mapped_doclist("Sales Order", source_name, { @@ -327,9 +327,9 @@ def make_sales_invoice(source_name, target_doclist=None): bean.run_method("onload_post_render") def update_item(obj, target, source_parent): - target.export_amount = flt(obj.export_amount) - flt(obj.billed_amt) - target.amount = target.export_amount * flt(source_parent.conversion_rate) - target.qty = obj.rate and target.export_amount / flt(obj.rate) or obj.qty + target.amount = flt(obj.amount) - flt(obj.billed_amt) + target.base_amount = target.amount * flt(source_parent.conversion_rate) + target.qty = obj.rate and target.amount / flt(obj.rate) or obj.qty doclist = get_mapped_doclist("Sales Order", source_name, { "Sales Order": { @@ -346,7 +346,7 @@ def make_sales_invoice(source_name, target_doclist=None): "warehouse": "warehouse" }, "postprocess": update_item, - "condition": lambda doc: doc.amount==0 or doc.billed_amt < doc.export_amount + "condition": lambda doc: doc.base_amount==0 or doc.billed_amt < doc.amount }, "Sales Taxes and Charges": { "doctype": "Sales Taxes and Charges", diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py index 7eda726cdd..ee667ce5d9 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -335,7 +335,7 @@ test_records = [ "qty": 10.0, "base_rate": 100.0, "rate": 100.0, - "amount": 1000.0, + "base_amount": 1000.0, "warehouse": "_Test Warehouse - _TC", } ], 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 3e500dc0e3..ae38de23f9 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 @@ -84,7 +84,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 = webnotes.conn.sql("""select soi.item_code, soi.qty, soi.amount, so.transaction_date, + item_details = webnotes.conn.sql("""select soi.item_code, soi.qty, soi.base_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 @@ -127,7 +127,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.amount + tav_dict.achieved += ad.base_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 2c45e21602..b7c030ffd4 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 @@ -27,8 +27,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 = webnotes.conn.sql("""select dt.name, dt.customer, dt.territory, dt.%s, - dt_item.item_code, dt_item.qty, dt_item.amount, st.sales_person, - st.allocated_percentage, dt_item.amount*st.allocated_percentage/100 + 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 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 d55e21016b..9861db3623 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 @@ -81,7 +81,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 = webnotes.conn.sql("""select soi.item_code, soi.qty, soi.amount, so.transaction_date, + item_details = webnotes.conn.sql("""select soi.item_code, soi.qty, soi.base_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 +125,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.amount + tav_dict.achieved += ad.base_amount return tim_map diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 0e01a81297..cf2347fa67 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -288,11 +288,11 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ if (!this.discount_amount_applied) { $.each(this.frm.item_doclist, function(i, item) { wn.model.round_floats_in(item); - item.export_amount = flt(item.rate * item.qty, precision("export_amount", item)); + item.amount = flt(item.rate * item.qty, precision("amount", item)); me._set_in_company_currency(item, "price_list_rate", "base_price_list_rate"); me._set_in_company_currency(item, "rate", "base_rate"); - me._set_in_company_currency(item, "export_amount", "amount"); + me._set_in_company_currency(item, "amount", "base_amount"); }); } }, @@ -318,11 +318,11 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }); if(cumulated_tax_fraction && !me.discount_amount_applied) { - item.amount = flt( - (item.export_amount * me.frm.doc.conversion_rate) / (1 + cumulated_tax_fraction), - precision("amount", item)); + item.base_amount = flt( + (item.amount * me.frm.doc.conversion_rate) / (1 + cumulated_tax_fraction), + precision("base_amount", item)); - item.base_rate = flt(item.amount / item.qty, precision("base_rate", item)); + item.base_rate = flt(item.base_amount / item.qty, precision("base_rate", item)); if(item.discount_percentage == 100) { item.base_price_list_rate = item.base_rate; @@ -364,8 +364,8 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ this.frm.doc.net_total = this.frm.doc.net_total_export = 0.0; $.each(this.frm.item_doclist, function(i, item) { - me.frm.doc.net_total += item.amount; - me.frm.doc.net_total_export += item.export_amount; + me.frm.doc.net_total += item.base_amount; + me.frm.doc.net_total_export += item.amount; }); wn.model.round_floats_in(this.frm.doc, ["net_total", "net_total_export"]); @@ -400,8 +400,8 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ // calculate item amount after Discount Amount if (grand_total_for_discount_amount) { $.each(this.frm.item_doclist, function(i, item) { - distributed_amount = flt(me.frm.doc.discount_amount) * item.amount / grand_total_for_discount_amount; - item.amount = flt(item.amount - distributed_amount, precision("amount", item)); + distributed_amount = flt(me.frm.doc.discount_amount) * item.base_amount / grand_total_for_discount_amount; + item.base_amount = flt(item.base_amount - distributed_amount, precision("base_amount", item)); }); this.discount_amount_applied = true; @@ -560,10 +560,10 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }); } - setup_field_label_map(["base_rate", "base_price_list_rate", "amount"], + setup_field_label_map(["base_rate", "base_price_list_rate", "base_amount"], company_currency, this.fname); - setup_field_label_map(["rate", "price_list_rate", "export_amount"], + setup_field_label_map(["rate", "price_list_rate", "amount"], this.frm.doc.currency, this.fname); setup_field_label_map(["tax_amount", "total"], company_currency, "other_charges"); @@ -579,7 +579,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ (wn.model.get_doclist(cur_frm.doctype, cur_frm.docname, {parentfield: "other_charges", included_in_print_rate: 1}).length); - $.each(["base_rate", "base_price_list_rate", "amount"], function(i, fname) { + $.each(["base_rate", "base_price_list_rate", "base_amount"], function(i, fname) { if(wn.meta.get_docfield(item_grid.doctype, fname)) item_grid.set_column_disp(fname, show); }); diff --git a/erpnext/startup/report_data_map.py b/erpnext/startup/report_data_map.py index df1ab34ebe..87be60aab0 100644 --- a/erpnext/startup/report_data_map.py +++ b/erpnext/startup/report_data_map.py @@ -173,7 +173,7 @@ data_map = { } }, "Sales Invoice Item": { - "columns": ["name", "parent", "item_code", "qty", "amount"], + "columns": ["name", "parent", "item_code", "qty", "base_amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -191,7 +191,7 @@ data_map = { } }, "Sales Order Item[Sales Analytics]": { - "columns": ["name", "parent", "item_code", "qty", "amount"], + "columns": ["name", "parent", "item_code", "qty", "base_amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -209,7 +209,7 @@ data_map = { } }, "Delivery Note Item[Sales Analytics]": { - "columns": ["name", "parent", "item_code", "qty", "amount"], + "columns": ["name", "parent", "item_code", "qty", "base_amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -241,7 +241,7 @@ data_map = { } }, "Purchase Invoice Item": { - "columns": ["name", "parent", "item_code", "qty", "amount"], + "columns": ["name", "parent", "item_code", "qty", "base_amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -259,7 +259,7 @@ data_map = { } }, "Purchase Order Item[Purchase Analytics]": { - "columns": ["name", "parent", "item_code", "qty", "amount"], + "columns": ["name", "parent", "item_code", "qty", "base_amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -277,7 +277,7 @@ data_map = { } }, "Purchase Receipt Item[Purchase Analytics]": { - "columns": ["name", "parent", "item_code", "qty", "amount"], + "columns": ["name", "parent", "item_code", "qty", "base_amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index 0dfa6d0eed..6239f28d8a 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -137,14 +137,14 @@ var set_print_hide= function(doc, cdt, cdn){ dn_item_fields['rate'].print_hide = 1; dn_item_fields['discount_percentage'].print_hide = 1; dn_item_fields['price_list_rate'].print_hide = 1; - dn_item_fields['export_amount'].print_hide = 1; + dn_item_fields['amount'].print_hide = 1; } else { if (dn_fields_copy['currency'].print_hide != 1) dn_fields['currency'].print_hide = 0; if (dn_item_fields_copy['rate'].print_hide != 1) dn_item_fields['rate'].print_hide = 0; - if (dn_item_fields_copy['export_amount'].print_hide != 1) - dn_item_fields['export_amount'].print_hide = 0; + if (dn_item_fields_copy['amount'].print_hide != 1) + dn_item_fields['amount'].print_hide = 0; } } diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index 248edda51a..c3a9b742bc 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -261,7 +261,7 @@ class DocType(SellingController): amount, total = 0, 0 for d in getlist(self.doclist, 'delivery_note_details'): if not (d.against_sales_order or d.against_sales_invoice): - amount += d.amount + amount += d.base_amount if amount != 0: total = (amount/self.doc.net_total)*self.doc.grand_total self.check_credit(total) diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py index a0def57154..3ea33aee6e 100644 --- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py @@ -36,7 +36,7 @@ class TestDeliveryNote(unittest.TestCase): self.assertEquals(len(si), len(dn.doclist)) - # modify export_amount + # modify amount si[1].rate = 200 self.assertRaises(webnotes.ValidationError, webnotes.bean(si).insert) @@ -98,7 +98,7 @@ class TestDeliveryNote(unittest.TestCase): pr = webnotes.bean(copy=pr_test_records[0]) pr.doc.posting_date = "2013-01-01" pr.doclist[1].rate = 100 - pr.doclist[1].amount = 100 + pr.doclist[1].base_amount = 100 pr.insert() pr.submit() @@ -245,7 +245,7 @@ test_records = [ "qty": 5.0, "base_rate": 100.0, "rate": 100.0, - "amount": 500.0, + "base_amount": 500.0, "warehouse": "_Test Warehouse - _TC", "stock_uom": "_Test UOM", "expense_account": "Cost of Goods Sold - _TC", diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index 06e5c3fb92..da7b15b071 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -156,7 +156,7 @@ test_records = [ "qty": 5.0, "rejected_qty": 0.0, "rate": 50.0, - "amount": 250.0, + "base_amount": 250.0, "warehouse": "_Test Warehouse - _TC", "stock_uom": "Nos", "uom": "_Test UOM", @@ -172,7 +172,7 @@ test_records = [ "qty": 5.0, "rejected_qty": 0.0, "rate": 50.0, - "amount": 250.0, + "base_amount": 250.0, "warehouse": "_Test Warehouse 1 - _TC", "stock_uom": "Nos", "uom": "_Test UOM", @@ -237,7 +237,7 @@ test_records = [ "qty": 10.0, "rejected_qty": 0.0, "rate": 500.0, - "amount": 5000.0, + "base_amount": 5000.0, "warehouse": "_Test Warehouse - _TC", "stock_uom": "Nos", "uom": "_Test UOM",