sinfactura-types 1.10.375 → 1.10.377

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/stock.js CHANGED
@@ -68,8 +68,16 @@ exports.MAX_STOCK_ADJUSTMENT_NOTE_BYTES = 280;
68
68
  * than the count.
69
69
  * - `PRODUCT_NOT_FOUND` · 404 — from the pre-check AND from classifying a
70
70
  * cancelled transaction, so it is reachable even after the pre-check passed.
71
- * - `STOCK_ADJUSTMENT_RACED` · 409 — a concurrent movement won the ledger write.
71
+ * - `STOCK_ADJUSTMENT_RACED` · 409 — a concurrent movement won the ledger write, or
72
+ * moved the product between an `opening_balance` check and its write.
72
73
  * Re-read and retry; the adjustment did NOT apply.
74
+ * - `OPENING_BALANCE_EXISTS` · 409 — `opening_balance` on a product that already
75
+ * has an opening row. Nothing applied; the product needs no second one.
76
+ * - `OPENING_BALANCE_QUANTITY_MISMATCH` · 400 — `opening_balance` whose
77
+ * `quantityDelta` is not the product's `counter − ledger` delta. `data.expectedQuantityDelta`
78
+ * carries the figure that would be accepted; `0` means there is nothing to explain.
79
+ * - `OPENING_BALANCE_UNVERIFIABLE` · 409 — the product's ledger is too long to sum,
80
+ * so the opening balance cannot be checked and is not written.
73
81
  *
74
82
  * ⚠️ Cross-cutting refusals are NOT repeated here — check `GATING_ERROR_CODES`
75
83
  * as well.
@@ -80,4 +88,7 @@ exports.STOCK_ADJUSTMENT_ERROR_CODES = [
80
88
  'STOCK_ADJUSTMENT_REASON_DIRECTION_MISMATCH',
81
89
  'PRODUCT_NOT_FOUND',
82
90
  'STOCK_ADJUSTMENT_RACED',
91
+ 'OPENING_BALANCE_EXISTS',
92
+ 'OPENING_BALANCE_QUANTITY_MISMATCH',
93
+ 'OPENING_BALANCE_UNVERIFIABLE',
83
94
  ];
package/dist/stock.d.ts CHANGED
@@ -554,12 +554,20 @@ declare global {
554
554
  * than the count.
555
555
  * - `PRODUCT_NOT_FOUND` · 404 — from the pre-check AND from classifying a
556
556
  * cancelled transaction, so it is reachable even after the pre-check passed.
557
- * - `STOCK_ADJUSTMENT_RACED` · 409 — a concurrent movement won the ledger write.
557
+ * - `STOCK_ADJUSTMENT_RACED` · 409 — a concurrent movement won the ledger write, or
558
+ * moved the product between an `opening_balance` check and its write.
558
559
  * Re-read and retry; the adjustment did NOT apply.
560
+ * - `OPENING_BALANCE_EXISTS` · 409 — `opening_balance` on a product that already
561
+ * has an opening row. Nothing applied; the product needs no second one.
562
+ * - `OPENING_BALANCE_QUANTITY_MISMATCH` · 400 — `opening_balance` whose
563
+ * `quantityDelta` is not the product's `counter − ledger` delta. `data.expectedQuantityDelta`
564
+ * carries the figure that would be accepted; `0` means there is nothing to explain.
565
+ * - `OPENING_BALANCE_UNVERIFIABLE` · 409 — the product's ledger is too long to sum,
566
+ * so the opening balance cannot be checked and is not written.
559
567
  *
560
568
  * ⚠️ Cross-cutting refusals are NOT repeated here — check `GATING_ERROR_CODES`
561
569
  * as well.
562
570
  */
563
- export declare const STOCK_ADJUSTMENT_ERROR_CODES: readonly ["ROLE_FORBIDDEN", "VALIDATION_FAILED", "STOCK_ADJUSTMENT_REASON_DIRECTION_MISMATCH", "PRODUCT_NOT_FOUND", "STOCK_ADJUSTMENT_RACED"];
571
+ export declare const STOCK_ADJUSTMENT_ERROR_CODES: readonly ["ROLE_FORBIDDEN", "VALIDATION_FAILED", "STOCK_ADJUSTMENT_REASON_DIRECTION_MISMATCH", "PRODUCT_NOT_FOUND", "STOCK_ADJUSTMENT_RACED", "OPENING_BALANCE_EXISTS", "OPENING_BALANCE_QUANTITY_MISMATCH", "OPENING_BALANCE_UNVERIFIABLE"];
564
572
  export type StockAdjustmentErrorCode = (typeof STOCK_ADJUSTMENT_ERROR_CODES)[number];
565
573
  export {};
package/dist/stock.js CHANGED
@@ -65,8 +65,16 @@ export const MAX_STOCK_ADJUSTMENT_NOTE_BYTES = 280;
65
65
  * than the count.
66
66
  * - `PRODUCT_NOT_FOUND` · 404 — from the pre-check AND from classifying a
67
67
  * cancelled transaction, so it is reachable even after the pre-check passed.
68
- * - `STOCK_ADJUSTMENT_RACED` · 409 — a concurrent movement won the ledger write.
68
+ * - `STOCK_ADJUSTMENT_RACED` · 409 — a concurrent movement won the ledger write, or
69
+ * moved the product between an `opening_balance` check and its write.
69
70
  * Re-read and retry; the adjustment did NOT apply.
71
+ * - `OPENING_BALANCE_EXISTS` · 409 — `opening_balance` on a product that already
72
+ * has an opening row. Nothing applied; the product needs no second one.
73
+ * - `OPENING_BALANCE_QUANTITY_MISMATCH` · 400 — `opening_balance` whose
74
+ * `quantityDelta` is not the product's `counter − ledger` delta. `data.expectedQuantityDelta`
75
+ * carries the figure that would be accepted; `0` means there is nothing to explain.
76
+ * - `OPENING_BALANCE_UNVERIFIABLE` · 409 — the product's ledger is too long to sum,
77
+ * so the opening balance cannot be checked and is not written.
70
78
  *
71
79
  * ⚠️ Cross-cutting refusals are NOT repeated here — check `GATING_ERROR_CODES`
72
80
  * as well.
@@ -77,4 +85,7 @@ export const STOCK_ADJUSTMENT_ERROR_CODES = [
77
85
  'STOCK_ADJUSTMENT_REASON_DIRECTION_MISMATCH',
78
86
  'PRODUCT_NOT_FOUND',
79
87
  'STOCK_ADJUSTMENT_RACED',
88
+ 'OPENING_BALANCE_EXISTS',
89
+ 'OPENING_BALANCE_QUANTITY_MISMATCH',
90
+ 'OPENING_BALANCE_UNVERIFIABLE',
80
91
  ];
@@ -85,7 +85,7 @@ declare global {
85
85
  * quietly missing a feature), but it means the caller must be updated in the
86
86
  * same change. Adding a key is never only additive downstream.
87
87
  */
88
- type FeatureKey = 'maxOrdersMonth' | 'maxInvoicesMonth' | 'maxProducts' | 'maxUsers' | 'maxCustomers' | 'maxStores' | 'priceListsMax' | 'afipInvoicing' | 'suppliers' | 'domesticPayments' | 'stripePayments' | 'cashManagement' | 'multiStore' | 'importExport' | 'advancedReports' | 'customBranding' | 'prioritySupport' | 'whatsappCommerce' | 'aiFeatures' | 'mobileApp' | 'customDomain' | 'advancedPricing' | 'marketplaceChannels' | 'storefront' | 'loyalty' | 'marketing' | 'mandatory2fa';
88
+ type FeatureKey = 'maxOrdersMonth' | 'maxInvoicesMonth' | 'maxProducts' | 'maxUsers' | 'maxCustomers' | 'maxStores' | 'maxWarehouses' | 'priceListsMax' | 'afipInvoicing' | 'suppliers' | 'domesticPayments' | 'stripePayments' | 'cashManagement' | 'multiStore' | 'importExport' | 'advancedReports' | 'customBranding' | 'prioritySupport' | 'whatsappCommerce' | 'aiFeatures' | 'mobileApp' | 'customDomain' | 'advancedPricing' | 'marketplaceChannels' | 'storefront' | 'loyalty' | 'marketing' | 'mandatory2fa';
89
89
  /** Resolved entitlements for a specific tenant (matrix + overrides applied). */
90
90
  type ResolvedEntitlements = Record<FeatureKey, Entitlement>;
91
91
  /**
@@ -115,8 +115,15 @@ declare global {
115
115
  type: EntitlementType;
116
116
  enabled?: boolean;
117
117
  limit?: number;
118
- source: 'plan' | 'override';
118
+ source: EntitlementSource;
119
119
  }
120
+ /**
121
+ * Which scope set an entitlement: the tier's plan grant, or a per-store
122
+ * `OVERRIDE#` row. It reaches the wire as `source` on every
123
+ * `PLAN_LIMIT_EXCEEDED` / feature refusal, where `'override'` means no plan
124
+ * change lifts the block, so an upgrade prompt would be dishonest.
125
+ */
126
+ type EntitlementSource = 'plan' | 'override';
120
127
  /**
121
128
  * What a tenant actually gets once plan defaults and overrides are merged —
122
129
  * the resolver's entire return value, not just its feature map. The tier and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.10.375",
3
+ "version": "1.10.377",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",