Geschäftszustände und Integrität
Hält Betriebs- und Finanzzustände durch getrennte Lebenszyklen, exakte Mengen und historienerhaltende Korrekturen konsistent.
business-states-data-integrity
Agenten mit diesem Skill
Wann ist der Skill hilfreich?
Nutze ihn bei teilweise gelieferten, berechneten oder korrigierten Aufträgen mit gleichzeitigen Änderungen gemeinsamer Mengen.
Wobei hilft er dir?
- Trennt Auftrags-, Liefer- und Rechnungsstatus.
- Verwendet präzise Beträge und historische Umrechnungsschnappschüsse.
- Schützt endgültige Dokumente und reserviert Bestand transaktional.
Das könntest du fragen
Modelliere Teillieferung und spätere Gutschrift ohne Umschreiben des Auftrags. Liefere und berechne zwei von fünf bestellten Artikeln und schreibe einen gut. Gleiche Mengen und Beträge ab, ohne abgeschlossene Originaldokumente umzuschreiben.
Ausführliche Dokumentation
Hier findest du die ursprüngliche Anleitung, Beispiele und Prüfschritte des Skills in ihrer Originalsprache.
Weniger anzeigen
Business States & Data Integrity
When to Use
Use when implementing state transitions, monetary/quantity calculations, inventory movements, document finalization, cancellations, or concurrent updates in CRM and ERP systems.
1. Orthogonal State Dimensions (Never Overload One status Column)
A SalesOrder has multiple independent lifecycle dimensions that progress in parallel:
- Order Lifecycle Status:
draft$\rightarrow$pending_approval$\rightarrow$confirmed$\rightarrow$completed/cancelled. - Fulfillment Status:
unfulfilled$\rightarrow$partially_fulfilled$\rightarrow$fulfilled$\rightarrow$returned. - Invoicing / Billing Status:
uninvoiced$\rightarrow$partially_invoiced$\rightarrow$invoiced$\rightarrow$credited.
Separating orthogonal statuses prevents impossible state combinations (e.g., an order that is partially_fulfilled and partially_invoiced at the same time).
2. Exact Money, Quantity, Unit-of-Measure & Currency Discipline
- Never Use IEEE-754 Float (
number/FLOAT/DOUBLE) for Money or Inventory Quantities:- Store monetary amounts as exact integer minor units (
amount_minor BIGINT, e.g., cents/fillér) or fixed-precisionNUMERIC(19, 4), always paired with an explicit ISO 4217currencycode (EUR,HUF,USD). - Store quantities with explicit
NUMERIC(18, 4)(or integer base units) paired with an explicitunit_of_measure(pcs,kg,m,hour).
- Store monetary amounts as exact integer minor units (
- Explicit Rounding & Tax Rules:
- Define line-level vs. document-level rounding (
HALF_UP/HALF_EVEN) and net-to-gross vs. gross-to-net calculation rules consistently across the entire document chain soQuote Total == Order Total == Invoice Totalwithout 1-cent rounding drift.
- Define line-level vs. document-level rounding (
- Currency & UoM Conversion Snapshots:
- When converting currencies or units of measure (e.g.,
1 box = 24 pcs,EUR -> HUF), store the exactexchange_rate,rate_date, andconversion_factorapplied on the transaction record.
- When converting currencies or units of measure (e.g.,
3. Immutability of Finalized Documents & Corrective Entries
Once a business document (Confirmed Order, Posted Shipment, Issued Invoice, Inventory Ledger Entry) is finalized:
- Forbid Direct Destructive Edits or
DELETEs: Do not allow overwriting quantities or deleting rows on finalized operational or financial documents. - Use Explicit Reversal / Amendment Workflows:
- Quote/Order changes after confirmation $\rightarrow$ create a new
Quote Revision(v2) or a trackedOrder Change / Amendment(re-triggering approval if thresholds are crossed). - Fulfillment/Return adjustments $\rightarrow$ record a compensating
Return / RMAorInventory Adjustmentmovement. - Billing corrections $\rightarrow$ issue a linked
Credit Note/Stornodocument.
- Quote/Order changes after confirmation $\rightarrow$ create a new
4. Concurrency Control on Shared Business Invariants
- Protect state transitions, sequence/document numbering (
SO-2026-000142), and stock allocations with transactional row locks (SELECT ... FOR UPDATE) or optimistic version checks (WHERE id = $1 AND status = 'pending_approval' AND version = $2) so double-clicks or parallel workers never double-confirm an order or over-allocate stock.
Enthaltene Dateien 1
SKILL.md
