From 9304396e171fb7aa1cbc642d2af70ee43d9c3515 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 28 Oct 2013 15:33:36 +0530 Subject: [PATCH] [fix] [minor] Cost center is mandatory if tax is include din valuation and perpetual inventory enabled --- .../doctype/purchase_invoice/purchase_invoice.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py index c1e92b9f4f..f3d359bd45 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -350,11 +350,14 @@ class DocType(BuyingController): ) # accumulate valuation tax - if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount) \ - and tax.cost_center: - valuation_tax.setdefault(tax.cost_center, 0) - valuation_tax[tax.cost_center] += \ - (tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.tax_amount) + if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount): + if auto_accounting_for_stock and not tax.cost_center: + webnotes.throw(_("Row %(row)s: Cost Center is mandatory \ + if tax/charges category is Valuation or Valuation and Total" % + {"row": tax.idx})) + valuation_tax.setdefault(tax.cost_center, 0) + valuation_tax[tax.cost_center] += \ + (tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.tax_amount) # item gl entries stock_item_and_auto_accounting_for_stock = False