mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 07:54:46 +00:00
[perpetual accounting] fixes in testcases
This commit is contained in:
@@ -620,11 +620,11 @@ class DocType(SellingController):
|
||||
# expense account gl entries
|
||||
if cint(webnotes.defaults.get_global_default("perpetual_accounting")) \
|
||||
and cint(self.doc.update_stock):
|
||||
|
||||
for item in self.doclist.get({"parentfield": "entries"}):
|
||||
self.check_expense_account(item)
|
||||
|
||||
if item.buying_amount:
|
||||
|
||||
gl_entries += self.get_gl_entries_for_stock(item.expense_account,
|
||||
-1*item.buying_amount, item.warehouse, cost_center=item.cost_center)
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
|
||||
def test_sales_invoice_gl_entry_without_aii(self):
|
||||
webnotes.defaults.set_global_default("perpetual_accounting", 0)
|
||||
|
||||
self.clear_stock_account_balance()
|
||||
si = webnotes.bean(copy=test_records[1])
|
||||
si.insert()
|
||||
si.submit()
|
||||
@@ -306,6 +306,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
gl_entries = webnotes.conn.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
||||
order by account asc""", si.doc.name, as_dict=1)
|
||||
|
||||
self.assertTrue(gl_entries)
|
||||
|
||||
expected_values = sorted([
|
||||
@@ -330,7 +331,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
|
||||
self.assertEquals(gle_count[0][0], 8)
|
||||
|
||||
def atest_pos_gl_entry_with_aii(self):
|
||||
def test_pos_gl_entry_with_aii(self):
|
||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
webnotes.defaults.set_global_default("perpetual_accounting", 1)
|
||||
|
||||
@@ -644,6 +645,11 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
count = no_of_months == 12 and 3 or 13
|
||||
for i in xrange(count):
|
||||
base_si = _test(i)
|
||||
|
||||
def clear_stock_account_balance(self):
|
||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
webnotes.conn.sql("delete from tabBin")
|
||||
webnotes.conn.sql("delete from `tabGL Entry`")
|
||||
|
||||
test_dependencies = ["Journal Voucher", "POS Setting", "Contact", "Address"]
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ def save_entries(gl_map, cancel, adv_adj, update_outstanding):
|
||||
total_debit = total_credit = 0.0
|
||||
def _swap(gle):
|
||||
gle.debit, gle.credit = abs(flt(gle.credit)), abs(flt(gle.debit))
|
||||
|
||||
|
||||
for entry in gl_map:
|
||||
gle = Document('GL Entry', fielddata=entry)
|
||||
|
||||
@@ -83,9 +83,7 @@ def save_entries(gl_map, cancel, adv_adj, update_outstanding):
|
||||
# update total debit / credit
|
||||
total_debit += flt(gle.debit)
|
||||
total_credit += flt(gle.credit)
|
||||
|
||||
# print gle.account, gle.debit, gle.credit, total_debit, total_credit
|
||||
|
||||
|
||||
if not cancel:
|
||||
validate_total_debit_credit(total_debit, total_credit)
|
||||
|
||||
|
||||
@@ -374,8 +374,7 @@ def get_stock_and_account_difference(warehouse_list=None):
|
||||
account_balance = get_balance_on(account)
|
||||
stock_value = sum([sum(bin_map.get(warehouse, {}).values())
|
||||
for warehouse in warehouse_list])
|
||||
|
||||
if flt(stock_value) - flt(account_balance):
|
||||
if abs(flt(stock_value) - flt(account_balance)) > 0.005:
|
||||
difference.setdefault(account, flt(stock_value) - flt(account_balance))
|
||||
|
||||
|
||||
return difference
|
||||
|
||||
Reference in New Issue
Block a user