Skip to content

Commit

Permalink
fix: Accomodate common_filters=None in Bank Reco API
Browse files Browse the repository at this point in the history
  • Loading branch information
marination committed Sep 23, 2024
1 parent e05f885 commit a6e74cc
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions hrms/hr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,21 +762,26 @@ def get_ec_matching_query(
filters.append(ec.docstatus == 1)
filters.append(ec.is_paid == 1)
filters.append(ec.clearance_date.isnull())
filters.append(ec.mode_of_payment.isin(mode_of_payments))
if exact_match:
filters.append(ec.total_sanctioned_amount == common_filters.amount)
if mode_of_payments:
filters.append(ec.mode_of_payment.isin(mode_of_payments))

if common_filters:
ref_rank = frappe.qb.terms.Case().when(ec.employee == common_filters.party, 1).else_(0) + 1

if exact_match:
filters.append(ec.total_sanctioned_amount == common_filters.amount)
else:
filters.append(ec.total_sanctioned_amount.gt(common_filters.amount))
else:
filters.append(ec.total_sanctioned_amount.gt(common_filters.amount))
ref_rank = ConstantColumn(1)

if from_date and to_date:
filters.append(ec.posting_date[from_date:to_date])

ref_rank = frappe.qb.terms.Case().when(ec.employee == common_filters.party, 1).else_(0)

ec_query = (
qb.from_(ec)
.select(
(ref_rank + 1).as_("rank"),
ref_rank.as_("rank"),
ec.name,
ec.total_sanctioned_amount.as_("paid_amount"),
ConstantColumn("").as_("reference_no"),
Expand Down

0 comments on commit a6e74cc

Please sign in to comment.