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

@@ -89,16 +89,6 @@ class DocType(BuyingController):
webnotes.msgprint("Another Purchase Receipt using the same Challan No. already exists.\
Please enter a valid Challan No.", raise_exception=1)
# update valuation rate
def update_valuation_rate(self):
for d in self.doclist.get({"parentfield": "purchase_receipt_details"}):
if d.qty:
d.valuation_rate = (flt(d.purchase_rate) + flt(d.item_tax_amount)/flt(d.qty)
+ flt(d.rm_supp_cost) / flt(d.qty)) / flt(d.conversion_factor)
else:
d.valuation_rate = 0.0
#check in manage account if purchase order required or not.
# ====================================================================================
def po_required(self):
@@ -134,8 +124,7 @@ class DocType(BuyingController):
pc_obj.validate_reference_value(self)
self.check_for_stopped_status(pc_obj)
# update valuation rate
self.update_valuation_rate()
self.update_valuation_rate("purchase_receipt_details")
# On Update

View File

@@ -36,7 +36,6 @@ class TestPurchaseReceipt(unittest.TestCase):
def test_purchase_receipt_gl_entry(self):
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_inventory_accounting")), 1)
pr = webnotes.bean(copy=test_records[0])
@@ -47,7 +46,6 @@ class TestPurchaseReceipt(unittest.TestCase):
gl_entries = webnotes.conn.sql("""select account, debit, credit
from `tabGL Entry` where voucher_type='Purchase Receipt' and voucher_no=%s
order by account desc""", pr.doc.name, as_dict=1)
self.assertTrue(gl_entries)
stock_in_hand_account = webnotes.conn.get_value("Company", pr.doc.company,