Clear rows from Journal Entry if no debit/credit
This commit is contained in:
parent
7f5089d19d
commit
43eeddfaf6
@ -97,8 +97,9 @@ def set_total_expense_zero(posting_date, cost_center=None):
|
||||
"fiscal_year": "_Test Fiscal Year 2013"
|
||||
}, cost_center or "_Test Cost Center - _TC")
|
||||
|
||||
make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
||||
"_Test Bank - _TC", -existing_expense, "_Test Cost Center - _TC", submit=True)
|
||||
if existing_expense:
|
||||
make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
||||
"_Test Bank - _TC", -existing_expense, "_Test Cost Center - _TC", submit=True)
|
||||
|
||||
def make_budget(cost_center=None):
|
||||
budget = frappe.new_doc("Budget")
|
||||
|
@ -37,8 +37,14 @@ class JournalEntry(AccountsController):
|
||||
self.validate_credit_debit_note()
|
||||
self.validate_empty_accounts_table()
|
||||
self.set_account_and_party_balance()
|
||||
self.clear_zero_debit_credit_row()
|
||||
if not self.title:
|
||||
self.title = self.get_title()
|
||||
|
||||
def clear_zero_debit_credit_row(self):
|
||||
self.accounts = [account for account in self.accounts if not (account.debit_in_account_currency==0.0 and account.credit_in_account_currency==0.0)]
|
||||
frappe.db.sql("""delete from `tabJournal Entry Account` where parent = %s and debit = 0.0 and credit = 0.0""", self.name)
|
||||
|
||||
|
||||
def on_submit(self):
|
||||
self.check_credit_limit()
|
||||
|
@ -171,8 +171,25 @@ class TestJournalEntry(unittest.TestCase):
|
||||
})
|
||||
|
||||
jv.submit()
|
||||
|
||||
def test_clear_blank_rows(self):
|
||||
je = make_journal_entry("_Test Bank - _TC", "_Test Account Stock Expenses - _TC", 100, save=False)
|
||||
je.append("accounts", {
|
||||
"account": "_Test Cash - _TC",
|
||||
"debit_in_account_currency": 0,
|
||||
"credit_in_account_currency": 0,
|
||||
"exchange_rate": 1
|
||||
})
|
||||
|
||||
self.assertEqual(len(je.get("accounts")), 3)
|
||||
je.save()
|
||||
self.assertEqual(len(je.get("accounts")), 2)
|
||||
|
||||
|
||||
def make_journal_entry(account1, account2, amount, cost_center=None, posting_date=None, exchange_rate=1, save=True, submit=False):
|
||||
if not cost_center:
|
||||
cost_center = "_Test Cost Center - _TC"
|
||||
|
||||
jv = frappe.new_doc("Journal Entry")
|
||||
jv.posting_date = posting_date or "2013-02-14"
|
||||
jv.company = "_Test Company"
|
||||
|
Loading…
x
Reference in New Issue
Block a user