sinfactura-types 1.10.374 → 1.10.376
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/index.js +1 -0
- package/dist/cjs/purchaseReceipt.js +46 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/purchaseReceipt.d.ts +100 -0
- package/dist/purchaseReceipt.js +43 -0
- package/dist/stock.d.ts +6 -0
- package/dist/subscription.d.ts +9 -2
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -70,6 +70,7 @@ __exportStar(require("./pricing.js"), exports);
|
|
|
70
70
|
__exportStar(require("./print.js"), exports);
|
|
71
71
|
__exportStar(require("./product.js"), exports);
|
|
72
72
|
__exportStar(require("./purchaseOrder.js"), exports);
|
|
73
|
+
__exportStar(require("./purchaseReceipt.js"), exports);
|
|
73
74
|
__exportStar(require("./pushDevice.js"), exports);
|
|
74
75
|
__exportStar(require("./reminder.js"), exports);
|
|
75
76
|
__exportStar(require("./report.js"), exports);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PURCHASE_RECEIPT_ERROR_CODES = exports.PURCHASE_RECEIPT_MAX_LINES = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The most lines one receipt may book. A receipt commits as ONE DynamoDB
|
|
6
|
+
* transaction of at most `2 + 2N` items — the receipt row, the purchase-order
|
|
7
|
+
* update, an `INCOME#` Put per line and a product `Update` per distinct product —
|
|
8
|
+
* against the 100-item transaction ceiling, so 49 is the largest N that fits.
|
|
9
|
+
*/
|
|
10
|
+
exports.PURCHASE_RECEIPT_MAX_LINES = 49;
|
|
11
|
+
/**
|
|
12
|
+
* Refusals from `POST /purchase-orders { mode: 'receive' }` and the receipt reads
|
|
13
|
+
* (`GET /purchase-orders?mode=receipts|receipt`).
|
|
14
|
+
*
|
|
15
|
+
* - `VALIDATION_FAILED` · 400 — includes more than `PURCHASE_RECEIPT_MAX_LINES`
|
|
16
|
+
* lines and two lines naming the same `purchaseOrderItemIndex`.
|
|
17
|
+
* - `ADMIN_REQUIRED` · 403
|
|
18
|
+
* - `PURCHASE_ORDER_NOT_FOUND` · 404
|
|
19
|
+
* - `PURCHASE_ORDER_LINE_NOT_FOUND` · 400 — an index past the end of `items`.
|
|
20
|
+
* - `PURCHASE_ORDER_ILLEGAL_TRANSITION` · 400 — the order is `draft`, `received`
|
|
21
|
+
* or `cancelled`; only `sent` and `partially_received` accept a delivery.
|
|
22
|
+
* - `PURCHASE_ORDER_VERSION_CONFLICT` · 409 — the order changed between the read
|
|
23
|
+
* and the commit. Nothing moved; re-read and retry with the SAME `receiptKey`.
|
|
24
|
+
* - `STOCK_INCOME_RACED` · 409 — the ledger-key retry budget ran out. Nothing moved.
|
|
25
|
+
* - `PRODUCT_NOT_FOUND` · 404 — a line's product no longer exists. Nothing moved.
|
|
26
|
+
* - `PURCHASE_RECEIPT_NOT_FOUND` · 404 — `mode=receipt` addressed nothing.
|
|
27
|
+
* - `INVALID_CURSOR` · 400
|
|
28
|
+
*
|
|
29
|
+
* A replay of a `receiptKey` that already committed is NOT a refusal: it answers
|
|
30
|
+
* 200 with the stored receipt and `replayed: true`.
|
|
31
|
+
*
|
|
32
|
+
* ⚠️ Cross-cutting refusals are NOT repeated here — check `GATING_ERROR_CODES`
|
|
33
|
+
* as well.
|
|
34
|
+
*/
|
|
35
|
+
exports.PURCHASE_RECEIPT_ERROR_CODES = [
|
|
36
|
+
'VALIDATION_FAILED',
|
|
37
|
+
'ADMIN_REQUIRED',
|
|
38
|
+
'PURCHASE_ORDER_NOT_FOUND',
|
|
39
|
+
'PURCHASE_ORDER_LINE_NOT_FOUND',
|
|
40
|
+
'PURCHASE_ORDER_ILLEGAL_TRANSITION',
|
|
41
|
+
'PURCHASE_ORDER_VERSION_CONFLICT',
|
|
42
|
+
'STOCK_INCOME_RACED',
|
|
43
|
+
'PRODUCT_NOT_FOUND',
|
|
44
|
+
'PURCHASE_RECEIPT_NOT_FOUND',
|
|
45
|
+
'INVALID_CURSOR',
|
|
46
|
+
];
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export * from './pricing.ts';
|
|
|
46
46
|
export * from './print.ts';
|
|
47
47
|
export * from './product.ts';
|
|
48
48
|
export * from './purchaseOrder.ts';
|
|
49
|
+
export * from './purchaseReceipt.ts';
|
|
49
50
|
export * from './pushDevice.ts';
|
|
50
51
|
export * from './reminder.ts';
|
|
51
52
|
export * from './report.ts';
|
package/dist/index.js
CHANGED
|
@@ -54,6 +54,7 @@ export * from "./pricing.js";
|
|
|
54
54
|
export * from "./print.js";
|
|
55
55
|
export * from "./product.js";
|
|
56
56
|
export * from "./purchaseOrder.js";
|
|
57
|
+
export * from "./purchaseReceipt.js";
|
|
57
58
|
export * from "./pushDevice.js";
|
|
58
59
|
export * from "./reminder.js";
|
|
59
60
|
export * from "./report.js";
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The most lines one receipt may book. A receipt commits as ONE DynamoDB
|
|
3
|
+
* transaction of at most `2 + 2N` items — the receipt row, the purchase-order
|
|
4
|
+
* update, an `INCOME#` Put per line and a product `Update` per distinct product —
|
|
5
|
+
* against the 100-item transaction ceiling, so 49 is the largest N that fits.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PURCHASE_RECEIPT_MAX_LINES = 49;
|
|
8
|
+
declare global {
|
|
9
|
+
/**
|
|
10
|
+
* One line of a receipt: how many units of ONE purchase-order line arrived in
|
|
11
|
+
* this delivery, and at what cost.
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ Addressed by `purchaseOrderItemIndex`, never by `productId`, for the
|
|
14
|
+
* reason `PurchaseOrderItem` gives: one order legitimately carries the same
|
|
15
|
+
* product on several lines.
|
|
16
|
+
*/
|
|
17
|
+
interface PurchaseReceiptItem {
|
|
18
|
+
/** Index into the ordering `PurchaseOrder.items`. */
|
|
19
|
+
purchaseOrderItemIndex: number;
|
|
20
|
+
/** Copied from the purchase-order line at receipt time. */
|
|
21
|
+
productId: string;
|
|
22
|
+
/** Copied from the purchase-order line at receipt time. */
|
|
23
|
+
name: string;
|
|
24
|
+
sku?: string;
|
|
25
|
+
/** Units that arrived against this line in THIS delivery. */
|
|
26
|
+
quantity: number;
|
|
27
|
+
/**
|
|
28
|
+
* Unit cost this delivery was valued at, in the purchase order's currency.
|
|
29
|
+
* The line's `unitCost` when the request named none, so it is always present.
|
|
30
|
+
*/
|
|
31
|
+
cost: number;
|
|
32
|
+
/**
|
|
33
|
+
* Batch these units arrived as. Recorded as sent and NOT validated: a
|
|
34
|
+
* receipt does not write the warehouse-level lot book, so nothing here
|
|
35
|
+
* reconciles against a `Lot` row.
|
|
36
|
+
*/
|
|
37
|
+
lotId?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* One physical delivery booked against a purchase order: every line that
|
|
41
|
+
* arrived together, committed in ONE transaction with the stock it moved.
|
|
42
|
+
*
|
|
43
|
+
* Idempotent on `receiptKey`, a client-minted UUID: booking the same key a
|
|
44
|
+
* second time answers the stored receipt instead of moving stock again.
|
|
45
|
+
*/
|
|
46
|
+
interface PurchaseReceipt {
|
|
47
|
+
storeId: string;
|
|
48
|
+
/**
|
|
49
|
+
* `${purchaseOrderId}#${receiptKey}` — the row's sort key, and the value every
|
|
50
|
+
* `INCOME#` row this receipt wrote carries as `receiptId`.
|
|
51
|
+
*
|
|
52
|
+
* ⚠️ Contains a `#`, so it must be URL-encoded (`%23`) in a query string.
|
|
53
|
+
*/
|
|
54
|
+
receiptId: string;
|
|
55
|
+
/** Client-minted UUID v4; the idempotency key. */
|
|
56
|
+
receiptKey: string;
|
|
57
|
+
purchaseOrderId: string;
|
|
58
|
+
supplierId: string;
|
|
59
|
+
/** Supplier name denormalized at receipt time, like the `INCOME#` rows beside it. */
|
|
60
|
+
supplierName?: string;
|
|
61
|
+
/** Currency catalogId of the purchase order the costs are expressed in. */
|
|
62
|
+
currency: string;
|
|
63
|
+
/** The `YYYYMMDD` day the goods arrived. */
|
|
64
|
+
dated: number;
|
|
65
|
+
/** Unix ms the receipt was recorded. */
|
|
66
|
+
createdAt: number;
|
|
67
|
+
/** The operator who booked it. */
|
|
68
|
+
userId: string;
|
|
69
|
+
/** Operator note. ⚠️ Never personal data — this row is not scrubbed and has no TTL. */
|
|
70
|
+
notes?: string;
|
|
71
|
+
items: PurchaseReceiptItem[];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Refusals from `POST /purchase-orders { mode: 'receive' }` and the receipt reads
|
|
76
|
+
* (`GET /purchase-orders?mode=receipts|receipt`).
|
|
77
|
+
*
|
|
78
|
+
* - `VALIDATION_FAILED` · 400 — includes more than `PURCHASE_RECEIPT_MAX_LINES`
|
|
79
|
+
* lines and two lines naming the same `purchaseOrderItemIndex`.
|
|
80
|
+
* - `ADMIN_REQUIRED` · 403
|
|
81
|
+
* - `PURCHASE_ORDER_NOT_FOUND` · 404
|
|
82
|
+
* - `PURCHASE_ORDER_LINE_NOT_FOUND` · 400 — an index past the end of `items`.
|
|
83
|
+
* - `PURCHASE_ORDER_ILLEGAL_TRANSITION` · 400 — the order is `draft`, `received`
|
|
84
|
+
* or `cancelled`; only `sent` and `partially_received` accept a delivery.
|
|
85
|
+
* - `PURCHASE_ORDER_VERSION_CONFLICT` · 409 — the order changed between the read
|
|
86
|
+
* and the commit. Nothing moved; re-read and retry with the SAME `receiptKey`.
|
|
87
|
+
* - `STOCK_INCOME_RACED` · 409 — the ledger-key retry budget ran out. Nothing moved.
|
|
88
|
+
* - `PRODUCT_NOT_FOUND` · 404 — a line's product no longer exists. Nothing moved.
|
|
89
|
+
* - `PURCHASE_RECEIPT_NOT_FOUND` · 404 — `mode=receipt` addressed nothing.
|
|
90
|
+
* - `INVALID_CURSOR` · 400
|
|
91
|
+
*
|
|
92
|
+
* A replay of a `receiptKey` that already committed is NOT a refusal: it answers
|
|
93
|
+
* 200 with the stored receipt and `replayed: true`.
|
|
94
|
+
*
|
|
95
|
+
* ⚠️ Cross-cutting refusals are NOT repeated here — check `GATING_ERROR_CODES`
|
|
96
|
+
* as well.
|
|
97
|
+
*/
|
|
98
|
+
export declare const PURCHASE_RECEIPT_ERROR_CODES: readonly ["VALIDATION_FAILED", "ADMIN_REQUIRED", "PURCHASE_ORDER_NOT_FOUND", "PURCHASE_ORDER_LINE_NOT_FOUND", "PURCHASE_ORDER_ILLEGAL_TRANSITION", "PURCHASE_ORDER_VERSION_CONFLICT", "STOCK_INCOME_RACED", "PRODUCT_NOT_FOUND", "PURCHASE_RECEIPT_NOT_FOUND", "INVALID_CURSOR"];
|
|
99
|
+
export type PurchaseReceiptErrorCode = (typeof PURCHASE_RECEIPT_ERROR_CODES)[number];
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The most lines one receipt may book. A receipt commits as ONE DynamoDB
|
|
3
|
+
* transaction of at most `2 + 2N` items — the receipt row, the purchase-order
|
|
4
|
+
* update, an `INCOME#` Put per line and a product `Update` per distinct product —
|
|
5
|
+
* against the 100-item transaction ceiling, so 49 is the largest N that fits.
|
|
6
|
+
*/
|
|
7
|
+
export const PURCHASE_RECEIPT_MAX_LINES = 49;
|
|
8
|
+
/**
|
|
9
|
+
* Refusals from `POST /purchase-orders { mode: 'receive' }` and the receipt reads
|
|
10
|
+
* (`GET /purchase-orders?mode=receipts|receipt`).
|
|
11
|
+
*
|
|
12
|
+
* - `VALIDATION_FAILED` · 400 — includes more than `PURCHASE_RECEIPT_MAX_LINES`
|
|
13
|
+
* lines and two lines naming the same `purchaseOrderItemIndex`.
|
|
14
|
+
* - `ADMIN_REQUIRED` · 403
|
|
15
|
+
* - `PURCHASE_ORDER_NOT_FOUND` · 404
|
|
16
|
+
* - `PURCHASE_ORDER_LINE_NOT_FOUND` · 400 — an index past the end of `items`.
|
|
17
|
+
* - `PURCHASE_ORDER_ILLEGAL_TRANSITION` · 400 — the order is `draft`, `received`
|
|
18
|
+
* or `cancelled`; only `sent` and `partially_received` accept a delivery.
|
|
19
|
+
* - `PURCHASE_ORDER_VERSION_CONFLICT` · 409 — the order changed between the read
|
|
20
|
+
* and the commit. Nothing moved; re-read and retry with the SAME `receiptKey`.
|
|
21
|
+
* - `STOCK_INCOME_RACED` · 409 — the ledger-key retry budget ran out. Nothing moved.
|
|
22
|
+
* - `PRODUCT_NOT_FOUND` · 404 — a line's product no longer exists. Nothing moved.
|
|
23
|
+
* - `PURCHASE_RECEIPT_NOT_FOUND` · 404 — `mode=receipt` addressed nothing.
|
|
24
|
+
* - `INVALID_CURSOR` · 400
|
|
25
|
+
*
|
|
26
|
+
* A replay of a `receiptKey` that already committed is NOT a refusal: it answers
|
|
27
|
+
* 200 with the stored receipt and `replayed: true`.
|
|
28
|
+
*
|
|
29
|
+
* ⚠️ Cross-cutting refusals are NOT repeated here — check `GATING_ERROR_CODES`
|
|
30
|
+
* as well.
|
|
31
|
+
*/
|
|
32
|
+
export const PURCHASE_RECEIPT_ERROR_CODES = [
|
|
33
|
+
'VALIDATION_FAILED',
|
|
34
|
+
'ADMIN_REQUIRED',
|
|
35
|
+
'PURCHASE_ORDER_NOT_FOUND',
|
|
36
|
+
'PURCHASE_ORDER_LINE_NOT_FOUND',
|
|
37
|
+
'PURCHASE_ORDER_ILLEGAL_TRANSITION',
|
|
38
|
+
'PURCHASE_ORDER_VERSION_CONFLICT',
|
|
39
|
+
'STOCK_INCOME_RACED',
|
|
40
|
+
'PRODUCT_NOT_FOUND',
|
|
41
|
+
'PURCHASE_RECEIPT_NOT_FOUND',
|
|
42
|
+
'INVALID_CURSOR',
|
|
43
|
+
];
|
package/dist/stock.d.ts
CHANGED
|
@@ -188,6 +188,12 @@ declare global {
|
|
|
188
188
|
purchaseOrderId?: string;
|
|
189
189
|
/** Index into the ordering `PurchaseOrder.items`. Present alongside `purchaseOrderId`. */
|
|
190
190
|
purchaseOrderItemIndex?: number;
|
|
191
|
+
/**
|
|
192
|
+
* The `PurchaseReceipt.receiptId` of the multi-line receipt that wrote this
|
|
193
|
+
* row. Absent on a row booked one line at a time through `POST
|
|
194
|
+
* /products/stock`, which records no receipt document.
|
|
195
|
+
*/
|
|
196
|
+
receiptId?: string;
|
|
191
197
|
/**
|
|
192
198
|
* The batch these units arrived as, on a lot-tracked product.
|
|
193
199
|
*
|
package/dist/subscription.d.ts
CHANGED
|
@@ -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:
|
|
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
|