fix: cost_center filter gives incorrect output

filtering on cost center gives invoices that are reconciled as having outstanding
This commit is contained in:
ruthra kumar 2022-12-14 16:05:15 +05:30
parent 2e2590b224
commit 6d9d730759
2 changed files with 8 additions and 1 deletions

View File

@ -23,6 +23,7 @@ class PaymentReconciliation(Document):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(PaymentReconciliation, self).__init__(*args, **kwargs) super(PaymentReconciliation, self).__init__(*args, **kwargs)
self.common_filter_conditions = [] self.common_filter_conditions = []
self.accounting_dimension_filter_conditions = []
self.ple_posting_date_filter = [] self.ple_posting_date_filter = []
@frappe.whitelist() @frappe.whitelist()
@ -193,6 +194,7 @@ class PaymentReconciliation(Document):
posting_date=self.ple_posting_date_filter, posting_date=self.ple_posting_date_filter,
min_outstanding=self.minimum_invoice_amount if self.minimum_invoice_amount else None, min_outstanding=self.minimum_invoice_amount if self.minimum_invoice_amount else None,
max_outstanding=self.maximum_invoice_amount if self.maximum_invoice_amount else None, max_outstanding=self.maximum_invoice_amount if self.maximum_invoice_amount else None,
accounting_dimensions=self.accounting_dimension_filter_conditions,
) )
if self.invoice_limit: if self.invoice_limit:
@ -381,7 +383,7 @@ class PaymentReconciliation(Document):
self.common_filter_conditions.append(ple.company == self.company) self.common_filter_conditions.append(ple.company == self.company)
if self.get("cost_center") and (get_invoices or get_return_invoices): if self.get("cost_center") and (get_invoices or get_return_invoices):
self.common_filter_conditions.append(ple.cost_center == self.cost_center) self.accounting_dimension_filter_conditions.append(ple.cost_center == self.cost_center)
if get_invoices: if get_invoices:
if self.from_invoice_date: if self.from_invoice_date:

View File

@ -836,6 +836,7 @@ def get_outstanding_invoices(
posting_date=None, posting_date=None,
min_outstanding=None, min_outstanding=None,
max_outstanding=None, max_outstanding=None,
accounting_dimensions=None,
): ):
ple = qb.DocType("Payment Ledger Entry") ple = qb.DocType("Payment Ledger Entry")
@ -866,6 +867,7 @@ def get_outstanding_invoices(
min_outstanding=min_outstanding, min_outstanding=min_outstanding,
max_outstanding=max_outstanding, max_outstanding=max_outstanding,
get_invoices=True, get_invoices=True,
accounting_dimensions=accounting_dimensions or [],
) )
for d in invoice_list: for d in invoice_list:
@ -1615,6 +1617,7 @@ class QueryPaymentLedger(object):
.where(ple.delinked == 0) .where(ple.delinked == 0)
.where(Criterion.all(filter_on_voucher_no)) .where(Criterion.all(filter_on_voucher_no))
.where(Criterion.all(self.common_filter)) .where(Criterion.all(self.common_filter))
.where(Criterion.all(self.dimensions_filter))
.where(Criterion.all(self.voucher_posting_date)) .where(Criterion.all(self.voucher_posting_date))
.groupby(ple.voucher_type, ple.voucher_no, ple.party_type, ple.party) .groupby(ple.voucher_type, ple.voucher_no, ple.party_type, ple.party)
) )
@ -1702,6 +1705,7 @@ class QueryPaymentLedger(object):
max_outstanding=None, max_outstanding=None,
get_payments=False, get_payments=False,
get_invoices=False, get_invoices=False,
accounting_dimensions=None,
): ):
""" """
Fetch voucher amount and outstanding amount from Payment Ledger using Database CTE Fetch voucher amount and outstanding amount from Payment Ledger using Database CTE
@ -1717,6 +1721,7 @@ class QueryPaymentLedger(object):
self.reset() self.reset()
self.vouchers = vouchers self.vouchers = vouchers
self.common_filter = common_filter or [] self.common_filter = common_filter or []
self.dimensions_filter = accounting_dimensions or []
self.voucher_posting_date = posting_date or [] self.voucher_posting_date = posting_date or []
self.min_outstanding = min_outstanding self.min_outstanding = min_outstanding
self.max_outstanding = max_outstanding self.max_outstanding = max_outstanding