Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f9f1f8d9d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| subtipos = self.catalog_manager.subtipos(cat) | ||
| self._subtipo_cb.configure(values=subtipos, state="readonly" if subtipos else "disabled") | ||
| self._subtipo_var.set(subtipos[0] if subtipos else "") |
There was a problem hiding this comment.
Populate OGND type selector with real OGND codes
When cat == "OGND", this code still fills the selector from subtipos("OGND"), but the catalog shape built in CatalogManager stores OGND values under OGND -> TIPOS -> {OGND,DNR,ORS,CNR}; that means the UI exposes only TIPOS and _classify_selected then saves/routes every OGND invoice as .../OGND/TIPOS. In practice users cannot choose DNR/ORS/CNR, so OGND classifications are written to the wrong destination and metadata.
Useful? React with 👍 / 👎.
| tipo_ognd = sanitize_folder_name(stp or "OGND") | ||
| return base / "OGND" / tipo_ognd | ||
|
|
||
| raise ValueError(f"Categoría no soportada: {categoria}") |
There was a problem hiding this comment.
Support legacy categories before rejecting destination build
Older client catalogs include INGRESOS (the previous default), and _normalize_catalog preserves unknown categories, so the category list can still offer INGRESOS after upgrade. build_dest_folder now rejects anything outside COMPRAS/GASTOS/OGND, so selecting that legacy category causes classification to fail with ValueError instead of moving the PDF, which is a migration regression for existing metadata.
Useful? React with 👍 / 👎.
Motivation
.dmaccount definitions and ensuring a consistent minimal catalog shape via_normalize_catalog.subtipoandnombre_cuenta) to map invoices to a deeper folder hierarchy and store precise account information in the DB.Tipo/Cuentain the UI so classifications produce consistent paths on the network drive.Description
CATALOG_DM_PATHand_normalize_namehelper and implementedCatalogManagermethods:load,load_from_dm,save,categorias,subtipos,cuentas,add_cuenta, and_normalize_catalog; defaults and minimum entries are enforced and malformed catalog files are backed up and replaced.load_from_dmthat reads legacycatalogo_de_cuentas.dmand populatesCOMPRAS,GASTOSandOGNDbranches based on parent codes.build_dest_folder,_month_bucket, and imports toclassifier.pyto compute destination paths on the network drive usingnetwork_drive()andsanitize_folder_nameand to bucket by month.ClassificationDBschema to ensuresubtipoandnombre_cuentacolumns exist, updatedget_record,get_records_map, andupsertto populate and returnsubtipo/nombre_cuenta, and adjustedupsertto backfillsubcategoriafor compatibility.classify_recordsignature and logic to acceptsubtipoandnombre_cuenta, computeyeardefault, usebuild_dest_folderfor destination, and persist the extended metadata to DB; preserved atomic copy/sha256 verification and safe removal logic.main_window.py) to hold aCatalogManager, pass it through the loader, exposeTipo(subtipo),CuentaandDestinopreview fields, update category/subtype/account selection logic and validation rules per category, and includesubtipo/nombre_cuentain exports and previous-classification display.Testing
pytestagainst the modified codebase and the existing tests completed successfully.Codex Task