Skip to content

Commit

Permalink
fix: debit note not pulled on reconciliation tool
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthra-kumar committed Dec 29, 2022
1 parent 92c895a commit cf133b2
Showing 1 changed file with 6 additions and 4 deletions.
Expand Up @@ -149,14 +149,16 @@ def get_dr_or_cr_notes(self):

reconciled_dr_or_cr = (
gl["debit_in_account_currency"]
if dr_or_cr == gl["credit_in_account_currency"]
if dr_or_cr.name == "credit_in_account_currency"
else gl["credit_in_account_currency"]
)

having_clause = qb.Field("amount") > 0

if self.minimum_payment_amount:
conditions.append(dr_or_cr.gte(self.minimum_payment_amount))
having_clause = qb.Field("amount") >= self.minimum_payment_amount
if self.maximum_payment_amount:
conditions.append(dr_or_cr.lte(self.maximum_payment_amount))
having_clause = having_clause & qb.Field("amount") <= self.maximum_payment_amount

sub_query = (
qb.from_(doc)
Expand Down Expand Up @@ -188,7 +190,7 @@ def get_dr_or_cr_notes(self):
)
.where(Criterion.all(conditions))
.groupby(gl.against_voucher)
.having(qb.Field("amount") > 0)
.having(having_clause)
)
dr_cr_notes = query.run(as_dict=True)
return dr_cr_notes
Expand Down

0 comments on commit cf133b2

Please sign in to comment.