make gl entry only if amount is there
This commit is contained in:
parent
4310fd6aa0
commit
98c6bbf1e7
@ -248,22 +248,23 @@ class DocType(AccountsController):
|
||||
from accounts.general_ledger import make_gl_entries
|
||||
gl_map = []
|
||||
for d in self.doclist.get({"parentfield": "entries"}):
|
||||
gl_map.append(
|
||||
self.get_gl_dict({
|
||||
"account": d.account,
|
||||
"against": d.against_account,
|
||||
"debit": d.debit,
|
||||
"credit": d.credit,
|
||||
"against_voucher_type": ((d.against_voucher and "Purchase Invoice")
|
||||
or (d.against_invoice and "Sales Invoice")
|
||||
or (d.against_jv and "Journal Voucher")),
|
||||
"against_voucher": d.against_voucher or d.against_invoice or d.against_jv,
|
||||
"remarks": self.doc.remark,
|
||||
"cost_center": d.cost_center
|
||||
}, cancel)
|
||||
)
|
||||
|
||||
make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj)
|
||||
if d.debit or d.credit:
|
||||
gl_map.append(
|
||||
self.get_gl_dict({
|
||||
"account": d.account,
|
||||
"against": d.against_account,
|
||||
"debit": d.debit,
|
||||
"credit": d.credit,
|
||||
"against_voucher_type": ((d.against_voucher and "Purchase Invoice")
|
||||
or (d.against_invoice and "Sales Invoice")
|
||||
or (d.against_jv and "Journal Voucher")),
|
||||
"against_voucher": d.against_voucher or d.against_invoice or d.against_jv,
|
||||
"remarks": self.doc.remark,
|
||||
"cost_center": d.cost_center
|
||||
}, cancel)
|
||||
)
|
||||
if gl_map:
|
||||
make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj)
|
||||
|
||||
def get_outstanding(self, args):
|
||||
args = eval(args)
|
||||
|
@ -422,16 +422,17 @@ class DocType(BuyingController):
|
||||
abbr = self.get_company_abbr()
|
||||
|
||||
# parent's gl entry
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": self.doc.credit_to,
|
||||
"against": self.doc.against_expense_account,
|
||||
"credit": self.doc.grand_total,
|
||||
"remarks": self.doc.remarks,
|
||||
"against_voucher": self.doc.name,
|
||||
"against_voucher_type": self.doc.doctype,
|
||||
}, is_cancel)
|
||||
)
|
||||
if self.doc.grand_total:
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": self.doc.credit_to,
|
||||
"against": self.doc.against_expense_account,
|
||||
"credit": self.doc.grand_total,
|
||||
"remarks": self.doc.remarks,
|
||||
"against_voucher": self.doc.name,
|
||||
"against_voucher_type": self.doc.doctype,
|
||||
}, is_cancel)
|
||||
)
|
||||
|
||||
# tax table gl entries
|
||||
for tax in getlist(self.doclist, "purchase_tax_details"):
|
||||
@ -506,7 +507,9 @@ class DocType(BuyingController):
|
||||
"cost_center": self.doc.write_off_cost_center
|
||||
}, is_cancel)
|
||||
)
|
||||
make_gl_entries(gl_entries, cancel=is_cancel)
|
||||
|
||||
if gl_entries:
|
||||
make_gl_entries(gl_entries, cancel=is_cancel)
|
||||
|
||||
|
||||
def check_next_docstatus(self):
|
||||
|
@ -637,16 +637,17 @@ class DocType(SellingController):
|
||||
abbr = self.get_company_abbr()
|
||||
|
||||
# parent's gl entry
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": self.doc.debit_to,
|
||||
"against": self.doc.against_income_account,
|
||||
"debit": self.doc.grand_total,
|
||||
"remarks": self.doc.remarks,
|
||||
"against_voucher": self.doc.name,
|
||||
"against_voucher_type": self.doc.doctype,
|
||||
}, is_cancel)
|
||||
)
|
||||
if self.doc.grand_total:
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": self.doc.debit_to,
|
||||
"against": self.doc.against_income_account,
|
||||
"debit": self.doc.grand_total,
|
||||
"remarks": self.doc.remarks,
|
||||
"against_voucher": self.doc.name,
|
||||
"against_voucher_type": self.doc.doctype,
|
||||
}, is_cancel)
|
||||
)
|
||||
|
||||
# tax table gl entries
|
||||
for tax in self.doclist.get({"parentfield": "other_charges"}):
|
||||
@ -745,8 +746,9 @@ class DocType(SellingController):
|
||||
|
||||
update_outstanding = self.doc.is_pos and self.doc.write_off_account and 'No' or 'Yes'
|
||||
merge_entries=cint(self.doc.is_pos)!=1 and 1 or 0
|
||||
make_gl_entries(gl_entries, cancel=is_cancel,
|
||||
update_outstanding=update_outstanding, merge_entries=merge_entries)
|
||||
if gl_entries:
|
||||
make_gl_entries(gl_entries, cancel=is_cancel,
|
||||
update_outstanding=update_outstanding, merge_entries=merge_entries)
|
||||
|
||||
def update_c_form(self):
|
||||
"""Update amended id in C-form"""
|
||||
|
Loading…
Reference in New Issue
Block a user