HOCO B2B
Team tasksAnis

SRV-18 — Billing V1 — invoices, payments, declarations, credit control

Invoices with legal mentions and statuses, payment recording and reseller declarations with proof, allocations, credit limit/exposure used at checkout, reseller finance summary.

FieldDetails
Task codeSRV-18
PhaseP1 — V1 build & integration
Product scopeV1
StatusDone (Mon 19 Oct 2026)
StartMon 19 Oct 2026
DueMon 19 Oct 2026
ResponsibleAnis — Full-stack developer
Co-responsible—
Effort1 person-day(s) planned · 5 from scratch · size S
Area · appServer · server
Depends onSRV-16, DQA-09
UnblocksDSH-07, MOB-12
Milestones—

Summary

Invoices with legal mentions and statuses, payment recording and reseller declarations with proof, allocations, credit limit/exposure used at checkout, reseller finance summary.

Description

V1 finance covers invoices, payments, reseller payment declarations and basic credit control (cahier §4.7, §5; FIN-01…FIN-05, FIN-10, ACL-04). This task generates invoices from orders at billing.invoiceOn (default SHIPPED) with InvoiceLine snapshots, FAC-YYYY-NNNNNN numbers and the legal mentions of the invoice template (DQA-09), tracks InvoiceStatus (UNPAID, PARTIALLY_PAID, PAID, OVERDUE by a daily job, CANCELLED), records payments in the back-office and reseller declarations with proof (PaymentStatus PENDING_VERIFICATION → CONFIRMED/REJECTED with reason), allocates payments to invoices (oldest first or manual), and maintains CreditAccount (ceiling, exposure, available) with CreditLimitChange history and the credit check used at checkout and at validation. Credit notes from returns (SRV-20) reduce the balance. It exposes the reseller finance summary. Financial data is visible only to authorised roles (ACL-04). Out of scope: due dates, reminders and accounting exports (V2, SRV-32) and the finance pages (DSH-07).

Subtasks

#SubtaskOwner
1Invoice generation consumer on billing.invoiceOn with InvoiceLine snapshots, HT/VAT/TTC totals and FAC numberingAnis
2Invoice PDF with legal mentions (seller RC, NIF, NIS, AI, address; buyer identifiers; totals; amount in words) from the DQA-09 templateAnis
3Invoice status computation from allocations and credit notes; daily OVERDUE job; admin.invoices.cancel with reasonAnis
4admin.payments.record (method, amount, reference, date, PAY numbering) and reseller payments.declare with PAYMENT_PROOF fileAnis
5admin.payments.verify: confirm or reject with PAYMENT_REJECT_REASON; reseller notifiedAnis
6Allocation engine: automatic oldest-first allocation and manual admin.payments.allocate; unallocated balance keptAnis
7CreditAccount: ceiling, exposure (unpaid invoices + validated uninvoiced credit orders − credit notes), available; CreditLimitChange history; admin.credit.get/updateAnis
8Credit check service replacing the SRV-15 stub, used by checkout and admin.orders.validate (credit.overLimitPolicy)Anis
9Reseller reads finance.summary, invoices.list/get, payments.list with self scopeAnis

Deliverables

  • apps/server/src/modules/billing/{invoices,payments,allocations,credit}.{service,router}.ts, jobs.ts, pdf/invoice.tsx
  • packages/contracts/src/{finance.ts,admin/finance.ts}
  • Invoice legal mentions checklist signed off with HOCO

Acceptance criteria

  • An order reaching SHIPPED (default) gets exactly one invoice with totals equal to its lines (FIN-01)
  • A declared payment stays PENDING_VERIFICATION and does not change invoice status until confirmed (FIN-03)
  • A payment of 150 000 DA against two unpaid invoices of 100 000 DA each leaves one PAID and one PARTIALLY_PAID (FIN-04)
  • A credit checkout that exceeds the available credit returns 422 CREDIT_LIMIT_EXCEEDED under BLOCK policy (FIN-05)
  • A user without finance.view gets 403 PERMISSION_DENIED on admin.invoices.list and sees no credit fields elsewhere (ACL-04)
  • finance.summary returns balance, available credit, unpaid invoices and recent payments for the reseller only (FIN-10)

Requirements covered

RequirementTitleRelease
FIN-01Invoices generated from orders with legal mentions and PDF; statuses unpaid, partially paid, paid, overdue, cancelledV1
FIN-02Payment methods: cash on delivery, bank transfer, CCP, BaridiMob, creditV1
FIN-03Payment recording in the back-office and payment declaration with proof by the resellerV1
FIN-04Partial payments and allocation to invoices (reconciliation)V1
FIN-05Basic credit control: ceiling, used and available credit checked at checkoutV1
FIN-10Reseller finance view: balance, available credit, invoices, paymentsV1
ACL-04Least privilege by default; financial data (purchase prices, margins, credit) strictly limitedV1

Screens

ScreenNameApp
BO-44InvoicesBO
BO-45Payments & declarationsBO
BO-46Credit accountsBO

API surface

Endpoint groupOperations
Reseller finance6
Finance12

Test measures

  • DB tests for allocation and status computation including credit notes
  • Unit tests for exposure computation
  • PDF snapshot test of the invoice with a sample order

Risks

  • Algerian invoicing specifics (stamp duty on cash payments, mandatory mentions) not confirmed — checklist reviewed with HOCO's accountant before the template is frozen

KPI

  • Delivered by Mon 19 Oct 2026 within 1 person-day(s).
  • Every acceptance criterion above demonstrated before hand-off; linked requirements' acceptance criteria pass.
  • Zero open critical defects, permission gaps or data-integrity regressions at sign-off.

Generated from content/plan/tasks.json by scripts/generate-team-tasks.mjs. Dates are computed by the scheduler (Sunday–Thursday weeks, holidays excluded) — change the plan, not this page.

On this page