mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-09 16:21:19 +00:00
[fix] [report] accounts receivable/payable
This commit is contained in:
@@ -24,7 +24,6 @@ def execute(filters=None):
|
|||||||
for gle in entries:
|
for gle in entries:
|
||||||
if cstr(gle.against_voucher) == gle.voucher_no or not gle.against_voucher \
|
if cstr(gle.against_voucher) == gle.voucher_no or not gle.against_voucher \
|
||||||
or [gle.against_voucher_type, gle.against_voucher] in entries_after_report_date:
|
or [gle.against_voucher_type, gle.against_voucher] in entries_after_report_date:
|
||||||
|
|
||||||
if gle.voucher_type == "Purchase Invoice":
|
if gle.voucher_type == "Purchase Invoice":
|
||||||
pi_info = pi_map.get(gle.voucher_no)
|
pi_info = pi_map.get(gle.voucher_no)
|
||||||
due_date = pi_info.get("due_date")
|
due_date = pi_info.get("due_date")
|
||||||
@@ -33,12 +32,12 @@ def execute(filters=None):
|
|||||||
else:
|
else:
|
||||||
due_date = bill_no = bill_date = ""
|
due_date = bill_no = bill_date = ""
|
||||||
|
|
||||||
invoiced_amount = gle.credit > 0 and gle.credit or 0
|
invoiced_amount = gle.credit > 0 and gle.credit or 0
|
||||||
paid_amount = get_paid_amount(gle, filters.get("report_date") or nowdate(),
|
outstanding_amount = get_outstanding_amount(gle,
|
||||||
entries_after_report_date)
|
filters.get("report_date") or nowdate())
|
||||||
outstanding_amount = invoiced_amount - paid_amount
|
|
||||||
|
|
||||||
if abs(flt(outstanding_amount)) > 0.01:
|
if abs(flt(outstanding_amount)) > 0.01:
|
||||||
|
paid_amount = invoiced_amount - outstanding_amount
|
||||||
row = [gle.posting_date, gle.account, gle.voucher_type, gle.voucher_no,
|
row = [gle.posting_date, gle.account, gle.voucher_type, gle.voucher_no,
|
||||||
gle.remarks, account_supplier_type_map.get(gle.account), due_date, bill_no,
|
gle.remarks, account_supplier_type_map.get(gle.account), due_date, bill_no,
|
||||||
bill_date, invoiced_amount, paid_amount, outstanding_amount]
|
bill_date, invoiced_amount, paid_amount, outstanding_amount]
|
||||||
@@ -116,17 +115,13 @@ def get_pi_map():
|
|||||||
|
|
||||||
return pi_map
|
return pi_map
|
||||||
|
|
||||||
def get_paid_amount(gle, report_date, entries_after_report_date):
|
def get_outstanding_amount(gle, report_date):
|
||||||
|
payment_amount = webnotes.conn.sql("""
|
||||||
paid_amount = 0
|
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||||
if flt(gle.debit) > 0 and (not gle.against_voucher or
|
from `tabGL Entry`
|
||||||
[gle.against_voucher_type, gle.against_voucher] in entries_after_report_date):
|
where account = %s and posting_date <= %s and against_voucher_type = %s
|
||||||
paid_amount = gle.debit
|
and against_voucher = %s and name != %s and ifnull(is_cancelled, 'No') = 'No'""",
|
||||||
elif flt(gle.credit) > 0:
|
(gle.account, report_date, gle.voucher_type, gle.voucher_no, gle.name))[0][0]
|
||||||
paid_amount = webnotes.conn.sql("""
|
|
||||||
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) from `tabGL Entry`
|
outstanding_amount = flt(gle.credit) - flt(gle.debit) - flt(payment_amount)
|
||||||
where account = %s and posting_date <= %s and against_voucher_type = %s
|
return outstanding_amount
|
||||||
and against_voucher = %s and name != %s and ifnull(is_cancelled, 'No') = 'No'""",
|
|
||||||
(gle.account, report_date, gle.voucher_type, gle.voucher_no, gle.name))[0][0]
|
|
||||||
|
|
||||||
return flt(paid_amount)
|
|
||||||
@@ -27,11 +27,11 @@ def execute(filters=None):
|
|||||||
and si_due_date_map.get(gle.voucher_no) or ""
|
and si_due_date_map.get(gle.voucher_no) or ""
|
||||||
|
|
||||||
invoiced_amount = gle.debit > 0 and gle.debit or 0
|
invoiced_amount = gle.debit > 0 and gle.debit or 0
|
||||||
payment_amount = get_payment_amount(gle, filters.get("report_date") or nowdate(),
|
outstanding_amount = get_outstanding_amount(gle,
|
||||||
entries_after_report_date)
|
filters.get("report_date") or nowdate())
|
||||||
outstanding_amount = invoiced_amount - payment_amount
|
|
||||||
|
|
||||||
if abs(flt(outstanding_amount)) > 0.01:
|
if abs(flt(outstanding_amount)) > 0.01:
|
||||||
|
payment_amount = invoiced_amount - outstanding_amount
|
||||||
row = [gle.posting_date, gle.account, gle.voucher_type, gle.voucher_no,
|
row = [gle.posting_date, gle.account, gle.voucher_type, gle.voucher_no,
|
||||||
gle.remarks, due_date, account_territory_map.get(gle.account),
|
gle.remarks, due_date, account_territory_map.get(gle.account),
|
||||||
invoiced_amount, payment_amount, outstanding_amount]
|
invoiced_amount, payment_amount, outstanding_amount]
|
||||||
@@ -104,6 +104,16 @@ def get_si_due_date_map():
|
|||||||
|
|
||||||
return si_due_date_map
|
return si_due_date_map
|
||||||
|
|
||||||
|
def get_outstanding_amount(gle, report_date):
|
||||||
|
payment_amount = webnotes.conn.sql("""
|
||||||
|
select sum(ifnull(credit, 0)) - sum(ifnull(debit, 0))
|
||||||
|
from `tabGL Entry`
|
||||||
|
where account = %s and posting_date <= %s and against_voucher_type = %s
|
||||||
|
and against_voucher = %s and name != %s and ifnull(is_cancelled, 'No') = 'No'""",
|
||||||
|
(gle.account, report_date, gle.voucher_type, gle.voucher_no, gle.name))[0][0]
|
||||||
|
|
||||||
|
return flt(gle.debit) - flt(gle.credit) - flt(payment_amount)
|
||||||
|
|
||||||
def get_payment_amount(gle, report_date, entries_after_report_date):
|
def get_payment_amount(gle, report_date, entries_after_report_date):
|
||||||
payment_amount = 0
|
payment_amount = 0
|
||||||
if flt(gle.credit) > 0 and (not gle.against_voucher or
|
if flt(gle.credit) > 0 and (not gle.against_voucher or
|
||||||
|
|||||||
Reference in New Issue
Block a user