[fix] [minor] rate calculation on server side, only if blank/0 (honour client side calculation sequence), shopping cart settings
This commit is contained in:
parent
c4dde9bd99
commit
47e14a9de4
@ -916,7 +916,6 @@ test_records = [
|
||||
"item_name": "_Test Item Home Desktop 100",
|
||||
"qty": 10,
|
||||
"ref_rate": 62.5,
|
||||
"export_rate": 62.5,
|
||||
"stock_uom": "_Test UOM",
|
||||
"item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}),
|
||||
"income_account": "Sales - _TC",
|
||||
@ -930,7 +929,6 @@ test_records = [
|
||||
"item_name": "_Test Item Home Desktop 200",
|
||||
"qty": 5,
|
||||
"ref_rate": 190.66,
|
||||
"export_rate": 190.66,
|
||||
"stock_uom": "_Test UOM",
|
||||
"income_account": "Sales - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
|
@ -98,7 +98,7 @@ class BuyingController(StockController):
|
||||
|
||||
if item.discount_rate == 100.0:
|
||||
item.import_rate = 0.0
|
||||
elif item.import_ref_rate:
|
||||
elif not item.import_rate:
|
||||
item.import_rate = flt(item.import_ref_rate * (1.0 - (item.discount_rate / 100.0)),
|
||||
self.precision("import_rate", item))
|
||||
|
||||
|
@ -191,7 +191,7 @@ class SellingController(StockController):
|
||||
|
||||
if item.adj_rate == 100:
|
||||
item.export_rate = 0
|
||||
elif item.ref_rate:
|
||||
elif not item.export_rate:
|
||||
item.export_rate = flt(item.ref_rate * (1.0 - (item.adj_rate / 100.0)),
|
||||
self.precision("export_rate", item))
|
||||
|
||||
|
@ -33,7 +33,7 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
self.assertEquals(len(si), len(dn.doclist))
|
||||
|
||||
# modify export_amount
|
||||
si[1].ref_rate = 200
|
||||
si[1].export_rate = 200
|
||||
self.assertRaises(webnotes.ValidationError, webnotes.bean(si).insert)
|
||||
|
||||
|
||||
|
@ -77,9 +77,9 @@ class TransactionBase(StatusUpdater):
|
||||
"""
|
||||
customer_defaults = self.get_customer_defaults()
|
||||
|
||||
customer_defaults["price_list_name"] = customer_defaults.get("price_list") or \
|
||||
customer_defaults["selling_price_list"] = customer_defaults.get("price_list") or \
|
||||
webnotes.conn.get_value("Customer Group", self.doc.customer_group, "default_price_list") or \
|
||||
self.doc.price_list
|
||||
self.doc.selling_price_list
|
||||
|
||||
for fieldname, val in customer_defaults.items():
|
||||
if self.meta.get_field(fieldname):
|
||||
|
@ -43,7 +43,7 @@ class DocType(DocListController):
|
||||
|
||||
def validate_price_lists(self):
|
||||
territory_name_map = self.validate_overlapping_territories("price_lists",
|
||||
"price_list")
|
||||
"selling_price_list")
|
||||
|
||||
# validate that a Shopping Cart Price List exists for the root territory
|
||||
# as a catch all!
|
||||
@ -92,9 +92,9 @@ class DocType(DocListController):
|
||||
raise_exception=ShoppingCartSetupError)
|
||||
|
||||
price_list_currency_map = webnotes.conn.get_values("Price List",
|
||||
[d.price_list for d in self.doclist.get({"parentfield": "price_lists"})],
|
||||
[d.selling_price_list for d in self.doclist.get({"parentfield": "price_lists"})],
|
||||
"currency")
|
||||
|
||||
|
||||
expected_to_exist = [currency + "-" + company_currency
|
||||
for currency in price_list_currency_map.values()
|
||||
if currency != company_currency]
|
||||
@ -126,7 +126,7 @@ class DocType(DocListController):
|
||||
return name
|
||||
|
||||
def get_price_list(self, billing_territory):
|
||||
price_list = self.get_name_from_territory(billing_territory, "price_lists", "price_list")
|
||||
price_list = self.get_name_from_territory(billing_territory, "price_lists", "selling_price_list")
|
||||
return price_list and price_list[0] or None
|
||||
|
||||
def get_tax_master(self, billing_territory):
|
||||
|
@ -26,7 +26,7 @@ class TestShoppingCartSettings(unittest.TestCase):
|
||||
cart_settings.doclist.append({
|
||||
"doctype": "Shopping Cart Price List",
|
||||
"parentfield": "price_lists",
|
||||
"price_list": price_list
|
||||
"selling_price_list": price_list
|
||||
})
|
||||
|
||||
for price_list in ("_Test Price List Rest of the World", "_Test Price List India",
|
||||
@ -34,13 +34,13 @@ class TestShoppingCartSettings(unittest.TestCase):
|
||||
_add_price_list(price_list)
|
||||
|
||||
controller = cart_settings.make_controller()
|
||||
controller.validate_overlapping_territories("price_lists", "price_list")
|
||||
controller.validate_overlapping_territories("price_lists", "selling_price_list")
|
||||
|
||||
_add_price_list("_Test Price List 2")
|
||||
|
||||
controller = cart_settings.make_controller()
|
||||
self.assertRaises(ShoppingCartSetupError, controller.validate_overlapping_territories,
|
||||
"price_lists", "price_list")
|
||||
"price_lists", "selling_price_list")
|
||||
|
||||
return cart_settings
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user