fixes in jv test and purchase invoice test
This commit is contained in:
parent
a1d4b78fbe
commit
9d794fccc1
@ -26,7 +26,6 @@ test_records = [[
|
|||||||
"fiscal_year": "_Test Fiscal Year 2013",
|
"fiscal_year": "_Test Fiscal Year 2013",
|
||||||
"naming_series": "_T-Journal Voucher-",
|
"naming_series": "_T-Journal Voucher-",
|
||||||
"posting_date": "2013-02-14",
|
"posting_date": "2013-02-14",
|
||||||
"tds_applicable": "No",
|
|
||||||
"user_remark": "test",
|
"user_remark": "test",
|
||||||
"voucher_type": "Bank Voucher",
|
"voucher_type": "Bank Voucher",
|
||||||
"cheque_no": "33",
|
"cheque_no": "33",
|
||||||
|
@ -493,4 +493,4 @@ class DocType(BuyingController):
|
|||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
pass
|
pass
|
||||||
|
|
@ -24,14 +24,9 @@ import json
|
|||||||
test_dependencies = ["Item", "Cost Center"]
|
test_dependencies = ["Item", "Cost Center"]
|
||||||
|
|
||||||
class TestPurchaseInvoice(unittest.TestCase):
|
class TestPurchaseInvoice(unittest.TestCase):
|
||||||
def test_gl_entries(self):
|
def test_gl_entries_without_auto_inventory_accounting(self):
|
||||||
wrapper = webnotes.bean(self.get_test_doclist())
|
wrapper = webnotes.bean(copy=test_records[0])
|
||||||
|
wrapper.run_method("calculate_taxes_and_totals")
|
||||||
# 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.insert()
|
wrapper.insert()
|
||||||
wrapper.submit()
|
wrapper.submit()
|
||||||
wrapper.load_from_db()
|
wrapper.load_from_db()
|
||||||
@ -53,14 +48,12 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
for d in gl_entries:
|
for d in gl_entries:
|
||||||
self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account))
|
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):
|
def test_purchase_invoice_calculation(self):
|
||||||
wrapper = webnotes.bean(self.get_test_doclist())
|
wrapper = webnotes.bean(copy=test_records[0])
|
||||||
|
wrapper.run_method("calculate_taxes_and_totals")
|
||||||
# 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.insert()
|
wrapper.insert()
|
||||||
wrapper.load_from_db()
|
wrapper.load_from_db()
|
||||||
|
|
||||||
@ -91,145 +84,173 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})):
|
for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})):
|
||||||
self.assertEqual(item.item_code, expected_values[i][0])
|
self.assertEqual(item.item_code, expected_values[i][0])
|
||||||
self.assertEqual(item.item_tax_amount, expected_values[i][1])
|
self.assertEqual(item.item_tax_amount, expected_values[i][1])
|
||||||
|
|
||||||
def get_test_doclist(self):
|
test_records = [
|
||||||
return [
|
[
|
||||||
# parent
|
# parent
|
||||||
{
|
{
|
||||||
"doctype": "Purchase Invoice",
|
"doctype": "Purchase Invoice",
|
||||||
"naming_series": "BILL",
|
"naming_series": "BILL",
|
||||||
"supplier_name": "_Test Supplier",
|
"supplier_name": "_Test Supplier",
|
||||||
"credit_to": "_Test Supplier - _TC",
|
"credit_to": "_Test Supplier - _TC",
|
||||||
"bill_no": "NA",
|
"bill_no": "NA",
|
||||||
"posting_date": "2013-02-03",
|
"posting_date": "2013-02-03",
|
||||||
"fiscal_year": "_Test Fiscal Year 2013",
|
"fiscal_year": "_Test Fiscal Year 2013",
|
||||||
"company": "_Test Company",
|
"company": "_Test Company",
|
||||||
"currency": "INR",
|
"currency": "INR",
|
||||||
"conversion_rate": 1,
|
"conversion_rate": 1,
|
||||||
"grand_total_import": 0 # for feed
|
"grand_total_import": 0 # for feed
|
||||||
},
|
},
|
||||||
# items
|
# items
|
||||||
{
|
{
|
||||||
"doctype": "Purchase Invoice Item",
|
"doctype": "Purchase Invoice Item",
|
||||||
"parentfield": "entries",
|
"parentfield": "entries",
|
||||||
"item_code": "_Test Item Home Desktop 100",
|
"item_code": "_Test Item Home Desktop 100",
|
||||||
"item_name": "_Test Item Home Desktop 100",
|
"item_name": "_Test Item Home Desktop 100",
|
||||||
"qty": 10,
|
"qty": 10,
|
||||||
"import_rate": 50,
|
"import_rate": 50,
|
||||||
"import_amount": 500,
|
"import_amount": 500,
|
||||||
"rate": 50,
|
"rate": 50,
|
||||||
"amount": 500,
|
"amount": 500,
|
||||||
"uom": "_Test UOM",
|
"uom": "_Test UOM",
|
||||||
"item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}),
|
"item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}),
|
||||||
"expense_head": "_Test Account Cost for Goods Sold - _TC",
|
"expense_head": "_Test Account Cost for Goods Sold - _TC",
|
||||||
"cost_center": "_Test Cost Center - _TC"
|
"cost_center": "_Test Cost Center - _TC"
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Purchase Invoice Item",
|
"doctype": "Purchase Invoice Item",
|
||||||
"parentfield": "entries",
|
"parentfield": "entries",
|
||||||
"item_code": "_Test Item Home Desktop 200",
|
"item_code": "_Test Item Home Desktop 200",
|
||||||
"item_name": "_Test Item Home Desktop 200",
|
"item_name": "_Test Item Home Desktop 200",
|
||||||
"qty": 5,
|
"qty": 5,
|
||||||
"import_rate": 150,
|
"import_rate": 150,
|
||||||
"import_amount": 750,
|
"import_amount": 750,
|
||||||
"rate": 150,
|
"rate": 150,
|
||||||
"amount": 750,
|
"amount": 750,
|
||||||
"uom": "_Test UOM",
|
"uom": "_Test UOM",
|
||||||
"expense_head": "_Test Account Cost for Goods Sold - _TC",
|
"expense_head": "_Test Account Cost for Goods Sold - _TC",
|
||||||
"cost_center": "_Test Cost Center - _TC"
|
"cost_center": "_Test Cost Center - _TC"
|
||||||
},
|
},
|
||||||
# taxes
|
# taxes
|
||||||
{
|
{
|
||||||
"doctype": "Purchase Taxes and Charges",
|
"doctype": "Purchase Taxes and Charges",
|
||||||
"parentfield": "purchase_tax_details",
|
"parentfield": "purchase_tax_details",
|
||||||
"charge_type": "Actual",
|
"charge_type": "Actual",
|
||||||
"account_head": "_Test Account Shipping Charges - _TC",
|
"account_head": "_Test Account Shipping Charges - _TC",
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"description": "Shipping Charges",
|
"description": "Shipping Charges",
|
||||||
"category": "Valuation and Total",
|
"category": "Valuation and Total",
|
||||||
"add_deduct_tax": "Add",
|
"add_deduct_tax": "Add",
|
||||||
"rate": 100
|
"rate": 100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Purchase Taxes and Charges",
|
"doctype": "Purchase Taxes and Charges",
|
||||||
"parentfield": "purchase_tax_details",
|
"parentfield": "purchase_tax_details",
|
||||||
"charge_type": "On Net Total",
|
"charge_type": "On Net Total",
|
||||||
"account_head": "_Test Account Customs Duty - _TC",
|
"account_head": "_Test Account Customs Duty - _TC",
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"description": "Customs Duty",
|
"description": "Customs Duty",
|
||||||
"category": "Valuation",
|
"category": "Valuation",
|
||||||
"add_deduct_tax": "Add",
|
"add_deduct_tax": "Add",
|
||||||
"rate": 10
|
"rate": 10
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Purchase Taxes and Charges",
|
"doctype": "Purchase Taxes and Charges",
|
||||||
"parentfield": "purchase_tax_details",
|
"parentfield": "purchase_tax_details",
|
||||||
"charge_type": "On Net Total",
|
"charge_type": "On Net Total",
|
||||||
"account_head": "_Test Account Excise Duty - _TC",
|
"account_head": "_Test Account Excise Duty - _TC",
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"description": "Excise Duty",
|
"description": "Excise Duty",
|
||||||
"category": "Total",
|
"category": "Total",
|
||||||
"add_deduct_tax": "Add",
|
"add_deduct_tax": "Add",
|
||||||
"rate": 12
|
"rate": 12
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Purchase Taxes and Charges",
|
"doctype": "Purchase Taxes and Charges",
|
||||||
"parentfield": "purchase_tax_details",
|
"parentfield": "purchase_tax_details",
|
||||||
"charge_type": "On Previous Row Amount",
|
"charge_type": "On Previous Row Amount",
|
||||||
"account_head": "_Test Account Education Cess - _TC",
|
"account_head": "_Test Account Education Cess - _TC",
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"description": "Education Cess",
|
"description": "Education Cess",
|
||||||
"category": "Total",
|
"category": "Total",
|
||||||
"add_deduct_tax": "Add",
|
"add_deduct_tax": "Add",
|
||||||
"rate": 2,
|
"rate": 2,
|
||||||
"row_id": 3
|
"row_id": 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Purchase Taxes and Charges",
|
"doctype": "Purchase Taxes and Charges",
|
||||||
"parentfield": "purchase_tax_details",
|
"parentfield": "purchase_tax_details",
|
||||||
"charge_type": "On Previous Row Amount",
|
"charge_type": "On Previous Row Amount",
|
||||||
"account_head": "_Test Account S&H Education Cess - _TC",
|
"account_head": "_Test Account S&H Education Cess - _TC",
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"description": "S&H Education Cess",
|
"description": "S&H Education Cess",
|
||||||
"category": "Total",
|
"category": "Total",
|
||||||
"add_deduct_tax": "Add",
|
"add_deduct_tax": "Add",
|
||||||
"rate": 1,
|
"rate": 1,
|
||||||
"row_id": 3
|
"row_id": 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Purchase Taxes and Charges",
|
"doctype": "Purchase Taxes and Charges",
|
||||||
"parentfield": "purchase_tax_details",
|
"parentfield": "purchase_tax_details",
|
||||||
"charge_type": "On Previous Row Total",
|
"charge_type": "On Previous Row Total",
|
||||||
"account_head": "_Test Account CST - _TC",
|
"account_head": "_Test Account CST - _TC",
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"description": "CST",
|
"description": "CST",
|
||||||
"category": "Total",
|
"category": "Total",
|
||||||
"add_deduct_tax": "Add",
|
"add_deduct_tax": "Add",
|
||||||
"rate": 2,
|
"rate": 2,
|
||||||
"row_id": 5
|
"row_id": 5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Purchase Taxes and Charges",
|
"doctype": "Purchase Taxes and Charges",
|
||||||
"parentfield": "purchase_tax_details",
|
"parentfield": "purchase_tax_details",
|
||||||
"charge_type": "On Net Total",
|
"charge_type": "On Net Total",
|
||||||
"account_head": "_Test Account VAT - _TC",
|
"account_head": "_Test Account VAT - _TC",
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"description": "VAT",
|
"description": "VAT",
|
||||||
"category": "Total",
|
"category": "Total",
|
||||||
"add_deduct_tax": "Add",
|
"add_deduct_tax": "Add",
|
||||||
"rate": 12.5
|
"rate": 12.5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Purchase Taxes and Charges",
|
"doctype": "Purchase Taxes and Charges",
|
||||||
"parentfield": "purchase_tax_details",
|
"parentfield": "purchase_tax_details",
|
||||||
"charge_type": "On Previous Row Total",
|
"charge_type": "On Previous Row Total",
|
||||||
"account_head": "_Test Account Discount - _TC",
|
"account_head": "_Test Account Discount - _TC",
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"description": "Discount",
|
"description": "Discount",
|
||||||
"category": "Total",
|
"category": "Total",
|
||||||
"add_deduct_tax": "Deduct",
|
"add_deduct_tax": "Deduct",
|
||||||
"rate": 10,
|
"rate": 10,
|
||||||
"row_id": 7
|
"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"
|
||||||
|
|
||||||
|
},
|
||||||
|
]
|
||||||
|
]
|
@ -250,7 +250,9 @@ class BuyingController(AccountsController):
|
|||||||
if self.doc.doctype == "Purchase Invoice" and self.doc.docstatus == 0:
|
if self.doc.doctype == "Purchase Invoice" and self.doc.docstatus == 0:
|
||||||
self.doc.total_advance = flt(self.doc.total_advance,
|
self.doc.total_advance = flt(self.doc.total_advance,
|
||||||
self.precision.main.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)
|
self.precision.main.outstanding_amount)
|
||||||
|
|
||||||
def _cleanup(self):
|
def _cleanup(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user