import type { FdoDecimal } from '@feedmepos/core/entity'; /** * Pure display derivation for the production run view. Kept out of the .vue * files so the "nothing yet is not failure" and reveal-by-status rules are * testable — see production-run-display.spec.ts. * * There is no status normalisation anywhere in here. A run document is correct * by construction: `FdoProductionRun` is a NEW entity with no pre-enum * ancestors, so a lookup keyed on `status` may index the table directly. */ /** The em dash used for "we cannot say yet". NEVER `0`, never `RM 0.00`, never `0%`. */ export declare const NOT_YET = "\u2014"; /** * One timestamp form across the Production listing, header and output cards. * * A malformed stored string stays visible verbatim: replacing corrupt data * with `—` would make the document look merely incomplete. An invalid `Date` * has no source text to preserve, so it uses the ordinary unavailable marker. */ export declare function formatProductionTimestamp(value: Date | string): string; export interface QuantityFormat { /** * Decimal places this quantity is meaningful to — `FdoInventoryUnit.precision`, * read through `getAllowedPrecision` so the answer agrees with what the entry * inputs allow. Null when the unit could not be resolved. * * It is a property of the UNIT, not of this screen: a kilogram base unit * carrying a gram measurement is meaningful to 0.001, a unit counted in * pieces to 1. A single hard-coded figure is wrong for one of them whichever * figure is picked. */ precision?: number | null; /** * The value is a positive MAGNITUDE leaving stock, so the sign is this * function's to draw. * * Owned here rather than as a `−` in the template because the sign and the * rounding are one decision: a template minus in front of a rounded-away * quantity is exactly the `−0 kg` this function exists to prevent, and a * template minus in front of a true zero says stock leaves when none does. */ deduction?: boolean; } /** * Quantity, trailing zeros trimmed, at the precision its unit is meaningful to. * `1` not `1.00`, `0.35` stays `0.35`. * * **A non-zero quantity is never rendered as zero** (ISSUE-001). Three branches, * and getting any two of them confused is the defect: * * 1. **Exactly zero** → `0`. Nothing moves, and that is worth saying plainly. * 2. **Non-zero but below the unit's smallest increment** → a BOUND, `<0.001`. * A one-piece run can draw 0.0004 kg of an ingredient; `0` told the reader * nothing would move and then stock moved. The bound is signed, so a * deduction reads `−<0.001 kg` rather than losing the direction with the * digits. * 3. **Anything else** → the figure, rounded to the unit's places. */ export declare function formatQuantity(value: number | FdoDecimal, unit?: string | null, options?: QuantityFormat): string; /** Percent at whole numbers, or `—` when nothing is produced yet. */ export declare function formatPercent(value: FdoDecimal | null | undefined): string; export declare function pluralise(count: number, singular: string, plural?: string): string; /** * Committed minus produced, floored at 0 — what the run still owes. * * Overproduction is legal (the kitchen made more than it committed to), and it * leaves NOTHING unaccounted, so it clamps to 0 rather than reading as a * negative remainder in close/shortfall copy. */ export declare function remainingQuantity(committed: FdoDecimal, produced: FdoDecimal): number; /** * The base unit shared by EVERY production item, or null when they differ or * cannot be resolved. * * Aggregate quantities (committed/produced totals) sum base amounts across * skus, which is only meaningful when the skus share a unit. When they do not, * callers render the total WITHOUT a unit rather than mislabelling `4 kg` on a * run that made kg and litres. Per-item figures are always unit-correct. * * A run carries no sku snapshot on `items` — a DRAFT or REQUESTING run is a * plan, so display resolves against live inventory. Issuance lines DO carry a * snapshot and it wins: it is the unit the movement was actually valued in. * With neither available (an unissued run in a view that has not loaded * inventory) the answer is null, and the caller drops the unit. */ export declare function sharedUnitAbbrev(run: FdoProductionRun, resolveSku?: (skuId: string) => FdoInventorySku | null | undefined): string | null; /** * Whether the outputs resolve to MORE THAN ONE unit. * * Deliberately distinct from `sharedUnitAbbrev` returning null, which also * happens when a unit is merely unknown — a DRAFT whose skus are not in any * issuance yet. Blanking a total needs the stronger claim: not "we cannot name * the unit" but "there are two, so no single total exists". Grams cannot be * added to bottles; grams can be added to grams we have not named. */ export declare function outputUnitsDiffer(run: FdoProductionRun, resolveSku?: (skuId: string) => FdoInventorySku | null | undefined): boolean; /** * `_id` where the unit has one; the abbrev is only a fallback for fixtures. * * Exported so every production surface decides "same unit" the same way as * {@link outputUnitsDiffer}. A second copy of this rule is how two surfaces * eventually disagree about whether a run's quantities are addable. */ export declare function unitKey(unit: FdoInventoryUnit): string; export interface ProductionOutputBatchItem { skuId: string; /** Base units — a batch line's stored amount is in its own `measurement`. */ amount: number; } export interface ProductionOutputBatch { /** Present on current records; older display fixtures may omit it. */ stockApplicationStatus?: 'PENDING' | 'APPLIED' | null; id: string; adjustmentId: string; /** 1-based, in the chronological order shown. Not a traceability lot code. */ index: number; /** When the kitchen actually finished this batch — user-entered. */ producedAt: string; /** When the system recorded it — server clock, never client-supplied. */ recordedAt: string; /** True when output was keyed in after the fact; the gap is what a variance investigation asks about. */ isBackdated: boolean; recordedBy: string; items: ProductionOutputBatchItem[]; /** Why this particular production event had the result it did. */ remark: string | null; wastages: (FdoProductionWastageLine & { remark?: string | null; })[]; } export declare function productionOutputBatches(run: FdoProductionRun): ProductionOutputBatch[]; /** * The FIXED wastage-reason vocabulary (`F_PRODUCTION_WASTAGE_REASON`), in the * order the picker shows it. Deliberately NOT the business's adjustment-template * reasons — production loss categories are universal, so the picker works the * same in every location and needs no fetch. */ export declare const PRODUCTION_WASTAGE_REASONS: F_PRODUCTION_WASTAGE_REASON[]; /** Display labels for the fixed vocabulary — the enum values stay UPPER in data. */ /** * The i18n key for a wastage reason. * * The words used to live here as a literal map, which put five user-facing * strings somewhere a translator cannot reach — the module is * English-only-by-construction rather than merely untranslated. The vocabulary * itself is fixed and cross-business (so it stays comparable across locations); * only its rendering is a locale concern. */ export declare function wastageReasonKey(reason: F_PRODUCTION_WASTAGE_REASON | string): string; /** * Enum value → display label. Null when there is no reason at all, so callers * can skip the segment entirely. */ export declare function formatWastageReason(reason: string | null | undefined): string | null; /** * Has the run stopped producing for good? * * The line between "no output yet" and "no output, final". Shared because the * listing and the detail page must answer it identically — they disagreed once, * and a run closed with nothing showed 0% in one place and `—` in the other. */ export declare function hasStopped(run: FdoProductionRun): boolean; /** * How a stopped run ended, in terms of what it made — never of which status it * carries. * * Closure is one terminal now, at target or short, because reaching the * committed quantity is a measurement and stopping is a decision. So the * outcome is DERIVED from committed versus produced, both already on the * document. Storing it would create durable state able to disagree with its own * inputs, and a closed run's batches are immutable, so there is nothing to gain * by caching it. * * `null` while the run can still produce — an open run has no outcome yet, and * a cancelled run never committed to one. */ export declare function closureOutcome(run: FdoProductionRun): 'target-reached' | 'below-target' | null; export type ProductionRunTerminalOutputOutcome = 'below-target' | 'at-target' | 'above-target'; /** * A stopped run's output outcome, compared per sku. * * Cross-output totals are deliberately absent. Five kilograms above target * cannot cancel one litre below target, and mixed-unit runs have no meaningful * aggregate percentage. A run is above target only when every commitment was * met and at least one was exceeded; any short item keeps the outcome below. */ export declare function terminalOutputOutcome(run: FdoProductionRun): ProductionRunTerminalOutputOutcome | null;