Rename fields: initial commit

This commit is contained in:
Nabin Hait 2014-02-10 17:54:04 +05:30
parent 777397489e
commit a7f757a3f4
33 changed files with 229 additions and 230 deletions

View File

@ -109,7 +109,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
entries_add: function(doc, cdt, cdn) {
var row = wn.model.get_doc(cdt, cdn);
this.frm.script_manager.copy_from_first_row("entries", row, ["expense_head", "cost_center"]);
this.frm.script_manager.copy_from_first_row("entries", row, ["expense_account", "cost_center"]);
}
});
@ -175,19 +175,19 @@ return{
}
}
cur_frm.set_query("expense_head", "entries", function(doc) {
cur_frm.set_query("expense_account", "entries", function(doc) {
return{
query: "accounts.doctype.purchase_invoice.purchase_invoice.get_expense_account",
filters: {'company': doc.company}
}
});
cur_frm.cscript.expense_head = function(doc, cdt, cdn){
cur_frm.cscript.expense_account = function(doc, cdt, cdn){
var d = locals[cdt][cdn];
if(d.idx == 1 && d.expense_head){
if(d.idx == 1 && d.expense_account){
var cl = getchildren('Purchase Invoice Item', doc.name, 'entries', doc.doctype);
for(var i = 0; i < cl.length; i++){
if(!cl[i].expense_head) cl[i].expense_head = d.expense_head;
if(!cl[i].expense_account) cl[i].expense_account = d.expense_account;
}
}
refresh_field('entries');

View File

@ -201,19 +201,19 @@ class DocType(BuyingController):
and self.doc.is_opening == 'No':
# in case of auto inventory accounting, against expense account is always
# Stock Received But Not Billed for a stock item
item.expense_head = stock_not_billed_account
item.expense_account = stock_not_billed_account
item.cost_center = None
if stock_not_billed_account not in against_accounts:
against_accounts.append(stock_not_billed_account)
elif not item.expense_head:
elif not item.expense_account:
msgprint(_("Expense account is mandatory for item") + ": " +
(item.item_code or item.item_name), raise_exception=1)
elif item.expense_head not in against_accounts:
elif item.expense_account not in against_accounts:
# if no auto_accounting_for_stock or not a stock item
against_accounts.append(item.expense_head)
against_accounts.append(item.expense_account)
self.doc.against_expense_account = ",".join(against_accounts)
@ -347,7 +347,7 @@ class DocType(BuyingController):
gl_entries.append(
self.get_gl_dict({
"account": item.expense_head,
"account": item.expense_account,
"against": self.doc.credit_to,
"debit": valuation_amt,
"remarks": self.doc.remarks or "Accounting Entry for Stock"
@ -358,7 +358,7 @@ class DocType(BuyingController):
# if not a stock item or auto inventory accounting disabled, book the expense
gl_entries.append(
self.get_gl_dict({
"account": item.expense_head,
"account": item.expense_account,
"against": self.doc.credit_to,
"debit": item.amount,
"remarks": self.doc.remarks,

View File

@ -77,7 +77,7 @@ class TestPurchaseInvoice(unittest.TestCase):
pi = webnotes.bean(copy=test_records[1])
pi.doclist[1].item_code = "_Test Non Stock Item"
pi.doclist[1].expense_head = "_Test Account Cost for Goods Sold - _TC"
pi.doclist[1].expense_account = "_Test Account Cost for Goods Sold - _TC"
pi.doclist.pop(2)
pi.doclist.pop(3)
pi.run_method("calculate_taxes_and_totals")
@ -235,7 +235,7 @@ test_records = [
"amount": 500,
"uom": "_Test UOM",
"item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}),
"expense_head": "_Test Account Cost for Goods Sold - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC",
"conversion_factor": 1.0,
@ -251,7 +251,7 @@ test_records = [
"rate": 150,
"amount": 750,
"uom": "_Test UOM",
"expense_head": "_Test Account Cost for Goods Sold - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC",
"conversion_factor": 1.0,
},
@ -373,7 +373,7 @@ test_records = [
"qty": 10.0,
"import_rate": 50.0,
"uom": "_Test UOM",
"expense_head": "_Test Account Cost for Goods Sold - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC",
"conversion_factor": 1.0,
},

View File

@ -252,7 +252,7 @@ erpnext.POS = Class.extend({
</div>',
{
item_code: obj.name,
item_price: format_currency(obj.ref_rate, obj.currency),
item_price: format_currency(obj.price_list_rate, obj.currency),
item_name: obj.name===obj.item_name ? "" : obj.item_name,
item_image: image
})).appendTo($wrap);

View File

@ -22,9 +22,9 @@ def get_items(price_list, sales_or_purchase, item=None, item_group=None):
args["name"] = "%%%s%%" % item
return webnotes.conn.sql("""select i.name, i.item_name, i.image,
item_det.ref_rate, item_det.currency
item_det.price_list_rate, item_det.currency
from `tabItem` i LEFT JOIN
(select item_code, ref_rate, currency from
(select item_code, price_list_rate, currency from
`tabItem Price` where price_list=%s) item_det
ON
item_det.item_code=i.name

View File

@ -47,8 +47,8 @@ class TestSalesInvoice(unittest.TestCase):
si.insert()
expected_values = {
"keys": ["ref_rate", "adj_rate", "export_rate", "export_amount",
"base_ref_rate", "basic_rate", "amount"],
"keys": ["price_list_rate", "discount_percentage", "export_rate", "export_amount",
"base_price_list_rate", "basic_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],
}
@ -91,14 +91,14 @@ class TestSalesInvoice(unittest.TestCase):
si.doc.currency = "USD"
si.doc.conversion_rate = 50
si.doclist[1].export_rate = 1
si.doclist[1].ref_rate = 1
si.doclist[1].price_list_rate = 1
si.doclist[2].export_rate = 3
si.doclist[2].ref_rate = 3
si.doclist[2].price_list_rate = 3
si.insert()
expected_values = {
"keys": ["ref_rate", "adj_rate", "export_rate", "export_amount",
"base_ref_rate", "basic_rate", "amount"],
"keys": ["price_list_rate", "discount_percentage", "export_rate", "export_amount",
"base_price_list_rate", "basic_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": ["ref_rate", "adj_rate", "export_rate", "export_amount",
"base_ref_rate", "basic_rate", "amount"],
"keys": ["price_list_rate", "discount_percentage", "export_rate", "export_amount",
"base_price_list_rate", "basic_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],
}
@ -248,8 +248,8 @@ class TestSalesInvoice(unittest.TestCase):
for i, tax in enumerate(si.doclist.get({"parentfield": "other_charges"})):
tax.idx = i+1
si.doclist[1].ref_rate = 62.5
si.doclist[1].ref_rate = 191
si.doclist[1].price_list_rate = 62.5
si.doclist[1].price_list_rate = 191
for i in [3, 5, 6, 7, 8, 9]:
si.doclist[i].included_in_print_rate = 1
@ -266,8 +266,8 @@ class TestSalesInvoice(unittest.TestCase):
si.insert()
expected_values = {
"keys": ["ref_rate", "adj_rate", "export_rate", "export_amount",
"base_ref_rate", "basic_rate", "amount"],
"keys": ["price_list_rate", "discount_percentage", "export_rate", "export_amount",
"base_price_list_rate", "basic_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],
}
@ -310,17 +310,17 @@ class TestSalesInvoice(unittest.TestCase):
si = webnotes.bean(copy=test_records[3])
si.doc.currency = "USD"
si.doc.conversion_rate = 50
si.doclist[1].ref_rate = 55.56
si.doclist[1].adj_rate = 10
si.doclist[2].ref_rate = 187.5
si.doclist[2].adj_rate = 20
si.doclist[1].price_list_rate = 55.56
si.doclist[1].discount_percentage = 10
si.doclist[2].price_list_rate = 187.5
si.doclist[2].discount_percentage = 20
si.doclist[9].rate = 5000
si.insert()
expected_values = {
"keys": ["ref_rate", "adj_rate", "export_rate", "export_amount",
"base_ref_rate", "basic_rate", "amount"],
"keys": ["price_list_rate", "discount_percentage", "export_rate", "export_amount",
"base_price_list_rate", "basic_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],
}
@ -961,7 +961,7 @@ test_records = [
"qty": 1.0,
"basic_rate": 500.0,
"amount": 500.0,
"ref_rate": 500.0,
"price_list_rate": 500.0,
"export_amount": 500.0,
"income_account": "Sales - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
@ -1011,7 +1011,7 @@ test_records = [
"item_code": "_Test Item Home Desktop 100",
"item_name": "_Test Item Home Desktop 100",
"qty": 10,
"ref_rate": 50,
"price_list_rate": 50,
"export_rate": 50,
"stock_uom": "_Test UOM",
"item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}),
@ -1025,7 +1025,7 @@ test_records = [
"item_code": "_Test Item Home Desktop 200",
"item_name": "_Test Item Home Desktop 200",
"qty": 5,
"ref_rate": 150,
"price_list_rate": 150,
"export_rate": 150,
"stock_uom": "_Test UOM",
"income_account": "Sales - _TC",
@ -1137,7 +1137,7 @@ test_records = [
"item_code": "_Test Item Home Desktop 100",
"item_name": "_Test Item Home Desktop 100",
"qty": 10,
"ref_rate": 62.5,
"price_list_rate": 62.5,
"stock_uom": "_Test UOM",
"item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}),
"income_account": "Sales - _TC",
@ -1150,7 +1150,7 @@ test_records = [
"item_code": "_Test Item Home Desktop 200",
"item_name": "_Test Item Home Desktop 200",
"qty": 5,
"ref_rate": 190.66,
"price_list_rate": 190.66,
"stock_uom": "_Test UOM",
"income_account": "Sales - _TC",
"cost_center": "_Test Cost Center - _TC",

View File

@ -17,10 +17,10 @@ def execute(filters=None):
data = []
for d in item_list:
expense_head = d.expense_head 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,
d.supplier_name, d.credit_to, d.project_name, d.company, d.purchase_order,
d.purchase_receipt, expense_head, d.qty, d.rate, d.amount]
d.purchase_receipt, expense_account, d.qty, d.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_head, pi_item.qty, pi_item.rate, pi_item.amount, pi.supplier_name
pi_item.expense_account, pi_item.qty, pi_item.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

@ -72,9 +72,9 @@ def get_columns(invoice_list):
expense_accounts = tax_accounts = expense_columns = tax_columns = []
if invoice_list:
expense_accounts = webnotes.conn.sql_list("""select distinct expense_head
from `tabPurchase Invoice Item` where docstatus = 1 and ifnull(expense_head, '') != ''
and parent in (%s) order by expense_head""" %
expense_accounts = webnotes.conn.sql_list("""select distinct expense_account
from `tabPurchase Invoice Item` where docstatus = 1 and ifnull(expense_account, '') != ''
and parent in (%s) order by expense_account""" %
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
tax_accounts = webnotes.conn.sql_list("""select distinct account_head
@ -116,14 +116,14 @@ def get_invoices(filters):
def get_invoice_expense_map(invoice_list):
expense_details = webnotes.conn.sql("""select parent, expense_head, sum(amount) as amount
from `tabPurchase Invoice Item` where parent in (%s) group by parent, expense_head""" %
expense_details = webnotes.conn.sql("""select parent, expense_account, sum(amount) as amount
from `tabPurchase Invoice Item` where parent in (%s) group by parent, expense_account""" %
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
invoice_expense_map = {}
for d in expense_details:
invoice_expense_map.setdefault(d.parent, webnotes._dict()).setdefault(d.expense_head, [])
invoice_expense_map[d.parent][d.expense_head] = flt(d.amount)
invoice_expense_map.setdefault(d.parent, webnotes._dict()).setdefault(d.expense_account, [])
invoice_expense_map[d.parent][d.expense_account] = flt(d.amount)
return invoice_expense_map

View File

@ -102,7 +102,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
},
callback: function(r) {
if(!r.exc) {
me.frm.script_manager.trigger("import_ref_rate", cdt, cdn);
me.frm.script_manager.trigger("price_list_rate", cdt, cdn);
}
}
});
@ -114,29 +114,29 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
this.get_price_list_currency("Buying");
},
import_ref_rate: function(doc, cdt, cdn) {
price_list_rate: function(doc, cdt, cdn) {
var item = wn.model.get_doc(cdt, cdn);
wn.model.round_floats_in(item, ["import_ref_rate", "discount_rate"]);
wn.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]);
item.import_rate = flt(item.import_ref_rate * (1 - item.discount_rate / 100.0),
item.import_rate = flt(item.price_list_rate * (1 - item.discount_percentage / 100.0),
precision("import_rate", item));
this.calculate_taxes_and_totals();
},
discount_rate: function(doc, cdt, cdn) {
this.import_ref_rate(doc, cdt, cdn);
discount_percentage: function(doc, cdt, cdn) {
this.price_list_rate(doc, cdt, cdn);
},
import_rate: function(doc, cdt, cdn) {
var item = wn.model.get_doc(cdt, cdn);
wn.model.round_floats_in(item, ["import_rate", "discount_rate"]);
wn.model.round_floats_in(item, ["import_rate", "discount_percentage"]);
if(item.import_ref_rate) {
item.discount_rate = flt((1 - item.import_rate / item.import_ref_rate) * 100.0,
precision("discount_rate", item));
if(item.price_list_rate) {
item.discount_percentage = flt((1 - item.import_rate / item.price_list_rate) * 100.0,
precision("discount_percentage", item));
} else {
item.discount_rate = 0.0;
item.discount_percentage = 0.0;
}
this.calculate_taxes_and_totals();
@ -235,7 +235,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
item.import_amount = flt(item.import_rate * item.qty, precision("import_amount", item));
item.item_tax_amount = 0.0;
me._set_in_company_currency(item, "import_ref_rate", "purchase_ref_rate");
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, "import_amount", "amount");
});
@ -414,10 +414,10 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
});
};
setup_field_label_map(["purchase_rate", "purchase_ref_rate", "amount", "rate"],
setup_field_label_map(["purchase_rate", "base_price_list_rate", "amount", "rate"],
company_currency, this.fname);
setup_field_label_map(["import_rate", "import_ref_rate", "import_amount"],
setup_field_label_map(["import_rate", "price_list_rate", "import_amount"],
this.frm.doc.currency, this.fname);
if(this.frm.fields_dict[this.other_fname]) {
@ -431,7 +431,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
// toggle columns
var item_grid = this.frm.fields_dict[this.fname].grid;
var fieldnames = $.map(["purchase_rate", "purchase_ref_rate", "amount", "rate"], function(fname) {
var fieldnames = $.map(["purchase_rate", "base_price_list_rate", "amount", "rate"], function(fname) {
return wn.meta.get_docfield(item_grid.doctype, fname, me.frm.docname) ? fname : null;
});

View File

@ -55,19 +55,19 @@ class DocType(BuyingController):
last_purchase_details = get_last_purchase_details(d.item_code, doc_name)
if last_purchase_details:
d.purchase_ref_rate = last_purchase_details['purchase_ref_rate'] * (flt(d.conversion_factor) or 1.0)
d.discount_rate = last_purchase_details['discount_rate']
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.import_ref_rate = d.purchase_ref_rate / conversion_rate
d.price_list_rate = d.base_price_list_rate / conversion_rate
d.import_rate = d.purchase_rate / conversion_rate
else:
# if no last purchase found, reset all values to 0
d.purchase_ref_rate = d.purchase_rate = d.import_ref_rate = d.import_rate = d.discount_rate = 0
d.base_price_list_rate = d.purchase_rate = d.price_list_rate = d.import_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.purchase_ref_rate = d.purchase_rate = d.import_ref_rate \
d.base_price_list_rate = d.purchase_rate = d.price_list_rate \
= d.import_rate = item_last_purchase_rate
def validate_for_items(self, obj):

View File

@ -91,10 +91,10 @@ class BuyingController(StockController):
self.round_floats_in(item)
if item.discount_rate == 100.0:
if item.discount_percentage == 100.0:
item.import_rate = 0.0
elif not item.import_rate:
item.import_rate = flt(item.import_ref_rate * (1.0 - (item.discount_rate / 100.0)),
item.import_rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)),
self.precision("import_rate", item))
item.import_amount = flt(item.import_rate * item.qty,
@ -102,7 +102,7 @@ class BuyingController(StockController):
item.item_tax_amount = 0.0;
self._set_in_company_currency(item, "import_amount", "amount")
self._set_in_company_currency(item, "import_ref_rate", "purchase_ref_rate")
self._set_in_company_currency(item, "price_list_rate", "base_price_list_rate")
self._set_in_company_currency(item, "import_rate", "rate")

View File

@ -117,12 +117,12 @@ class SellingController(StockController):
item.basic_rate = flt(item.amount / item.qty, self.precision("basic_rate", item))
if item.adj_rate == 100:
item.base_ref_rate = item.basic_rate
if item.discount_percentage == 100:
item.base_price_list_rate = item.basic_rate
item.basic_rate = 0.0
else:
item.base_ref_rate = flt(item.basic_rate / (1 - (item.adj_rate / 100.0)),
self.precision("base_ref_rate", item))
item.base_price_list_rate = flt(item.basic_rate / (1 - (item.discount_percentage / 100.0)),
self.precision("base_price_list_rate", item))
def get_current_tax_fraction(self, tax, item_tax_map):
"""
@ -152,16 +152,16 @@ class SellingController(StockController):
for item in self.item_doclist:
self.round_floats_in(item)
if item.adj_rate == 100:
if item.discount_percentage == 100:
item.export_rate = 0
elif not item.export_rate:
item.export_rate = flt(item.ref_rate * (1.0 - (item.adj_rate / 100.0)),
item.export_rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)),
self.precision("export_rate", item))
item.export_amount = flt(item.export_rate * item.qty,
self.precision("export_amount", item))
self._set_in_company_currency(item, "ref_rate", "base_ref_rate")
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, "export_amount", "amount")
@ -281,22 +281,22 @@ class SellingController(StockController):
for d in self.doclist.get({"parentfield": self.fname}):
discount = flt(webnotes.conn.get_value("Item", d.item_code, "max_discount"))
if discount and flt(d.adj_rate) > discount:
if discount and flt(d.discount_percentage) > discount:
webnotes.throw(_("You cannot give more than ") + cstr(discount) + "% " +
_("discount on Item Code") + ": " + cstr(d.item_code))
def get_item_list(self):
il = []
for d in self.doclist.get({"parentfield": self.fname}):
reserved_warehouse = ""
warehouse = ""
reserved_qty_for_main_item = 0
if self.doc.doctype == "Sales Order":
if (webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == 'Yes' or
self.has_sales_bom(d.item_code)) and not d.reserved_warehouse:
self.has_sales_bom(d.item_code)) and not d.warehouse:
webnotes.throw(_("Please enter Reserved Warehouse for item ") +
d.item_code + _(" as it is stock Item or packing item"))
reserved_warehouse = d.reserved_warehouse
warehouse = d.warehouse
if flt(d.qty) > flt(d.delivered_qty):
reserved_qty_for_main_item = flt(d.qty) - flt(d.delivered_qty)
@ -306,7 +306,7 @@ class SellingController(StockController):
already_delivered_qty = self.get_already_delivered_qty(self.doc.name,
d.against_sales_order, d.prevdoc_detail_docname)
so_qty, reserved_warehouse = self.get_so_qty_and_warehouse(d.prevdoc_detail_docname)
so_qty, warehouse = self.get_so_qty_and_warehouse(d.prevdoc_detail_docname)
if already_delivered_qty + d.qty > so_qty:
reserved_qty_for_main_item = -(so_qty - already_delivered_qty)
@ -319,7 +319,7 @@ class SellingController(StockController):
# the packing details table's qty is already multiplied with parent's qty
il.append(webnotes._dict({
'warehouse': p.warehouse,
'reserved_warehouse': reserved_warehouse,
'warehouse': warehouse,
'item_code': p.item_code,
'qty': flt(p.qty),
'reserved_qty': (flt(p.qty)/flt(d.qty)) * reserved_qty_for_main_item,
@ -331,7 +331,7 @@ class SellingController(StockController):
else:
il.append(webnotes._dict({
'warehouse': d.warehouse,
'reserved_warehouse': reserved_warehouse,
'warehouse': warehouse,
'item_code': d.item_code,
'qty': d.qty,
'reserved_qty': reserved_qty_for_main_item,
@ -354,10 +354,10 @@ class SellingController(StockController):
return qty and flt(qty[0][0]) or 0.0
def get_so_qty_and_warehouse(self, so_detail):
so_item = webnotes.conn.sql("""select qty, reserved_warehouse from `tabSales Order Item`
so_item = webnotes.conn.sql("""select qty, warehouse from `tabSales Order Item`
where name = %s and docstatus = 1""", so_detail, as_dict=1)
so_qty = so_item and flt(so_item[0]["qty"]) or 0.0
so_warehouse = so_item and so_item[0]["reserved_warehouse"] or ""
so_warehouse = so_item and so_item[0]["warehouse"] or ""
return so_qty, so_warehouse
def check_stop_sales_order(self, ref_fieldname):

View File

@ -121,7 +121,7 @@ class DocType:
if not self.doc.buying_price_list:
webnotes.throw(_("Please select Price List"))
rate = webnotes.conn.get_value("Item Price", {"price_list": self.doc.buying_price_list,
"item_code": arg["item_code"]}, "ref_rate") or 0
"item_code": arg["item_code"]}, "price_list_rate") or 0
elif self.doc.rm_cost_as_per == 'Standard Rate':
rate = arg['standard_rate']
@ -415,8 +415,8 @@ def get_bom_items_as_dict(bom, qty=1, fetch_exploded=1):
item.description,
item.stock_uom,
item.default_warehouse,
item.purchase_account as expense_account,
item.cost_center
item.expense_account as expense_account,
item.buying_cost_center
from
`tab%(table)s` bom_item, `tabItem` item
where

View File

@ -108,7 +108,7 @@ class DocType:
msgprint(_("Please enter sales order in the above table"))
return []
items = webnotes.conn.sql("""select distinct parent, item_code, reserved_warehouse,
items = webnotes.conn.sql("""select distinct parent, item_code, warehouse,
(qty - ifnull(delivered_qty, 0)) as pending_qty
from `tabSales Order Item` so_item
where parent in (%s) and docstatus = 1 and ifnull(qty, 0) > ifnull(delivered_qty, 0)
@ -140,7 +140,7 @@ class DocType:
from tabItem where name=%s""", p['item_code'])
pi = addchild(self.doc, 'pp_details', 'Production Plan Item', self.doclist)
pi.sales_order = p['parent']
pi.warehouse = p['reserved_warehouse']
pi.warehouse = p['warehouse']
pi.item_code = p['item_code']
pi.description = item_details and item_details[0][0] or ''
pi.stock_uom = item_details and item_details[0][1] or ''

View File

@ -31,15 +31,15 @@ pscript.feature_dict = {
//'Sales Order': {'fields':['packing_details']}
},
'fs_discounts': {
'Delivery Note': {'delivery_note_details':['adj_rate']},
'Quotation': {'quotation_details':['adj_rate']},
'Sales Invoice': {'entries':['adj_rate']},
'Sales Order': {'sales_order_details':['adj_rate','ref_rate']}
'Delivery Note': {'delivery_note_details':['discount_percentage']},
'Quotation': {'quotation_details':['discount_percentage']},
'Sales Invoice': {'entries':['discount_percentage']},
'Sales Order': {'sales_order_details':['discount_percentage','price_list_rate']}
},
'fs_purchase_discounts': {
'Purchase Order': {'po_details':['purchase_ref_rate', 'discount_rate', 'import_ref_rate']},
'Purchase Receipt': {'purchase_receipt_details':['purchase_ref_rate', 'discount_rate', 'import_ref_rate']},
'Purchase Invoice': {'entries':['purchase_ref_rate', 'discount_rate', 'import_ref_rate']}
'Purchase Order': {'po_details':['base_price_list_rate', 'discount_percentage', 'price_list_rate']},
'Purchase Receipt': {'purchase_receipt_details':['base_price_list_rate', 'discount_percentage', 'price_list_rate']},
'Purchase Invoice': {'entries':['base_price_list_rate', 'discount_percentage', 'price_list_rate']}
},
'fs_brands': {
'Delivery Note': {'delivery_note_details':['brand']},
@ -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_ref_rate','amount','basic_rate']},
'Delivery Note': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'delivery_note_details':['base_price_list_rate','amount','basic_rate']},
'POS Setting': {'fields':['conversion_rate','currency']},
'Quotation': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'quotation_details':['base_ref_rate','amount','basic_rate']},
'Sales Invoice': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'entries':['base_ref_rate','amount','basic_rate']},
'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']},
'Sales BOM': {'fields':['currency']},
'Sales Order': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'sales_order_details':['base_ref_rate','amount','basic_rate']}
'Sales Order': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'sales_order_details':['base_price_list_rate','amount','basic_rate']}
},
'fs_imports': {
@ -127,18 +127,18 @@ pscript.feature_dict = {
'fields': ['conversion_rate', 'currency', 'grand_total',
'in_words', 'net_total', 'other_charges_added',
'other_charges_deducted'],
'entries': ['purchase_ref_rate', 'amount','rate']
'entries': ['base_price_list_rate', 'amount','rate']
},
'Purchase Order': {
'fields': ['conversion_rate','currency', 'grand_total',
'in_words', 'net_total', 'other_charges_added',
'other_charges_deducted'],
'po_details': ['purchase_ref_rate', 'amount','purchase_rate']
'po_details': ['base_price_list_rate', 'amount','purchase_rate']
},
'Purchase Receipt': {
'fields': ['conversion_rate', 'currency','grand_total', 'in_words',
'net_total', 'other_charges_added', 'other_charges_deducted'],
'purchase_receipt_details': ['purchase_ref_rate','amount','purchase_rate']
'purchase_receipt_details': ['base_price_list_rate','amount','purchase_rate']
},
'Supplier Quotation': {
'fields':['conversion_rate','currency']

View File

@ -85,15 +85,15 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
this.get_terms();
},
reserved_warehouse: function(doc, cdt, cdn) {
warehouse: function(doc, cdt, cdn) {
var item = wn.model.get_doc(cdt, cdn);
if(item.item_code && item.reserved_warehouse) {
if(item.item_code && item.warehouse) {
return this.frm.call({
method: "erpnext.selling.utils.get_available_qty",
child: item,
args: {
item_code: item.item_code,
warehouse: item.reserved_warehouse,
warehouse: item.warehouse,
},
});
}

View File

@ -49,11 +49,11 @@ class DocType(SellingController):
check_list, flag = [], 0
chk_dupl_itm = []
for d in getlist(self.doclist, 'sales_order_details'):
e = [d.item_code, d.description, d.reserved_warehouse, d.prevdoc_docname or '']
e = [d.item_code, d.description, d.warehouse, d.prevdoc_docname or '']
f = [d.item_code, d.description]
if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == 'Yes':
if not d.reserved_warehouse:
if not d.warehouse:
msgprint("""Please enter Reserved Warehouse for item %s
as it is stock Item""" % d.item_code, raise_exception=1)
@ -71,7 +71,7 @@ class DocType(SellingController):
d.transaction_date = self.doc.transaction_date
tot_avail_qty = webnotes.conn.sql("select projected_qty from `tabBin` \
where item_code = '%s' and warehouse = '%s'" % (d.item_code,d.reserved_warehouse))
where item_code = '%s' and warehouse = '%s'" % (d.item_code,d.warehouse))
d.projected_qty = tot_avail_qty and flt(tot_avail_qty[0][0]) or 0
def validate_sales_mntc_quotation(self):
@ -130,8 +130,8 @@ class DocType(SellingController):
def validate_warehouse(self):
from erpnext.stock.utils import validate_warehouse_company
warehouses = list(set([d.reserved_warehouse for d in
self.doclist.get({"doctype": self.tname}) if d.reserved_warehouse]))
warehouses = list(set([d.warehouse for d in
self.doclist.get({"doctype": self.tname}) if d.warehouse]))
for w in warehouses:
validate_warehouse_company(w, self.doc.company)
@ -235,7 +235,7 @@ class DocType(SellingController):
if webnotes.conn.get_value("Item", d['item_code'], "is_stock_item") == "Yes":
args = {
"item_code": d['item_code'],
"warehouse": d['reserved_warehouse'],
"warehouse": d['warehouse'],
"reserved_qty": flt(update_stock) * flt(d['reserved_qty']),
"posting_date": self.doc.transaction_date,
"voucher_type": self.doc.doctype,
@ -270,7 +270,7 @@ def make_material_request(source_name, target_doclist=None):
"doctype": "Material Request Item",
"field_map": {
"parent": "sales_order_no",
"reserved_warehouse": "warehouse",
"warehouse": "warehouse",
"stock_uom": "uom"
}
}
@ -302,7 +302,7 @@ def make_delivery_note(source_name, target_doclist=None):
"export_rate": "export_rate",
"name": "prevdoc_detail_docname",
"parent": "against_sales_order",
"reserved_warehouse": "warehouse"
"warehouse": "warehouse"
},
"postprocess": update_item,
"condition": lambda doc: doc.delivered_qty < doc.qty
@ -343,7 +343,7 @@ def make_sales_invoice(source_name, target_doclist=None):
"field_map": {
"name": "so_detail",
"parent": "sales_order",
"reserved_warehouse": "warehouse"
"warehouse": "warehouse"
},
"postprocess": update_item,
"condition": lambda doc: doc.amount==0 or doc.billed_amt < doc.export_amount

View File

@ -106,20 +106,20 @@ class TestSalesOrder(unittest.TestCase):
def test_reserved_qty_for_so(self):
# reset bin
self.delete_bin(test_records[0][1]["item_code"], test_records[0][1]["reserved_warehouse"])
self.delete_bin(test_records[0][1]["item_code"], test_records[0][1]["warehouse"])
# submit
so = self.create_so()
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].reserved_warehouse, 10.0)
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 10.0)
# cancel
so.cancel()
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].reserved_warehouse, 0.0)
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 0.0)
def test_reserved_qty_for_partial_delivery(self):
# reset bin
self.delete_bin(test_records[0][1]["item_code"], test_records[0][1]["reserved_warehouse"])
self.delete_bin(test_records[0][1]["item_code"], test_records[0][1]["warehouse"])
# submit so
so = self.create_so()
@ -130,25 +130,25 @@ class TestSalesOrder(unittest.TestCase):
# submit dn
dn = self.create_dn_against_so(so)
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].reserved_warehouse, 5.0)
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 5.0)
# stop so
so.load_from_db()
so.obj.stop_sales_order()
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].reserved_warehouse, 0.0)
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 0.0)
# unstop so
so.load_from_db()
so.obj.unstop_sales_order()
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].reserved_warehouse, 5.0)
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 5.0)
# cancel dn
dn.cancel()
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].reserved_warehouse, 10.0)
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 10.0)
def test_reserved_qty_for_over_delivery(self):
# reset bin
self.delete_bin(test_records[0][1]["item_code"], test_records[0][1]["reserved_warehouse"])
self.delete_bin(test_records[0][1]["item_code"], test_records[0][1]["warehouse"])
# submit so
so = self.create_so()
@ -161,11 +161,11 @@ class TestSalesOrder(unittest.TestCase):
# submit dn
dn = self.create_dn_against_so(so, 15)
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].reserved_warehouse, 0.0)
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 0.0)
# cancel dn
dn.cancel()
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].reserved_warehouse, 10.0)
self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 10.0)
def test_reserved_qty_for_so_with_packing_list(self):
from erpnext.selling.doctype.sales_bom.test_sales_bom import test_records as sbom_test_records
@ -175,24 +175,24 @@ class TestSalesOrder(unittest.TestCase):
test_record[1]["item_code"] = "_Test Sales BOM Item"
# reset bin
self.delete_bin(sbom_test_records[0][1]["item_code"], test_record[1]["reserved_warehouse"])
self.delete_bin(sbom_test_records[0][2]["item_code"], test_record[1]["reserved_warehouse"])
self.delete_bin(sbom_test_records[0][1]["item_code"], test_record[1]["warehouse"])
self.delete_bin(sbom_test_records[0][2]["item_code"], test_record[1]["warehouse"])
# submit
so = self.create_so(test_record)
self.check_reserved_qty(sbom_test_records[0][1]["item_code"],
so.doclist[1].reserved_warehouse, 50.0)
so.doclist[1].warehouse, 50.0)
self.check_reserved_qty(sbom_test_records[0][2]["item_code"],
so.doclist[1].reserved_warehouse, 20.0)
so.doclist[1].warehouse, 20.0)
# cancel
so.cancel()
self.check_reserved_qty(sbom_test_records[0][1]["item_code"],
so.doclist[1].reserved_warehouse, 0.0)
so.doclist[1].warehouse, 0.0)
self.check_reserved_qty(sbom_test_records[0][2]["item_code"],
so.doclist[1].reserved_warehouse, 0.0)
so.doclist[1].warehouse, 0.0)
def test_reserved_qty_for_partial_delivery_with_packing_list(self):
from erpnext.selling.doctype.sales_bom.test_sales_bom import test_records as sbom_test_records
@ -203,8 +203,8 @@ class TestSalesOrder(unittest.TestCase):
test_record[1]["item_code"] = "_Test Sales BOM Item"
# reset bin
self.delete_bin(sbom_test_records[0][1]["item_code"], test_record[1]["reserved_warehouse"])
self.delete_bin(sbom_test_records[0][2]["item_code"], test_record[1]["reserved_warehouse"])
self.delete_bin(sbom_test_records[0][1]["item_code"], test_record[1]["warehouse"])
self.delete_bin(sbom_test_records[0][2]["item_code"], test_record[1]["warehouse"])
# submit
so = self.create_so(test_record)
@ -216,33 +216,33 @@ class TestSalesOrder(unittest.TestCase):
dn = self.create_dn_against_so(so)
self.check_reserved_qty(sbom_test_records[0][1]["item_code"],
so.doclist[1].reserved_warehouse, 25.0)
so.doclist[1].warehouse, 25.0)
self.check_reserved_qty(sbom_test_records[0][2]["item_code"],
so.doclist[1].reserved_warehouse, 10.0)
so.doclist[1].warehouse, 10.0)
# stop so
so.load_from_db()
so.obj.stop_sales_order()
self.check_reserved_qty(sbom_test_records[0][1]["item_code"],
so.doclist[1].reserved_warehouse, 0.0)
so.doclist[1].warehouse, 0.0)
self.check_reserved_qty(sbom_test_records[0][2]["item_code"],
so.doclist[1].reserved_warehouse, 0.0)
so.doclist[1].warehouse, 0.0)
# unstop so
so.load_from_db()
so.obj.unstop_sales_order()
self.check_reserved_qty(sbom_test_records[0][1]["item_code"],
so.doclist[1].reserved_warehouse, 25.0)
so.doclist[1].warehouse, 25.0)
self.check_reserved_qty(sbom_test_records[0][2]["item_code"],
so.doclist[1].reserved_warehouse, 10.0)
so.doclist[1].warehouse, 10.0)
# cancel dn
dn.cancel()
self.check_reserved_qty(sbom_test_records[0][1]["item_code"],
so.doclist[1].reserved_warehouse, 50.0)
so.doclist[1].warehouse, 50.0)
self.check_reserved_qty(sbom_test_records[0][2]["item_code"],
so.doclist[1].reserved_warehouse, 20.0)
so.doclist[1].warehouse, 20.0)
def test_reserved_qty_for_over_delivery_with_packing_list(self):
from erpnext.selling.doctype.sales_bom.test_sales_bom import test_records as sbom_test_records
@ -252,8 +252,8 @@ class TestSalesOrder(unittest.TestCase):
test_record[1]["item_code"] = "_Test Sales BOM Item"
# reset bin
self.delete_bin(sbom_test_records[0][1]["item_code"], test_record[1]["reserved_warehouse"])
self.delete_bin(sbom_test_records[0][2]["item_code"], test_record[1]["reserved_warehouse"])
self.delete_bin(sbom_test_records[0][1]["item_code"], test_record[1]["warehouse"])
self.delete_bin(sbom_test_records[0][2]["item_code"], test_record[1]["warehouse"])
# submit
so = self.create_so(test_record)
@ -268,16 +268,16 @@ class TestSalesOrder(unittest.TestCase):
dn = self.create_dn_against_so(so, 15)
self.check_reserved_qty(sbom_test_records[0][1]["item_code"],
so.doclist[1].reserved_warehouse, 0.0)
so.doclist[1].warehouse, 0.0)
self.check_reserved_qty(sbom_test_records[0][2]["item_code"],
so.doclist[1].reserved_warehouse, 0.0)
so.doclist[1].warehouse, 0.0)
# cancel dn
dn.cancel()
self.check_reserved_qty(sbom_test_records[0][1]["item_code"],
so.doclist[1].reserved_warehouse, 50.0)
so.doclist[1].warehouse, 50.0)
self.check_reserved_qty(sbom_test_records[0][2]["item_code"],
so.doclist[1].reserved_warehouse, 20.0)
so.doclist[1].warehouse, 20.0)
def test_warehouse_user(self):
webnotes.defaults.add_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", "Restriction")
@ -294,7 +294,7 @@ class TestSalesOrder(unittest.TestCase):
so.doc.company = "_Test Company 1"
so.doc.conversion_rate = 0.02
so.doc.plc_conversion_rate = 0.02
so.doclist[1].reserved_warehouse = "_Test Warehouse 2 - _TC1"
so.doclist[1].warehouse = "_Test Warehouse 2 - _TC1"
self.assertRaises(BeanPermissionError, so.insert)
webnotes.set_user("test2@example.com")
@ -336,7 +336,7 @@ test_records = [
"basic_rate": 100.0,
"export_rate": 100.0,
"amount": 1000.0,
"reserved_warehouse": "_Test Warehouse - _TC",
"warehouse": "_Test Warehouse - _TC",
}
],
]

View File

@ -151,7 +151,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
},
callback: function(r) {
if(!r.exc) {
me.frm.script_manager.trigger("ref_rate", cdt, cdn);
me.frm.script_manager.trigger("price_list_rate", cdt, cdn);
}
}
});
@ -163,34 +163,34 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
this.get_price_list_currency("Selling");
},
ref_rate: function(doc, cdt, cdn) {
price_list_rate: function(doc, cdt, cdn) {
var item = wn.model.get_doc(cdt, cdn);
wn.model.round_floats_in(item, ["ref_rate", "adj_rate"]);
wn.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]);
item.export_rate = flt(item.ref_rate * (1 - item.adj_rate / 100.0),
item.export_rate = flt(item.price_list_rate * (1 - item.discount_percentage / 100.0),
precision("export_rate", item));
this.calculate_taxes_and_totals();
},
adj_rate: function(doc, cdt, cdn) {
discount_percentage: function(doc, cdt, cdn) {
var item = wn.model.get_doc(cdt, cdn);
if(!item.ref_rate) {
item.adj_rate = 0.0;
if(!item.price_list_rate) {
item.discount_percentage = 0.0;
} else {
this.ref_rate(doc, cdt, cdn);
this.price_list_rate(doc, cdt, cdn);
}
},
export_rate: function(doc, cdt, cdn) {
var item = wn.model.get_doc(cdt, cdn);
wn.model.round_floats_in(item, ["export_rate", "ref_rate"]);
wn.model.round_floats_in(item, ["export_rate", "price_list_rate"]);
if(item.ref_rate) {
item.adj_rate = flt((1 - item.export_rate / item.ref_rate) * 100.0,
precision("adj_rate", item));
if(item.price_list_rate) {
item.discount_percentage = flt((1 - item.export_rate / item.price_list_rate) * 100.0,
precision("discount_percentage", item));
} else {
item.adj_rate = 0.0;
item.discount_percentage = 0.0;
}
this.calculate_taxes_and_totals();
@ -263,7 +263,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
},
toggle_editable_price_list_rate: function() {
var df = wn.meta.get_docfield(this.tname, "ref_rate", this.frm.doc.name);
var df = wn.meta.get_docfield(this.tname, "price_list_rate", this.frm.doc.name);
var editable_price_list_rate = cint(wn.defaults.get_default("editable_price_list_rate"));
if(df && editable_price_list_rate) {
@ -290,7 +290,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
wn.model.round_floats_in(item);
item.export_amount = flt(item.export_rate * item.qty, precision("export_amount", item));
me._set_in_company_currency(item, "ref_rate", "base_ref_rate");
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, "export_amount", "amount");
});
@ -324,12 +324,12 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
item.basic_rate = flt(item.amount / item.qty, precision("basic_rate", item));
if(item.adj_rate == 100) {
item.base_ref_rate = item.basic_rate;
if(item.discount_percentage == 100) {
item.base_price_list_rate = item.basic_rate;
item.basic_rate = 0.0;
} else {
item.base_ref_rate = flt(item.basic_rate / (1 - item.adj_rate / 100.0),
precision("base_ref_rate", item));
item.base_price_list_rate = flt(item.basic_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_ref_rate", "amount"],
setup_field_label_map(["basic_rate", "base_price_list_rate", "amount"],
company_currency, this.fname);
setup_field_label_map(["export_rate", "ref_rate", "export_amount"],
setup_field_label_map(["export_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_ref_rate", "amount"], function(i, fname) {
$.each(["basic_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

@ -89,7 +89,7 @@ class DocType(TransactionBase):
if based_on == 'Itemwise Discount':
if doc_obj:
for t in getlist(doc_obj.doclist, doc_obj.fname):
self.validate_auth_rule(doctype_name, t.adj_rate, based_on, add_cond, company,t.item_code )
self.validate_auth_rule(doctype_name, t.discount_percentage, based_on, add_cond, company,t.item_code )
else:
self.validate_auth_rule(doctype_name, auth_value, based_on, add_cond, company)
@ -99,12 +99,12 @@ class DocType(TransactionBase):
def validate_approving_authority(self, doctype_name,company, total, doc_obj = ''):
av_dis = 0
if doc_obj:
ref_rate, basic_rate = 0, 0
price_list_rate, basic_rate = 0, 0
for d in getlist(doc_obj.doclist, doc_obj.fname):
if d.base_ref_rate and d.basic_rate:
ref_rate += flt(d.base_ref_rate)
if d.base_price_list_rate and d.basic_rate:
price_list_rate += flt(d.base_price_list_rate)
basic_rate += flt(d.basic_rate)
if ref_rate: av_dis = 100 - flt(basic_rate * 100 / ref_rate)
if price_list_rate: av_dis = 100 - flt(basic_rate * 100 / price_list_rate)
final_based_on = ['Grand Total','Average Discount','Customerwise Discount','Itemwise Discount']
# Individual User

View File

@ -132,11 +132,10 @@ data_map = {
},
"Sales Order Item": {
"columns": ["item.name as name", "item_code", "(ifnull(qty, 0) - ifnull(delivered_qty, 0)) as qty",
"reserved_warehouse as warehouse"],
"columns": ["item.name as name", "item_code", "(ifnull(qty, 0) - ifnull(delivered_qty, 0)) as qty", "warehouse"],
"from": "`tabSales Order Item` item, `tabSales Order` main",
"conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
"ifnull(reserved_warehouse, '')!=''", "ifnull(qty, 0) > ifnull(delivered_qty, 0)"],
"ifnull(warehouse, '')!=''", "ifnull(qty, 0) > ifnull(delivered_qty, 0)"],
"links": {
"item_code": ["Item", "name"],
"warehouse": ["Warehouse", "name"]

View File

@ -135,8 +135,8 @@ 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['adj_rate'].print_hide = 1;
dn_item_fields['ref_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)

View File

@ -242,12 +242,12 @@ class DocType(SellingController):
def update_reserved_qty(self, d):
if d['reserved_qty'] < 0 :
# Reduce reserved qty from reserved warehouse mentioned in so
if not d["reserved_warehouse"]:
if not d["warehouse"]:
webnotes.throw(_("Reserved Warehouse is missing in Sales Order"))
args = {
"item_code": d['item_code'],
"warehouse": d["reserved_warehouse"],
"warehouse": d["warehouse"],
"voucher_type": self.doc.doctype,
"voucher_no": self.doc.name,
"reserved_qty": (self.doc.docstatus==1 and 1 or -1)*flt(d['reserved_qty']),

View File

@ -52,7 +52,7 @@ cur_frm.fields_dict['default_bom'].get_query = function(doc) {
// Expense Account
// ---------------------------------
cur_frm.fields_dict['purchase_account'].get_query = function(doc) {
cur_frm.fields_dict['expense_account'].get_query = function(doc) {
return {
filters: {
'debit_or_credit': "Debit",
@ -76,7 +76,7 @@ cur_frm.fields_dict['default_income_account'].get_query = function(doc) {
// Purchase Cost Center
// -----------------------------
cur_frm.fields_dict['cost_center'].get_query = function(doc) {
cur_frm.fields_dict['buying_cost_center'].get_query = function(doc) {
return {
filters:{ 'group_or_ledger': "Ledger" }
}
@ -85,7 +85,7 @@ cur_frm.fields_dict['cost_center'].get_query = function(doc) {
// Sales Cost Center
// -----------------------------
cur_frm.fields_dict['default_sales_cost_center'].get_query = function(doc) {
cur_frm.fields_dict['selling_cost_center'].get_query = function(doc) {
return {
filters:{ 'group_or_ledger': "Ledger" }
}

View File

@ -310,8 +310,8 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
# get last purchase order item details
last_purchase_order = webnotes.conn.sql("""\
select po.name, po.transaction_date, po.conversion_rate,
po_item.conversion_factor, po_item.purchase_ref_rate,
po_item.discount_rate, po_item.purchase_rate
po_item.conversion_factor, po_item.base_price_list_rate,
po_item.discount_percentage, po_item.purchase_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
@ -321,7 +321,7 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
# get last purchase receipt item details
last_purchase_receipt = webnotes.conn.sql("""\
select pr.name, pr.posting_date, pr.posting_time, pr.conversion_rate,
pr_item.conversion_factor, pr_item.purchase_ref_rate, pr_item.discount_rate,
pr_item.conversion_factor, pr_item.base_price_list_rate, pr_item.discount_percentage,
pr_item.purchase_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
@ -351,15 +351,15 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
conversion_factor = flt(last_purchase.conversion_factor)
out = webnotes._dict({
"purchase_ref_rate": flt(last_purchase.purchase_ref_rate) / conversion_factor,
"base_price_list_rate": flt(last_purchase.base_price_list_rate) / conversion_factor,
"purchase_rate": flt(last_purchase.purchase_rate) / conversion_factor,
"discount_rate": flt(last_purchase.discount_rate),
"discount_percentage": flt(last_purchase.discount_percentage),
"purchase_date": purchase_date
})
conversion_rate = flt(conversion_rate) or 1.0
out.update({
"import_ref_rate": out.purchase_ref_rate / conversion_rate,
"price_list_rate": out.base_price_list_rate / conversion_rate,
"import_rate": out.purchase_rate / conversion_rate,
"rate": out.purchase_rate
})

View File

@ -81,7 +81,7 @@ test_records = [
"stock_uom": "_Test UOM",
"default_income_account": "Sales - _TC",
"default_warehouse": "_Test Warehouse - _TC",
"purchase_account": "_Test Account Cost for Goods Sold - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"selling_cost_center": "_Test Cost Center - _TC",
}, {
"doctype": "Item Reorder",
@ -111,7 +111,7 @@ test_records = [
"stock_uom": "_Test UOM",
"default_income_account": "Sales - _TC",
"default_warehouse": "_Test Warehouse - _TC",
"purchase_account": "_Test Account Cost for Goods Sold - _TC"
"expense_account": "_Test Account Cost for Goods Sold - _TC"
}],
[{
"doctype": "Item",
@ -121,7 +121,7 @@ test_records = [
"item_group": "_Test Item Group Desktops",
"default_warehouse": "_Test Warehouse - _TC",
"default_income_account": "Sales - _TC",
"purchase_account": "_Test Account Cost for Goods Sold - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"is_stock_item": "Yes",
"is_asset_item": "No",
"has_batch_no": "No",
@ -148,7 +148,7 @@ test_records = [
"item_group": "_Test Item Group Desktops",
"default_warehouse": "_Test Warehouse - _TC",
"default_income_account": "Sales - _TC",
"purchase_account": "_Test Account Cost for Goods Sold - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"is_stock_item": "Yes",
"is_asset_item": "No",
"has_batch_no": "No",
@ -169,7 +169,7 @@ test_records = [
"description": "_Test Sales BOM Item",
"item_group": "_Test Item Group Desktops",
"default_income_account": "Sales - _TC",
"purchase_account": "_Test Account Cost for Goods Sold - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"is_stock_item": "No",
"is_asset_item": "No",
"has_batch_no": "No",
@ -191,7 +191,7 @@ test_records = [
"is_stock_item": "Yes",
"default_warehouse": "_Test Warehouse - _TC",
"default_income_account": "Sales - _TC",
"purchase_account": "_Test Account Cost for Goods Sold - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"is_asset_item": "No",
"has_batch_no": "No",
"has_serial_no": "No",
@ -268,7 +268,7 @@ test_records = [
"item_group": "_Test Item Group Desktops",
"default_warehouse": "_Test Warehouse - _TC",
"default_income_account": "Sales - _TC",
"purchase_account": "_Test Account Cost for Goods Sold - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"is_stock_item": "Yes",
"is_asset_item": "No",
"has_batch_no": "No",
@ -291,7 +291,7 @@ test_records = [
"is_stock_item": "Yes",
"default_warehouse": "_Test Warehouse - _TC",
"default_income_account": "Sales - _TC",
"purchase_account": "_Test Account Cost for Goods Sold - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"is_asset_item": "No",
"has_batch_no": "No",
"has_serial_no": "No",

View File

@ -17,7 +17,7 @@ test_records = [
"doctype": "Item Price",
"price_list": "_Test Price List",
"item_code": "_Test Item",
"ref_rate": 100
"price_list_rate": 100
}
]
]

View File

@ -65,7 +65,7 @@ def make_packing_list(obj, item_table_fieldname):
parent_items = []
for d in obj.doclist.get({"parentfield": item_table_fieldname}):
warehouse = (item_table_fieldname == "sales_order_details") \
and d.reserved_warehouse or d.warehouse
and d.warehouse or d.warehouse
if webnotes.conn.get_value("Sales BOM", {"new_item_code": d.item_code}):
for i in get_sales_bom_items(d.item_code):
update_packing_list_item(obj, i['item_code'], flt(i['qty'])*flt(d.qty),

View File

@ -373,7 +373,7 @@ class DocType(StockController):
def get_item_details(self, arg):
arg = json.loads(arg)
item = webnotes.conn.sql("""select stock_uom, description, item_name,
purchase_account, cost_center from `tabItem`
expense_account, buying_cost_center from `tabItem`
where name = %s and (ifnull(end_of_life,'')='' or end_of_life ='0000-00-00'
or end_of_life > now())""", (arg.get('item_code')), as_dict = 1)
if not item:
@ -384,9 +384,9 @@ class DocType(StockController):
'stock_uom' : item and item[0]['stock_uom'] or '',
'description' : item and item[0]['description'] or '',
'item_name' : item and item[0]['item_name'] or '',
'expense_account' : item and item[0]['purchase_account'] or arg.get("expense_account") \
'expense_account' : item and item[0]['expense_account'] or arg.get("expense_account") \
or webnotes.conn.get_value("Company", arg.get("company"), "default_expense_account"),
'cost_center' : item and item[0]['cost_center'] or arg.get("cost_center"),
'cost_center' : item and item[0]['buying_cost_center'] or arg.get("cost_center"),
'qty' : 0,
'transfer_qty' : 0,
'conversion_factor' : 1,
@ -464,7 +464,7 @@ class DocType(StockController):
# add finished good item to Stock Entry Detail table -- along with bom_no
if self.doc.production_order and self.doc.purpose == "Manufacture/Repack":
item = webnotes.conn.get_value("Item", pro_obj.doc.production_item, ["item_name",
"description", "stock_uom", "purchase_account", "cost_center"], as_dict=1)
"description", "stock_uom", "expense_account", "buying_cost_center"], as_dict=1)
self.add_to_stock_entry_detail({
cstr(pro_obj.doc.production_item): {
"to_warehouse": pro_obj.doc.fg_warehouse,
@ -473,8 +473,8 @@ class DocType(StockController):
"item_name": item.item_name,
"description": item.description,
"stock_uom": item.stock_uom,
"expense_account": item.purchase_account,
"cost_center": item.cost_center,
"expense_account": item.expense_account,
"cost_center": item.buying_cost_center,
}
}, bom_no=pro_obj.doc.bom_no, idx=idx)
@ -483,7 +483,7 @@ class DocType(StockController):
self.doc.from_warehouse = ""
item = webnotes.conn.sql("""select name, item_name, description,
stock_uom, purchase_account, cost_center from `tabItem`
stock_uom, expense_account, buying_cost_center from `tabItem`
where name=(select item from tabBOM where name=%s)""",
self.doc.bom_no, as_dict=1)
self.add_to_stock_entry_detail({
@ -493,8 +493,8 @@ class DocType(StockController):
"description": item[0]["description"],
"stock_uom": item[0]["stock_uom"],
"from_warehouse": "",
"expense_account": item[0].purchase_account,
"cost_center": item[0].cost_center,
"expense_account": item[0].expense_account,
"cost_center": item[0].buying_cost_center,
}
}, bom_no=self.doc.bom_no, idx=idx)
@ -911,7 +911,7 @@ def make_return_jv_from_purchase_receipt(se, ref):
ref_item = ref_item[0]
account = ref_item.expense_head
account = ref_item.expense_account
if account not in children:
children.append(account)

View File

@ -480,7 +480,7 @@ class TestStockEntry(unittest.TestCase):
pi.doc.posting_date = pr.doc.posting_date
pi.doc.credit_to = "_Test Supplier - _TC"
for d in pi.doclist.get({"parentfield": "entries"}):
d.expense_head = "_Test Account Cost for Goods Sold - _TC"
d.expense_account = "_Test Account Cost for Goods Sold - _TC"
d.cost_center = "_Test Cost Center - _TC"
for d in pi.doclist.get({"parentfield": "other_charges"}):
@ -583,7 +583,7 @@ class TestStockEntry(unittest.TestCase):
pi.doc.posting_date = pr.doc.posting_date
pi.doc.credit_to = "_Test Supplier - _TC"
for d in pi.doclist.get({"parentfield": "entries"}):
d.expense_head = "_Test Account Cost for Goods Sold - _TC"
d.expense_account = "_Test Account Cost for Goods Sold - _TC"
d.cost_center = "_Test Cost Center - _TC"
for d in pi.doclist.get({"parentfield": "other_charges"}):
d.cost_center = "_Test Cost Center - _TC"

View File

@ -132,7 +132,7 @@ def get_basic_details(args, item_bean):
"warehouse": user_default_warehouse or args.warehouse or item.default_warehouse,
"income_account": item.default_income_account or args.income_account \
or webnotes.conn.get_value("Company", args.company, "default_income_account"),
"expense_account": item.purchase_account or args.expense_account \
"expense_account": item.expense_account or args.expense_account \
or webnotes.conn.get_value("Company", args.company, "default_expense_account"),
"cost_center": item.selling_cost_center \
if args.transaction_type == "selling" else args.buying_cost_center,
@ -165,7 +165,7 @@ def get_price_list_rate(args, item_bean, out):
validate_conversion_rate(args, meta)
price_list_rate = webnotes.conn.get_value("Item Price",
{"price_list": args.price_list, "item_code": args.item_code}, "ref_rate")
{"price_list": args.price_list, "item_code": args.item_code}, "price_list_rate")
if not price_list_rate: return {}
@ -223,7 +223,7 @@ def validate_conversion_rate(args, meta):
# discount = flt(res[0][0])
# break
#
# return {"adj_rate": discount}
# return {"discount_percentage": discount}
def get_party_item_code(args, item_bean, out):
if args.transaction_type == "selling":

View File

@ -58,7 +58,7 @@ def get_price_list():
rate = {}
price_list = webnotes.conn.sql("""select ip.item_code, ip.buying, ip.selling,
concat(ip.price_list, " - ", ip.currency, " ", ip.ref_rate) as price
concat(ip.price_list, " - ", ip.currency, " ", ip.price_list_rate) as price
from `tabItem Price` ip, `tabPrice List` pl
where ip.price_list=pl.name and pl.enabled=1""", as_dict=1)
@ -86,8 +86,8 @@ def get_last_purchase_rate():
po_item.item_code,
po_item.item_name,
po.transaction_date as posting_date,
po_item.purchase_ref_rate,
po_item.discount_rate,
po_item.base_price_list_rate,
po_item.discount_percentage,
po_item.purchase_rate
from `tabPurchase Order` po, `tabPurchase Order Item` po_item
where po.name = po_item.parent and po.docstatus = 1)
@ -96,8 +96,8 @@ def get_last_purchase_rate():
pr_item.item_code,
pr_item.item_name,
pr.posting_date,
pr_item.purchase_ref_rate,
pr_item.discount_rate,
pr_item.base_price_list_rate,
pr_item.discount_percentage,
pr_item.purchase_rate
from `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pr_item
where pr.name = pr_item.parent and pr.docstatus = 1)

View File

@ -76,7 +76,7 @@ def get_reserved_qty(item_code, warehouse):
(select qty as dnpi_qty, qty as so_item_qty,
ifnull(delivered_qty, 0) as so_item_delivered_qty, parent, name
from `tabSales Order Item` so_item
where item_code = %s and reserved_warehouse = %s
where item_code = %s and warehouse = %s
and exists(select * from `tabSales Order` so
where so.name = so_item.parent and so.docstatus = 1
and so.status != 'Stopped'))