mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 14:39:19 +00:00
[minor] make gl entry through bean and testcases
This commit is contained in:
@@ -18,10 +18,10 @@ class DocType:
|
||||
self.validate_posting_date()
|
||||
self.check_credit_limit()
|
||||
self.check_pl_account()
|
||||
|
||||
def on_update(self, adv_adj, update_outstanding = 'Yes'):
|
||||
self.validate_account_details(adv_adj)
|
||||
self.validate_cost_center()
|
||||
|
||||
def on_update_with_args(self, adv_adj, update_outstanding = 'Yes'):
|
||||
self.validate_account_details(adv_adj)
|
||||
validate_freezed_account(self.doc.account, adv_adj)
|
||||
check_freezing_date(self.doc.posting_date, adv_adj)
|
||||
check_negative_balance(self.doc.account, adv_adj)
|
||||
|
||||
@@ -49,7 +49,7 @@ class DocType(AccountsController):
|
||||
from accounts.utils import remove_against_link_from_jv
|
||||
remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_jv")
|
||||
|
||||
self.make_gl_entries()
|
||||
self.make_gl_entries(1)
|
||||
|
||||
def on_trash(self):
|
||||
pass
|
||||
@@ -258,7 +258,7 @@ class DocType(AccountsController):
|
||||
})
|
||||
)
|
||||
if gl_map:
|
||||
make_gl_entries(gl_map, cancel=self.doc.docstatus==2, adv_adj=adv_adj)
|
||||
make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj)
|
||||
|
||||
def get_outstanding(self, args):
|
||||
args = eval(args)
|
||||
|
||||
@@ -66,20 +66,24 @@ def save_entries(gl_map, adv_adj, update_outstanding):
|
||||
if flt(entry["debit"]) < 0 or flt(entry["credit"]) < 0:
|
||||
_swap(entry)
|
||||
|
||||
gle = Document('GL Entry', fielddata=entry)
|
||||
gle_obj = webnotes.get_obj(doc=gle)
|
||||
gle_obj.validate()
|
||||
gle.save(1)
|
||||
gle_obj.on_update(adv_adj, update_outstanding)
|
||||
make_entry(entry, adv_adj, update_outstanding)
|
||||
|
||||
validate_expense_against_budget(entry)
|
||||
|
||||
# update total debit / credit
|
||||
total_debit += flt(gle.debit)
|
||||
total_credit += flt(gle.credit)
|
||||
|
||||
total_debit += flt(entry["debit"])
|
||||
total_credit += flt(entry["credit"])
|
||||
|
||||
validate_total_debit_credit(total_debit, total_credit)
|
||||
|
||||
def make_entry(args, adv_adj, update_outstanding):
|
||||
args.update({"doctype": "GL Entry"})
|
||||
gle = webnotes.bean([args])
|
||||
gle.ignore_permissions = 1
|
||||
gle.insert()
|
||||
gle.run_method("on_update_with_args", adv_adj, update_outstanding)
|
||||
gle.submit()
|
||||
|
||||
def validate_total_debit_credit(total_debit, total_credit):
|
||||
if abs(total_debit - total_credit) > 0.005:
|
||||
webnotes.throw(_("Debit and Credit not equal for this voucher: Diff (Debit) is ") +
|
||||
@@ -102,4 +106,4 @@ def delete_gl_entries(gl_entries, adv_adj, update_outstanding):
|
||||
if entry.get("against_voucher") and entry.get("against_voucher_type") != "POS" \
|
||||
and update_outstanding == 'Yes':
|
||||
update_outstanding_amt(entry["account"], entry.get("against_voucher_type"),
|
||||
entry.get("against_voucher"))
|
||||
entry.get("against_voucher"), on_cancel=True)
|
||||
Reference in New Issue
Block a user