mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 21:19:19 +00:00
Supplier bill info in accounts payable report
This commit is contained in:
@@ -19,8 +19,8 @@ def execute(filters=None):
|
|||||||
for gle in get_gl_entries(filters, before_report_date=False)]
|
for gle in get_gl_entries(filters, before_report_date=False)]
|
||||||
|
|
||||||
account_supplier_type_map = get_account_supplier_type_map()
|
account_supplier_type_map = get_account_supplier_type_map()
|
||||||
pi_map = get_pi_map()
|
voucher_detail_map = get_voucher_details()
|
||||||
|
|
||||||
# Age of the invoice on this date
|
# Age of the invoice on this date
|
||||||
age_on = getdate(filters.get("report_date")) > getdate(nowdate()) \
|
age_on = getdate(filters.get("report_date")) > getdate(nowdate()) \
|
||||||
and nowdate() or filters.get("report_date")
|
and nowdate() or filters.get("report_date")
|
||||||
@@ -29,14 +29,8 @@ 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":
|
voucher_details = voucher_detail_map.get(gle.voucher_type, {}).get(gle.voucher_no, {})
|
||||||
pi_info = pi_map.get(gle.voucher_no)
|
|
||||||
due_date = pi_info.get("due_date")
|
|
||||||
bill_no = pi_info.get("bill_no")
|
|
||||||
bill_date = pi_info.get("bill_date")
|
|
||||||
else:
|
|
||||||
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
|
||||||
outstanding_amount = get_outstanding_amount(gle,
|
outstanding_amount = get_outstanding_amount(gle,
|
||||||
filters.get("report_date") or nowdate())
|
filters.get("report_date") or nowdate())
|
||||||
@@ -44,13 +38,15 @@ def execute(filters=None):
|
|||||||
if abs(flt(outstanding_amount)) > 0.01:
|
if abs(flt(outstanding_amount)) > 0.01:
|
||||||
paid_amount = invoiced_amount - outstanding_amount
|
paid_amount = invoiced_amount - outstanding_amount
|
||||||
row = [gle.posting_date, gle.account, account_supplier.get(gle.account, ""),
|
row = [gle.posting_date, gle.account, account_supplier.get(gle.account, ""),
|
||||||
gle.voucher_type, gle.voucher_no,
|
gle.voucher_type, gle.voucher_no, gle.remarks,
|
||||||
gle.remarks, account_supplier_type_map.get(gle.account), due_date, bill_no,
|
account_supplier_type_map.get(gle.account),
|
||||||
bill_date, invoiced_amount, paid_amount, outstanding_amount]
|
voucher_details.get("due_date", ""), voucher_details.get("bill_no", ""),
|
||||||
|
voucher_details.get("bill_date", ""), invoiced_amount,
|
||||||
|
paid_amount, outstanding_amount]
|
||||||
|
|
||||||
# Ageing
|
# Ageing
|
||||||
if filters.get("ageing_based_on") == "Due Date":
|
if filters.get("ageing_based_on") == "Due Date":
|
||||||
ageing_based_on_date = due_date
|
ageing_based_on_date = voucher_details.get("due_date", "")
|
||||||
else:
|
else:
|
||||||
ageing_based_on_date = gle.posting_date
|
ageing_based_on_date = gle.posting_date
|
||||||
|
|
||||||
@@ -112,14 +108,15 @@ def get_account_supplier_type_map():
|
|||||||
|
|
||||||
return account_supplier_type_map
|
return account_supplier_type_map
|
||||||
|
|
||||||
def get_pi_map():
|
def get_voucher_details():
|
||||||
""" get due_date from sales invoice """
|
voucher_details = {}
|
||||||
pi_map = {}
|
for dt in ["Purchase Invoice", "Journal Voucher"]:
|
||||||
for t in webnotes.conn.sql("""select name, due_date, bill_no, bill_date
|
voucher_details.setdefault(dt, webnotes._dict())
|
||||||
from `tabPurchase Invoice`""", as_dict=1):
|
for t in webnotes.conn.sql("""select name, due_date, bill_no, bill_date
|
||||||
pi_map[t.name] = t
|
from `tab%s`""" % dt, as_dict=1):
|
||||||
|
voucher_details[dt].setdefault(t.name, t)
|
||||||
|
|
||||||
return pi_map
|
return voucher_details
|
||||||
|
|
||||||
def get_outstanding_amount(gle, report_date):
|
def get_outstanding_amount(gle, report_date):
|
||||||
payment_amount = webnotes.conn.sql("""
|
payment_amount = webnotes.conn.sql("""
|
||||||
|
|||||||
Reference in New Issue
Block a user