Merge pull request #43073 from frappe/mergify/bp/version-14-hotfix/pr-43070
fix: AP filter to simulate employee advance as a ledger impacting voucher (backport #43070)
This commit is contained in:
@@ -162,6 +162,11 @@ frappe.query_reports["Accounts Payable"] = {
|
|||||||
label: __("Group by Voucher"),
|
label: __("Group by Voucher"),
|
||||||
fieldtype: "Check",
|
fieldtype: "Check",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldname: "handle_employee_advances",
|
||||||
|
label: __("Handle Employee Advances"),
|
||||||
|
fieldtype: "Check",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
formatter: function (value, row, column, data, default_formatter) {
|
formatter: function (value, row, column, data, default_formatter) {
|
||||||
|
|||||||
@@ -112,18 +112,8 @@ class ReceivablePayableReport:
|
|||||||
|
|
||||||
self.build_data()
|
self.build_data()
|
||||||
|
|
||||||
def init_voucher_balance(self):
|
def build_voucher_dict(self, ple):
|
||||||
# build all keys, since we want to exclude vouchers beyond the report date
|
return frappe._dict(
|
||||||
for ple in self.ple_entries:
|
|
||||||
# get the balance object for voucher_type
|
|
||||||
|
|
||||||
if self.filters.get("ignore_accounts"):
|
|
||||||
key = (ple.voucher_type, ple.voucher_no, ple.party)
|
|
||||||
else:
|
|
||||||
key = (ple.account, ple.voucher_type, ple.voucher_no, ple.party)
|
|
||||||
|
|
||||||
if key not in self.voucher_balance:
|
|
||||||
self.voucher_balance[key] = frappe._dict(
|
|
||||||
voucher_type=ple.voucher_type,
|
voucher_type=ple.voucher_type,
|
||||||
voucher_no=ple.voucher_no,
|
voucher_no=ple.voucher_no,
|
||||||
party=ple.party,
|
party=ple.party,
|
||||||
@@ -141,6 +131,20 @@ class ReceivablePayableReport:
|
|||||||
outstanding_in_account_currency=0.0,
|
outstanding_in_account_currency=0.0,
|
||||||
cost_center=ple.cost_center,
|
cost_center=ple.cost_center,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def init_voucher_balance(self):
|
||||||
|
# build all keys, since we want to exclude vouchers beyond the report date
|
||||||
|
for ple in self.ple_entries:
|
||||||
|
# get the balance object for voucher_type
|
||||||
|
|
||||||
|
if self.filters.get("ignore_accounts"):
|
||||||
|
key = (ple.voucher_type, ple.voucher_no, ple.party)
|
||||||
|
else:
|
||||||
|
key = (ple.account, ple.voucher_type, ple.voucher_no, ple.party)
|
||||||
|
|
||||||
|
if key not in self.voucher_balance:
|
||||||
|
self.voucher_balance[key] = self.build_voucher_dict(ple)
|
||||||
|
|
||||||
self.get_invoices(ple)
|
self.get_invoices(ple)
|
||||||
|
|
||||||
if self.filters.get("group_by_party"):
|
if self.filters.get("group_by_party"):
|
||||||
@@ -208,6 +212,18 @@ class ReceivablePayableReport:
|
|||||||
|
|
||||||
row = self.voucher_balance.get(key)
|
row = self.voucher_balance.get(key)
|
||||||
|
|
||||||
|
# Build and use a separate row for Employee Advances.
|
||||||
|
# This allows Payments or Journals made against Emp Advance to be processed.
|
||||||
|
if (
|
||||||
|
not row
|
||||||
|
and ple.against_voucher_type == "Employee Advance"
|
||||||
|
and self.filters.handle_employee_advances
|
||||||
|
):
|
||||||
|
_d = self.build_voucher_dict(ple)
|
||||||
|
_d.voucher_type = ple.against_voucher_type
|
||||||
|
_d.voucher_no = ple.against_voucher_no
|
||||||
|
row = self.voucher_balance[key] = _d
|
||||||
|
|
||||||
if not row:
|
if not row:
|
||||||
# no invoice, this is an invoice / stand-alone payment / credit note
|
# no invoice, this is an invoice / stand-alone payment / credit note
|
||||||
if self.filters.get("ignore_accounts"):
|
if self.filters.get("ignore_accounts"):
|
||||||
|
|||||||
Reference in New Issue
Block a user