feat(Bank Reconcilitation Beta): prioritize ranking parameters#331
feat(Bank Reconcilitation Beta): prioritize ranking parameters#331PatrickDEissler wants to merge 2 commits intoversion-15-hotfixfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request introduces weighted ranking parameters for the Bank Reconciliation Beta feature to prioritize matching criteria. The change addresses the issue where all parameters (date, name, amount, reference) had equal weight in voucher matching, which was suboptimal for real-world scenarios where exact amounts are more reliable indicators than posting dates (especially for Purchase Invoices).
Changes:
- Added six weight constants (REF_RANK_WEIGHT=3, PARTY_RANK_WEIGHT=2, AMOUNT_RANK_WEIGHT=2, DATE_RANK_WEIGHT=1, NAME_MATCH_WEIGHT=3, REF_MATCH_WEIGHT=3) to prioritize ranking parameters
- Updated all rank_expression calculations across 10 matching query functions to apply these weights
- Removed the post-processing rank increment for reference number matches found in transaction descriptions
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| reference_no = voucher["reference_no"] | ||
| if reference_no and (reference_no.strip() in transaction.description): | ||
| voucher["rank"] += 1 | ||
| voucher["name_in_desc_match"] = 1 |
There was a problem hiding this comment.
The rank increment for reference number matches found in transaction description was removed but should have been updated to use the weight. For voucher types that don't compute name_match in their SQL queries (Bank Transaction, Loan Disbursement, Loan Repayment, Payment Entry, Journal Entry), this post-processing step needs to apply the weighted rank increment. The line should be: voucher["rank"] += REF_MATCH_WEIGHT
| voucher["name_in_desc_match"] = 1 | |
| voucher["rank"] += REF_MATCH_WEIGHT |
| REF_RANK_WEIGHT = 3 # Reference number match | ||
| PARTY_RANK_WEIGHT = 2 # Party match | ||
| AMOUNT_RANK_WEIGHT = 2 # Amount match | ||
| DATE_RANK_WEIGHT = 1 # Date match | ||
| NAME_MATCH_WEIGHT = 3 # Name (Paid From) match | ||
| REF_MATCH_WEIGHT = 3 # Reference number match in description |
There was a problem hiding this comment.
The comment for REF_MATCH_WEIGHT says "Reference number match in description" but REF_RANK_WEIGHT also says "Reference number match". These should be more clearly differentiated. REF_RANK_WEIGHT should say "Reference field equality match" and REF_MATCH_WEIGHT should say "Reference number found in transaction description".
| REF_RANK_WEIGHT = 3 # Reference number match | |
| PARTY_RANK_WEIGHT = 2 # Party match | |
| AMOUNT_RANK_WEIGHT = 2 # Amount match | |
| DATE_RANK_WEIGHT = 1 # Date match | |
| NAME_MATCH_WEIGHT = 3 # Name (Paid From) match | |
| REF_MATCH_WEIGHT = 3 # Reference number match in description | |
| REF_RANK_WEIGHT = 3 # Reference field equality match | |
| PARTY_RANK_WEIGHT = 2 # Party match | |
| AMOUNT_RANK_WEIGHT = 2 # Amount match | |
| DATE_RANK_WEIGHT = 1 # Date match | |
| NAME_MATCH_WEIGHT = 3 # Name (Paid From) match | |
| REF_MATCH_WEIGHT = 3 # Reference number found in transaction description |
Problem
All parameters (like date, name, amount) etc. had the same strength in for the ranking in "Match Voucher" tab.
Example: Purchase Invoices are rarely paid on the Posting Date, but they are often paid with the exact Grand Total. Currently both parameters have the same effect on the ranking.
Assumption of this PR
In practice a prioritization of the parameters increase the chances of having the correct vouchers further up in the list of vouchers.
Solution
Add hardcoded weights to prioritize the ranking in the Bank Reconciliation Beta (Match Voucher).