110 Commits

Author SHA1 Message Date
Claude Agent
9f2fd24d93 docs(design): add design system with typography, colors, and mobile specs
Industrial/utilitarian aesthetic with amber accent, Space Grotesk + DM Sans +
JetBrains Mono stack, full dark mode, and dedicated mobile design including
bottom nav and card-based order views. Updates CLAUDE.md to enforce DESIGN.md
compliance on all visual work.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 10:29:13 +00:00
Claude Agent
7a1fa16fef fix(tests): resolve 10 skipped tests and add log file output to test.sh
- test.sh: save each run to qa-reports/test_run_<timestamp>.log with
  ANSI-stripped output; show per-stage skip counts in summary
- test_qa_plsql: fix wrong table names (parteneri→nom_parteneri,
  com_antet→comenzi, comenzi_articole→comenzi_elemente), pass
  datetime for data_comanda, use string JSON values for Oracle
  get_string(), lookup article with valid price policy
- test_integration: fix article search min_length (1→2 chars),
  use unique SKU per run to avoid soft-delete 409 conflicts
- test_qa_responsive: return early instead of skip on empty tables

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 14:11:21 +00:00
Claude Agent
61193b793f test(business-rules): add 44 regression tests for kit pricing, discount, and SKU mapping
38 unit tests (no Oracle) covering: discount VAT split, build_articles_json,
kit detection pattern, sync_prices skip logic, VAT included normalization,
validate_kit_component_prices (pret=0 allowed), dual policy assignment,
and resolve_codmat_ids deduplication.

6 Oracle integration tests covering: multi-kit discount merge, per-kit
discount placement, distributed mode total, markup no negative discount,
price=0 component import, and duplicate CODMAT different prices.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 13:30:52 +00:00
Claude Agent
f07946b489 feat(dashboard): show article subtotal, discount, and transport in order detail receipt
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 22:39:21 +00:00
Claude Agent
af78ee181a chore: remove obsolete files and scripts with hardcoded credentials
- Delete api/admin.py (dead Flask app, project uses FastAPI)
- Delete test_import_comanda.py (broken Windows paths, references missing SQL)
- Delete scripts/work/ (untracked: hardcoded passwords and API keys)
- Delete api/database-scripts/mapari_sql.sql (one-time migration, already applied)
- Delete api/database-scripts/08_merge_kituri.sql (one-time migration, already applied)
- Delete api/database-scripts/mapari_articole_web_roa.csv (unused seed data)

Kept: 07_drop_procent_pret.sql as reminder to apply column drop migration

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 22:38:23 +00:00
Claude Agent
f2bf6805b4 cleanup resolved missing skus 2026-03-25 22:29:33 +00:00
Claude Agent
a659f3bafb docs: cleanup stale documentation and fix outdated references
- Delete README-ORACLE-MODES.md (references Docker infra that doesn't exist)
- Delete .claude/HANDOFF.md (completed CI/CD session handoff, no longer needed)
- Fix api/README.md: correct run command to ./start.sh, update test commands
  to use ./test.sh instead of deleted test_app_basic.py/test_integration.py
- Fix scripts/HANDOFF_MAPPING.md: mark deleted scripts as removed
- Remove dead README-ORACLE-MODES.md link from README doc table

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 22:23:21 +00:00
Claude Agent
bc56befc15 docs: update project documentation for recent changes
- README.md: fix stale pct_total reference → cantitate_roa, add price_sync_service
  to project tree, update docs/ description (PRD/stories removed), add scripts/
  directory, add Documentatie Tehnica section linking all doc files
- api/README.md: add missing price_sync_service and invoice_service to services table

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 22:20:18 +00:00
Claude Agent
91ddb4fbdd fix(mappings): allow SKU=CODMAT mappings for quantity conversion
Remove validation that blocked creating mappings when SKU matches an
existing CODMAT. Users need this for unit quantity conversion (e.g.,
website sells 50 units per SKU but ROA tracks 100, requiring
cantitate_roa=0.5).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 22:01:30 +00:00
Claude Agent
580ca595a5 fix(import): insert kit discount lines per-kit under components instead of deferred cross-kit
Discount lines now appear immediately after each kit's components on the order,
making it clear which package each discount belongs to.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 21:39:14 +00:00
Claude Agent
47b5723f92 fix(sync): prevent kit/bax price sync from overwriting individual CRM prices
Three code paths could overwrite CRM list prices with wrong values when
web unit (50 buc) differs from ROA unit (100 buc):

- price_sync_service: kit path now skips components that have their own
  ARTICOLE_TERTI mapping (individual path handles them with correct ÷0.5)
- validation_service: sync_prices_from_order now skips bax SKUs
  (cantitate_roa > 1) in addition to multi-component kits
- pack_import_comenzi: skip negative kit discount (markup), ROUND prices
  to nzecimale_pretv decimals

Also adds:
- SQL script for 6 ARTICOLE_TERTI mappings (cantitate_roa=0.5) for cup
  articles where web=50buc, ROA=100buc/set
- Oracle schema reference documentation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 19:05:49 +00:00
Claude Agent
1703232866 fix(sync): allow kit components with price=0 to import
Price=0 is a valid state for kit components in crm_politici_pret_art,
inserted automatically by the price sync system. Previously, the kit
validation treated pret=0 the same as missing, blocking orders from
importing even when all SKU mappings were correctly configured.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 15:33:16 +00:00
Claude Agent
adf5a9d96d feat(sync): uppercase client names in SQLite for consistency with Oracle
Existing 741 rows also updated via UPPER() on customer_name,
shipping_name, billing_name.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 15:02:23 +00:00
Claude Agent
dcc2c9f308 fix: update all test suites to match current API and UI
- test_requirements: replace removed add_import_order with upsert_order +
  add_sync_run_order, fix add_order_items/update_addresses signatures
- E2E logs: replace #runsTableBody with #runsDropdown (dropdown UI)
- E2E mappings: rewrite for flat-row list design (no more table headers)
- E2E missing_skus: use .filter-pill[data-sku-status] instead of button IDs,
  #quickMapModal instead of #mapModal
- QA logs monitor: 1h session window + known issues filter for pre-existing
  ORA-00942 errors
- Oracle integration: force-update settings singleton to override dummy values
  from test_requirements module, fix TNS_ADMIN directory in conftest
- PL/SQL tests: graceful skip when PARTENERI table inaccessible

All 6 test stages now pass in ./test.sh full.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 16:36:46 +00:00
Claude Agent
70267d9d8d corectie pljson 2026-03-24 11:48:13 +00:00
Claude Agent
419464a62c feat: add CI/CD testing infrastructure with test.sh orchestrator
Complete testing system: pyproject.toml (pytest markers), test.sh
orchestrator with auto app start/stop and colorful summary,
pre-push hook, Gitea Actions workflow.

New QA tests: API health (7 endpoints), responsive (3 viewports),
log monitoring (ERROR/ORA-/Traceback detection), real GoMag sync,
PL/SQL package validation, smoke prod (read-only).

Converted test_app_basic.py and test_integration.py to pytest.
Added pytestmark to all existing tests (unit/e2e/oracle).
E2E conftest upgraded: console error collector, screenshot on
failure, auto-detect live app on :5003.

Usage: ./test.sh ci (30s) | ./test.sh full (2-3min)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 10:40:25 +00:00
Claude Agent
b625609645 feat: configurable invoice line sorting via RF_SORTARE_COMANDA option
cursor_comanda in PACK_FACTURARE now reads RF_SORTARE_COMANDA from OPTIUNI:
1=alphabetical (default, existing behavior), 0=original web order (by ID_COMANDA_ELEMENT).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 09:15:17 +00:00
Claude Agent
61ae58ef25 fix: kit discount amount + price sync no auto-insert + repackaging kit detection
Kit discount: v_disc_amt is per-kit, not per-unit — remove division by
v_cantitate_web so discount lines compute correctly (e.g. -2 x 5 = -10).

Price sync: stop auto-inserting missing articles into price policies
(was inserting with wrong proc_tvav from GoMag). Log warning instead.

Kit detection: extend to single-component repackagings (cantitate_roa > 1)
in both PL/SQL package and price sync/validation services.

Add repackaging kit pricing test for separate_line and distributed modes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 11:04:09 +00:00
Claude Agent
10c1afca01 feat: show prices for all mappings + remove VAT% display
Join price policies directly into get_mappings() query so single-article
mappings display prices without extra API calls. Remove VAT percentage
from kit price display.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 23:15:26 +00:00
Claude Agent
5addeb08bd fix: NULL SUMA in PACK_FACTURARE for discount lines + SKU enrichment fallback
PACK_FACTURARE: use PTVA from COMENZI_ELEMENTE (NVL2) in adauga_articol_factura
instead of fetching PROC_TVAV from price list, fixing NULL SUMA for discount
lines with multiple TVA rates (11%, 21%).

sync.py: broaden direct SKU enrichment to all unmapped SKUs regardless of
mapping_status, fixing stale status edge cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 22:32:28 +00:00
Claude Agent
3fabe3f4b1 kituri 2026-03-20 21:07:32 +00:00
Claude Agent
b221b257a3 fix: price sync kit components + vat_included type bug
- Fix vat_included comparison: GoMag API returns int 1, not str "1",
  causing all prices to be multiplied by TVA again (double TVA)
- Normalize vat_included to string in gomag_client at parse time
- Price sync now processes kit components individually by looking up
  each component's CODMAT as standalone GoMag product
- Add _insert_component_price for components without existing Oracle price
- resolve_mapped_codmats: ROW_NUMBER dedup for CODMATs with multiple
  NOM_ARTICOLE entries, prefer article with current stock
- pack_import_comenzi: merge_or_insert_articol to merge quantities when
  same article appears from kit + individual on same order

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 15:07:53 +00:00
Claude Agent
0666d6bcdf fix: defer kit discount insertion to avoid duplicate check collision (separate_line)
When 2+ kits produce discount lines with the same unit price and VAT rate,
adauga_articol_comanda raises RAISE_APPLICATION_ERROR(-20000) on the duplicate
(ID_ARTICOL, PTVA, PRET, SIGN(CANTITATE)) check. Defer discount insertion
until after the main article loop, accumulating cross-kit discounts and merging
collisions by summing qty. Different prices remain as separate lines.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 11:57:57 +00:00
Claude Agent
5a10b4fa42 chore: add version comments (20.03.2026) to pack_import_comenzi and pack_import_parteneri
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 10:39:43 +00:00
Claude Agent
6c72be5f86 fix: add ROOT_PATH prefix to missing SKUs CSV export URL for IIS proxy
The export CSV button used a hardcoded /api/validate/missing-skus-csv path,
bypassing the IIS /gomag reverse proxy prefix. Also add changelog comments
to PACK_COMENZI and PACK_FACTURARE for the duplicate CODMAT discrimination.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 10:37:11 +00:00
Claude Agent
9a545617c2 chore: add version comments (20.03.2026) to pack_comenzi and pack_facturare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 10:37:09 +00:00
Claude Agent
95565af4cd fix: discriminare pe PRET+SIGN(CANTITATE) pentru duplicate CODMAT pe comanda
Permite articole duplicate cu preturi diferite pe aceeasi comanda (kit + direct
cu acelasi CODMAT) si articol + retur la acelasi pret. Cheia de unicitate devine
(ID_COMANDA, ID_ARTICOL, PTVA, PRET, SIGN(CANTITATE)).

Modificari in 8 locuri: duplicate check (pack_comenzi), cursor_comanda factura/aviz,
cursor_lucrare ambele ramuri, adauga_articol_lucrare_pret, adauga_articol_factura,
inchide_comanda. Zero signatura schimbata, zero schema change, zero VFP impact.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 10:32:55 +00:00
Claude Agent
93314e7a6a fix: bridge SKU→policy mapping for ARTICOLE_TERTI mapped articles
codmat_policy_map had CODMAT keys only, but build_articles_json looks
up by GoMag SKU — mapped articles like FRSETP250 never got per-article
id_pol, causing Oracle to use default sales policy and fail when price
exists only in production policy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 00:16:37 +00:00
Claude Agent
d802a08512 mapari sql 2026-03-19 23:57:52 +00:00
Claude Agent
f68adbb072 chore: bump CSS cache version to v=17 2026-03-19 23:29:25 +00:00
Claude Agent
eccd9dd753 style(design): FINDING-008 — add color-scheme: light declaration 2026-03-19 23:29:17 +00:00
Claude Agent
73fe53394e style(design): FINDING-007 — add text-wrap: balance to headings 2026-03-19 23:29:09 +00:00
Claude Agent
039cbb1438 style(design): FINDING-005 — increase filter pill padding for 44px touch target 2026-03-19 23:28:48 +00:00
Claude Agent
1353d4b8cf style(design): FINDING-004 — add tabular-nums to table cells for aligned numbers 2026-03-19 23:28:39 +00:00
Claude Agent
f1c7625ec7 style(design): FINDING-003 — add focus ring to search input, remove outline:none 2026-03-19 23:28:30 +00:00
Claude Agent
a898666869 style(design): FINDING-002 — increase checkbox size from 13px to 18px 2026-03-19 23:28:08 +00:00
Claude Agent
1cea8cace0 style(design): FINDING-001 — increase pagination button size to 44px touch target 2026-03-19 23:27:56 +00:00
Claude Agent
327f0e6ea2 refactor(ui): unify mapping form into single shared component
Extract the SKU mapping modal (HTML + JS) from dashboard, logs, and
missing_skus into a shared component in base.html + shared.js. All pages
now use the same compact layout with CODMAT/Cant. column headers.

- Fix missing_skus backdrop bug: event.stopPropagation() on icon click
  prevents double modal open from <a> + <tr> event bubbling
- Shrink mappings addModal from modal-lg to regular size with compact layout
- Remove ~500 lines of duplicated modal HTML and JS across 4 pages
- Each page keeps a thin wrapper (openDashQuickMap, openLogsQuickMap,
  openMapModal) that calls shared openQuickMap() with an onSave callback

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 23:21:43 +00:00
Claude Agent
c806ca2d81 fix(ui): format price sync timestamps as dd.mm.yyyy hh24:mi:ss Bucharest time
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 22:55:38 +00:00
Claude Agent
952989d34b fix: remove procent_pret from quick-map modals, fix catalog price sync
Remove leftover procent_pret input fields and validation from dashboard,
logs and missing_skus quick-map modals (missed in 9e5901a). Fix GoMag
Products API returning dict-keyed products instead of array, which caused
catalog price sync to find 0 products with SKU.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 22:53:36 +00:00
Claude Agent
aa6e035c02 fix(oracle): use na.cont instead of na.cont_vanzare in kit pricing
The column cont_vanzare does not exist in nom_articole. The correct
column name is cont, consistent with all Python code references.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 22:32:20 +00:00
Claude Agent
9e5901a8fb feat(pricing): kit/pachet pricing with price list lookup, replace procent_pret
- Oracle PL/SQL: kit pricing logic with Mode A (distributed discount) and
  Mode B (separate discount line), dual policy support, PRETURI_CU_TVA flag
- Eliminate procent_pret from entire stack (Oracle, Python, JS, HTML)
- New settings: kit_pricing_mode, kit_discount_codmat, price_sync_enabled
- Settings UI: cards for Kit Pricing and Price Sync configuration
- Mappings UI: kit badges with lazy-loaded component prices from price list
- Price sync from orders: auto-update ROA prices when web prices differ
- Catalog price sync: new service to sync all GoMag product prices to ROA
- Kit component price validation: pre-check prices before import
- New endpoint GET /api/mappings/{sku}/prices for component price display
- New endpoints POST /api/price-sync/start, GET status, GET history
- DDL script 07_drop_procent_pret.sql (run after deploy confirmation)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 22:29:18 +00:00
Claude Agent
bedb93affe feat(dashboard): receipt-style order detail with inline transport and discount rows
Replace totals bar + VAT subtotals table with transport/discount as table
rows (with CODMAT from settings, proper VAT rate) and a single Total footer.
Right-align qty/price/TVA columns, thousands separator (ro-RO), discount
shown as qty=-1 price=positive.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 18:44:56 +00:00
Claude Agent
c534a972a9 feat: multi-gestiune stock verification setting
Replace single-select gestiune dropdown with multi-select checkboxes.
Settings stores comma-separated IDs, Python builds IN clause with bind
variables, Oracle PL/SQL splits CSV via REGEXP_SUBSTR for stock lookup.
Empty selection = all warehouses (unchanged behavior).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 16:15:40 +00:00
Claude Agent
695dafacd5 feat: dual pricing policies + discount VAT splitting
Add production pricing policy (id_pol_productie) for articles with cont 341/345,
smart discount VAT splitting across multiple rates, per-article id_pol support,
and mapped SKU price validation. Settings UI updated with new controls.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 15:10:05 +00:00
Claude Agent
69a3088579 refactor(dashboard): move search box to filter bar after period dropdown
Search was hidden in card header — now inline with filters for better
discoverability. Compact refresh button to icon-only. On mobile, search
and period dropdown share the same row via flex.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 16:08:58 +00:00
Claude Agent
3d212979d9 refactor(dashboard): move search box from filter bar to card header
Reduces vertical space by eliminating the second row in the filter bar.
Search input is now next to the "Comenzi" title, hidden on mobile.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 14:04:10 +00:00
Claude Agent
7dd39f9712 feat(order-detail): show CODMAT for direct SKUs + mapping validations
- Enrich order detail items with NOM_ARTICOLE data for direct SKUs
  (SKU=CODMAT) that have no ARTICOLE_TERTI entry
- Validate CODMAT exists in nomenclator before saving mapping (400)
- Block redundant self-mapping when SKU is already direct CODMAT (409)
- Show "direct" badge in CODMAT column for direct SKUs
- Show info alert in quick map modal for direct SKUs
- Display backend validation errors inline in modal

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 13:10:20 +00:00
Claude Agent
f74322beab fix(dashboard): update sync card after completion + use Bucharest timezone
Sync card was showing previous run data after sync completed because the
last_run query excluded the current run_id even after it finished. Now only
excludes during active running state.

All datetime.now() and SQLite datetime('now') replaced with Europe/Bucharest
timezone to fix times displayed 2 hours behind (was using UTC).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 13:02:18 +00:00
Claude Agent
7a2408e310 fix(import): resolve correct id_articol for duplicate CODMATs + gestiune setting
Unified id_articol selection logic in Python (resolve_codmat_ids) and PL/SQL
(resolve_id_articol): filters sters=0 AND inactiv=0, prefers article with
stock in configured gestiune, falls back to MAX(id_articol). Eliminates
mismatch where Python and PL/SQL could pick different id_articol for the
same CODMAT, causing ORA-20000 price-not-found errors.

- Add resolve_codmat_ids helper in validation_service.py (single batch query)
- Refactor validate_skus/validate_prices/ensure_prices to use it
- Add resolve_id_articol function in PL/SQL package body
- Add p_id_gestiune parameter to importa_comanda (spec + body)
- Add /api/settings/gestiuni endpoint and id_gestiune setting
- Add gestiune dropdown in settings UI

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 12:18:18 +00:00