fix: Show GL balance in Accounts Receivable and payable summary
This commit is contained in:
@@ -117,6 +117,11 @@ frappe.query_reports["Accounts Receivable Summary"] = {
|
|||||||
"label": __("Show Future Payments"),
|
"label": __("Show Future Payments"),
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"show_gl_balance",
|
||||||
|
"label": __("Show GL Balance"),
|
||||||
|
"fieldtype": "Check",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
onload: function(report) {
|
onload: function(report) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, scrub
|
from frappe import _, scrub
|
||||||
from frappe.utils import cint
|
from frappe.utils import cint, flt
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
|
||||||
from erpnext.accounts.party import get_partywise_advanced_payment_amount
|
from erpnext.accounts.party import get_partywise_advanced_payment_amount
|
||||||
@@ -37,6 +37,9 @@ class AccountsReceivableSummary(ReceivablePayableReport):
|
|||||||
party_advance_amount = get_partywise_advanced_payment_amount(self.party_type,
|
party_advance_amount = get_partywise_advanced_payment_amount(self.party_type,
|
||||||
self.filters.report_date, self.filters.show_future_payments, self.filters.company) or {}
|
self.filters.report_date, self.filters.show_future_payments, self.filters.company) or {}
|
||||||
|
|
||||||
|
if self.filters.show_gl_balance:
|
||||||
|
gl_balance_map = get_gl_balance(self.filters.report_date)
|
||||||
|
|
||||||
for party, party_dict in iteritems(self.party_total):
|
for party, party_dict in iteritems(self.party_total):
|
||||||
if party_dict.outstanding == 0:
|
if party_dict.outstanding == 0:
|
||||||
continue
|
continue
|
||||||
@@ -56,6 +59,10 @@ class AccountsReceivableSummary(ReceivablePayableReport):
|
|||||||
# but in summary report advance shown in separate column
|
# but in summary report advance shown in separate column
|
||||||
row.paid -= row.advance
|
row.paid -= row.advance
|
||||||
|
|
||||||
|
if self.filters.show_gl_balance:
|
||||||
|
row.gl_balance = gl_balance_map.get(party)
|
||||||
|
row.diff = flt(row.outstanding) - flt(row.gl_balance)
|
||||||
|
|
||||||
self.data.append(row)
|
self.data.append(row)
|
||||||
|
|
||||||
def get_party_total(self, args):
|
def get_party_total(self, args):
|
||||||
@@ -115,6 +122,10 @@ class AccountsReceivableSummary(ReceivablePayableReport):
|
|||||||
self.add_column(_(credit_debit_label), fieldname='credit_note')
|
self.add_column(_(credit_debit_label), fieldname='credit_note')
|
||||||
self.add_column(_('Outstanding Amount'), fieldname='outstanding')
|
self.add_column(_('Outstanding Amount'), fieldname='outstanding')
|
||||||
|
|
||||||
|
if self.filters.show_gl_balance:
|
||||||
|
self.add_column(_('GL Balance'), fieldname='gl_balance')
|
||||||
|
self.add_column(_('Difference'), fieldname='diff')
|
||||||
|
|
||||||
self.setup_ageing_columns()
|
self.setup_ageing_columns()
|
||||||
|
|
||||||
if self.party_type == "Customer":
|
if self.party_type == "Customer":
|
||||||
@@ -141,3 +152,7 @@ class AccountsReceivableSummary(ReceivablePayableReport):
|
|||||||
|
|
||||||
# Add column for total due amount
|
# Add column for total due amount
|
||||||
self.add_column(label="Total Amount Due", fieldname='total_due')
|
self.add_column(label="Total Amount Due", fieldname='total_due')
|
||||||
|
|
||||||
|
def get_gl_balance(report_date):
|
||||||
|
return frappe._dict(frappe.db.get_all("GL Entry", fields=['party', 'sum(debit - credit)'],
|
||||||
|
filters={'posting_date': ("<=", report_date), 'is_cancelled': 0}, group_by='party', as_list=1))
|
||||||
|
|||||||
Reference in New Issue
Block a user