-
Notifications
You must be signed in to change notification settings - Fork 12
rcv: Refactor grouping logic for RCV parsing #937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rcv: Refactor grouping logic for RCV parsing #937
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the RCV (Registro de Compra y Venta) CSV parsing logic to correctly group rows by the combination of folio + tipo docto + rut instead of just folio. This change ensures that rows with the same folio but different document types or RUT values are treated as separate entries, which is necessary for properly handling "Otros Impuestos" (Other Taxes) data.
- Changed the grouping key from
foliotoentry_key(combination of folio, tipo docto, and rut) - Added support for different RUT field names between RCV Venta and RCV Compra schemas
- Updated test expectations to verify the new grouping behavior with edge cases
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/cl_sii/rcv/parse_csv.py | Refactored grouping logic to use composite key (folio + tipo docto + rut) instead of just folio, and added rut_key variable for schema-specific field names |
| src/tests/test_rcv_parse_csv.py | Expanded test to verify 5 distinct entries are correctly parsed with the new grouping logic, including cases with same folio but different tipo docto or rut |
| src/tests/test_data/sii-rcv/RCV-venta-extra-empty-impuestos-rows.csv | Added 3 new test rows to cover edge cases: same folio with different tipo docto (row 6), same folio with different rut (row 7), and additional otros impuestos row (row 8) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4e36668 to
0c4ddbd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Updated to handle case when a main row is encountered and the entry_key already exists and the code doesn't update the stored row. - Changed the grouping key from folio to entry_key (combination of folio, tipo docto, and rut) - Solves the issue where some rows with the same `folio` but different `rut` or `tipo docto` were missing. Ref: https://app.shortcut.com/cordada/story/17311/
0c4ddbd to
9898051
Compare
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #937 +/- ##
===========================================
- Coverage 88.90% 88.79% -0.11%
===========================================
Files 40 40
Lines 3759 3767 +8
Branches 389 390 +1
===========================================
+ Hits 3342 3345 +3
- Misses 265 267 +2
- Partials 152 155 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|


folio + tipo docto + rutto handle "Otros Impuestos".foliobut differentrutortipo doctowere missing.Ref: https://app.shortcut.com/cordada/story/17311/