Skip to content

Current Implementation State ​

Обязательный файл для AI agents. Читать перед новой задачей; обновлять после каждой итерации.

Last updated ​

2026-07-28 — реализован fail-closed supplier-settlement workflow: полное назначение банковского платежа, частичная оплата долга, детерминированный FIFO foundation и блокировка переплаты до появления подтверждённого Syrve supplier-advance transport.

Last completed task ​

В myhoreca-pay закреплены следующие инварианты:

  • оплачиваются только snapshots с IsProcessed == true и IsDeleted == false;
  • BankTransaction.Amount = DocumentSettlementAmount + SupplierAdvanceAmount + UnallocatedPaymentAmount;
  • confirm/approve/queue/dry-run/execute/retry запрещены, пока UnallocatedPaymentAmount != 0;
  • остаток долга по накладным не считается нераспределённым остатком банковского платежа;
  • автоматическое предложение строится чистой FIFO-политикой, фиксируется при confirm и не пересчитывается worker-ом;
  • timeout/неизвестный write outcome требует readback и не допускает слепой повтор;
  • Posted не означает Reconciled: успешный readback обязан подтвердить ожидаемые остатки;
  • переплата формирует только локальное требование SupplierAdvance, но не runnable posting: внешняя запись, fake ID и fake success не создаются.

IikoConnector не изменялся. Для подтверждения supplier-level FIFO и полного create/readback/apply/reversal-контракта аванса подготовлен отдельный prompt: docs/docs/ai-agents/iikoconnector-supplier-settlement-prompt.md.

Changed backend files ​

  • Domain/data: Entities.cs, DomainEnums.cs, ApiConstants.cs, PayDbContext.cs.
  • Pure settlement foundation: SupplierSettlementArithmetic.cs, SupplierSettlementAllocator.cs, SupplierSettlementWorkflowPolicy.cs, SupplierSettlementPlan.cs, SupplierSettlementPostingOperationPlanner.cs.
  • Allocation/contracts: ApplicationAbstractions.cs, SyrveOrchestration.cs, PaymentAllocationPreviewCalculator.cs, PaymentAllocationWarningCatalog.cs.
  • Posting/workbench/worker/reconciliation: AccountantWorkItemApproveAndQueueService.cs, AccountantWorkItemQueryService.cs, WorkflowStateGuardService.cs, IikoSyrveAppServices.cs, SyrvePaymentWriteGates.cs, SyrveOrchestrationServices.cs, SyrveReconciliationService.cs, SyrveWorkers.cs.
  • Migration: 20260728170721_AddSupplierSettlementFoundation.cs + designer + PayDbContextModelSnapshot.cs.

Changed frontend files ​

  • API contracts expose canonical settlement totals, allocation method and line sequence.
  • PaymentPostingFlowPage.tsx supports FIFO/manual preview, displays payment remainder and invoice debt separately, and disables confirm for a blocking result.
  • Helpers, styles, Russian messages, mocks and Playwright coverage were updated without route changes or redesign.

Changed docs / tests / config ​

  • Executable Reqnroll features cover arithmetic, incomplete workflow, FIFO, processing-state safety, advance foundation, 1:N posting plan, UI behavior, recovery, reconciliation and the end-to-end regression set.
  • Architecture/API/workflow/role docs and codegraph/manifest.yaml were synchronized.
  • New living decision document: docs/docs/architecture/supplier-settlement.md.
  • Supplier-advance roadmap remains explicitly non-runnable.
  • Reqnroll is used through the existing xUnit test project; generated *.feature.cs files are ignored.

New or changed API endpoints ​

  • Endpoint paths are unchanged.
  • Allocation preview/response contracts add canonical fields: documentSettlementAmount, supplierAdvanceAmount, unallocatedPaymentAmount, invoiceDebtRemaining, allocationMethod, and line sequence.
  • Stable business codes include payment_not_fully_distributed, supplier_advance_transport_unavailable, write_outcome_unknown_readback_required, bank_transaction_not_found, document_processing_state_unknown, document_not_processed, document_deleted, and document_not_payable.

New or changed frontend routes / hooks / contracts ​

  • Routes and hooks are unchanged.
  • Allocation contracts now expose FIFO/manual mode and the canonical financial totals.
  • The UI shows Нераспределено из платежа separately from Останется задолженность по документам.

Commands run and results ​

text
Reqnroll supplier-settlement features
  → 57 passed, 0 failed

targeted parser/sync/candidates/allocation/workbench/posting/worker/reconciliation tests
  → 270 passed, 0 failed

final supplier-settlement + workbench classifier regression
  → 78 passed, 0 failed

final transport/worker boundary regression
  → 61 passed, 0 failed

dotnet build MyHoreca.Pay.slnx --no-restore
  → success, 0 warnings, 0 errors

full MyHoreca.Pay.UnitTests
  → 933 passed, 4 skipped, 14 failed
  → all 14 failures reproduce the pre-existing baseline:
    bank adapter/import expectations (8), full-document parser expectations (2),
    SyrvePaymentWritePreflight legacy fixtures (3), AccountantWorkItemQuery legacy
    classification (1)

MyHoreca.Pay.IntegrationTests
  → 4 passed, 1 intentionally skipped, 0 failed

MyHoreca.Pay.ArchitectureTests
  → 8 passed, 1 failed
  → existing System.Text.Json usage in TelegramBotUpdateHandler.cs and
    TelegramLongPollingHostedService.cs

dotnet test MyHoreca.Pay.slnx --no-build --no-restore
  → Unit: 933 passed / 4 skipped / 14 baseline failed
  → Integration: 4 passed / 1 intentionally skipped / 0 failed
  → Architecture: 8 passed / 1 baseline failed

MigrationPolicyTests
  → 2 passed, 0 failed

DbMigrator against fresh PostgreSQL
  → complete Pay + connector migration chain and seed passed

npx tsc -b --pretty false
  → passed

npm run build
  → passed; existing Vite chunk-size warning only

targeted Playwright supplier-settlement scenarios
  → 2 passed, 0 failed

npm run test:mocked -- --reporter=line
  → 25 passed, 16 failed
  → both new settlement tests passed; failures reproduce existing upload/navigation/UI-system
    baseline caused by missing mocked backend/proxy behavior

npm run lint
  → existing baseline: 10 errors, 8 warnings

docs: npm run build
  → passed; existing language-environment highlight warning only

scripts/validate-codegraph.ps1
  → passed

Known gaps / TODO ​

  • IikoConnector 1.2.7 list-record flags are non-nullable bool. Missing processed is safely blocked as false, but missing deleted cannot be distinguished from explicit false when processed=true; a presence-aware connector contract is still required.
  • Full-document responses do not provide a confirmed processing-state contract and therefore do not override the list/batch source of truth.
  • The accountant-confirmed FIFO business field is not yet known. Foundation uses DueDate only when supplied, otherwise DocumentDate, then external document ID.
  • It is unconfirmed whether Syrve can perform supplier-level FIFO or atomically combine document settlement with an advance.
  • Supplier advance write/readback/application/reversal is intentionally unavailable until real RMS and CHAIN traces exist.
  • Existing unit/architecture/frontend test and lint baselines listed above were not weakened.

Recommendations for next iteration ​

  1. Run the dedicated IikoConnector trace prompt and capture exact RMS/CHAIN contracts for advance create/readback/apply/reversal and unknown outcomes.
  2. Make processing flags presence-aware in IikoConnector, then consume nullable values here.
  3. Confirm the accountant-approved FIFO ordering date (DueDate versus DocumentDate).
  4. After verified transport contracts exist, activate the prepared 1:N posting-operation model with independent idempotency, evidence, readback and reversal per operation.