Repository navigation
fix(fx): leave only the truly borrowed part of a loan repayment to reconcile by hand - #464
Merged
Merged
Conversation
…ther loan with a result The default kept a loan's borrowed-principal count (borrowedLeft) too high when its returned principal repaid another loan at a nonzero result: only a gain-0 row took the spent units out. A later pass-on of the paid-for rest then went outside 1633/1637, and the loan note said `_manual` with too small a boxGain (PASS: 35 instead of 55 of 75 EUR). Tax figures never changed. Every repayment now retires the borrowed units it spends from their loan, borrowed units first; only a gain-0 row still counts them outside the boxes. docs/casillas.md, docs/traza-fx.md and the #449 Hard Trace now say that a repayment with a result is always in 1633/1637, and that another loan's principal is outside only for the part of its loan your currency has not paid, also when it paid another part (PR #463 review).
…borrowed principal pays it docs/casillas.md and docs/traza-fx.md told the user that a loan's principal stays borrowed until currency of their own pays the loan. The code counts a loan as paid by any repayment in 1633/1637, also a row with a result paid with another loan's borrowed principal (P2: L2's principal repays L1 with a 5 EUR result, then L1's principal repays L3 inside the boxes, the plain note with gain 75; only at gain 0, P2-ZERO, does L1 stay borrowed: `_manual`, boxGain 15 of 65). The docs now say that, CLAUDE.md #449 pins P2 and P2-ZERO, and the PASS-ZERO test no longer claims the same split as PASS (PR #463 review).
Contributor
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #464 +/- ##
=======================================
Coverage 94.07% 94.07%
=======================================
Files 64 64
Lines 8382 8383 +1
Branches 2904 2905 +1
=======================================
+ Hits 7885 7886 +1
Misses 409 409
Partials 88 88
🚀 New features to boost your workflow:
|
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.
Problem
CodeRabbit reviewed #463 after it shipped in v0.66.12. It found that the loan note could leave too much to reconcile by hand. This affects only the default method, «Criterio DGT (multidivisa)».
When shares bought on a loan are sold, they give back that loan's dollars. Those dollars can repay another loan. The engine took them out of their own loan's still-borrowed count only when that repayment booked 0. When it booked a gain or a loss, the count stayed too high.
Later, a funding paid for the rest of that loan. Its dollars still counted as borrowed, so their repayment of a third loan was placed outside 1633/1637. In the reviewer's case the note said 35 € of 75 € were in the boxes, so 40 € were left to reconcile by hand. The right split is 55 € in the boxes and 20 € by hand.
The docs also described the hand-reconcile case wrongly. They said another loan's dollars stay outside the boxes until your own currency pays that loan. The code actually counts a loan as paid by any repayment inside 1633/1637, and a repayment with a result is always inside.
Fix
docs/casillas.md,docs/traza-fx.mdand the Both FX methods: a buy paid by a later day's sale (overnight overdraft) misses the economic total #449 section ofCLAUDE.mdnow say what the code does:What users see
boxGain/boxLoss) and the hint text that prints it can change. In the default method this happens only when the Cash Report passes the loan gate and one loan's dollars repay another at a nonzero result.boxGainwent from 35.00 to 55.00. One handwritten chain of 4 loans (CHAIN4) moved from 39.00 to 51.00 for the same reason. Both were checked by hand.Left on purpose
Checks
Follow-up to #463, from the CodeRabbit review of its exact diff on the fork mirror.