Fix loan auto-match (SQLite float-binding bug) + searchable matching modal#56
Merged
Merged
Conversation
Root cause: the amount band used whereBetween with float bounds. SQLite binds PHP floats as text, so 'ABS(amount) BETWEEN 285.0 AND 315.0' compared a numeric column against text bounds and never matched — auto-match silently found nothing on every loan. Fixed with CAST(? AS REAL). Also: - Auto-match now uses the configured monthly_rate (the real debit) for the amount band instead of only the computed annuity payment. - The payment-day proximity check now wraps month boundaries, so a debit that shifts into the next month (e.g. a 30th due date posting on the 1st) matches. - The 'Buchung zuordnen' modal gains a search box (description/counterparty/ reference/amount) and raises the cap from 50 to 100, so older payments are reachable instead of being stuck behind 5 pages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
Auto-match silently found nothing on every loan. The amount filter used
whereBetween(DB::raw('ABS(amount)'), [$low, $high])with float bounds. SQLite binds PHP floats as text, soABS(amount) BETWEEN '285.0' AND '315.0'compares a numeric column against text — where numerics always sort before text — and matches nothing. Verified:Fixed with
CAST(? AS REAL). This is why your loan payments were all matched manually and auto-match reported 'Keine passenden Buchungen gefunden'.Also fixed
monthly_rate(the actual debit) for the band, not just the computed annuity — everywhere else already usesmonthly_rate.Tests
LoanPaymentMatchingTest: monthly_rate matching, month-boundary wrap, text search, amount search. All pass; frontend builds.