fixes in jv test and purchase invoice test

This commit is contained in:
Anand Doshi 2013-02-27 13:34:22 +05:30
parent a1d4b78fbe
commit 9d794fccc1
4 changed files with 182 additions and 160 deletions

View File

@ -26,7 +26,6 @@ test_records = [[
"fiscal_year": "_Test Fiscal Year 2013",
"naming_series": "_T-Journal Voucher-",
"posting_date": "2013-02-14",
"tds_applicable": "No",
"user_remark": "test",
"voucher_type": "Bank Voucher",
"cheque_no": "33",

View File

@ -24,14 +24,9 @@ import json
test_dependencies = ["Item", "Cost Center"]
class TestPurchaseInvoice(unittest.TestCase):
def test_gl_entries(self):
wrapper = webnotes.bean(self.get_test_doclist())
# circumvent the disabled calculation call
obj = webnotes.get_obj(doc=wrapper.doc, doclist=wrapper.doclist)
obj.calculate_taxes_and_totals()
wrapper.set_doclist(obj.doclist)
def test_gl_entries_without_auto_inventory_accounting(self):
wrapper = webnotes.bean(copy=test_records[0])
wrapper.run_method("calculate_taxes_and_totals")
wrapper.insert()
wrapper.submit()
wrapper.load_from_db()
@ -53,14 +48,12 @@ class TestPurchaseInvoice(unittest.TestCase):
for d in gl_entries:
self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account))
def test_gl_entries_with_auto_inventory_accounting(self):
pi = webnotes.bean(copy=test_records[1])
def test_purchase_invoice_calculation(self):
wrapper = webnotes.bean(self.get_test_doclist())
# circumvent the disabled calculation call
obj = webnotes.get_obj(doc=wrapper.doc, doclist=wrapper.doclist)
obj.calculate_taxes_and_totals()
wrapper.set_doclist(obj.doclist)
wrapper = webnotes.bean(copy=test_records[0])
wrapper.run_method("calculate_taxes_and_totals")
wrapper.insert()
wrapper.load_from_db()
@ -92,8 +85,8 @@ class TestPurchaseInvoice(unittest.TestCase):
self.assertEqual(item.item_code, expected_values[i][0])
self.assertEqual(item.item_tax_amount, expected_values[i][1])
def get_test_doclist(self):
return [
test_records = [
[
# parent
{
"doctype": "Purchase Invoice",
@ -232,4 +225,32 @@ class TestPurchaseInvoice(unittest.TestCase):
"rate": 10,
"row_id": 7
},
],
[
# parent
{
"doctype": "Purchase Invoice",
"supplier_name": "_Test Supplier",
"credit_to": "_Test Supplier - _TC",
"bill_no": "NA",
"posting_date": "2013-02-03",
"fiscal_year": "_Test Fiscal Year 2013",
"company": "_Test Company",
"currency": "INR",
"conversion_rate": 1,
},
# items
{
"doctype": "Purchase Invoice Item",
"parentfield": "entries",
"item_code": "_Test Item",
"item_name": "_Test Item",
"qty": 10,
"import_rate": 50,
"uom": "_Test UOM",
"expense_head": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC"
},
]
]

View File

@ -250,7 +250,9 @@ class BuyingController(AccountsController):
if self.doc.doctype == "Purchase Invoice" and self.doc.docstatus == 0:
self.doc.total_advance = flt(self.doc.total_advance,
self.precision.main.total_advance)
self.doc.outstanding_amount = flt(self.doc.grand_total - self.doc.total_advance,
self.doc.total_amount_to_pay = flt(self.doc.grand_total - flt(self.doc.write_off_amount,
self.precision.main.write_off_amount), self.precision.main.total_amount_to_pay)
self.doc.outstanding_amount = flt(self.doc.total_amount_to_pay - self.doc.total_advance,
self.precision.main.outstanding_amount)
def _cleanup(self):