Commit Graph

16 Commits

Author SHA1 Message Date
bf37d7b05e feat(staging): add VPS staging seed (10 users + 8 clients + 7 suppliers + 10 orders + 20 PR + 20 audit + 59 help) (SEED-VPS-STAGING)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-11 18:39:58 +03:00
c1ce29c55e feat(help): add HelpArticle model + CRUD endpoints + 5 seeded articles (HELP-MODULE-P0)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-10 23:23:52 +03:00
51bda9310d chore(scripts): add ACTUAL-X-VERIF auto-check script
Fix update hook: recompute actuals when PAID entry amount/code changes
(not just on status transitions). 15/15 tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-07 15:46:15 +03:00
db6c43424c chore(scripts): add ORDER-IMG-VERIF auto-check script
Bash script for VPS automated verification of S62/S63 specs:
- ORDER-IMG-1 backend (upload/reject/serve/delete)
- ORDER-IMG-2 smeta extraction (idempotence, manual override)
- INVOICE-DOC-SYNC (create/issue/cancel/delete + Document cascade)
- Screenshots UI (5 pages)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-29 12:13:14 +03:00
4027cf0ee9 feat(client-invoices): INVOICE-DOC-SYNC sync ClientInvoice with Document
- create() wraps in $transaction, creates Document INVOICE/CLIENT alongside
- update() propagates invoiceNumber change to Document title/reference
- issue() sets Document.sentAt
- cancel() sets Document.closedAt
- delete() removes Document before deleting ClientInvoice
- Backfill script for existing invoices (idempotent)
- Downgrade @fastify/static to v7.0.4 (Fastify 4 compat)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-29 11:33:59 +03:00
fa07cc658b backup: n8n workflows + pg dump 20260429_020001 2026-04-29 02:00:04 +00:00
8cd97ebff7 feat: PO-POSTPAY-AUTO — auto PaymentRequest on SDN sign + postpay modes
- PostpayMode enum (SIMPLE/PER_DELIVERY) on POPaymentSchedule
- isPostDelivery flag on POInstallment (auto-set at creation)
- SDN.sign() → triggerPostpayOnSdnSign: creates/recalculates PaymentRequest
  - SIMPLE: 1 PR per postpay installment, dueDate = signedDate + postDeliveryDays
  - PER_DELIVERY: 1 PR per SDN, amount = deliveredAmount × postpayPercent/100
- SDN.cancel() → rejects PENDING/APPROVED PRs, preserves PAID PRs
- Frontend: postpayMode Radio in PO drawer, "После отгрузки" tag on installments
- Rename УПД tabs: исходящие → Клиенты, входящие → Поставщики
- Backfill: 2 installments marked isPostDelivery=true

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-28 13:27:57 +03:00
3fbb92b2aa fix: FinancialTracking.budgetX × Order.quantity — 3 sites + backfill
Bug: budgetX stored per-unit smeta costs instead of totals, causing
absurd overrun percentages (7140% for qty=1700, 3831% for qty=100).

Fix 3 write sites:
- estimates.service.ts syncFinancialTracking: .mul(qty)
- financial.service.ts applyRevision: revision.delta*.mul(qty)
- revisions.service.ts applyRevisionToBudget: (smeta + deltas) * qty

financial.service.ts initFromSmeta was already correct (L36-40).
committedX/actualX from PO.totalAmount — already totals, no fix needed.

Backfill: 2 FTs corrected, alertLevel RED→NONE for both.
Script is one-shot non-idempotent (never re-run).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-28 11:23:57 +03:00
44635e4a04 feat: PO delivery date mandatory + planning UX fixes + backfill
- PO confirm: require expectedDeliveryDate for direct POs, auto-create
  lots+LotLines when confirming PO without any lots
- createLotsForPO: no longer skips items without requirementId, creates
  PurchaseLotLine records for each lot
- generateFromTender: pre-fill expectedDeliveryDate from offerDeliveryDays
- Frontend: disable confirm button without delivery date set
- Planning: diamond size d=7 for PDL forecasts (visually distinct from
  7×7 reception squares), fix empty status filter Validation error
- Backfill script: po-delivery-backfill.ts (2 POs fixed)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 20:52:27 +03:00
c6eae3a77e fix(s53a-mig): step 1 reconstructs originalQuantity from POLine consumed
Two-pass backfill: cas 1 (non-consumed, origQty=qty) and cas 2
(consumed, origQty=qty+SUM(POLine.consumedQuantity) for active POs).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 17:28:25 +03:00
eb8c951b42 feat(s53a-mig): data migration script for PR lifecycle refactor
4-step migration: backfill originalQuantity, link POLines to PRs via lotLines,
create retro PRs for orphan POLines, merge residual PRs.
Dry-run by default, --apply for real execution. Idempotent.

Local DB results: 54 PRs backfilled, 4 retro PRs created, 4 residuals merged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 14:51:20 +03:00
9033427d23 fix(steel-refs): deduplicate SteelReference, add @@unique, AI self-verification
- Delete old seed (Russian profileType labels) causing weight duplicates
- Consolidate to single seed: 69 entries, 9 canonical types (SQUARE_TUBE etc.)
- Add @@unique([profileType, section]) constraint to prevent duplicates
- findWeightPerMeter prefers CANONICAL_PROFILE_TYPES over legacy labels
- bulkImport blocks duplicate sections across different profileTypes
- AI offer parser: self-verification ±1₽ per line, ±10₽ total, server-side validateRawArithmetic

Root cause: tube 20x20x1.5 had weight 0.885 (old seed) vs 0.841 (correct ГОСТ)
causing 5% quantity/price error in KP analysis.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-24 16:29:19 +03:00
d552cb32b5 fix: remove duplicate СРОЧНО priority — keep only Срочный (session 34)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 15:48:24 +03:00
3053cd32ad fix: align supplier tags with all MaterialCategory values + add specific service tags
- Added 8 specific service tags (LASER_CUTTING, TUBE_BENDING_SVC, etc.)
- Added PIPE_CUT to category_tag_mappings (was missing)
- Updated all 14 category mappings with both generic + specific tags
- Updated fallback categoryToTag in tenders.service.ts
- SQL migration script: scripts/fix-supplier-tags.sql

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 15:48:23 +03:00
f6e5d96796 fix: analyzeImpact matches PR by description instead of sourceId — fixes P0 quantity corruption and P1 mass ПОМЕНЯТЬ tag (session 34)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 15:48:17 +03:00
357017f706 feat: add spec_32b module (auto-pipeline) 2026-03-25 17:11:49 +00:00