fix: set valuation rate for customer items to zero

- In stock reconciliation always set valuation rate of customer provided
items to zero during validation.
- Let user know the valuation has been changed.
This commit is contained in:
Ankush Menat 2021-03-23 12:16:58 +05:30
parent 714b780868
commit e76ecb8f74
No known key found for this signature in database
GPG Key ID: 8EA82E09BBD13AAF

View File

@ -29,9 +29,10 @@ class StockReconciliation(StockController):
self.remove_items_with_no_change() self.remove_items_with_no_change()
self.validate_data() self.validate_data()
self.validate_expense_account() self.validate_expense_account()
self.validate_customer_provided_item()
self.set_zero_value_for_customer_provided_items()
self.set_total_qty_and_amount() self.set_total_qty_and_amount()
self.validate_putaway_capacity() self.validate_putaway_capacity()
self.validate_customer_provided_item()
if self._action=="submit": if self._action=="submit":
self.make_batches('warehouse') self.make_batches('warehouse')
@ -437,6 +438,20 @@ class StockReconciliation(StockController):
if frappe.db.get_value("Account", self.expense_account, "report_type") == "Profit and Loss": if frappe.db.get_value("Account", self.expense_account, "report_type") == "Profit and Loss":
frappe.throw(_("Difference Account must be a Asset/Liability type account, since this Stock Reconciliation is an Opening Entry"), OpeningEntryAccountError) frappe.throw(_("Difference Account must be a Asset/Liability type account, since this Stock Reconciliation is an Opening Entry"), OpeningEntryAccountError)
def set_zero_value_for_customer_provided_items(self):
changed_any_values = False
for d in self.get('items'):
is_customer_item = frappe.db.get_value('Item', d.item_code, 'is_customer_provided_item')
if is_customer_item and d.valuation_rate:
d.valuation_rate = 0.0
changed_any_values = True
if changed_any_values:
msgprint(_("Valuation rate for customer provided items has been set to zero."),
title=_("Note"), indicator="blue")
def set_total_qty_and_amount(self): def set_total_qty_and_amount(self):
for d in self.get("items"): for d in self.get("items"):
d.amount = flt(d.qty, d.precision("qty")) * flt(d.valuation_rate, d.precision("valuation_rate")) d.amount = flt(d.qty, d.precision("qty")) * flt(d.valuation_rate, d.precision("valuation_rate"))