Field Rename: rate field mass replacement

This commit is contained in:
Nabin Hait 2014-02-10 18:26:49 +05:30
parent a7f757a3f4
commit 7979f7ed21
29 changed files with 133 additions and 178 deletions

View File

@ -169,13 +169,13 @@ class DocType(BuyingController):
super(DocType, self).validate_with_previous_doc(self.tname, {
"Purchase Order Item": {
"ref_dn_field": "po_detail",
"compare_fields": [["import_rate", "="]],
"compare_fields": [["rate", "="]],
"is_child_table": True,
"allow_duplicate_prev_row_id": True
},
"Purchase Receipt Item": {
"ref_dn_field": "pr_detail",
"compare_fields": [["import_rate", "="]],
"compare_fields": [["rate", "="]],
"is_child_table": True
}
})

View File

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

View File

@ -295,13 +295,13 @@ class DocType(SellingController):
super(DocType, self).validate_with_previous_doc(self.tname, {
"Sales Order Item": {
"ref_dn_field": "so_detail",
"compare_fields": [["export_rate", "="]],
"compare_fields": [["rate", "="]],
"is_child_table": True,
"allow_duplicate_prev_row_id": True
},
"Delivery Note Item": {
"ref_dn_field": "dn_detail",
"compare_fields": [["export_rate", "="]],
"compare_fields": [["rate", "="]],
"is_child_table": True
}
})
@ -806,9 +806,9 @@ def make_delivery_note(source_name, target_doclist=None):
def update_item(source_doc, target_doc, source_parent):
target_doc.amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \
flt(source_doc.basic_rate)
flt(source_doc.base_rate)
target_doc.export_amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \
flt(source_doc.export_rate)
flt(source_doc.rate)
target_doc.qty = flt(source_doc.qty) - flt(source_doc.delivered_qty)
doclist = get_mapped_doclist("Sales Invoice", source_name, {

View File

@ -8,7 +8,7 @@ wn.model.map_info["Sales Invoice"] = {
},
field_map: {
"Sales Invoice Item": {
"basic_rate": "rate",
"base_rate": "rate",
"time_log_batch": "name",
"qty": "total_hours",
"stock_uom": "=Hour",

View File

@ -47,8 +47,8 @@ class TestSalesInvoice(unittest.TestCase):
si.insert()
expected_values = {
"keys": ["price_list_rate", "discount_percentage", "export_rate", "export_amount",
"base_price_list_rate", "basic_rate", "amount"],
"keys": ["price_list_rate", "discount_percentage", "rate", "export_amount",
"base_price_list_rate", "base_rate", "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],
}
@ -90,15 +90,15 @@ class TestSalesInvoice(unittest.TestCase):
si = webnotes.bean(copy=test_records[2])
si.doc.currency = "USD"
si.doc.conversion_rate = 50
si.doclist[1].export_rate = 1
si.doclist[1].rate = 1
si.doclist[1].price_list_rate = 1
si.doclist[2].export_rate = 3
si.doclist[2].rate = 3
si.doclist[2].price_list_rate = 3
si.insert()
expected_values = {
"keys": ["price_list_rate", "discount_percentage", "export_rate", "export_amount",
"base_price_list_rate", "basic_rate", "amount"],
"keys": ["price_list_rate", "discount_percentage", "rate", "export_amount",
"base_price_list_rate", "base_rate", "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", "export_rate", "export_amount",
"base_price_list_rate", "basic_rate", "amount"],
"keys": ["price_list_rate", "discount_percentage", "rate", "export_amount",
"base_price_list_rate", "base_rate", "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", "export_rate", "export_amount",
"base_price_list_rate", "basic_rate", "amount"],
"keys": ["price_list_rate", "discount_percentage", "rate", "export_amount",
"base_price_list_rate", "base_rate", "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", "export_rate", "export_amount",
"base_price_list_rate", "basic_rate", "amount"],
"keys": ["price_list_rate", "discount_percentage", "rate", "export_amount",
"base_price_list_rate", "base_rate", "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],
}
@ -890,11 +890,11 @@ test_records = [
},
{
"amount": 500.0,
"basic_rate": 500.0,
"base_rate": 500.0,
"description": "138-CMS Shoe",
"doctype": "Sales Invoice Item",
"export_amount": 500.0,
"export_rate": 500.0,
"rate": 500.0,
"income_account": "Sales - _TC",
"cost_center": "_Test Cost Center - _TC",
"item_name": "138-CMS Shoe",
@ -959,7 +959,7 @@ test_records = [
"doctype": "Sales Invoice Item",
"parentfield": "entries",
"qty": 1.0,
"basic_rate": 500.0,
"base_rate": 500.0,
"amount": 500.0,
"price_list_rate": 500.0,
"export_amount": 500.0,
@ -1012,7 +1012,7 @@ test_records = [
"item_name": "_Test Item Home Desktop 100",
"qty": 10,
"price_list_rate": 50,
"export_rate": 50,
"rate": 50,
"stock_uom": "_Test UOM",
"item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}),
"income_account": "Sales - _TC",
@ -1026,7 +1026,7 @@ test_records = [
"item_name": "_Test Item Home Desktop 200",
"qty": 5,
"price_list_rate": 150,
"export_rate": 150,
"rate": 150,
"stock_uom": "_Test UOM",
"income_account": "Sales - _TC",
"cost_center": "_Test Cost Center - _TC",

View File

@ -42,7 +42,7 @@ def execute(filters=None):
icon = """<a href="%s"><i class="icon icon-share" style="cursor: pointer;"></i></a>""" \
% ("/".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.basic_rate,
row.description, row.warehouse, row.qty, row.base_rate,
row.qty and (buying_amount / row.qty) or 0, row.amount, buying_amount,
gross_profit, gross_profit_percent, row.project])
@ -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.basic_rate, item.amount, item.name as "item_row",
item.qty, item.base_rate, item.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.basic_rate, item.amount, item.name as "item_row",
item.qty, item.base_rate, item.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

View File

@ -20,7 +20,7 @@ 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.rate, d.amount]
d.purchase_receipt, expense_account, d.qty, d.base_rate, d.amount]
for tax in tax_accounts:
row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0))
@ -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.rate, pi_item.amount, pi.supplier_name
pi_item.expense_account, pi_item.qty, pi_item.base_rate, pi_item.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)

View File

@ -18,7 +18,7 @@ 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.basic_rate, d.amount]
d.delivery_note, d.income_account, d.qty, d.base_rate, d.amount]
for tax in tax_accounts:
row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0))
@ -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.basic_rate, si_item.amount, si.customer_name
si_item.qty, si_item.base_rate, si_item.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)

View File

@ -118,8 +118,8 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
var item = wn.model.get_doc(cdt, cdn);
wn.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]);
item.import_rate = flt(item.price_list_rate * (1 - item.discount_percentage / 100.0),
precision("import_rate", item));
item.rate = flt(item.price_list_rate * (1 - item.discount_percentage / 100.0),
precision("rate", item));
this.calculate_taxes_and_totals();
},
@ -128,12 +128,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
this.price_list_rate(doc, cdt, cdn);
},
import_rate: function(doc, cdt, cdn) {
rate: function(doc, cdt, cdn) {
var item = wn.model.get_doc(cdt, cdn);
wn.model.round_floats_in(item, ["import_rate", "discount_percentage"]);
wn.model.round_floats_in(item, ["rate", "discount_percentage"]);
if(item.price_list_rate) {
item.discount_percentage = flt((1 - item.import_rate / item.price_list_rate) * 100.0,
item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0,
precision("discount_percentage", item));
} else {
item.discount_percentage = 0.0;
@ -219,24 +219,13 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
calculate_item_values: function() {
var me = this;
if(this.frm.doc.doctype != "Purchase Invoice") {
// hack!
var purchase_rate_df = wn.meta.get_docfield(this.tname, "rate", this.frm.doc.name);
wn.meta.docfield_copy[this.tname][this.frm.doc.name]["rate"] =
$.extend({}, purchase_rate_df);
}
$.each(this.frm.item_doclist, function(i, item) {
if(me.frm.doc.doctype != "Purchase Invoice") {
item.rate = item.purchase_rate;
}
wn.model.round_floats_in(item);
item.import_amount = flt(item.import_rate * item.qty, precision("import_amount", item));
item.import_amount = flt(item.rate * item.qty, precision("import_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, "import_rate", "rate");
me._set_in_company_currency(item, "rate", "base_rate");
me._set_in_company_currency(item, "import_amount", "amount");
});
@ -301,18 +290,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
this._super();
this.frm.doc.in_words = this.frm.doc.in_words_import = "";
// except in purchase invoice, rate field is purchase_rate
// reset fieldname of rate
if(this.frm.doc.doctype != "Purchase Invoice") {
// clear hack
delete wn.meta.docfield_copy[this.tname][this.frm.doc.name]["rate"];
$.each(this.frm.item_doclist, function(i, item) {
item.purchase_rate = item.rate;
delete item["rate"];
});
}
if(this.frm.item_doclist.length) {
if(!wn.meta.get_docfield(this.frm.item_doclist[0].doctype, "item_tax_amount", this.frm.doctype)) {
$.each(this.frm.item_doclist, function(i, item) {
@ -414,10 +391,10 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
});
};
setup_field_label_map(["purchase_rate", "base_price_list_rate", "amount", "rate"],
setup_field_label_map(["base_rate", "base_price_list_rate", "amount", "base_rate"],
company_currency, this.fname);
setup_field_label_map(["import_rate", "price_list_rate", "import_amount"],
setup_field_label_map(["rate", "price_list_rate", "import_amount"],
this.frm.doc.currency, this.fname);
if(this.frm.fields_dict[this.other_fname]) {
@ -431,7 +408,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
// toggle columns
var item_grid = this.frm.fields_dict[this.fname].grid;
var fieldnames = $.map(["purchase_rate", "base_price_list_rate", "amount", "rate"], function(fname) {
var fieldnames = $.map(["base_rate", "base_price_list_rate", "amount", "base_rate"], function(fname) {
return wn.meta.get_docfield(item_grid.doctype, fname, me.frm.docname) ? fname : null;
});

View File

@ -30,12 +30,12 @@ class DocType(BuyingController):
last_purchase_rate = None
if last_purchase_details and \
(last_purchase_details.purchase_date > this_purchase_date):
last_purchase_rate = last_purchase_details['purchase_rate']
last_purchase_rate = last_purchase_details['base_rate']
elif is_submit == 1:
# even if this transaction is the latest one, it should be submitted
# for it to be considered for latest purchase rate
if flt(d.conversion_factor):
last_purchase_rate = flt(d.purchase_rate) / flt(d.conversion_factor)
last_purchase_rate = flt(d.base_rate) / flt(d.conversion_factor)
else:
webnotes.throw(_("Row ") + cstr(d.idx) + ": " +
_("UOM Conversion Factor is mandatory"))
@ -57,18 +57,18 @@ class DocType(BuyingController):
if last_purchase_details:
d.base_price_list_rate = last_purchase_details['base_price_list_rate'] * (flt(d.conversion_factor) or 1.0)
d.discount_percentage = last_purchase_details['discount_percentage']
d.purchase_rate = last_purchase_details['purchase_rate'] * (flt(d.conversion_factor) or 1.0)
d.base_rate = last_purchase_details['base_rate'] * (flt(d.conversion_factor) or 1.0)
d.price_list_rate = d.base_price_list_rate / conversion_rate
d.import_rate = d.purchase_rate / conversion_rate
d.rate = d.base_rate / conversion_rate
else:
# if no last purchase found, reset all values to 0
d.base_price_list_rate = d.purchase_rate = d.price_list_rate = d.import_rate = d.discount_percentage = 0
d.base_price_list_rate = d.base_rate = d.price_list_rate = d.rate = d.discount_percentage = 0
item_last_purchase_rate = webnotes.conn.get_value("Item",
d.item_code, "last_purchase_rate")
if item_last_purchase_rate:
d.base_price_list_rate = d.purchase_rate = d.price_list_rate \
= d.import_rate = item_last_purchase_rate
d.base_price_list_rate = d.base_rate = d.price_list_rate \
= d.rate = item_last_purchase_rate
def validate_for_items(self, obj):
check_list, chk_dupl_itm=[],[]

View File

@ -58,7 +58,7 @@ class DocType(BuyingController):
},
"Supplier Quotation Item": {
"ref_dn_field": "supplier_quotation_item",
"compare_fields": [["import_rate", "="], ["project_name", "="], ["item_code", "="],
"compare_fields": [["rate", "="], ["project_name", "="], ["item_code", "="],
["uom", "="]],
"is_child_table": True
}
@ -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.import_rate)
target.amount = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.purchase_rate)
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)
doclist = get_mapped_doclist("Purchase Order", source_name, {
"Purchase Order": {
@ -229,8 +229,8 @@ def make_purchase_invoice(source_name, target_doclist=None):
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)
if flt(obj.purchase_rate):
target.qty = target.amount / flt(obj.purchase_rate)
if flt(obj.base_rate):
target.qty = target.amount / flt(obj.base_rate)
doclist = get_mapped_doclist("Purchase Order", source_name, {
"Purchase Order": {
@ -244,7 +244,6 @@ def make_purchase_invoice(source_name, target_doclist=None):
"field_map": {
"name": "po_detail",
"parent": "purchase_order",
"purchase_rate": "rate"
},
"postprocess": update_item,
"condition": lambda doc: doc.amount==0 or doc.billed_amt < doc.import_amount

View File

@ -138,7 +138,7 @@ test_records = [
"item_name": "_Test FG Item",
"parentfield": "po_details",
"qty": 10.0,
"import_rate": 500.0,
"rate": 500.0,
"amount": 5000.0,
"warehouse": "_Test Warehouse - _TC",
"stock_uom": "_Test UOM",

View File

@ -55,7 +55,7 @@ test_records = [
"item_name": "_Test FG Item",
"parentfield": "quotation_items",
"qty": 10.0,
"import_rate": 500.0,
"rate": 500.0,
"amount": 5000.0,
"warehouse": "_Test Warehouse - _TC",
"uom": "_Test UOM",

View File

@ -79,31 +79,22 @@ class BuyingController(StockController):
self.calculate_total_advance("Purchase Invoice", "advance_allocation_details")
def calculate_item_values(self):
# hack! - cleaned up in _cleanup()
if self.doc.doctype != "Purchase Invoice":
df = self.meta.get_field("purchase_rate", parentfield=self.fname)
df.fieldname = "rate"
for item in self.item_doclist:
# hack! - cleaned up in _cleanup()
if self.doc.doctype != "Purchase Invoice":
item.rate = item.purchase_rate
self.round_floats_in(item)
if item.discount_percentage == 100.0:
item.import_rate = 0.0
elif not item.import_rate:
item.import_rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)),
self.precision("import_rate", item))
item.rate = 0.0
elif not item.rate:
item.rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)),
self.precision("rate", item))
item.import_amount = flt(item.import_rate * item.qty,
item.import_amount = flt(item.rate * item.qty,
self.precision("import_amount", item))
item.item_tax_amount = 0.0;
self._set_in_company_currency(item, "import_amount", "amount")
self._set_in_company_currency(item, "price_list_rate", "base_price_list_rate")
self._set_in_company_currency(item, "import_rate", "rate")
self._set_in_company_currency(item, "rate", "base_rate")
def calculate_net_total(self):
@ -160,16 +151,6 @@ class BuyingController(StockController):
def _cleanup(self):
super(BuyingController, self)._cleanup()
# except in purchase invoice, rate field is purchase_rate
# reset fieldname of rate
if self.doc.doctype != "Purchase Invoice":
df = self.meta.get_field("rate", parentfield=self.fname)
df.fieldname = "purchase_rate"
for item in self.item_doclist:
item.purchase_rate = item.rate
del item.fields["rate"]
if not self.meta.get_field("item_tax_amount", parentfield=self.fname):
for item in self.item_doclist:
del item.fields["item_tax_amount"]

View File

@ -115,13 +115,13 @@ class SellingController(StockController):
item.amount = flt((item.export_amount * self.doc.conversion_rate) /
(1 + cumulated_tax_fraction), self.precision("amount", item))
item.basic_rate = flt(item.amount / item.qty, self.precision("basic_rate", item))
item.base_rate = flt(item.amount / item.qty, self.precision("base_rate", item))
if item.discount_percentage == 100:
item.base_price_list_rate = item.basic_rate
item.basic_rate = 0.0
item.base_price_list_rate = item.base_rate
item.base_rate = 0.0
else:
item.base_price_list_rate = flt(item.basic_rate / (1 - (item.discount_percentage / 100.0)),
item.base_price_list_rate = flt(item.base_rate / (1 - (item.discount_percentage / 100.0)),
self.precision("base_price_list_rate", item))
def get_current_tax_fraction(self, tax, item_tax_map):
@ -153,16 +153,16 @@ class SellingController(StockController):
self.round_floats_in(item)
if item.discount_percentage == 100:
item.export_rate = 0
elif not item.export_rate:
item.export_rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)),
self.precision("export_rate", item))
item.rate = 0
elif not item.rate:
item.rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)),
self.precision("rate", item))
item.export_amount = flt(item.export_rate * item.qty,
item.export_amount = flt(item.rate * item.qty,
self.precision("export_amount", item))
self._set_in_company_currency(item, "price_list_rate", "base_price_list_rate")
self._set_in_company_currency(item, "export_rate", "basic_rate")
self._set_in_company_currency(item, "rate", "base_rate")
self._set_in_company_currency(item, "export_amount", "amount")
def calculate_net_total(self):

View File

@ -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','basic_rate']},
'Delivery Note': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'delivery_note_details':['base_price_list_rate','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','basic_rate']},
'Sales Invoice': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'entries':['base_price_list_rate','amount','basic_rate']},
'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']},
'Sales BOM': {'fields':['currency']},
'Sales Order': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'sales_order_details':['base_price_list_rate','amount','basic_rate']}
'Sales Order': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'sales_order_details':['base_price_list_rate','amount','base_rate']}
},
'fs_imports': {
@ -133,12 +133,12 @@ pscript.feature_dict = {
'fields': ['conversion_rate','currency', 'grand_total',
'in_words', 'net_total', 'other_charges_added',
'other_charges_deducted'],
'po_details': ['base_price_list_rate', 'amount','purchase_rate']
'po_details': ['base_price_list_rate', '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','purchase_rate']
'purchase_receipt_details': ['base_price_list_rate','amount','base_rate']
},
'Supplier Quotation': {
'fields':['conversion_rate','currency']

View File

@ -60,8 +60,8 @@ test_records = [
"item_name": "CPU",
"parentfield": "quotation_details",
"qty": 10.0,
"basic_rate": 100.0,
"export_rate": 100.0,
"base_rate": 100.0,
"rate": 100.0,
"amount": 1000.0,
}
],

View File

@ -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.basic_rate)
target.export_amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.export_rate)
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.qty = flt(obj.qty) - flt(obj.delivered_qty)
doclist = get_mapped_doclist("Sales Order", source_name, {
@ -299,7 +299,7 @@ def make_delivery_note(source_name, target_doclist=None):
"Sales Order Item": {
"doctype": "Delivery Note Item",
"field_map": {
"export_rate": "export_rate",
"rate": "rate",
"name": "prevdoc_detail_docname",
"parent": "against_sales_order",
"warehouse": "warehouse"
@ -329,7 +329,7 @@ def make_sales_invoice(source_name, target_doclist=None):
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.export_rate and target.export_amount / flt(obj.export_rate) or obj.qty
target.qty = obj.rate and target.export_amount / flt(obj.rate) or obj.qty
doclist = get_mapped_doclist("Sales Order", source_name, {
"Sales Order": {

View File

@ -333,8 +333,8 @@ test_records = [
"item_name": "CPU",
"parentfield": "sales_order_details",
"qty": 10.0,
"basic_rate": 100.0,
"export_rate": 100.0,
"base_rate": 100.0,
"rate": 100.0,
"amount": 1000.0,
"warehouse": "_Test Warehouse - _TC",
}

View File

@ -167,8 +167,8 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
var item = wn.model.get_doc(cdt, cdn);
wn.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]);
item.export_rate = flt(item.price_list_rate * (1 - item.discount_percentage / 100.0),
precision("export_rate", item));
item.rate = flt(item.price_list_rate * (1 - item.discount_percentage / 100.0),
precision("rate", item));
this.calculate_taxes_and_totals();
},
@ -182,12 +182,12 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
}
},
export_rate: function(doc, cdt, cdn) {
rate: function(doc, cdt, cdn) {
var item = wn.model.get_doc(cdt, cdn);
wn.model.round_floats_in(item, ["export_rate", "price_list_rate"]);
wn.model.round_floats_in(item, ["rate", "price_list_rate"]);
if(item.price_list_rate) {
item.discount_percentage = flt((1 - item.export_rate / item.price_list_rate) * 100.0,
item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0,
precision("discount_percentage", item));
} else {
item.discount_percentage = 0.0;
@ -288,10 +288,10 @@ 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.export_rate * item.qty, precision("export_amount", item));
item.export_amount = flt(item.rate * item.qty, precision("export_amount", item));
me._set_in_company_currency(item, "price_list_rate", "base_price_list_rate");
me._set_in_company_currency(item, "export_rate", "basic_rate");
me._set_in_company_currency(item, "rate", "base_rate");
me._set_in_company_currency(item, "export_amount", "amount");
});
}
@ -322,13 +322,13 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
(item.export_amount * me.frm.doc.conversion_rate) / (1 + cumulated_tax_fraction),
precision("amount", item));
item.basic_rate = flt(item.amount / item.qty, precision("basic_rate", item));
item.base_rate = flt(item.amount / item.qty, precision("base_rate", item));
if(item.discount_percentage == 100) {
item.base_price_list_rate = item.basic_rate;
item.basic_rate = 0.0;
item.base_price_list_rate = item.base_rate;
item.base_rate = 0.0;
} else {
item.base_price_list_rate = flt(item.basic_rate / (1 - item.discount_percentage / 100.0),
item.base_price_list_rate = flt(item.base_rate / (1 - item.discount_percentage / 100.0),
precision("base_price_list_rate", item));
}
}
@ -560,10 +560,10 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
});
}
setup_field_label_map(["basic_rate", "base_price_list_rate", "amount"],
setup_field_label_map(["base_rate", "base_price_list_rate", "amount"],
company_currency, this.fname);
setup_field_label_map(["export_rate", "price_list_rate", "export_amount"],
setup_field_label_map(["rate", "price_list_rate", "export_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(["basic_rate", "base_price_list_rate", "amount"], function(i, fname) {
$.each(["base_rate", "base_price_list_rate", "amount"], function(i, fname) {
if(wn.meta.get_docfield(item_grid.doctype, fname))
item_grid.set_column_disp(fname, show);
});

View File

@ -99,12 +99,12 @@ class DocType(TransactionBase):
def validate_approving_authority(self, doctype_name,company, total, doc_obj = ''):
av_dis = 0
if doc_obj:
price_list_rate, basic_rate = 0, 0
price_list_rate, base_rate = 0, 0
for d in getlist(doc_obj.doclist, doc_obj.fname):
if d.base_price_list_rate and d.basic_rate:
if d.base_price_list_rate and d.base_rate:
price_list_rate += flt(d.base_price_list_rate)
basic_rate += flt(d.basic_rate)
if price_list_rate: av_dis = 100 - flt(basic_rate * 100 / price_list_rate)
base_rate += flt(d.base_rate)
if price_list_rate: av_dis = 100 - flt(base_rate * 100 / price_list_rate)
final_based_on = ['Grand Total','Average Discount','Customerwise Discount','Itemwise Discount']
# Individual User

View File

@ -134,15 +134,15 @@ var set_print_hide= function(doc, cdt, cdn){
if (doc.print_without_amount) {
dn_fields['currency'].print_hide = 1;
dn_item_fields['export_rate'].print_hide = 1;
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;
} else {
if (dn_fields_copy['currency'].print_hide != 1)
dn_fields['currency'].print_hide = 0;
if (dn_item_fields_copy['export_rate'].print_hide != 1)
dn_item_fields['export_rate'].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;
}

View File

@ -96,7 +96,7 @@ class DocType(SellingController):
super(DocType, self).validate_with_previous_doc(self.tname, {
fn[0] + " Item": {
"ref_dn_field": "prevdoc_detail_docname",
"compare_fields": [["export_rate", "="]],
"compare_fields": [["rate", "="]],
"is_child_table": True
}
})

View File

@ -37,7 +37,7 @@ class TestDeliveryNote(unittest.TestCase):
self.assertEquals(len(si), len(dn.doclist))
# modify export_amount
si[1].export_rate = 200
si[1].rate = 200
self.assertRaises(webnotes.ValidationError, webnotes.bean(si).insert)
@ -97,7 +97,7 @@ class TestDeliveryNote(unittest.TestCase):
# back dated purchase receipt
pr = webnotes.bean(copy=pr_test_records[0])
pr.doc.posting_date = "2013-01-01"
pr.doclist[1].import_rate = 100
pr.doclist[1].rate = 100
pr.doclist[1].amount = 100
pr.insert()
@ -243,8 +243,8 @@ test_records = [
"item_name": "_Test Item",
"parentfield": "delivery_note_details",
"qty": 5.0,
"basic_rate": 100.0,
"export_rate": 100.0,
"base_rate": 100.0,
"rate": 100.0,
"amount": 500.0,
"warehouse": "_Test Warehouse - _TC",
"stock_uom": "_Test UOM",

View File

@ -245,8 +245,7 @@ class DocType(DocListController):
self.recalculate_bin_qty(newdn)
def set_last_purchase_rate(self, newdn):
from erpnext.buying.utils import get_last_purchase_details
last_purchase_rate = get_last_purchase_details(newdn).get("purchase_rate", 0)
last_purchase_rate = get_last_purchase_details(newdn).get("base_rate", 0)
webnotes.conn.set_value("Item", newdn, "last_purchase_rate", last_purchase_rate)
def recalculate_bin_qty(self, newdn):
@ -311,7 +310,7 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
last_purchase_order = webnotes.conn.sql("""\
select po.name, po.transaction_date, po.conversion_rate,
po_item.conversion_factor, po_item.base_price_list_rate,
po_item.discount_percentage, po_item.purchase_rate
po_item.discount_percentage, po_item.base_rate
from `tabPurchase Order` po, `tabPurchase Order Item` po_item
where po.docstatus = 1 and po_item.item_code = %s and po.name != %s and
po.name = po_item.parent
@ -322,7 +321,7 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
last_purchase_receipt = webnotes.conn.sql("""\
select pr.name, pr.posting_date, pr.posting_time, pr.conversion_rate,
pr_item.conversion_factor, pr_item.base_price_list_rate, pr_item.discount_percentage,
pr_item.purchase_rate
pr_item.base_rate
from `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pr_item
where pr.docstatus = 1 and pr_item.item_code = %s and pr.name != %s and
pr.name = pr_item.parent
@ -352,7 +351,7 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
conversion_factor = flt(last_purchase.conversion_factor)
out = webnotes._dict({
"base_price_list_rate": flt(last_purchase.base_price_list_rate) / conversion_factor,
"purchase_rate": flt(last_purchase.purchase_rate) / conversion_factor,
"base_rate": flt(last_purchase.base_rate) / conversion_factor,
"discount_percentage": flt(last_purchase.discount_percentage),
"purchase_date": purchase_date
})
@ -360,8 +359,8 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
conversion_rate = flt(conversion_rate) or 1.0
out.update({
"price_list_rate": out.base_price_list_rate / conversion_rate,
"import_rate": out.purchase_rate / conversion_rate,
"rate": out.purchase_rate
"rate": out.base_rate / conversion_rate,
"base_rate": out.base_rate
})
return out

View File

@ -121,7 +121,7 @@ class DocType(BuyingController):
super(DocType, self).validate_with_previous_doc(self.tname, {
"Purchase Order Item": {
"ref_dn_field": "prevdoc_detail_docname",
"compare_fields": [["import_rate", "="]],
"compare_fields": [["rate", "="]],
"is_child_table": True
}
})
@ -316,7 +316,6 @@ def make_purchase_invoice(source_name, target_doclist=None):
"parent": "purchase_receipt",
"prevdoc_detail_docname": "po_detail",
"prevdoc_docname": "purchase_order",
"purchase_rate": "rate"
},
},
"Purchase Taxes and Charges": {

View File

@ -26,8 +26,8 @@ class TestPurchaseReceipt(unittest.TestCase):
self.assertEquals(pi[0]["doctype"], "Purchase Invoice")
self.assertEquals(len(pi), len(pr.doclist))
# modify import_rate
pi[1].import_rate = 200
# modify rate
pi[1].rate = 200
self.assertRaises(webnotes.ValidationError, webnotes.bean(pi).submit)
def test_purchase_receipt_no_gl_entry(self):
@ -155,7 +155,7 @@ test_records = [
"received_qty": 5.0,
"qty": 5.0,
"rejected_qty": 0.0,
"import_rate": 50.0,
"rate": 50.0,
"amount": 250.0,
"warehouse": "_Test Warehouse - _TC",
"stock_uom": "Nos",
@ -171,7 +171,7 @@ test_records = [
"received_qty": 5.0,
"qty": 5.0,
"rejected_qty": 0.0,
"import_rate": 50.0,
"rate": 50.0,
"amount": 250.0,
"warehouse": "_Test Warehouse 1 - _TC",
"stock_uom": "Nos",
@ -236,7 +236,7 @@ test_records = [
"received_qty": 10.0,
"qty": 10.0,
"rejected_qty": 0.0,
"import_rate": 500.0,
"rate": 500.0,
"amount": 5000.0,
"warehouse": "_Test Warehouse - _TC",
"stock_uom": "Nos",

View File

@ -562,7 +562,7 @@ class TestStockEntry(unittest.TestCase):
po = webnotes.bean(copy=purchase_order_test_records[0])
po.doc.is_subcontracted = None
po.doclist[1].item_code = "_Test Item"
po.doclist[1].import_rate = 50
po.doclist[1].rate = 50
po.insert()
po.submit()

View File

@ -80,7 +80,7 @@ def get_last_purchase_rate():
query = """select * from (select
result.item_code,
result.purchase_rate
result.base_rate
from (
(select
po_item.item_code,
@ -88,7 +88,7 @@ def get_last_purchase_rate():
po.transaction_date as posting_date,
po_item.base_price_list_rate,
po_item.discount_percentage,
po_item.purchase_rate
po_item.base_rate
from `tabPurchase Order` po, `tabPurchase Order Item` po_item
where po.name = po_item.parent and po.docstatus = 1)
union
@ -98,7 +98,7 @@ def get_last_purchase_rate():
pr.posting_date,
pr_item.base_price_list_rate,
pr_item.discount_percentage,
pr_item.purchase_rate
pr_item.base_rate
from `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pr_item
where pr.name = pr_item.parent and pr.docstatus = 1)
) result
@ -106,7 +106,7 @@ def get_last_purchase_rate():
group by item_code"""
for d in webnotes.conn.sql(query, as_dict=1):
item_last_purchase_rate_map.setdefault(d.item_code, d.purchase_rate)
item_last_purchase_rate_map.setdefault(d.item_code, d.base_rate)
return item_last_purchase_rate_map