commonified some purchase code, added test case for auto inventory accounting for purchase invoice

This commit is contained in:
Anand Doshi
2013-02-27 18:10:30 +05:30
parent 9d794fccc1
commit 4a7248ee0b
7 changed files with 186 additions and 80 deletions

View File

@@ -86,4 +86,11 @@ class AccountsController(TransactionBase):
from `tabItem` where name in (%s) and is_stock_item='Yes'""" % \
(", ".join((["%s"]*len(item_codes))),), item_codes)]
return self._stock_items
return self._stock_items
@property
def company_abbr(self):
if not hasattr(self, "_abbr"):
self._abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
return self._abbr

View File

@@ -232,7 +232,7 @@ class BuyingController(AccountsController):
else:
self.doc.grand_total = flt(self.doc.net_total,
self.precision.main.grand_total)
self.doc.grand_total_print = flt(
self.doc.grand_total_import = flt(
self.doc.grand_total / self.doc.conversion_rate,
self.precision.main.grand_total_import)
@@ -327,6 +327,16 @@ class BuyingController(AccountsController):
item.item_code in self.stock_items:
item.item_tax_amount += flt(current_tax_amount,
self.precision.item.item_tax_amount)
# update valuation rate
def update_valuation_rate(self, parentfield):
for d in self.doclist.get({"parentfield": parentfield}):
if d.qty:
d.valuation_rate = (flt(d.purchase_rate or d.rate)
+ (flt(d.item_tax_amount) + flt(d.rm_supp_cost)) / flt(d.qty)
) / flt(d.conversion_factor)
else:
d.valuation_rate = 0.0
@property
def precision(self):