Rename fields: amount related fields

This commit is contained in:
Nabin Hait 2014-02-10 19:20:15 +05:30
parent 7979f7ed21
commit 1eb560130a
32 changed files with 140 additions and 140 deletions

View File

@ -27,8 +27,8 @@ class DocType(BuyingController):
'target_field': 'billed_amt', 'target_field': 'billed_amt',
'target_parent_dt': 'Purchase Order', 'target_parent_dt': 'Purchase Order',
'target_parent_field': 'per_billed', 'target_parent_field': 'per_billed',
'target_ref_field': 'import_amount', 'target_ref_field': 'amount',
'source_field': 'import_amount', 'source_field': 'amount',
'percent_join_field': 'purchase_order', 'percent_join_field': 'purchase_order',
}] }]
@ -54,7 +54,7 @@ class DocType(BuyingController):
self.validate_write_off_account() self.validate_write_off_account()
self.update_raw_material_cost() self.update_raw_material_cost()
self.update_valuation_rate("entries") 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") "purchase_receipt_details")
def set_missing_values(self, for_validate=False): def set_missing_values(self, for_validate=False):
@ -342,8 +342,8 @@ class DocType(BuyingController):
# expense will be booked in sales invoice # expense will be booked in sales invoice
stock_item_and_auto_accounting_for_stock = True stock_item_and_auto_accounting_for_stock = True
valuation_amt = flt(item.amount + item.item_tax_amount + item.rm_supp_cost, valuation_amt = flt(item.base_amount + item.item_tax_amount + item.rm_supp_cost,
self.precision("amount", item)) self.precision("base_amount", item))
gl_entries.append( gl_entries.append(
self.get_gl_dict({ 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 # if not a stock item or auto inventory accounting disabled, book the expense
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({
"account": item.expense_account, "account": item.expense_account,
"against": self.doc.credit_to, "against": self.doc.credit_to,
"debit": item.amount, "debit": item.base_amount,
"remarks": self.doc.remarks, "remarks": self.doc.remarks,
"cost_center": item.cost_center "cost_center": item.cost_center
}) })

View File

@ -230,9 +230,9 @@ test_records = [
"item_name": "_Test Item Home Desktop 100", "item_name": "_Test Item Home Desktop 100",
"qty": 10, "qty": 10,
"rate": 50, "rate": 50,
"import_amount": 500,
"base_rate": 50,
"amount": 500, "amount": 500,
"base_rate": 50,
"base_amount": 500,
"uom": "_Test UOM", "uom": "_Test UOM",
"item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}), "item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}),
"expense_account": "_Test Account Cost for Goods Sold - _TC", "expense_account": "_Test Account Cost for Goods Sold - _TC",
@ -247,9 +247,9 @@ test_records = [
"item_name": "_Test Item Home Desktop 200", "item_name": "_Test Item Home Desktop 200",
"qty": 5, "qty": 5,
"rate": 150, "rate": 150,
"import_amount": 750,
"base_rate": 150,
"amount": 750, "amount": 750,
"base_rate": 150,
"base_amount": 750,
"uom": "_Test UOM", "uom": "_Test UOM",
"expense_account": "_Test Account Cost for Goods Sold - _TC", "expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC", "cost_center": "_Test Cost Center - _TC",

View File

@ -131,8 +131,8 @@ erpnext.POS = Class.extend({
this.sales_or_purchase = (party == "Customer" ? "Sales" : "Purchase"); this.sales_or_purchase = (party == "Customer" ? "Sales" : "Purchase");
this.net_total = "net_total_" + export_or_import; this.net_total = "net_total_" + export_or_import;
this.grand_total = "grand_total_" + export_or_import; this.grand_total = "grand_total_" + export_or_import;
this.amount = export_or_import + "_amount"; // this.amount = export_or_import + "_amount";
this.rate = export_or_import + "_rate"; // this.rate = export_or_import + "_rate";
}, },
call_function: function(class_name, fn, event_name) { call_function: function(class_name, fn, event_name) {
this.wrapper.find("." + class_name).on(event_name || "click", fn); this.wrapper.find("." + class_name).on(event_name || "click", fn);
@ -401,8 +401,8 @@ erpnext.POS = Class.extend({
item_code: d.item_code, item_code: d.item_code,
item_name: d.item_name===d.item_code ? "" : ("<br>" + d.item_name), item_name: d.item_name===d.item_code ? "" : ("<br>" + d.item_name),
qty: d.qty, qty: d.qty,
rate: format_currency(d[me.rate], me.frm.doc.currency), rate: format_currency(d.rate, me.frm.doc.currency),
amount: format_currency(d[me.amount], me.frm.doc.currency) amount: format_currency(d.amount, me.frm.doc.currency)
} }
)).appendTo($items); )).appendTo($items);
}); });

View File

@ -29,12 +29,12 @@ class DocType(SellingController):
self.status_updater = [{ self.status_updater = [{
'source_dt': 'Sales Invoice Item', 'source_dt': 'Sales Invoice Item',
'target_field': 'billed_amt', 'target_field': 'billed_amt',
'target_ref_field': 'export_amount', 'target_ref_field': 'amount',
'target_dt': 'Sales Order Item', 'target_dt': 'Sales Order Item',
'join_field': 'so_detail', 'join_field': 'so_detail',
'target_parent_dt': 'Sales Order', 'target_parent_dt': 'Sales Order',
'target_parent_field': 'per_billed', 'target_parent_field': 'per_billed',
'source_field': 'export_amount', 'source_field': 'amount',
'join_field': 'so_detail', 'join_field': 'so_detail',
'percent_join_field': 'sales_order', 'percent_join_field': 'sales_order',
'status_field': 'billing_status', 'status_field': 'billing_status',
@ -73,7 +73,7 @@ class DocType(SellingController):
self.validate_c_form() self.validate_c_form()
self.validate_time_logs_are_submitted() self.validate_time_logs_are_submitted()
self.validate_recurring_invoice() 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") "delivery_note_details")
def on_submit(self): def on_submit(self):
@ -522,12 +522,12 @@ class DocType(SellingController):
def make_item_gl_entries(self, gl_entries): def make_item_gl_entries(self, gl_entries):
# income account gl entries # income account gl entries
for item in self.doclist.get({"parentfield": "entries"}): for item in self.doclist.get({"parentfield": "entries"}):
if flt(item.amount): if flt(item.base_amount):
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({
"account": item.income_account, "account": item.income_account,
"against": self.doc.debit_to, "against": self.doc.debit_to,
"credit": item.amount, "credit": item.base_amount,
"remarks": self.doc.remarks, "remarks": self.doc.remarks,
"cost_center": item.cost_center "cost_center": item.cost_center
}) })
@ -805,9 +805,9 @@ def make_delivery_note(source_name, target_doclist=None):
bean.run_method("onload_post_render") bean.run_method("onload_post_render")
def update_item(source_doc, target_doc, source_parent): 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) 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) flt(source_doc.rate)
target_doc.qty = flt(source_doc.qty) - flt(source_doc.delivered_qty) target_doc.qty = flt(source_doc.qty) - flt(source_doc.delivered_qty)

View File

@ -47,8 +47,8 @@ class TestSalesInvoice(unittest.TestCase):
si.insert() si.insert()
expected_values = { expected_values = {
"keys": ["price_list_rate", "discount_percentage", "rate", "export_amount", "keys": ["price_list_rate", "discount_percentage", "rate", "amount",
"base_price_list_rate", "base_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 100": [50, 0, 50, 500, 50, 50, 500],
"_Test Item Home Desktop 200": [150, 0, 150, 750, 150, 150, 750], "_Test Item Home Desktop 200": [150, 0, 150, 750, 150, 150, 750],
} }
@ -97,8 +97,8 @@ class TestSalesInvoice(unittest.TestCase):
si.insert() si.insert()
expected_values = { expected_values = {
"keys": ["price_list_rate", "discount_percentage", "rate", "export_amount", "keys": ["price_list_rate", "discount_percentage", "rate", "amount",
"base_price_list_rate", "base_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 100": [1, 0, 1, 10, 50, 50, 500],
"_Test Item Home Desktop 200": [3, 0, 3, 15, 150, 150, 750], "_Test Item Home Desktop 200": [3, 0, 3, 15, 150, 150, 750],
} }
@ -153,8 +153,8 @@ class TestSalesInvoice(unittest.TestCase):
si.insert() si.insert()
expected_values = { expected_values = {
"keys": ["price_list_rate", "discount_percentage", "rate", "export_amount", "keys": ["price_list_rate", "discount_percentage", "rate", "amount",
"base_price_list_rate", "base_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 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], "_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() si.insert()
expected_values = { expected_values = {
"keys": ["price_list_rate", "discount_percentage", "rate", "export_amount", "keys": ["price_list_rate", "discount_percentage", "rate", "amount",
"base_price_list_rate", "base_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 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], "_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() si.insert()
expected_values = { expected_values = {
"keys": ["price_list_rate", "discount_percentage", "rate", "export_amount", "keys": ["price_list_rate", "discount_percentage", "rate", "amount",
"base_price_list_rate", "base_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 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], "_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" "territory": "_Test Territory"
}, },
{ {
"amount": 500.0, "base_amount": 500.0,
"base_rate": 500.0, "base_rate": 500.0,
"description": "138-CMS Shoe", "description": "138-CMS Shoe",
"doctype": "Sales Invoice Item", "doctype": "Sales Invoice Item",
"export_amount": 500.0, "amount": 500.0,
"rate": 500.0, "rate": 500.0,
"income_account": "Sales - _TC", "income_account": "Sales - _TC",
"cost_center": "_Test Cost Center - _TC", "cost_center": "_Test Cost Center - _TC",
@ -960,9 +960,9 @@ test_records = [
"parentfield": "entries", "parentfield": "entries",
"qty": 1.0, "qty": 1.0,
"base_rate": 500.0, "base_rate": 500.0,
"amount": 500.0, "base_amount": 500.0,
"price_list_rate": 500.0, "price_list_rate": 500.0,
"export_amount": 500.0, "amount": 500.0,
"income_account": "Sales - _TC", "income_account": "Sales - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC", "expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC", "cost_center": "_Test Cost Center - _TC",

View File

@ -20,7 +20,7 @@ def execute(filters=None):
"Gross Profit:Currency", "Gross Profit %:Percent", "Project:Link/Project"] "Gross Profit:Currency", "Gross Profit %:Percent", "Project:Link/Project"]
data = [] data = []
for row in source: 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()) 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]),) % ("/".join(["#Form", row.parenttype, row.name]),)
data.append([row.name, icon, row.posting_date, row.posting_time, row.item_code, row.item_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.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]) gross_profit, gross_profit_percent, row.project])
return columns, data return columns, data
@ -93,7 +93,7 @@ def get_source_data(filters):
delivery_note_items = webnotes.conn.sql("""select item.parenttype, dn.name, delivery_note_items = webnotes.conn.sql("""select item.parenttype, dn.name,
dn.posting_date, dn.posting_time, dn.project_name, dn.posting_date, dn.posting_time, dn.project_name,
item.item_code, item.item_name, item.description, item.warehouse, 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 timestamp(dn.posting_date, dn.posting_time) as posting_datetime
from `tabDelivery Note` dn, `tabDelivery Note Item` item from `tabDelivery Note` dn, `tabDelivery Note Item` item
where item.parent = dn.name and dn.docstatus = 1 %s 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, sales_invoice_items = webnotes.conn.sql("""select item.parenttype, si.name,
si.posting_date, si.posting_time, si.project_name, si.posting_date, si.posting_time, si.project_name,
item.item_code, item.item_name, item.description, item.warehouse, 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 timestamp(si.posting_date, si.posting_time) as posting_datetime
from `tabSales Invoice` si, `tabSales Invoice Item` item from `tabSales Invoice` si, `tabSales Invoice Item` item
where item.parent = si.name and si.docstatus = 1 %s where item.parent = si.name and si.docstatus = 1 %s

View File

@ -20,12 +20,12 @@ def execute(filters=None):
expense_account = d.expense_account or aii_account_map.get(d.company) 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, 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.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: for tax in tax_accounts:
row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0)) row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0))
total_tax = sum(row[last_col:]) total_tax = sum(row[last_col:])
row += [total_tax, d.amount + total_tax] row += [total_tax, d.base_amount + total_tax]
data.append(row) 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, 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.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.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 from `tabPurchase Invoice` pi, `tabPurchase Invoice Item` pi_item
where pi.name = pi_item.parent and pi.docstatus = 1 %s %s 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) order by pi.posting_date desc, pi_item.item_code desc""" % (conditions, match_conditions), filters, as_dict=1)

View File

@ -18,13 +18,13 @@ def execute(filters=None):
for d in item_list: for d in item_list:
row = [d.item_code, d.item_name, d.item_group, d.parent, d.posting_date, 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.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: for tax in tax_accounts:
row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0)) row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0))
total_tax = sum(row[last_col:]) total_tax = sum(row[last_col:])
row += [total_tax, d.amount + total_tax] row += [total_tax, d.base_amount + total_tax]
data.append(row) 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, 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.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.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 from `tabSales Invoice` si, `tabSales Invoice Item` si_item
where si.name = si_item.parent and si.docstatus = 1 %s 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) order by si.posting_date desc, si_item.item_code desc""" % conditions, filters, as_dict=1)

View File

@ -116,7 +116,7 @@ def get_invoices(filters):
def get_invoice_expense_map(invoice_list): 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""" % 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) ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)

View File

@ -114,7 +114,7 @@ def get_invoices(filters):
conditions, filters, as_dict=1) conditions, filters, as_dict=1)
def get_invoice_income_map(invoice_list): 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""" % 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) ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)

View File

@ -221,12 +221,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
$.each(this.frm.item_doclist, function(i, item) { $.each(this.frm.item_doclist, function(i, item) {
wn.model.round_floats_in(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; 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, "price_list_rate", "base_price_list_rate");
me._set_in_company_currency(item, "rate", "base_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; this.frm.doc.net_total = this.frm.doc.net_total_import = 0.0;
$.each(this.frm.item_doclist, function(i, item) { $.each(this.frm.item_doclist, function(i, item) {
me.frm.doc.net_total += item.amount; me.frm.doc.net_total += item.base_amount;
me.frm.doc.net_total_import += item.import_amount; me.frm.doc.net_total_import += item.amount;
}); });
wn.model.round_floats_in(this.frm.doc, ["net_total", "net_total_import"]); 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); 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); this.frm.doc.currency, this.fname);
if(this.frm.fields_dict[this.other_fname]) { if(this.frm.fields_dict[this.other_fname]) {
@ -408,7 +408,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
// toggle columns // toggle columns
var item_grid = this.frm.fields_dict[this.fname].grid; 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; return wn.meta.get_docfield(item_grid.doctype, fname, me.frm.docname) ? fname : null;
}); });

View File

@ -190,8 +190,8 @@ def make_purchase_receipt(source_name, target_doclist=None):
def update_item(obj, target, source_parent): def update_item(obj, target, source_parent):
target.qty = flt(obj.qty) - flt(obj.received_qty) target.qty = flt(obj.qty) - flt(obj.received_qty)
target.stock_qty = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.conversion_factor) 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.rate)
target.amount = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.base_rate) target.base_amount = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.base_rate)
doclist = get_mapped_doclist("Purchase Order", source_name, { doclist = get_mapped_doclist("Purchase Order", source_name, {
"Purchase Order": { "Purchase Order": {
@ -227,10 +227,10 @@ def make_purchase_invoice(source_name, target_doclist=None):
bean.run_method("set_missing_values") bean.run_method("set_missing_values")
def update_item(obj, target, source_parent): def update_item(obj, target, source_parent):
target.import_amount = flt(obj.import_amount) - flt(obj.billed_amt) target.amount = flt(obj.amount) - flt(obj.billed_amt)
target.amount = target.import_amount * flt(source_parent.conversion_rate) target.base_amount = target.amount * flt(source_parent.conversion_rate)
if flt(obj.base_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, { doclist = get_mapped_doclist("Purchase Order", source_name, {
"Purchase Order": { "Purchase Order": {
@ -246,7 +246,7 @@ def make_purchase_invoice(source_name, target_doclist=None):
"parent": "purchase_order", "parent": "purchase_order",
}, },
"postprocess": update_item, "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": { "Purchase Taxes and Charges": {
"doctype": "Purchase Taxes and Charges", "doctype": "Purchase Taxes and Charges",

View File

@ -139,7 +139,7 @@ test_records = [
"parentfield": "po_details", "parentfield": "po_details",
"qty": 10.0, "qty": 10.0,
"rate": 500.0, "rate": 500.0,
"amount": 5000.0, "base_amount": 5000.0,
"warehouse": "_Test Warehouse - _TC", "warehouse": "_Test Warehouse - _TC",
"stock_uom": "_Test UOM", "stock_uom": "_Test UOM",
"uom": "_Test UOM", "uom": "_Test UOM",

View File

@ -56,7 +56,7 @@ test_records = [
"parentfield": "quotation_items", "parentfield": "quotation_items",
"qty": 10.0, "qty": 10.0,
"rate": 500.0, "rate": 500.0,
"amount": 5000.0, "base_amount": 5000.0,
"warehouse": "_Test Warehouse - _TC", "warehouse": "_Test Warehouse - _TC",
"uom": "_Test UOM", "uom": "_Test UOM",
} }

View File

@ -276,7 +276,7 @@ class AccountsController(TransactionBase):
# note: grand_total_for_current_item contains the contribution of # note: grand_total_for_current_item contains the contribution of
# item's amount, previously applied tax and the current tax on that item # item's amount, previously applied tax and the current tax on that item
if i==0: 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)) self.precision("total", tax))
else: else:
tax.grand_total_for_current_item = \ tax.grand_total_for_current_item = \
@ -314,10 +314,10 @@ class AccountsController(TransactionBase):
# distribute the tax amount proportionally to each item row # distribute the tax amount proportionally to each item row
actual = flt(tax.rate, self.precision("tax_amount", tax)) actual = flt(tax.rate, self.precision("tax_amount", tax))
current_tax_amount = (self.doc.net_total 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) or 0)
elif tax.charge_type == "On Net Total": 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": elif tax.charge_type == "On Previous Row Amount":
current_tax_amount = (tax_rate / 100.0) * \ current_tax_amount = (tax_rate / 100.0) * \
self.tax_doclist[cint(tax.row_id) - 1].tax_amount_for_current_item self.tax_doclist[cint(tax.row_id) - 1].tax_amount_for_current_item

View File

@ -88,11 +88,11 @@ class BuyingController(StockController):
item.rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)), item.rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)),
self.precision("rate", item)) self.precision("rate", item))
item.import_amount = flt(item.rate * item.qty, item.amount = flt(item.rate * item.qty,
self.precision("import_amount", item)) self.precision("amount", item))
item.item_tax_amount = 0.0; 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, "price_list_rate", "base_price_list_rate")
self._set_in_company_currency(item, "rate", "base_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 self.doc.net_total = self.doc.net_total_import = 0.0
for item in self.item_doclist: for item in self.item_doclist:
self.doc.net_total += item.amount self.doc.net_total += item.base_amount
self.doc.net_total_import += item.import_amount self.doc.net_total_import += item.amount
self.round_floats_in(self.doc, ["net_total", "net_total_import"]) 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}): for d in self.doclist.get({"parentfield": parentfield}):
if d.item_code and d.item_code in stock_items: if d.item_code and d.item_code in stock_items:
stock_items_qty += flt(d.qty) 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 last_stock_item_idx = d.idx
total_valuation_amount = sum([flt(d.tax_amount) for d in total_valuation_amount = sum([flt(d.tax_amount) for d in
@ -186,7 +186,7 @@ class BuyingController(StockController):
valuation_amount_adjustment = total_valuation_amount valuation_amount_adjustment = total_valuation_amount
for i, item in enumerate(self.doclist.get({"parentfield": parentfield})): for i, item in enumerate(self.doclist.get({"parentfield": parentfield})):
if item.item_code and item.qty and item.item_code in stock_items: 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 else flt(item.qty) / stock_items_qty
if i == (last_stock_item_idx - 1): if i == (last_stock_item_idx - 1):
@ -203,7 +203,7 @@ class BuyingController(StockController):
"UOM Conversion Detail", {"parent": item.item_code, "uom": item.uom}, "UOM Conversion Detail", {"parent": item.item_code, "uom": item.uom},
"conversion_factor")) or 1 "conversion_factor")) or 1
qty_in_stock_uom = flt(item.qty * item.conversion_factor) 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) / qty_in_stock_uom)
else: else:
item.valuation_rate = 0.0 item.valuation_rate = 0.0

View File

@ -112,10 +112,10 @@ class SellingController(StockController):
cumulated_tax_fraction += tax.tax_fraction_for_current_item cumulated_tax_fraction += tax.tax_fraction_for_current_item
if cumulated_tax_fraction and not self.discount_amount_applied: if cumulated_tax_fraction and not self.discount_amount_applied:
item.amount = flt((item.export_amount * self.doc.conversion_rate) / item.base_amount = flt((item.amount * self.doc.conversion_rate) /
(1 + cumulated_tax_fraction), self.precision("amount", item)) (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: if item.discount_percentage == 100:
item.base_price_list_rate = item.base_rate 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)), item.rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)),
self.precision("rate", item)) self.precision("rate", item))
item.export_amount = flt(item.rate * item.qty, item.amount = flt(item.rate * item.qty,
self.precision("export_amount", item)) self.precision("amount", item))
self._set_in_company_currency(item, "price_list_rate", "base_price_list_rate") 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, "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): def calculate_net_total(self):
self.doc.net_total = self.doc.net_total_export = 0.0 self.doc.net_total = self.doc.net_total_export = 0.0
for item in self.item_doclist: for item in self.item_doclist:
self.doc.net_total += item.amount self.doc.net_total += item.base_amount
self.doc.net_total_export += item.export_amount self.doc.net_total_export += item.amount
self.round_floats_in(self.doc, ["net_total", "net_total_export"]) self.round_floats_in(self.doc, ["net_total", "net_total_export"])
@ -197,8 +197,8 @@ class SellingController(StockController):
if grand_total_for_discount_amount: if grand_total_for_discount_amount:
# calculate item amount after Discount Amount # calculate item amount after Discount Amount
for item in self.item_doclist: for item in self.item_doclist:
distributed_amount = flt(self.doc.discount_amount) * item.amount / grand_total_for_discount_amount distributed_amount = flt(self.doc.discount_amount) * item.base_amount / grand_total_for_discount_amount
item.amount = flt(item.amount - distributed_amount, self.precision("amount", item)) item.base_amount = flt(item.base_amount - distributed_amount, self.precision("base_amount", item))
self.discount_amount_applied = True self.discount_amount_applied = True
self._calculate_taxes_and_totals() self._calculate_taxes_and_totals()

View File

@ -32,7 +32,7 @@ def get_project_details():
project_start_date, completion_date from tabProject where docstatus < 2""", as_dict=1) project_start_date, completion_date from tabProject where docstatus < 2""", as_dict=1)
def get_purchased_items_cost(): 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, '') != '' from `tabPurchase Receipt Item` where ifnull(project_name, '') != ''
and docstatus = 1 group by project_name""", as_dict=1) and docstatus = 1 group by project_name""", as_dict=1)
@ -55,12 +55,12 @@ def get_issued_items_cost():
return se_item_map return se_item_map
def get_delivered_items_cost(): 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 from `tabDelivery Note` dn, `tabDelivery Note Item` dn_item
where dn.name = dn_item.parent and dn.docstatus = 1 and ifnull(dn.project_name, '') != '' where dn.name = dn_item.parent and dn.docstatus = 1 and ifnull(dn.project_name, '') != ''
group by dn.project_name""", as_dict=1) 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 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, '') != '' and ifnull(si.is_pos, 0) = 1 and ifnull(si.project_name, '') != ''

View File

@ -114,12 +114,12 @@ pscript.feature_dict = {
'Sales Order': {'sales_order_details':['page_break']} 'Sales Order': {'sales_order_details':['page_break']}
}, },
'fs_exports': { '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']}, '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']}, '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','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 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': { 'fs_imports': {
@ -127,18 +127,18 @@ pscript.feature_dict = {
'fields': ['conversion_rate', 'currency', 'grand_total', 'fields': ['conversion_rate', 'currency', 'grand_total',
'in_words', 'net_total', 'other_charges_added', 'in_words', 'net_total', 'other_charges_added',
'other_charges_deducted'], 'other_charges_deducted'],
'entries': ['base_price_list_rate', 'amount','rate'] 'entries': ['base_price_list_rate', 'base_amount','base_rate']
}, },
'Purchase Order': { 'Purchase Order': {
'fields': ['conversion_rate','currency', 'grand_total', 'fields': ['conversion_rate','currency', 'grand_total',
'in_words', 'net_total', 'other_charges_added', 'in_words', 'net_total', 'other_charges_added',
'other_charges_deducted'], 'other_charges_deducted'],
'po_details': ['base_price_list_rate', 'amount','base_rate'] 'po_details': ['base_price_list_rate', 'base_amount','base_rate']
}, },
'Purchase Receipt': { 'Purchase Receipt': {
'fields': ['conversion_rate', 'currency','grand_total', 'in_words', 'fields': ['conversion_rate', 'currency','grand_total', 'in_words',
'net_total', 'other_charges_added', 'other_charges_deducted'], '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': { 'Supplier Quotation': {
'fields':['conversion_rate','currency'] 'fields':['conversion_rate','currency']

View File

@ -599,7 +599,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
// note: grand_total_for_current_item contains the contribution of // note: grand_total_for_current_item contains the contribution of
// item's amount, previously applied tax and the current tax on that item // item's amount, previously applied tax and the current tax on that item
if(i==0) { 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)); precision("total", tax));
} else { } else {
tax.grand_total_for_current_item = 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 // distribute the tax amount proportionally to each item row
var actual = flt(tax.rate, precision("tax_amount", tax)); var actual = flt(tax.rate, precision("tax_amount", tax));
current_tax_amount = this.frm.doc.net_total ? 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; 0.0;
} else if(tax.charge_type == "On Net Total") { } 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") { } else if(tax.charge_type == "On Previous Row Amount") {
current_tax_amount = (tax_rate / 100.0) * current_tax_amount = (tax_rate / 100.0) *

View File

@ -62,7 +62,7 @@ test_records = [
"qty": 10.0, "qty": 10.0,
"base_rate": 100.0, "base_rate": 100.0,
"rate": 100.0, "rate": 100.0,
"amount": 1000.0, "base_amount": 1000.0,
} }
], ],
] ]

View File

@ -281,8 +281,8 @@ def make_material_request(source_name, target_doclist=None):
@webnotes.whitelist() @webnotes.whitelist()
def make_delivery_note(source_name, target_doclist=None): def make_delivery_note(source_name, target_doclist=None):
def update_item(obj, target, source_parent): def update_item(obj, target, source_parent):
target.amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.base_rate) target.base_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.amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.rate)
target.qty = flt(obj.qty) - flt(obj.delivered_qty) target.qty = flt(obj.qty) - flt(obj.delivered_qty)
doclist = get_mapped_doclist("Sales Order", source_name, { 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") bean.run_method("onload_post_render")
def update_item(obj, target, source_parent): def update_item(obj, target, source_parent):
target.export_amount = flt(obj.export_amount) - flt(obj.billed_amt) target.amount = flt(obj.amount) - flt(obj.billed_amt)
target.amount = target.export_amount * flt(source_parent.conversion_rate) target.base_amount = target.amount * flt(source_parent.conversion_rate)
target.qty = obj.rate and target.export_amount / flt(obj.rate) or obj.qty target.qty = obj.rate and target.amount / flt(obj.rate) or obj.qty
doclist = get_mapped_doclist("Sales Order", source_name, { doclist = get_mapped_doclist("Sales Order", source_name, {
"Sales Order": { "Sales Order": {
@ -346,7 +346,7 @@ def make_sales_invoice(source_name, target_doclist=None):
"warehouse": "warehouse" "warehouse": "warehouse"
}, },
"postprocess": update_item, "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": { "Sales Taxes and Charges": {
"doctype": "Sales Taxes and Charges", "doctype": "Sales Taxes and Charges",

View File

@ -335,7 +335,7 @@ test_records = [
"qty": 10.0, "qty": 10.0,
"base_rate": 100.0, "base_rate": 100.0,
"rate": 100.0, "rate": 100.0,
"amount": 1000.0, "base_amount": 1000.0,
"warehouse": "_Test Warehouse - _TC", "warehouse": "_Test Warehouse - _TC",
} }
], ],

View File

@ -84,7 +84,7 @@ def get_target_distribution_details(filters):
def get_achieved_details(filters): def get_achieved_details(filters):
start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:] 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 st.sales_person, MONTHNAME(so.transaction_date) as month_name
from `tabSales Order Item` soi, `tabSales Order` so, `tabSales Team` st from `tabSales Order Item` soi, `tabSales Order` so, `tabSales Team` st
where soi.parent=so.name and so.docstatus=1 and 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"): if (filters["target_on"] == "Amount"):
tav_dict.target = flt(sd.target_amount) * month_percentage / 100 tav_dict.target = flt(sd.target_amount) * month_percentage / 100
if ad.month_name == month: if ad.month_name == month:
tav_dict.achieved += ad.amount tav_dict.achieved += ad.base_amount
return sim_map return sim_map

View File

@ -27,8 +27,8 @@ def get_entries(filters):
date_field = filters["doc_type"] == "Sales Order" and "transaction_date" or "posting_date" date_field = filters["doc_type"] == "Sales Order" and "transaction_date" or "posting_date"
conditions, items = get_conditions(filters, date_field) conditions, items = get_conditions(filters, date_field)
entries = webnotes.conn.sql("""select dt.name, dt.customer, dt.territory, dt.%s, 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, dt_item.item_code, dt_item.qty, dt_item.base_amount, st.sales_person,
st.allocated_percentage, dt_item.amount*st.allocated_percentage/100 st.allocated_percentage, dt_item.base_amount*st.allocated_percentage/100
from `tab%s` dt, `tab%s Item` dt_item, `tabSales Team` st 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' 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""" % and dt.docstatus = 1 %s order by st.sales_person, dt.name desc""" %

View File

@ -81,7 +81,7 @@ def get_target_distribution_details(filters):
def get_achieved_details(filters): def get_achieved_details(filters):
start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:] 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 so.territory, MONTHNAME(so.transaction_date) as month_name
from `tabSales Order Item` soi, `tabSales Order` so from `tabSales Order Item` soi, `tabSales Order` so
where soi.parent=so.name and so.docstatus=1 and so.transaction_date>=%s and 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"): if (filters["target_on"] == "Amount"):
tav_dict.target = flt(td.target_amount) * month_percentage / 100 tav_dict.target = flt(td.target_amount) * month_percentage / 100
if ad.month_name == month: if ad.month_name == month:
tav_dict.achieved += ad.amount tav_dict.achieved += ad.base_amount
return tim_map return tim_map

View File

@ -288,11 +288,11 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
if (!this.discount_amount_applied) { if (!this.discount_amount_applied) {
$.each(this.frm.item_doclist, function(i, item) { $.each(this.frm.item_doclist, function(i, item) {
wn.model.round_floats_in(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, "price_list_rate", "base_price_list_rate");
me._set_in_company_currency(item, "rate", "base_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) { if(cumulated_tax_fraction && !me.discount_amount_applied) {
item.amount = flt( item.base_amount = flt(
(item.export_amount * me.frm.doc.conversion_rate) / (1 + cumulated_tax_fraction), (item.amount * me.frm.doc.conversion_rate) / (1 + cumulated_tax_fraction),
precision("amount", item)); 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) { if(item.discount_percentage == 100) {
item.base_price_list_rate = item.base_rate; 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; this.frm.doc.net_total = this.frm.doc.net_total_export = 0.0;
$.each(this.frm.item_doclist, function(i, item) { $.each(this.frm.item_doclist, function(i, item) {
me.frm.doc.net_total += item.amount; me.frm.doc.net_total += item.base_amount;
me.frm.doc.net_total_export += item.export_amount; me.frm.doc.net_total_export += item.amount;
}); });
wn.model.round_floats_in(this.frm.doc, ["net_total", "net_total_export"]); 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 // calculate item amount after Discount Amount
if (grand_total_for_discount_amount) { if (grand_total_for_discount_amount) {
$.each(this.frm.item_doclist, function(i, item) { $.each(this.frm.item_doclist, function(i, item) {
distributed_amount = flt(me.frm.doc.discount_amount) * item.amount / grand_total_for_discount_amount; distributed_amount = flt(me.frm.doc.discount_amount) * item.base_amount / grand_total_for_discount_amount;
item.amount = flt(item.amount - distributed_amount, precision("amount", item)); item.base_amount = flt(item.base_amount - distributed_amount, precision("base_amount", item));
}); });
this.discount_amount_applied = true; 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); 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); this.frm.doc.currency, this.fname);
setup_field_label_map(["tax_amount", "total"], company_currency, "other_charges"); 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, (wn.model.get_doclist(cur_frm.doctype, cur_frm.docname,
{parentfield: "other_charges", included_in_print_rate: 1}).length); {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)) if(wn.meta.get_docfield(item_grid.doctype, fname))
item_grid.set_column_disp(fname, show); item_grid.set_column_disp(fname, show);
}); });

View File

@ -173,7 +173,7 @@ data_map = {
} }
}, },
"Sales Invoice Item": { "Sales Invoice Item": {
"columns": ["name", "parent", "item_code", "qty", "amount"], "columns": ["name", "parent", "item_code", "qty", "base_amount"],
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
"order_by": "parent", "order_by": "parent",
"links": { "links": {
@ -191,7 +191,7 @@ data_map = {
} }
}, },
"Sales Order Item[Sales Analytics]": { "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, '')!=''"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
"order_by": "parent", "order_by": "parent",
"links": { "links": {
@ -209,7 +209,7 @@ data_map = {
} }
}, },
"Delivery Note Item[Sales Analytics]": { "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, '')!=''"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
"order_by": "parent", "order_by": "parent",
"links": { "links": {
@ -241,7 +241,7 @@ data_map = {
} }
}, },
"Purchase Invoice Item": { "Purchase Invoice Item": {
"columns": ["name", "parent", "item_code", "qty", "amount"], "columns": ["name", "parent", "item_code", "qty", "base_amount"],
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
"order_by": "parent", "order_by": "parent",
"links": { "links": {
@ -259,7 +259,7 @@ data_map = {
} }
}, },
"Purchase Order Item[Purchase Analytics]": { "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, '')!=''"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
"order_by": "parent", "order_by": "parent",
"links": { "links": {
@ -277,7 +277,7 @@ data_map = {
} }
}, },
"Purchase Receipt Item[Purchase Analytics]": { "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, '')!=''"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
"order_by": "parent", "order_by": "parent",
"links": { "links": {

View File

@ -137,14 +137,14 @@ var set_print_hide= function(doc, cdt, cdn){
dn_item_fields['rate'].print_hide = 1; dn_item_fields['rate'].print_hide = 1;
dn_item_fields['discount_percentage'].print_hide = 1; dn_item_fields['discount_percentage'].print_hide = 1;
dn_item_fields['price_list_rate'].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 { } else {
if (dn_fields_copy['currency'].print_hide != 1) if (dn_fields_copy['currency'].print_hide != 1)
dn_fields['currency'].print_hide = 0; dn_fields['currency'].print_hide = 0;
if (dn_item_fields_copy['rate'].print_hide != 1) if (dn_item_fields_copy['rate'].print_hide != 1)
dn_item_fields['rate'].print_hide = 0; dn_item_fields['rate'].print_hide = 0;
if (dn_item_fields_copy['export_amount'].print_hide != 1) if (dn_item_fields_copy['amount'].print_hide != 1)
dn_item_fields['export_amount'].print_hide = 0; dn_item_fields['amount'].print_hide = 0;
} }
} }

View File

@ -261,7 +261,7 @@ class DocType(SellingController):
amount, total = 0, 0 amount, total = 0, 0
for d in getlist(self.doclist, 'delivery_note_details'): for d in getlist(self.doclist, 'delivery_note_details'):
if not (d.against_sales_order or d.against_sales_invoice): if not (d.against_sales_order or d.against_sales_invoice):
amount += d.amount amount += d.base_amount
if amount != 0: if amount != 0:
total = (amount/self.doc.net_total)*self.doc.grand_total total = (amount/self.doc.net_total)*self.doc.grand_total
self.check_credit(total) self.check_credit(total)

View File

@ -36,7 +36,7 @@ class TestDeliveryNote(unittest.TestCase):
self.assertEquals(len(si), len(dn.doclist)) self.assertEquals(len(si), len(dn.doclist))
# modify export_amount # modify amount
si[1].rate = 200 si[1].rate = 200
self.assertRaises(webnotes.ValidationError, webnotes.bean(si).insert) 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 = webnotes.bean(copy=pr_test_records[0])
pr.doc.posting_date = "2013-01-01" pr.doc.posting_date = "2013-01-01"
pr.doclist[1].rate = 100 pr.doclist[1].rate = 100
pr.doclist[1].amount = 100 pr.doclist[1].base_amount = 100
pr.insert() pr.insert()
pr.submit() pr.submit()
@ -245,7 +245,7 @@ test_records = [
"qty": 5.0, "qty": 5.0,
"base_rate": 100.0, "base_rate": 100.0,
"rate": 100.0, "rate": 100.0,
"amount": 500.0, "base_amount": 500.0,
"warehouse": "_Test Warehouse - _TC", "warehouse": "_Test Warehouse - _TC",
"stock_uom": "_Test UOM", "stock_uom": "_Test UOM",
"expense_account": "Cost of Goods Sold - _TC", "expense_account": "Cost of Goods Sold - _TC",

View File

@ -156,7 +156,7 @@ test_records = [
"qty": 5.0, "qty": 5.0,
"rejected_qty": 0.0, "rejected_qty": 0.0,
"rate": 50.0, "rate": 50.0,
"amount": 250.0, "base_amount": 250.0,
"warehouse": "_Test Warehouse - _TC", "warehouse": "_Test Warehouse - _TC",
"stock_uom": "Nos", "stock_uom": "Nos",
"uom": "_Test UOM", "uom": "_Test UOM",
@ -172,7 +172,7 @@ test_records = [
"qty": 5.0, "qty": 5.0,
"rejected_qty": 0.0, "rejected_qty": 0.0,
"rate": 50.0, "rate": 50.0,
"amount": 250.0, "base_amount": 250.0,
"warehouse": "_Test Warehouse 1 - _TC", "warehouse": "_Test Warehouse 1 - _TC",
"stock_uom": "Nos", "stock_uom": "Nos",
"uom": "_Test UOM", "uom": "_Test UOM",
@ -237,7 +237,7 @@ test_records = [
"qty": 10.0, "qty": 10.0,
"rejected_qty": 0.0, "rejected_qty": 0.0,
"rate": 500.0, "rate": 500.0,
"amount": 5000.0, "base_amount": 5000.0,
"warehouse": "_Test Warehouse - _TC", "warehouse": "_Test Warehouse - _TC",
"stock_uom": "Nos", "stock_uom": "Nos",
"uom": "_Test UOM", "uom": "_Test UOM",