refactor: remove SalesInvoiceItemsService and update sales invoice handling
- Deleted SalesInvoiceItemsService as it was not implemented. - Changed variable declaration from `const` to `let` in SalesInvoicesService for sales invoice creation. - Updated response handling after sending to TSP provider in SalesInvoicesService. - Renamed payload properties in TspProvider DTOs for clarity. - Enhanced error handling in SalesInvoiceTspSwitchService for unsupported providers. - Refactored SalesInvoiceTspService to utilize utility functions for payload building and sending. - Updated PrismaService to increase connection limit and utilize dynamic options. - Added new migration scripts to update database schema for sale_invoice_tsp_attempts. - Introduced utility functions for building payloads and handling responses in sales invoice processing.
This commit is contained in:
@@ -78,3 +78,27 @@ Operational guide for AI/coding agents working in `consumer_api`.
|
||||
- Building payloads from the wrong invoice (must match the expected new/ref invoice in each flow).
|
||||
- Creating attempts without persisting request payload and final response payload.
|
||||
- Mismatch between DTO shapes and shared service input contracts.
|
||||
|
||||
## Thread Notes (May 2026)
|
||||
- Shared sale-invoice creation was introduced and must be injected/exported correctly in consuming modules (example failure: `UnknownDependenciesException` for `SharedSaleInvoiceCreateService`).
|
||||
- In `SalesInvoiceTspService.revoke`, prepare all creation/update data from `relatedInvoice` (no external `dataToUpdate` argument expected).
|
||||
- Prisma client is generated to `src/generated/prisma` via:
|
||||
- `provider = "prisma-client"`
|
||||
- `output = "../../src/generated/prisma"`
|
||||
- `moduleFormat = "cjs"`
|
||||
- Docker/runtime must include generated Prisma artifacts and `@prisma/client` runtime; missing `@prisma/client/runtime/client` indicates build/copy/install mismatch.
|
||||
- Seeder commands that use `tsx` require dev dependencies/runtime tools; if running in slim production container, use a dedicated seed target/container or run seed from build/dev image.
|
||||
- `pnpm` invocation in containers should use executable form (`pnpm ...`), not `node /app/pnpm`.
|
||||
- Added SQL/Prisma error normalization utility: `src/common/utils/prisma-error.util.ts`; prefer mapping duplicate/constraint DB errors to domain-friendly messages.
|
||||
- Partner-module list endpoints were standardized toward `ResponseMapper.paginate` where pagination response contract is expected.
|
||||
- For heavy license provisioning (100+), request path should not synchronously insert all licenses; queue/background + batching is required.
|
||||
|
||||
## Migration Drift Playbook (Prisma/MySQL)
|
||||
- If Prisma reports `modified after applied`, never edit an already-applied migration in-place for shared environments; create a new forward migration instead.
|
||||
- If migration history and DB drift mismatch:
|
||||
1. Verify local migration folders are complete and ordered.
|
||||
2. Check `_prisma_migrations` for missing/applied names.
|
||||
3. Use `prisma migrate resolve` only to reconcile history state, then apply a forward fix migration.
|
||||
- Duplicate FK error seen in this repo: `sales_invoices_ref_id_fkey` (MySQL 1826). Recheck migration SQL for repeated `ADD CONSTRAINT` statements before rerun.
|
||||
- Drift that repeatedly showed in this project: missing FK/unique on `sale_invoice_tsp_attempts.invoice_id`. Validate both schema and migration SQL produce the same final state.
|
||||
- `prisma migrate status` may show up-to-date while `migrate dev` still detects drift (shadow DB/application history issue); treat `migrate dev` output as source of truth for fixing local history.
|
||||
|
||||
Reference in New Issue
Block a user