@adatechnology/purchase-contracts 0.0.0-stage → 0.1.0
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/README.md +16 -2
- package/dist/index.cjs +1548 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2005 -0
- package/dist/index.d.ts +2005 -0
- package/dist/index.js +1420 -0
- package/dist/index.js.map +1 -0
- package/package.json +34 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2005 @@
|
|
|
1
|
+
import { RecipeUnit, Rational } from '@adatechnology/recipe-contracts';
|
|
2
|
+
export { Rational, ZERO, add, compare, multiply, subtract } from '@adatechnology/recipe-contracts';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
7
|
+
*
|
|
8
|
+
* Compras funciona sozinho: o item comprado é um texto com unidade de compra (`cx`, `fardo`, `kg`). Com um catálogo
|
|
9
|
+
* ligado (ficha técnica, estoque ou o do host), o item aponta para ele por `itemRef`, opaco para o módulo. Quantidade
|
|
10
|
+
* e preço são texto decimal exato (até 4 casas); dinheiro de pedido e nota fecha em 2 casas.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
declare const ORDER_STATUS: {
|
|
14
|
+
readonly DRAFT: "draft";
|
|
15
|
+
readonly PENDING_APPROVAL: "pending_approval";
|
|
16
|
+
readonly APPROVED: "approved";
|
|
17
|
+
readonly SENT: "sent";
|
|
18
|
+
readonly PARTIALLY_RECEIVED: "partially_received";
|
|
19
|
+
readonly RECEIVED: "received";
|
|
20
|
+
readonly CLOSED: "closed";
|
|
21
|
+
readonly CANCELED: "canceled";
|
|
22
|
+
};
|
|
23
|
+
type OrderStatus = (typeof ORDER_STATUS)[keyof typeof ORDER_STATUS];
|
|
24
|
+
declare const ORDER_STATUSES: readonly OrderStatus[];
|
|
25
|
+
/** Pedido que ainda pode chegar: conta como "a caminho" no estoque previsto. */
|
|
26
|
+
declare const OPEN_ORDER_STATUSES: readonly OrderStatus[];
|
|
27
|
+
declare const DISPATCH_CHANNEL: {
|
|
28
|
+
readonly WHATSAPP: "whatsapp";
|
|
29
|
+
readonly EMAIL: "email";
|
|
30
|
+
readonly MANUAL: "manual";
|
|
31
|
+
};
|
|
32
|
+
type DispatchChannel = (typeof DISPATCH_CHANNEL)[keyof typeof DISPATCH_CHANNEL];
|
|
33
|
+
declare const DISPATCH_CHANNELS: readonly DispatchChannel[];
|
|
34
|
+
declare const DIVERGENCE: {
|
|
35
|
+
readonly NONE: "none";
|
|
36
|
+
readonly QUANTITY: "quantity";
|
|
37
|
+
readonly PRICE: "price";
|
|
38
|
+
readonly BOTH: "both";
|
|
39
|
+
};
|
|
40
|
+
type Divergence = (typeof DIVERGENCE)[keyof typeof DIVERGENCE];
|
|
41
|
+
/** Situação de cada integração de um recebimento: `skipped` = porta não ligada. */
|
|
42
|
+
declare const INTEGRATION_STATUS: {
|
|
43
|
+
readonly SKIPPED: "skipped";
|
|
44
|
+
readonly DONE: "done";
|
|
45
|
+
readonly FAILED: "failed";
|
|
46
|
+
};
|
|
47
|
+
type IntegrationStatus = (typeof INTEGRATION_STATUS)[keyof typeof INTEGRATION_STATUS];
|
|
48
|
+
declare const PAYMENT_STATUS: {
|
|
49
|
+
readonly NONE: "none";
|
|
50
|
+
readonly OPEN: "open";
|
|
51
|
+
readonly PARTIAL: "partial";
|
|
52
|
+
readonly PAID: "paid";
|
|
53
|
+
};
|
|
54
|
+
type PaymentStatus = (typeof PAYMENT_STATUS)[keyof typeof PAYMENT_STATUS];
|
|
55
|
+
declare const SORT_ORDER: {
|
|
56
|
+
readonly ASC: "asc";
|
|
57
|
+
readonly DESC: "desc";
|
|
58
|
+
};
|
|
59
|
+
type SortOrder = (typeof SORT_ORDER)[keyof typeof SORT_ORDER];
|
|
60
|
+
type Supplier = {
|
|
61
|
+
readonly id: string;
|
|
62
|
+
readonly name: string;
|
|
63
|
+
/** CPF/CNPJ só com dígitos (ou alfanumérico), sem máscara. */
|
|
64
|
+
readonly document: string | null;
|
|
65
|
+
readonly contactName: string | null;
|
|
66
|
+
readonly email: string | null;
|
|
67
|
+
readonly phone: string | null;
|
|
68
|
+
/** Número para receber o pedido (E.164 sem `+` ou com). */
|
|
69
|
+
readonly whatsapp: string | null;
|
|
70
|
+
/** Condição de pagamento em dias a partir do recebimento: `[0]` à vista, `[30, 60, 90]`. */
|
|
71
|
+
readonly paymentTermDays: readonly number[];
|
|
72
|
+
/** Dias entre o envio e a entrega, para a previsão padrão do pedido. */
|
|
73
|
+
readonly leadTimeDays: number | null;
|
|
74
|
+
/** Valor mínimo de pedido (2 casas). */
|
|
75
|
+
readonly minimumOrderAmount: string | null;
|
|
76
|
+
/** 0 = domingo … 6 = sábado. Vazio = qualquer dia. */
|
|
77
|
+
readonly deliveryWeekdays: readonly number[];
|
|
78
|
+
readonly notes: string;
|
|
79
|
+
readonly isActive: boolean;
|
|
80
|
+
readonly createdAt: string;
|
|
81
|
+
readonly updatedAt: string;
|
|
82
|
+
};
|
|
83
|
+
/** O que o fornecedor vende: código dele, embalagem e conversão para a unidade do estoque. */
|
|
84
|
+
type SupplierItem = {
|
|
85
|
+
readonly id: string;
|
|
86
|
+
readonly supplierId: string;
|
|
87
|
+
/** Id do item no catálogo ligado (insumo do `recipe-module`, produto do host); `null` = item livre. */
|
|
88
|
+
readonly itemRef: string | null;
|
|
89
|
+
readonly itemName: string;
|
|
90
|
+
readonly supplierSku: string | null;
|
|
91
|
+
/** Unidade em que se compra: `cx`, `fardo`, `kg`, `un`… */
|
|
92
|
+
readonly purchaseUnit: string;
|
|
93
|
+
/** Quantas unidades de estoque vêm em uma unidade de compra (caixa com 12 = `12`). */
|
|
94
|
+
readonly unitsPerPurchase: string;
|
|
95
|
+
/** Unidade de estoque (`kg`, `un`…); `null` em item livre sem estoque. */
|
|
96
|
+
readonly stockUnit: RecipeUnit | null;
|
|
97
|
+
/** Último preço por unidade de compra (do último recebimento ou digitado). */
|
|
98
|
+
readonly lastPrice: string | null;
|
|
99
|
+
readonly lastPriceAt: string | null;
|
|
100
|
+
/** Menor = preferido primeiro, entre os fornecedores do mesmo item. */
|
|
101
|
+
readonly priority: number;
|
|
102
|
+
readonly isActive: boolean;
|
|
103
|
+
readonly createdAt: string;
|
|
104
|
+
readonly updatedAt: string;
|
|
105
|
+
};
|
|
106
|
+
type OrderLine = {
|
|
107
|
+
readonly id: string;
|
|
108
|
+
readonly position: number;
|
|
109
|
+
readonly supplierItemId: string | null;
|
|
110
|
+
readonly itemRef: string | null;
|
|
111
|
+
readonly itemName: string;
|
|
112
|
+
readonly supplierSku: string | null;
|
|
113
|
+
readonly purchaseUnit: string;
|
|
114
|
+
readonly unitsPerPurchase: string;
|
|
115
|
+
readonly stockUnit: RecipeUnit | null;
|
|
116
|
+
/** Na unidade de compra. */
|
|
117
|
+
readonly quantity: string;
|
|
118
|
+
readonly unitPrice: string;
|
|
119
|
+
/** `quantity × unitPrice`, 2 casas. */
|
|
120
|
+
readonly lineTotal: string;
|
|
121
|
+
readonly receivedQuantity: string;
|
|
122
|
+
readonly canceledQuantity: string;
|
|
123
|
+
/** `quantity − received − canceled` (nunca negativo). */
|
|
124
|
+
readonly pendingQuantity: string;
|
|
125
|
+
readonly notes: string | null;
|
|
126
|
+
};
|
|
127
|
+
type PurchaseOrder = {
|
|
128
|
+
readonly id: string;
|
|
129
|
+
/** Sequencial por empresa: o número que se fala com o fornecedor. */
|
|
130
|
+
readonly number: number;
|
|
131
|
+
readonly supplierId: string;
|
|
132
|
+
readonly supplierName: string | null;
|
|
133
|
+
readonly status: OrderStatus;
|
|
134
|
+
/** `aaaa-mm-dd`. */
|
|
135
|
+
readonly expectedAt: string | null;
|
|
136
|
+
readonly isLate: boolean;
|
|
137
|
+
readonly subtotal: string;
|
|
138
|
+
readonly freight: string;
|
|
139
|
+
readonly discount: string;
|
|
140
|
+
readonly total: string;
|
|
141
|
+
readonly paymentTermDays: readonly number[];
|
|
142
|
+
readonly notes: string;
|
|
143
|
+
readonly requiresApproval: boolean;
|
|
144
|
+
readonly createdBy: string | null;
|
|
145
|
+
readonly submittedAt: string | null;
|
|
146
|
+
readonly approvedBy: string | null;
|
|
147
|
+
readonly approvedAt: string | null;
|
|
148
|
+
readonly rejectionReason: string | null;
|
|
149
|
+
readonly sentAt: string | null;
|
|
150
|
+
readonly sentVia: DispatchChannel | null;
|
|
151
|
+
readonly canceledAt: string | null;
|
|
152
|
+
readonly cancelReason: string | null;
|
|
153
|
+
readonly closedAt: string | null;
|
|
154
|
+
readonly paymentStatus: PaymentStatus;
|
|
155
|
+
readonly createdAt: string;
|
|
156
|
+
readonly updatedAt: string;
|
|
157
|
+
readonly lines: readonly OrderLine[];
|
|
158
|
+
};
|
|
159
|
+
type PurchaseOrderSummary = Omit<PurchaseOrder, 'lines'> & {
|
|
160
|
+
readonly lineCount: number;
|
|
161
|
+
};
|
|
162
|
+
type ReceiptLine = {
|
|
163
|
+
readonly id: string;
|
|
164
|
+
readonly orderLineId: string | null;
|
|
165
|
+
readonly itemRef: string | null;
|
|
166
|
+
readonly itemName: string;
|
|
167
|
+
readonly supplierSku: string | null;
|
|
168
|
+
readonly purchaseUnit: string;
|
|
169
|
+
readonly unitsPerPurchase: string;
|
|
170
|
+
readonly stockUnit: RecipeUnit | null;
|
|
171
|
+
/** Na unidade de compra. */
|
|
172
|
+
readonly quantity: string;
|
|
173
|
+
readonly unitPrice: string;
|
|
174
|
+
readonly lineTotal: string;
|
|
175
|
+
/** Custo por unidade de estoque com frete e desconto rateados (4 casas). */
|
|
176
|
+
readonly landedUnitCost: string | null;
|
|
177
|
+
readonly batchCode: string | null;
|
|
178
|
+
readonly expiresAt: string | null;
|
|
179
|
+
readonly divergence: Divergence;
|
|
180
|
+
readonly divergenceReason: string | null;
|
|
181
|
+
readonly stockStatus: IntegrationStatus;
|
|
182
|
+
};
|
|
183
|
+
type Receipt = {
|
|
184
|
+
readonly id: string;
|
|
185
|
+
readonly orderId: string | null;
|
|
186
|
+
readonly orderNumber: number | null;
|
|
187
|
+
readonly supplierId: string;
|
|
188
|
+
readonly supplierName: string | null;
|
|
189
|
+
readonly receivedAt: string;
|
|
190
|
+
readonly invoiceNumber: string | null;
|
|
191
|
+
/** Chave de acesso da NF-e (44 dígitos), única por empresa. */
|
|
192
|
+
readonly invoiceKey: string | null;
|
|
193
|
+
readonly invoiceIssuedAt: string | null;
|
|
194
|
+
readonly subtotal: string;
|
|
195
|
+
readonly freight: string;
|
|
196
|
+
readonly discount: string;
|
|
197
|
+
readonly total: string;
|
|
198
|
+
readonly notes: string;
|
|
199
|
+
readonly actorId: string | null;
|
|
200
|
+
readonly stockStatus: IntegrationStatus;
|
|
201
|
+
readonly payableStatus: IntegrationStatus;
|
|
202
|
+
/** Referência da conta a pagar criada pela porta `payables` (opaca). */
|
|
203
|
+
readonly payableRef: string | null;
|
|
204
|
+
readonly paymentStatus: PaymentStatus;
|
|
205
|
+
readonly createdAt: string;
|
|
206
|
+
readonly lines: readonly ReceiptLine[];
|
|
207
|
+
};
|
|
208
|
+
type PricePoint = {
|
|
209
|
+
readonly supplierId: string;
|
|
210
|
+
readonly supplierName: string | null;
|
|
211
|
+
readonly receiptId: string;
|
|
212
|
+
readonly receivedAt: string;
|
|
213
|
+
readonly purchaseUnit: string;
|
|
214
|
+
readonly unitPrice: string;
|
|
215
|
+
/** Por unidade de estoque, com rateio. */
|
|
216
|
+
readonly landedUnitCost: string | null;
|
|
217
|
+
readonly stockUnit: RecipeUnit | null;
|
|
218
|
+
};
|
|
219
|
+
type ItemCost = {
|
|
220
|
+
readonly itemRef: string;
|
|
221
|
+
readonly stockUnit: RecipeUnit | null;
|
|
222
|
+
readonly lastCost: string | null;
|
|
223
|
+
readonly lastReceivedAt: string | null;
|
|
224
|
+
readonly lastSupplierId: string | null;
|
|
225
|
+
/** Média ponderada pela quantidade, na janela de dias da configuração. */
|
|
226
|
+
readonly averageCost: string | null;
|
|
227
|
+
readonly averageWindowDays: number;
|
|
228
|
+
};
|
|
229
|
+
/** Quanto do item já foi pedido e ainda não chegou, em unidade de estoque. */
|
|
230
|
+
type IncomingSupply = {
|
|
231
|
+
readonly itemRef: string;
|
|
232
|
+
readonly quantity: string;
|
|
233
|
+
readonly unit: RecipeUnit;
|
|
234
|
+
readonly orderCount: number;
|
|
235
|
+
/** Previsão mais próxima (`aaaa-mm-dd`) entre os pedidos abertos. */
|
|
236
|
+
readonly nextExpectedAt: string | null;
|
|
237
|
+
};
|
|
238
|
+
type SuggestionLine = {
|
|
239
|
+
readonly itemRef: string;
|
|
240
|
+
readonly itemName: string;
|
|
241
|
+
readonly stockUnit: RecipeUnit;
|
|
242
|
+
readonly neededQuantity: string;
|
|
243
|
+
readonly onHandQuantity: string | null;
|
|
244
|
+
readonly incomingQuantity: string;
|
|
245
|
+
readonly minimumQuantity: string | null;
|
|
246
|
+
/** Falta, já descontando o que está a caminho, na unidade de estoque. */
|
|
247
|
+
readonly shortageQuantity: string;
|
|
248
|
+
readonly supplierItemId: string | null;
|
|
249
|
+
readonly purchaseUnit: string | null;
|
|
250
|
+
readonly unitsPerPurchase: string | null;
|
|
251
|
+
/** Quantidade sugerida na unidade de compra (arredondada para cima). */
|
|
252
|
+
readonly suggestedQuantity: string | null;
|
|
253
|
+
readonly unitPrice: string | null;
|
|
254
|
+
readonly estimatedTotal: string | null;
|
|
255
|
+
};
|
|
256
|
+
type SuggestionGroup = {
|
|
257
|
+
readonly supplierId: string | null;
|
|
258
|
+
readonly supplierName: string | null;
|
|
259
|
+
readonly lines: readonly SuggestionLine[];
|
|
260
|
+
readonly estimatedTotal: string;
|
|
261
|
+
/** Total abaixo do pedido mínimo do fornecedor. */
|
|
262
|
+
readonly belowMinimumOrder: boolean;
|
|
263
|
+
};
|
|
264
|
+
type PurchaseSuggestion = {
|
|
265
|
+
readonly groups: readonly SuggestionGroup[];
|
|
266
|
+
/** `false` sem porta de demanda: a sugestão sai vazia. */
|
|
267
|
+
readonly hasDemandSource: boolean;
|
|
268
|
+
};
|
|
269
|
+
type Installment = {
|
|
270
|
+
readonly number: number;
|
|
271
|
+
/** `aaaa-mm-dd`. */
|
|
272
|
+
readonly dueDate: string;
|
|
273
|
+
/** 2 casas. A soma das parcelas é exatamente o total. */
|
|
274
|
+
readonly amount: string;
|
|
275
|
+
};
|
|
276
|
+
/** Item da nota já casado com o cadastro, pronto para virar linha de recebimento (a pessoa confere antes). */
|
|
277
|
+
type NfePreviewLine = {
|
|
278
|
+
readonly itemNumber: number;
|
|
279
|
+
readonly supplierSku: string;
|
|
280
|
+
readonly description: string;
|
|
281
|
+
readonly unit: string;
|
|
282
|
+
readonly quantity: string;
|
|
283
|
+
readonly unitPrice: string;
|
|
284
|
+
readonly total: string;
|
|
285
|
+
readonly batchCode: string | null;
|
|
286
|
+
readonly expiresAt: string | null;
|
|
287
|
+
/** Item do fornecedor com o mesmo código (`cProd`); `null` = item novo, precisa ligar. */
|
|
288
|
+
readonly supplierItemId: string | null;
|
|
289
|
+
readonly itemRef: string | null;
|
|
290
|
+
readonly itemName: string | null;
|
|
291
|
+
readonly unitsPerPurchase: string | null;
|
|
292
|
+
readonly stockUnit: RecipeUnit | null;
|
|
293
|
+
/** Linha pendente do pedido para o mesmo item. */
|
|
294
|
+
readonly orderLineId: string | null;
|
|
295
|
+
};
|
|
296
|
+
type NfePreview = {
|
|
297
|
+
readonly accessKey: string;
|
|
298
|
+
readonly number: string;
|
|
299
|
+
readonly series: string | null;
|
|
300
|
+
readonly issuedAt: string | null;
|
|
301
|
+
readonly issuer: {
|
|
302
|
+
readonly document: string | null;
|
|
303
|
+
readonly name: string;
|
|
304
|
+
};
|
|
305
|
+
/** Fornecedor com o mesmo CNPJ/CPF do emitente; `null` = cadastrar antes de receber. */
|
|
306
|
+
readonly supplierId: string | null;
|
|
307
|
+
/** Recebimento que já usou esta chave (nota repetida). */
|
|
308
|
+
readonly alreadyReceivedReceiptId: string | null;
|
|
309
|
+
readonly freight: string;
|
|
310
|
+
readonly discount: string;
|
|
311
|
+
readonly total: string;
|
|
312
|
+
readonly installments: readonly Installment[];
|
|
313
|
+
readonly lines: readonly NfePreviewLine[];
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
318
|
+
*/
|
|
319
|
+
|
|
320
|
+
declare const PURCHASE_LIMITS: {
|
|
321
|
+
readonly NAME: 160;
|
|
322
|
+
readonly DOCUMENT: 20;
|
|
323
|
+
readonly CONTACT: 120;
|
|
324
|
+
readonly EMAIL: 254;
|
|
325
|
+
readonly PHONE: 30;
|
|
326
|
+
readonly SKU: 100;
|
|
327
|
+
readonly UNIT: 12;
|
|
328
|
+
readonly ITEM_REF: 128;
|
|
329
|
+
readonly NOTE: 2000;
|
|
330
|
+
readonly REASON: 500;
|
|
331
|
+
readonly BATCH_CODE: 100;
|
|
332
|
+
readonly INVOICE_NUMBER: 30;
|
|
333
|
+
readonly SEARCH: 100;
|
|
334
|
+
readonly PAGE_SIZE: 100;
|
|
335
|
+
readonly ORDER_LINES: 300;
|
|
336
|
+
readonly TERMS: 24;
|
|
337
|
+
readonly TERM_DAYS: 365;
|
|
338
|
+
readonly LEAD_DAYS: 365;
|
|
339
|
+
readonly PRIORITY: 1000;
|
|
340
|
+
readonly LOOKUP: 500;
|
|
341
|
+
readonly IDEMPOTENCY_KEY: 128;
|
|
342
|
+
readonly XML_BYTES: 5000000;
|
|
343
|
+
readonly REPORT_DAYS: 400;
|
|
344
|
+
};
|
|
345
|
+
/** Dinheiro: até 2 casas. */
|
|
346
|
+
declare const moneySchema: z.ZodString;
|
|
347
|
+
/** `id` opcional: o host que já tem fornecedores (no estoque, por exemplo) importa mantendo o mesmo id. */
|
|
348
|
+
declare const createSupplierSchema: z.ZodObject<{
|
|
349
|
+
name: z.ZodString;
|
|
350
|
+
document: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>>, string | null, string | null | undefined>;
|
|
351
|
+
contactName: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | null, string | null | undefined>;
|
|
352
|
+
email: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"">, z.ZodString]>>>, string | null, string | null | undefined>;
|
|
353
|
+
phone: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>, string | null, string | null | undefined>;
|
|
354
|
+
whatsapp: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>, string | null, string | null | undefined>;
|
|
355
|
+
paymentTermDays: z.ZodDefault<z.ZodEffects<z.ZodArray<z.ZodNumber, "many">, number[], number[]>>;
|
|
356
|
+
leadTimeDays: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
357
|
+
minimumOrderAmount: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
358
|
+
deliveryWeekdays: z.ZodDefault<z.ZodEffects<z.ZodArray<z.ZodNumber, "many">, number[], number[]>>;
|
|
359
|
+
notes: z.ZodDefault<z.ZodString>;
|
|
360
|
+
isActive: z.ZodDefault<z.ZodBoolean>;
|
|
361
|
+
id: z.ZodOptional<z.ZodString>;
|
|
362
|
+
}, "strip", z.ZodTypeAny, {
|
|
363
|
+
whatsapp: string | null;
|
|
364
|
+
email: string | null;
|
|
365
|
+
paymentTermDays: number[];
|
|
366
|
+
notes: string;
|
|
367
|
+
name: string;
|
|
368
|
+
document: string | null;
|
|
369
|
+
contactName: string | null;
|
|
370
|
+
phone: string | null;
|
|
371
|
+
leadTimeDays: number | null;
|
|
372
|
+
minimumOrderAmount: string | null;
|
|
373
|
+
deliveryWeekdays: number[];
|
|
374
|
+
isActive: boolean;
|
|
375
|
+
id?: string | undefined;
|
|
376
|
+
}, {
|
|
377
|
+
name: string;
|
|
378
|
+
whatsapp?: string | null | undefined;
|
|
379
|
+
email?: string | null | undefined;
|
|
380
|
+
id?: string | undefined;
|
|
381
|
+
paymentTermDays?: number[] | undefined;
|
|
382
|
+
notes?: string | undefined;
|
|
383
|
+
document?: string | null | undefined;
|
|
384
|
+
contactName?: string | null | undefined;
|
|
385
|
+
phone?: string | null | undefined;
|
|
386
|
+
leadTimeDays?: number | null | undefined;
|
|
387
|
+
minimumOrderAmount?: string | null | undefined;
|
|
388
|
+
deliveryWeekdays?: number[] | undefined;
|
|
389
|
+
isActive?: boolean | undefined;
|
|
390
|
+
}>;
|
|
391
|
+
type CreateSupplierInput = z.input<typeof createSupplierSchema>;
|
|
392
|
+
type CreateSupplierData = z.output<typeof createSupplierSchema>;
|
|
393
|
+
declare const updateSupplierSchema: z.ZodEffects<z.ZodObject<{
|
|
394
|
+
name: z.ZodOptional<z.ZodString>;
|
|
395
|
+
document: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>>, string | null | undefined, string | null | undefined>;
|
|
396
|
+
contactName: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | null | undefined, string | null | undefined>;
|
|
397
|
+
email: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"">, z.ZodString]>>>, string | null | undefined, string | null | undefined>;
|
|
398
|
+
phone: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>, string | null | undefined, string | null | undefined>;
|
|
399
|
+
whatsapp: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>, string | null | undefined, string | null | undefined>;
|
|
400
|
+
paymentTermDays: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodNumber, "many">, number[], number[]>>;
|
|
401
|
+
leadTimeDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
402
|
+
minimumOrderAmount: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
403
|
+
deliveryWeekdays: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodNumber, "many">, number[], number[]>>;
|
|
404
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
405
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
406
|
+
}, "strip", z.ZodTypeAny, {
|
|
407
|
+
whatsapp?: string | null | undefined;
|
|
408
|
+
email?: string | null | undefined;
|
|
409
|
+
paymentTermDays?: number[] | undefined;
|
|
410
|
+
notes?: string | undefined;
|
|
411
|
+
name?: string | undefined;
|
|
412
|
+
document?: string | null | undefined;
|
|
413
|
+
contactName?: string | null | undefined;
|
|
414
|
+
phone?: string | null | undefined;
|
|
415
|
+
leadTimeDays?: number | null | undefined;
|
|
416
|
+
minimumOrderAmount?: string | null | undefined;
|
|
417
|
+
deliveryWeekdays?: number[] | undefined;
|
|
418
|
+
isActive?: boolean | undefined;
|
|
419
|
+
}, {
|
|
420
|
+
whatsapp?: string | null | undefined;
|
|
421
|
+
email?: string | null | undefined;
|
|
422
|
+
paymentTermDays?: number[] | undefined;
|
|
423
|
+
notes?: string | undefined;
|
|
424
|
+
name?: string | undefined;
|
|
425
|
+
document?: string | null | undefined;
|
|
426
|
+
contactName?: string | null | undefined;
|
|
427
|
+
phone?: string | null | undefined;
|
|
428
|
+
leadTimeDays?: number | null | undefined;
|
|
429
|
+
minimumOrderAmount?: string | null | undefined;
|
|
430
|
+
deliveryWeekdays?: number[] | undefined;
|
|
431
|
+
isActive?: boolean | undefined;
|
|
432
|
+
}>, {
|
|
433
|
+
whatsapp?: string | null | undefined;
|
|
434
|
+
email?: string | null | undefined;
|
|
435
|
+
paymentTermDays?: number[] | undefined;
|
|
436
|
+
notes?: string | undefined;
|
|
437
|
+
name?: string | undefined;
|
|
438
|
+
document?: string | null | undefined;
|
|
439
|
+
contactName?: string | null | undefined;
|
|
440
|
+
phone?: string | null | undefined;
|
|
441
|
+
leadTimeDays?: number | null | undefined;
|
|
442
|
+
minimumOrderAmount?: string | null | undefined;
|
|
443
|
+
deliveryWeekdays?: number[] | undefined;
|
|
444
|
+
isActive?: boolean | undefined;
|
|
445
|
+
}, {
|
|
446
|
+
whatsapp?: string | null | undefined;
|
|
447
|
+
email?: string | null | undefined;
|
|
448
|
+
paymentTermDays?: number[] | undefined;
|
|
449
|
+
notes?: string | undefined;
|
|
450
|
+
name?: string | undefined;
|
|
451
|
+
document?: string | null | undefined;
|
|
452
|
+
contactName?: string | null | undefined;
|
|
453
|
+
phone?: string | null | undefined;
|
|
454
|
+
leadTimeDays?: number | null | undefined;
|
|
455
|
+
minimumOrderAmount?: string | null | undefined;
|
|
456
|
+
deliveryWeekdays?: number[] | undefined;
|
|
457
|
+
isActive?: boolean | undefined;
|
|
458
|
+
}>;
|
|
459
|
+
type UpdateSupplierInput = z.input<typeof updateSupplierSchema>;
|
|
460
|
+
type UpdateSupplierData = z.output<typeof updateSupplierSchema>;
|
|
461
|
+
declare const SUPPLIER_SORTS: readonly ["name", "createdAt", "updatedAt"];
|
|
462
|
+
type SupplierSort = (typeof SUPPLIER_SORTS)[number];
|
|
463
|
+
declare const listSuppliersQuerySchema: z.ZodObject<{
|
|
464
|
+
search: z.ZodOptional<z.ZodString>;
|
|
465
|
+
isActive: z.ZodOptional<z.ZodEffects<z.ZodEnum<["true", "false"]>, boolean, "true" | "false">>;
|
|
466
|
+
sort: z.ZodDefault<z.ZodEnum<["name", "createdAt", "updatedAt"]>>;
|
|
467
|
+
order: z.ZodDefault<z.ZodEnum<["asc", "desc"]>>;
|
|
468
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
469
|
+
pageSize: z.ZodDefault<z.ZodNumber>;
|
|
470
|
+
}, "strip", z.ZodTypeAny, {
|
|
471
|
+
sort: "createdAt" | "updatedAt" | "name";
|
|
472
|
+
order: "asc" | "desc";
|
|
473
|
+
page: number;
|
|
474
|
+
pageSize: number;
|
|
475
|
+
isActive?: boolean | undefined;
|
|
476
|
+
search?: string | undefined;
|
|
477
|
+
}, {
|
|
478
|
+
sort?: "createdAt" | "updatedAt" | "name" | undefined;
|
|
479
|
+
isActive?: "true" | "false" | undefined;
|
|
480
|
+
search?: string | undefined;
|
|
481
|
+
order?: "asc" | "desc" | undefined;
|
|
482
|
+
page?: number | undefined;
|
|
483
|
+
pageSize?: number | undefined;
|
|
484
|
+
}>;
|
|
485
|
+
type ListSuppliersQuery = z.output<typeof listSuppliersQuerySchema>;
|
|
486
|
+
declare const supplierLookupSchema: z.ZodObject<{
|
|
487
|
+
ids: z.ZodArray<z.ZodString, "many">;
|
|
488
|
+
}, "strip", z.ZodTypeAny, {
|
|
489
|
+
ids: string[];
|
|
490
|
+
}, {
|
|
491
|
+
ids: string[];
|
|
492
|
+
}>;
|
|
493
|
+
type SupplierLookupData = z.output<typeof supplierLookupSchema>;
|
|
494
|
+
declare const createSupplierItemSchema: z.ZodObject<{
|
|
495
|
+
itemRef: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
496
|
+
itemName: z.ZodString;
|
|
497
|
+
supplierSku: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | null, string | null | undefined>;
|
|
498
|
+
purchaseUnit: z.ZodString;
|
|
499
|
+
unitsPerPurchase: z.ZodDefault<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>, string, string | number>>;
|
|
500
|
+
stockUnit: z.ZodDefault<z.ZodNullable<z.ZodEnum<[RecipeUnit, ...RecipeUnit[]]>>>;
|
|
501
|
+
lastPrice: z.ZodDefault<z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>>>;
|
|
502
|
+
priority: z.ZodDefault<z.ZodNumber>;
|
|
503
|
+
isActive: z.ZodDefault<z.ZodBoolean>;
|
|
504
|
+
}, "strip", z.ZodTypeAny, {
|
|
505
|
+
isActive: boolean;
|
|
506
|
+
itemRef: string | null;
|
|
507
|
+
itemName: string;
|
|
508
|
+
supplierSku: string | null;
|
|
509
|
+
purchaseUnit: string;
|
|
510
|
+
unitsPerPurchase: string;
|
|
511
|
+
stockUnit: RecipeUnit | null;
|
|
512
|
+
lastPrice: string | null;
|
|
513
|
+
priority: number;
|
|
514
|
+
}, {
|
|
515
|
+
itemName: string;
|
|
516
|
+
purchaseUnit: string;
|
|
517
|
+
isActive?: boolean | undefined;
|
|
518
|
+
itemRef?: string | null | undefined;
|
|
519
|
+
supplierSku?: string | null | undefined;
|
|
520
|
+
unitsPerPurchase?: string | number | undefined;
|
|
521
|
+
stockUnit?: RecipeUnit | null | undefined;
|
|
522
|
+
lastPrice?: string | number | null | undefined;
|
|
523
|
+
priority?: number | undefined;
|
|
524
|
+
}>;
|
|
525
|
+
type CreateSupplierItemInput = z.input<typeof createSupplierItemSchema>;
|
|
526
|
+
type CreateSupplierItemData = z.output<typeof createSupplierItemSchema>;
|
|
527
|
+
declare const updateSupplierItemSchema: z.ZodEffects<z.ZodObject<{
|
|
528
|
+
itemRef: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodString>>>;
|
|
529
|
+
itemName: z.ZodOptional<z.ZodString>;
|
|
530
|
+
supplierSku: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | null | undefined, string | null | undefined>;
|
|
531
|
+
purchaseUnit: z.ZodOptional<z.ZodString>;
|
|
532
|
+
unitsPerPurchase: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>, string, string | number>>;
|
|
533
|
+
stockUnit: z.ZodOptional<z.ZodNullable<z.ZodEnum<[RecipeUnit, ...RecipeUnit[]]>>>;
|
|
534
|
+
lastPrice: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>>>;
|
|
535
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
536
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
537
|
+
}, "strip", z.ZodTypeAny, {
|
|
538
|
+
isActive?: boolean | undefined;
|
|
539
|
+
itemRef?: string | null | undefined;
|
|
540
|
+
itemName?: string | undefined;
|
|
541
|
+
supplierSku?: string | null | undefined;
|
|
542
|
+
purchaseUnit?: string | undefined;
|
|
543
|
+
unitsPerPurchase?: string | undefined;
|
|
544
|
+
stockUnit?: RecipeUnit | null | undefined;
|
|
545
|
+
lastPrice?: string | null | undefined;
|
|
546
|
+
priority?: number | undefined;
|
|
547
|
+
}, {
|
|
548
|
+
isActive?: boolean | undefined;
|
|
549
|
+
itemRef?: string | null | undefined;
|
|
550
|
+
itemName?: string | undefined;
|
|
551
|
+
supplierSku?: string | null | undefined;
|
|
552
|
+
purchaseUnit?: string | undefined;
|
|
553
|
+
unitsPerPurchase?: string | number | undefined;
|
|
554
|
+
stockUnit?: RecipeUnit | null | undefined;
|
|
555
|
+
lastPrice?: string | number | null | undefined;
|
|
556
|
+
priority?: number | undefined;
|
|
557
|
+
}>, {
|
|
558
|
+
isActive?: boolean | undefined;
|
|
559
|
+
itemRef?: string | null | undefined;
|
|
560
|
+
itemName?: string | undefined;
|
|
561
|
+
supplierSku?: string | null | undefined;
|
|
562
|
+
purchaseUnit?: string | undefined;
|
|
563
|
+
unitsPerPurchase?: string | undefined;
|
|
564
|
+
stockUnit?: RecipeUnit | null | undefined;
|
|
565
|
+
lastPrice?: string | null | undefined;
|
|
566
|
+
priority?: number | undefined;
|
|
567
|
+
}, {
|
|
568
|
+
isActive?: boolean | undefined;
|
|
569
|
+
itemRef?: string | null | undefined;
|
|
570
|
+
itemName?: string | undefined;
|
|
571
|
+
supplierSku?: string | null | undefined;
|
|
572
|
+
purchaseUnit?: string | undefined;
|
|
573
|
+
unitsPerPurchase?: string | number | undefined;
|
|
574
|
+
stockUnit?: RecipeUnit | null | undefined;
|
|
575
|
+
lastPrice?: string | number | null | undefined;
|
|
576
|
+
priority?: number | undefined;
|
|
577
|
+
}>;
|
|
578
|
+
type UpdateSupplierItemData = z.output<typeof updateSupplierItemSchema>;
|
|
579
|
+
declare const listSupplierItemsQuerySchema: z.ZodObject<{
|
|
580
|
+
supplierId: z.ZodOptional<z.ZodString>;
|
|
581
|
+
itemRef: z.ZodOptional<z.ZodString>;
|
|
582
|
+
search: z.ZodOptional<z.ZodString>;
|
|
583
|
+
isActive: z.ZodOptional<z.ZodEffects<z.ZodEnum<["true", "false"]>, boolean, "true" | "false">>;
|
|
584
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
585
|
+
pageSize: z.ZodDefault<z.ZodNumber>;
|
|
586
|
+
}, "strip", z.ZodTypeAny, {
|
|
587
|
+
page: number;
|
|
588
|
+
pageSize: number;
|
|
589
|
+
supplierId?: string | undefined;
|
|
590
|
+
isActive?: boolean | undefined;
|
|
591
|
+
search?: string | undefined;
|
|
592
|
+
itemRef?: string | undefined;
|
|
593
|
+
}, {
|
|
594
|
+
supplierId?: string | undefined;
|
|
595
|
+
isActive?: "true" | "false" | undefined;
|
|
596
|
+
search?: string | undefined;
|
|
597
|
+
page?: number | undefined;
|
|
598
|
+
pageSize?: number | undefined;
|
|
599
|
+
itemRef?: string | undefined;
|
|
600
|
+
}>;
|
|
601
|
+
type ListSupplierItemsQuery = z.output<typeof listSupplierItemsQuerySchema>;
|
|
602
|
+
/**
|
|
603
|
+
* Linha de pedido. Com `supplierItemId`, item, código, unidade e conversão vêm do cadastro (e o preço, do último
|
|
604
|
+
* preço se não vier). Sem ele, a linha é livre: `itemName` e `purchaseUnit` são obrigatórios.
|
|
605
|
+
*/
|
|
606
|
+
declare const orderLineInputSchema: z.ZodEffects<z.ZodObject<{
|
|
607
|
+
supplierItemId: z.ZodOptional<z.ZodString>;
|
|
608
|
+
itemRef: z.ZodOptional<z.ZodString>;
|
|
609
|
+
itemName: z.ZodOptional<z.ZodString>;
|
|
610
|
+
supplierSku: z.ZodOptional<z.ZodString>;
|
|
611
|
+
purchaseUnit: z.ZodOptional<z.ZodString>;
|
|
612
|
+
unitsPerPurchase: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>, string, string | number>>;
|
|
613
|
+
stockUnit: z.ZodOptional<z.ZodEnum<[RecipeUnit, ...RecipeUnit[]]>>;
|
|
614
|
+
quantity: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>, string, string | number>;
|
|
615
|
+
unitPrice: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>>;
|
|
616
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
617
|
+
}, "strip", z.ZodTypeAny, {
|
|
618
|
+
quantity: string;
|
|
619
|
+
notes?: string | undefined;
|
|
620
|
+
itemRef?: string | undefined;
|
|
621
|
+
itemName?: string | undefined;
|
|
622
|
+
supplierSku?: string | undefined;
|
|
623
|
+
purchaseUnit?: string | undefined;
|
|
624
|
+
unitsPerPurchase?: string | undefined;
|
|
625
|
+
stockUnit?: RecipeUnit | undefined;
|
|
626
|
+
supplierItemId?: string | undefined;
|
|
627
|
+
unitPrice?: string | undefined;
|
|
628
|
+
}, {
|
|
629
|
+
quantity: string | number;
|
|
630
|
+
notes?: string | undefined;
|
|
631
|
+
itemRef?: string | undefined;
|
|
632
|
+
itemName?: string | undefined;
|
|
633
|
+
supplierSku?: string | undefined;
|
|
634
|
+
purchaseUnit?: string | undefined;
|
|
635
|
+
unitsPerPurchase?: string | number | undefined;
|
|
636
|
+
stockUnit?: RecipeUnit | undefined;
|
|
637
|
+
supplierItemId?: string | undefined;
|
|
638
|
+
unitPrice?: string | number | undefined;
|
|
639
|
+
}>, {
|
|
640
|
+
quantity: string;
|
|
641
|
+
notes?: string | undefined;
|
|
642
|
+
itemRef?: string | undefined;
|
|
643
|
+
itemName?: string | undefined;
|
|
644
|
+
supplierSku?: string | undefined;
|
|
645
|
+
purchaseUnit?: string | undefined;
|
|
646
|
+
unitsPerPurchase?: string | undefined;
|
|
647
|
+
stockUnit?: RecipeUnit | undefined;
|
|
648
|
+
supplierItemId?: string | undefined;
|
|
649
|
+
unitPrice?: string | undefined;
|
|
650
|
+
}, {
|
|
651
|
+
quantity: string | number;
|
|
652
|
+
notes?: string | undefined;
|
|
653
|
+
itemRef?: string | undefined;
|
|
654
|
+
itemName?: string | undefined;
|
|
655
|
+
supplierSku?: string | undefined;
|
|
656
|
+
purchaseUnit?: string | undefined;
|
|
657
|
+
unitsPerPurchase?: string | number | undefined;
|
|
658
|
+
stockUnit?: RecipeUnit | undefined;
|
|
659
|
+
supplierItemId?: string | undefined;
|
|
660
|
+
unitPrice?: string | number | undefined;
|
|
661
|
+
}>;
|
|
662
|
+
type OrderLineInput = z.input<typeof orderLineInputSchema>;
|
|
663
|
+
type OrderLineData = z.output<typeof orderLineInputSchema>;
|
|
664
|
+
declare const createOrderSchema: z.ZodObject<{
|
|
665
|
+
supplierId: z.ZodString;
|
|
666
|
+
expectedAt: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
|
|
667
|
+
notes: z.ZodDefault<z.ZodString>;
|
|
668
|
+
freight: z.ZodDefault<z.ZodString>;
|
|
669
|
+
discount: z.ZodDefault<z.ZodString>;
|
|
670
|
+
/** Ausente: a condição do fornecedor. */
|
|
671
|
+
paymentTermDays: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodNumber, "many">, number[], number[]>>;
|
|
672
|
+
lines: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
673
|
+
supplierItemId: z.ZodOptional<z.ZodString>;
|
|
674
|
+
itemRef: z.ZodOptional<z.ZodString>;
|
|
675
|
+
itemName: z.ZodOptional<z.ZodString>;
|
|
676
|
+
supplierSku: z.ZodOptional<z.ZodString>;
|
|
677
|
+
purchaseUnit: z.ZodOptional<z.ZodString>;
|
|
678
|
+
unitsPerPurchase: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>, string, string | number>>;
|
|
679
|
+
stockUnit: z.ZodOptional<z.ZodEnum<[RecipeUnit, ...RecipeUnit[]]>>;
|
|
680
|
+
quantity: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>, string, string | number>;
|
|
681
|
+
unitPrice: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>>;
|
|
682
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
683
|
+
}, "strip", z.ZodTypeAny, {
|
|
684
|
+
quantity: string;
|
|
685
|
+
notes?: string | undefined;
|
|
686
|
+
itemRef?: string | undefined;
|
|
687
|
+
itemName?: string | undefined;
|
|
688
|
+
supplierSku?: string | undefined;
|
|
689
|
+
purchaseUnit?: string | undefined;
|
|
690
|
+
unitsPerPurchase?: string | undefined;
|
|
691
|
+
stockUnit?: RecipeUnit | undefined;
|
|
692
|
+
supplierItemId?: string | undefined;
|
|
693
|
+
unitPrice?: string | undefined;
|
|
694
|
+
}, {
|
|
695
|
+
quantity: string | number;
|
|
696
|
+
notes?: string | undefined;
|
|
697
|
+
itemRef?: string | undefined;
|
|
698
|
+
itemName?: string | undefined;
|
|
699
|
+
supplierSku?: string | undefined;
|
|
700
|
+
purchaseUnit?: string | undefined;
|
|
701
|
+
unitsPerPurchase?: string | number | undefined;
|
|
702
|
+
stockUnit?: RecipeUnit | undefined;
|
|
703
|
+
supplierItemId?: string | undefined;
|
|
704
|
+
unitPrice?: string | number | undefined;
|
|
705
|
+
}>, {
|
|
706
|
+
quantity: string;
|
|
707
|
+
notes?: string | undefined;
|
|
708
|
+
itemRef?: string | undefined;
|
|
709
|
+
itemName?: string | undefined;
|
|
710
|
+
supplierSku?: string | undefined;
|
|
711
|
+
purchaseUnit?: string | undefined;
|
|
712
|
+
unitsPerPurchase?: string | undefined;
|
|
713
|
+
stockUnit?: RecipeUnit | undefined;
|
|
714
|
+
supplierItemId?: string | undefined;
|
|
715
|
+
unitPrice?: string | undefined;
|
|
716
|
+
}, {
|
|
717
|
+
quantity: string | number;
|
|
718
|
+
notes?: string | undefined;
|
|
719
|
+
itemRef?: string | undefined;
|
|
720
|
+
itemName?: string | undefined;
|
|
721
|
+
supplierSku?: string | undefined;
|
|
722
|
+
purchaseUnit?: string | undefined;
|
|
723
|
+
unitsPerPurchase?: string | number | undefined;
|
|
724
|
+
stockUnit?: RecipeUnit | undefined;
|
|
725
|
+
supplierItemId?: string | undefined;
|
|
726
|
+
unitPrice?: string | number | undefined;
|
|
727
|
+
}>, "many">;
|
|
728
|
+
}, "strip", z.ZodTypeAny, {
|
|
729
|
+
lines: {
|
|
730
|
+
quantity: string;
|
|
731
|
+
notes?: string | undefined;
|
|
732
|
+
itemRef?: string | undefined;
|
|
733
|
+
itemName?: string | undefined;
|
|
734
|
+
supplierSku?: string | undefined;
|
|
735
|
+
purchaseUnit?: string | undefined;
|
|
736
|
+
unitsPerPurchase?: string | undefined;
|
|
737
|
+
stockUnit?: RecipeUnit | undefined;
|
|
738
|
+
supplierItemId?: string | undefined;
|
|
739
|
+
unitPrice?: string | undefined;
|
|
740
|
+
}[];
|
|
741
|
+
supplierId: string;
|
|
742
|
+
freight: string;
|
|
743
|
+
discount: string;
|
|
744
|
+
notes: string;
|
|
745
|
+
expectedAt?: string | null | undefined;
|
|
746
|
+
paymentTermDays?: number[] | undefined;
|
|
747
|
+
}, {
|
|
748
|
+
lines: {
|
|
749
|
+
quantity: string | number;
|
|
750
|
+
notes?: string | undefined;
|
|
751
|
+
itemRef?: string | undefined;
|
|
752
|
+
itemName?: string | undefined;
|
|
753
|
+
supplierSku?: string | undefined;
|
|
754
|
+
purchaseUnit?: string | undefined;
|
|
755
|
+
unitsPerPurchase?: string | number | undefined;
|
|
756
|
+
stockUnit?: RecipeUnit | undefined;
|
|
757
|
+
supplierItemId?: string | undefined;
|
|
758
|
+
unitPrice?: string | number | undefined;
|
|
759
|
+
}[];
|
|
760
|
+
supplierId: string;
|
|
761
|
+
expectedAt?: string | null | undefined;
|
|
762
|
+
freight?: string | undefined;
|
|
763
|
+
discount?: string | undefined;
|
|
764
|
+
paymentTermDays?: number[] | undefined;
|
|
765
|
+
notes?: string | undefined;
|
|
766
|
+
}>;
|
|
767
|
+
type CreateOrderInput = z.input<typeof createOrderSchema>;
|
|
768
|
+
type CreateOrderData = z.output<typeof createOrderSchema>;
|
|
769
|
+
/** Só no rascunho. `lines` presente substitui todas as linhas. */
|
|
770
|
+
declare const updateOrderSchema: z.ZodEffects<z.ZodObject<{
|
|
771
|
+
expectedAt: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
|
|
772
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
773
|
+
freight: z.ZodOptional<z.ZodString>;
|
|
774
|
+
discount: z.ZodOptional<z.ZodString>;
|
|
775
|
+
paymentTermDays: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodNumber, "many">, number[], number[]>>;
|
|
776
|
+
lines: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
777
|
+
supplierItemId: z.ZodOptional<z.ZodString>;
|
|
778
|
+
itemRef: z.ZodOptional<z.ZodString>;
|
|
779
|
+
itemName: z.ZodOptional<z.ZodString>;
|
|
780
|
+
supplierSku: z.ZodOptional<z.ZodString>;
|
|
781
|
+
purchaseUnit: z.ZodOptional<z.ZodString>;
|
|
782
|
+
unitsPerPurchase: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>, string, string | number>>;
|
|
783
|
+
stockUnit: z.ZodOptional<z.ZodEnum<[RecipeUnit, ...RecipeUnit[]]>>;
|
|
784
|
+
quantity: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>, string, string | number>;
|
|
785
|
+
unitPrice: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>>;
|
|
786
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
787
|
+
}, "strip", z.ZodTypeAny, {
|
|
788
|
+
quantity: string;
|
|
789
|
+
notes?: string | undefined;
|
|
790
|
+
itemRef?: string | undefined;
|
|
791
|
+
itemName?: string | undefined;
|
|
792
|
+
supplierSku?: string | undefined;
|
|
793
|
+
purchaseUnit?: string | undefined;
|
|
794
|
+
unitsPerPurchase?: string | undefined;
|
|
795
|
+
stockUnit?: RecipeUnit | undefined;
|
|
796
|
+
supplierItemId?: string | undefined;
|
|
797
|
+
unitPrice?: string | undefined;
|
|
798
|
+
}, {
|
|
799
|
+
quantity: string | number;
|
|
800
|
+
notes?: string | undefined;
|
|
801
|
+
itemRef?: string | undefined;
|
|
802
|
+
itemName?: string | undefined;
|
|
803
|
+
supplierSku?: string | undefined;
|
|
804
|
+
purchaseUnit?: string | undefined;
|
|
805
|
+
unitsPerPurchase?: string | number | undefined;
|
|
806
|
+
stockUnit?: RecipeUnit | undefined;
|
|
807
|
+
supplierItemId?: string | undefined;
|
|
808
|
+
unitPrice?: string | number | undefined;
|
|
809
|
+
}>, {
|
|
810
|
+
quantity: string;
|
|
811
|
+
notes?: string | undefined;
|
|
812
|
+
itemRef?: string | undefined;
|
|
813
|
+
itemName?: string | undefined;
|
|
814
|
+
supplierSku?: string | undefined;
|
|
815
|
+
purchaseUnit?: string | undefined;
|
|
816
|
+
unitsPerPurchase?: string | undefined;
|
|
817
|
+
stockUnit?: RecipeUnit | undefined;
|
|
818
|
+
supplierItemId?: string | undefined;
|
|
819
|
+
unitPrice?: string | undefined;
|
|
820
|
+
}, {
|
|
821
|
+
quantity: string | number;
|
|
822
|
+
notes?: string | undefined;
|
|
823
|
+
itemRef?: string | undefined;
|
|
824
|
+
itemName?: string | undefined;
|
|
825
|
+
supplierSku?: string | undefined;
|
|
826
|
+
purchaseUnit?: string | undefined;
|
|
827
|
+
unitsPerPurchase?: string | number | undefined;
|
|
828
|
+
stockUnit?: RecipeUnit | undefined;
|
|
829
|
+
supplierItemId?: string | undefined;
|
|
830
|
+
unitPrice?: string | number | undefined;
|
|
831
|
+
}>, "many">>;
|
|
832
|
+
}, "strip", z.ZodTypeAny, {
|
|
833
|
+
lines?: {
|
|
834
|
+
quantity: string;
|
|
835
|
+
notes?: string | undefined;
|
|
836
|
+
itemRef?: string | undefined;
|
|
837
|
+
itemName?: string | undefined;
|
|
838
|
+
supplierSku?: string | undefined;
|
|
839
|
+
purchaseUnit?: string | undefined;
|
|
840
|
+
unitsPerPurchase?: string | undefined;
|
|
841
|
+
stockUnit?: RecipeUnit | undefined;
|
|
842
|
+
supplierItemId?: string | undefined;
|
|
843
|
+
unitPrice?: string | undefined;
|
|
844
|
+
}[] | undefined;
|
|
845
|
+
expectedAt?: string | null | undefined;
|
|
846
|
+
freight?: string | undefined;
|
|
847
|
+
discount?: string | undefined;
|
|
848
|
+
paymentTermDays?: number[] | undefined;
|
|
849
|
+
notes?: string | undefined;
|
|
850
|
+
}, {
|
|
851
|
+
lines?: {
|
|
852
|
+
quantity: string | number;
|
|
853
|
+
notes?: string | undefined;
|
|
854
|
+
itemRef?: string | undefined;
|
|
855
|
+
itemName?: string | undefined;
|
|
856
|
+
supplierSku?: string | undefined;
|
|
857
|
+
purchaseUnit?: string | undefined;
|
|
858
|
+
unitsPerPurchase?: string | number | undefined;
|
|
859
|
+
stockUnit?: RecipeUnit | undefined;
|
|
860
|
+
supplierItemId?: string | undefined;
|
|
861
|
+
unitPrice?: string | number | undefined;
|
|
862
|
+
}[] | undefined;
|
|
863
|
+
expectedAt?: string | null | undefined;
|
|
864
|
+
freight?: string | undefined;
|
|
865
|
+
discount?: string | undefined;
|
|
866
|
+
paymentTermDays?: number[] | undefined;
|
|
867
|
+
notes?: string | undefined;
|
|
868
|
+
}>, {
|
|
869
|
+
lines?: {
|
|
870
|
+
quantity: string;
|
|
871
|
+
notes?: string | undefined;
|
|
872
|
+
itemRef?: string | undefined;
|
|
873
|
+
itemName?: string | undefined;
|
|
874
|
+
supplierSku?: string | undefined;
|
|
875
|
+
purchaseUnit?: string | undefined;
|
|
876
|
+
unitsPerPurchase?: string | undefined;
|
|
877
|
+
stockUnit?: RecipeUnit | undefined;
|
|
878
|
+
supplierItemId?: string | undefined;
|
|
879
|
+
unitPrice?: string | undefined;
|
|
880
|
+
}[] | undefined;
|
|
881
|
+
expectedAt?: string | null | undefined;
|
|
882
|
+
freight?: string | undefined;
|
|
883
|
+
discount?: string | undefined;
|
|
884
|
+
paymentTermDays?: number[] | undefined;
|
|
885
|
+
notes?: string | undefined;
|
|
886
|
+
}, {
|
|
887
|
+
lines?: {
|
|
888
|
+
quantity: string | number;
|
|
889
|
+
notes?: string | undefined;
|
|
890
|
+
itemRef?: string | undefined;
|
|
891
|
+
itemName?: string | undefined;
|
|
892
|
+
supplierSku?: string | undefined;
|
|
893
|
+
purchaseUnit?: string | undefined;
|
|
894
|
+
unitsPerPurchase?: string | number | undefined;
|
|
895
|
+
stockUnit?: RecipeUnit | undefined;
|
|
896
|
+
supplierItemId?: string | undefined;
|
|
897
|
+
unitPrice?: string | number | undefined;
|
|
898
|
+
}[] | undefined;
|
|
899
|
+
expectedAt?: string | null | undefined;
|
|
900
|
+
freight?: string | undefined;
|
|
901
|
+
discount?: string | undefined;
|
|
902
|
+
paymentTermDays?: number[] | undefined;
|
|
903
|
+
notes?: string | undefined;
|
|
904
|
+
}>;
|
|
905
|
+
type UpdateOrderData = z.output<typeof updateOrderSchema>;
|
|
906
|
+
declare const reasonSchema: z.ZodObject<{
|
|
907
|
+
reason: z.ZodString;
|
|
908
|
+
}, "strip", z.ZodTypeAny, {
|
|
909
|
+
reason: string;
|
|
910
|
+
}, {
|
|
911
|
+
reason: string;
|
|
912
|
+
}>;
|
|
913
|
+
type ReasonData = z.output<typeof reasonSchema>;
|
|
914
|
+
declare const optionalReasonSchema: z.ZodObject<{
|
|
915
|
+
reason: z.ZodDefault<z.ZodString>;
|
|
916
|
+
}, "strip", z.ZodTypeAny, {
|
|
917
|
+
reason: string;
|
|
918
|
+
}, {
|
|
919
|
+
reason?: string | undefined;
|
|
920
|
+
}>;
|
|
921
|
+
type OptionalReasonData = z.output<typeof optionalReasonSchema>;
|
|
922
|
+
declare const sendOrderSchema: z.ZodObject<{
|
|
923
|
+
channel: z.ZodDefault<z.ZodEnum<[DispatchChannel, ...DispatchChannel[]]>>;
|
|
924
|
+
/** Preço no texto do pedido (padrão: sem). */
|
|
925
|
+
withPrices: z.ZodDefault<z.ZodBoolean>;
|
|
926
|
+
}, "strip", z.ZodTypeAny, {
|
|
927
|
+
channel: DispatchChannel;
|
|
928
|
+
withPrices: boolean;
|
|
929
|
+
}, {
|
|
930
|
+
channel?: DispatchChannel | undefined;
|
|
931
|
+
withPrices?: boolean | undefined;
|
|
932
|
+
}>;
|
|
933
|
+
type SendOrderData = z.output<typeof sendOrderSchema>;
|
|
934
|
+
declare const ORDER_SORTS: readonly ["number", "createdAt", "expectedAt", "total"];
|
|
935
|
+
type OrderSort = (typeof ORDER_SORTS)[number];
|
|
936
|
+
declare const listOrdersQuerySchema: z.ZodObject<{
|
|
937
|
+
status: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string[], string>, string[], string>, OrderStatus[], string>>;
|
|
938
|
+
supplierId: z.ZodOptional<z.ZodString>;
|
|
939
|
+
/** Número do pedido ou nome do fornecedor. */
|
|
940
|
+
search: z.ZodOptional<z.ZodString>;
|
|
941
|
+
late: z.ZodOptional<z.ZodEffects<z.ZodEnum<["true", "false"]>, boolean, "true" | "false">>;
|
|
942
|
+
from: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
943
|
+
to: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
944
|
+
sort: z.ZodDefault<z.ZodEnum<["number", "createdAt", "expectedAt", "total"]>>;
|
|
945
|
+
order: z.ZodDefault<z.ZodEnum<["asc", "desc"]>>;
|
|
946
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
947
|
+
pageSize: z.ZodDefault<z.ZodNumber>;
|
|
948
|
+
}, "strip", z.ZodTypeAny, {
|
|
949
|
+
sort: "number" | "expectedAt" | "total" | "createdAt";
|
|
950
|
+
order: "asc" | "desc";
|
|
951
|
+
page: number;
|
|
952
|
+
pageSize: number;
|
|
953
|
+
supplierId?: string | undefined;
|
|
954
|
+
status?: OrderStatus[] | undefined;
|
|
955
|
+
search?: string | undefined;
|
|
956
|
+
late?: boolean | undefined;
|
|
957
|
+
from?: string | undefined;
|
|
958
|
+
to?: string | undefined;
|
|
959
|
+
}, {
|
|
960
|
+
supplierId?: string | undefined;
|
|
961
|
+
status?: string | undefined;
|
|
962
|
+
sort?: "number" | "expectedAt" | "total" | "createdAt" | undefined;
|
|
963
|
+
search?: string | undefined;
|
|
964
|
+
order?: "asc" | "desc" | undefined;
|
|
965
|
+
page?: number | undefined;
|
|
966
|
+
pageSize?: number | undefined;
|
|
967
|
+
late?: "true" | "false" | undefined;
|
|
968
|
+
from?: string | undefined;
|
|
969
|
+
to?: string | undefined;
|
|
970
|
+
}>;
|
|
971
|
+
type ListOrdersQuery = z.output<typeof listOrdersQuerySchema>;
|
|
972
|
+
declare const receiptLineInputSchema: z.ZodEffects<z.ZodObject<{
|
|
973
|
+
/** Linha do pedido que está chegando (recebimento com pedido). */
|
|
974
|
+
orderLineId: z.ZodOptional<z.ZodString>;
|
|
975
|
+
supplierItemId: z.ZodOptional<z.ZodString>;
|
|
976
|
+
itemRef: z.ZodOptional<z.ZodString>;
|
|
977
|
+
itemName: z.ZodOptional<z.ZodString>;
|
|
978
|
+
supplierSku: z.ZodOptional<z.ZodString>;
|
|
979
|
+
purchaseUnit: z.ZodOptional<z.ZodString>;
|
|
980
|
+
unitsPerPurchase: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>, string, string | number>>;
|
|
981
|
+
stockUnit: z.ZodOptional<z.ZodEnum<[RecipeUnit, ...RecipeUnit[]]>>;
|
|
982
|
+
/** Na unidade de compra. */
|
|
983
|
+
quantity: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>, string, string | number>;
|
|
984
|
+
/** Ausente: o preço do pedido (ou o último do fornecedor). */
|
|
985
|
+
unitPrice: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>>;
|
|
986
|
+
batchCode: z.ZodOptional<z.ZodString>;
|
|
987
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
|
|
988
|
+
divergenceReason: z.ZodOptional<z.ZodString>;
|
|
989
|
+
}, "strip", z.ZodTypeAny, {
|
|
990
|
+
quantity: string;
|
|
991
|
+
itemRef?: string | undefined;
|
|
992
|
+
itemName?: string | undefined;
|
|
993
|
+
supplierSku?: string | undefined;
|
|
994
|
+
purchaseUnit?: string | undefined;
|
|
995
|
+
unitsPerPurchase?: string | undefined;
|
|
996
|
+
stockUnit?: RecipeUnit | undefined;
|
|
997
|
+
supplierItemId?: string | undefined;
|
|
998
|
+
unitPrice?: string | undefined;
|
|
999
|
+
orderLineId?: string | undefined;
|
|
1000
|
+
batchCode?: string | undefined;
|
|
1001
|
+
expiresAt?: string | null | undefined;
|
|
1002
|
+
divergenceReason?: string | undefined;
|
|
1003
|
+
}, {
|
|
1004
|
+
quantity: string | number;
|
|
1005
|
+
itemRef?: string | undefined;
|
|
1006
|
+
itemName?: string | undefined;
|
|
1007
|
+
supplierSku?: string | undefined;
|
|
1008
|
+
purchaseUnit?: string | undefined;
|
|
1009
|
+
unitsPerPurchase?: string | number | undefined;
|
|
1010
|
+
stockUnit?: RecipeUnit | undefined;
|
|
1011
|
+
supplierItemId?: string | undefined;
|
|
1012
|
+
unitPrice?: string | number | undefined;
|
|
1013
|
+
orderLineId?: string | undefined;
|
|
1014
|
+
batchCode?: string | undefined;
|
|
1015
|
+
expiresAt?: string | null | undefined;
|
|
1016
|
+
divergenceReason?: string | undefined;
|
|
1017
|
+
}>, {
|
|
1018
|
+
quantity: string;
|
|
1019
|
+
itemRef?: string | undefined;
|
|
1020
|
+
itemName?: string | undefined;
|
|
1021
|
+
supplierSku?: string | undefined;
|
|
1022
|
+
purchaseUnit?: string | undefined;
|
|
1023
|
+
unitsPerPurchase?: string | undefined;
|
|
1024
|
+
stockUnit?: RecipeUnit | undefined;
|
|
1025
|
+
supplierItemId?: string | undefined;
|
|
1026
|
+
unitPrice?: string | undefined;
|
|
1027
|
+
orderLineId?: string | undefined;
|
|
1028
|
+
batchCode?: string | undefined;
|
|
1029
|
+
expiresAt?: string | null | undefined;
|
|
1030
|
+
divergenceReason?: string | undefined;
|
|
1031
|
+
}, {
|
|
1032
|
+
quantity: string | number;
|
|
1033
|
+
itemRef?: string | undefined;
|
|
1034
|
+
itemName?: string | undefined;
|
|
1035
|
+
supplierSku?: string | undefined;
|
|
1036
|
+
purchaseUnit?: string | undefined;
|
|
1037
|
+
unitsPerPurchase?: string | number | undefined;
|
|
1038
|
+
stockUnit?: RecipeUnit | undefined;
|
|
1039
|
+
supplierItemId?: string | undefined;
|
|
1040
|
+
unitPrice?: string | number | undefined;
|
|
1041
|
+
orderLineId?: string | undefined;
|
|
1042
|
+
batchCode?: string | undefined;
|
|
1043
|
+
expiresAt?: string | null | undefined;
|
|
1044
|
+
divergenceReason?: string | undefined;
|
|
1045
|
+
}>;
|
|
1046
|
+
type ReceiptLineInput = z.input<typeof receiptLineInputSchema>;
|
|
1047
|
+
type ReceiptLineData = z.output<typeof receiptLineInputSchema>;
|
|
1048
|
+
declare const receiveSchema: z.ZodObject<{
|
|
1049
|
+
/** Obrigatório no recebimento sem pedido; com pedido, vem dele. */
|
|
1050
|
+
supplierId: z.ZodOptional<z.ZodString>;
|
|
1051
|
+
/** ISO com fuso. Ausente: agora. */
|
|
1052
|
+
receivedAt: z.ZodOptional<z.ZodString>;
|
|
1053
|
+
invoiceNumber: z.ZodOptional<z.ZodString>;
|
|
1054
|
+
invoiceKey: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
1055
|
+
invoiceIssuedAt: z.ZodOptional<z.ZodString>;
|
|
1056
|
+
freight: z.ZodDefault<z.ZodString>;
|
|
1057
|
+
discount: z.ZodDefault<z.ZodString>;
|
|
1058
|
+
notes: z.ZodDefault<z.ZodString>;
|
|
1059
|
+
/** Mesmo valor reenviado devolve o recebimento já gravado (clique duplo, rede caindo). */
|
|
1060
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
1061
|
+
/** Parcelas da conta a pagar; ausente: pela condição do pedido/fornecedor, ou pelas duplicatas da nota. */
|
|
1062
|
+
installments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1063
|
+
dueDate: z.ZodEffects<z.ZodString, string, string>;
|
|
1064
|
+
amount: z.ZodString;
|
|
1065
|
+
}, "strip", z.ZodTypeAny, {
|
|
1066
|
+
dueDate: string;
|
|
1067
|
+
amount: string;
|
|
1068
|
+
}, {
|
|
1069
|
+
dueDate: string;
|
|
1070
|
+
amount: string;
|
|
1071
|
+
}>, "many">>;
|
|
1072
|
+
lines: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
1073
|
+
/** Linha do pedido que está chegando (recebimento com pedido). */
|
|
1074
|
+
orderLineId: z.ZodOptional<z.ZodString>;
|
|
1075
|
+
supplierItemId: z.ZodOptional<z.ZodString>;
|
|
1076
|
+
itemRef: z.ZodOptional<z.ZodString>;
|
|
1077
|
+
itemName: z.ZodOptional<z.ZodString>;
|
|
1078
|
+
supplierSku: z.ZodOptional<z.ZodString>;
|
|
1079
|
+
purchaseUnit: z.ZodOptional<z.ZodString>;
|
|
1080
|
+
unitsPerPurchase: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>, string, string | number>>;
|
|
1081
|
+
stockUnit: z.ZodOptional<z.ZodEnum<[RecipeUnit, ...RecipeUnit[]]>>;
|
|
1082
|
+
/** Na unidade de compra. */
|
|
1083
|
+
quantity: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>, string, string | number>;
|
|
1084
|
+
/** Ausente: o preço do pedido (ou o último do fornecedor). */
|
|
1085
|
+
unitPrice: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>, string, string | number>>;
|
|
1086
|
+
batchCode: z.ZodOptional<z.ZodString>;
|
|
1087
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
|
|
1088
|
+
divergenceReason: z.ZodOptional<z.ZodString>;
|
|
1089
|
+
}, "strip", z.ZodTypeAny, {
|
|
1090
|
+
quantity: string;
|
|
1091
|
+
itemRef?: string | undefined;
|
|
1092
|
+
itemName?: string | undefined;
|
|
1093
|
+
supplierSku?: string | undefined;
|
|
1094
|
+
purchaseUnit?: string | undefined;
|
|
1095
|
+
unitsPerPurchase?: string | undefined;
|
|
1096
|
+
stockUnit?: RecipeUnit | undefined;
|
|
1097
|
+
supplierItemId?: string | undefined;
|
|
1098
|
+
unitPrice?: string | undefined;
|
|
1099
|
+
orderLineId?: string | undefined;
|
|
1100
|
+
batchCode?: string | undefined;
|
|
1101
|
+
expiresAt?: string | null | undefined;
|
|
1102
|
+
divergenceReason?: string | undefined;
|
|
1103
|
+
}, {
|
|
1104
|
+
quantity: string | number;
|
|
1105
|
+
itemRef?: string | undefined;
|
|
1106
|
+
itemName?: string | undefined;
|
|
1107
|
+
supplierSku?: string | undefined;
|
|
1108
|
+
purchaseUnit?: string | undefined;
|
|
1109
|
+
unitsPerPurchase?: string | number | undefined;
|
|
1110
|
+
stockUnit?: RecipeUnit | undefined;
|
|
1111
|
+
supplierItemId?: string | undefined;
|
|
1112
|
+
unitPrice?: string | number | undefined;
|
|
1113
|
+
orderLineId?: string | undefined;
|
|
1114
|
+
batchCode?: string | undefined;
|
|
1115
|
+
expiresAt?: string | null | undefined;
|
|
1116
|
+
divergenceReason?: string | undefined;
|
|
1117
|
+
}>, {
|
|
1118
|
+
quantity: string;
|
|
1119
|
+
itemRef?: string | undefined;
|
|
1120
|
+
itemName?: string | undefined;
|
|
1121
|
+
supplierSku?: string | undefined;
|
|
1122
|
+
purchaseUnit?: string | undefined;
|
|
1123
|
+
unitsPerPurchase?: string | undefined;
|
|
1124
|
+
stockUnit?: RecipeUnit | undefined;
|
|
1125
|
+
supplierItemId?: string | undefined;
|
|
1126
|
+
unitPrice?: string | undefined;
|
|
1127
|
+
orderLineId?: string | undefined;
|
|
1128
|
+
batchCode?: string | undefined;
|
|
1129
|
+
expiresAt?: string | null | undefined;
|
|
1130
|
+
divergenceReason?: string | undefined;
|
|
1131
|
+
}, {
|
|
1132
|
+
quantity: string | number;
|
|
1133
|
+
itemRef?: string | undefined;
|
|
1134
|
+
itemName?: string | undefined;
|
|
1135
|
+
supplierSku?: string | undefined;
|
|
1136
|
+
purchaseUnit?: string | undefined;
|
|
1137
|
+
unitsPerPurchase?: string | number | undefined;
|
|
1138
|
+
stockUnit?: RecipeUnit | undefined;
|
|
1139
|
+
supplierItemId?: string | undefined;
|
|
1140
|
+
unitPrice?: string | number | undefined;
|
|
1141
|
+
orderLineId?: string | undefined;
|
|
1142
|
+
batchCode?: string | undefined;
|
|
1143
|
+
expiresAt?: string | null | undefined;
|
|
1144
|
+
divergenceReason?: string | undefined;
|
|
1145
|
+
}>, "many">;
|
|
1146
|
+
}, "strip", z.ZodTypeAny, {
|
|
1147
|
+
lines: {
|
|
1148
|
+
quantity: string;
|
|
1149
|
+
itemRef?: string | undefined;
|
|
1150
|
+
itemName?: string | undefined;
|
|
1151
|
+
supplierSku?: string | undefined;
|
|
1152
|
+
purchaseUnit?: string | undefined;
|
|
1153
|
+
unitsPerPurchase?: string | undefined;
|
|
1154
|
+
stockUnit?: RecipeUnit | undefined;
|
|
1155
|
+
supplierItemId?: string | undefined;
|
|
1156
|
+
unitPrice?: string | undefined;
|
|
1157
|
+
orderLineId?: string | undefined;
|
|
1158
|
+
batchCode?: string | undefined;
|
|
1159
|
+
expiresAt?: string | null | undefined;
|
|
1160
|
+
divergenceReason?: string | undefined;
|
|
1161
|
+
}[];
|
|
1162
|
+
freight: string;
|
|
1163
|
+
discount: string;
|
|
1164
|
+
notes: string;
|
|
1165
|
+
supplierId?: string | undefined;
|
|
1166
|
+
receivedAt?: string | undefined;
|
|
1167
|
+
invoiceNumber?: string | undefined;
|
|
1168
|
+
invoiceKey?: string | undefined;
|
|
1169
|
+
invoiceIssuedAt?: string | undefined;
|
|
1170
|
+
idempotencyKey?: string | undefined;
|
|
1171
|
+
installments?: {
|
|
1172
|
+
dueDate: string;
|
|
1173
|
+
amount: string;
|
|
1174
|
+
}[] | undefined;
|
|
1175
|
+
}, {
|
|
1176
|
+
lines: {
|
|
1177
|
+
quantity: string | number;
|
|
1178
|
+
itemRef?: string | undefined;
|
|
1179
|
+
itemName?: string | undefined;
|
|
1180
|
+
supplierSku?: string | undefined;
|
|
1181
|
+
purchaseUnit?: string | undefined;
|
|
1182
|
+
unitsPerPurchase?: string | number | undefined;
|
|
1183
|
+
stockUnit?: RecipeUnit | undefined;
|
|
1184
|
+
supplierItemId?: string | undefined;
|
|
1185
|
+
unitPrice?: string | number | undefined;
|
|
1186
|
+
orderLineId?: string | undefined;
|
|
1187
|
+
batchCode?: string | undefined;
|
|
1188
|
+
expiresAt?: string | null | undefined;
|
|
1189
|
+
divergenceReason?: string | undefined;
|
|
1190
|
+
}[];
|
|
1191
|
+
supplierId?: string | undefined;
|
|
1192
|
+
freight?: string | undefined;
|
|
1193
|
+
discount?: string | undefined;
|
|
1194
|
+
notes?: string | undefined;
|
|
1195
|
+
receivedAt?: string | undefined;
|
|
1196
|
+
invoiceNumber?: string | undefined;
|
|
1197
|
+
invoiceKey?: string | undefined;
|
|
1198
|
+
invoiceIssuedAt?: string | undefined;
|
|
1199
|
+
idempotencyKey?: string | undefined;
|
|
1200
|
+
installments?: {
|
|
1201
|
+
dueDate: string;
|
|
1202
|
+
amount: string;
|
|
1203
|
+
}[] | undefined;
|
|
1204
|
+
}>;
|
|
1205
|
+
type ReceiveInput = z.input<typeof receiveSchema>;
|
|
1206
|
+
type ReceiveData = z.output<typeof receiveSchema>;
|
|
1207
|
+
declare const listReceiptsQuerySchema: z.ZodObject<{
|
|
1208
|
+
supplierId: z.ZodOptional<z.ZodString>;
|
|
1209
|
+
orderId: z.ZodOptional<z.ZodString>;
|
|
1210
|
+
from: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1211
|
+
to: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1212
|
+
/** Só os que tiveram falha numa integração (estoque ou contas), para reprocessar. */
|
|
1213
|
+
failed: z.ZodOptional<z.ZodEffects<z.ZodEnum<["true", "false"]>, boolean, "true" | "false">>;
|
|
1214
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
1215
|
+
pageSize: z.ZodDefault<z.ZodNumber>;
|
|
1216
|
+
}, "strip", z.ZodTypeAny, {
|
|
1217
|
+
page: number;
|
|
1218
|
+
pageSize: number;
|
|
1219
|
+
failed?: boolean | undefined;
|
|
1220
|
+
supplierId?: string | undefined;
|
|
1221
|
+
from?: string | undefined;
|
|
1222
|
+
to?: string | undefined;
|
|
1223
|
+
orderId?: string | undefined;
|
|
1224
|
+
}, {
|
|
1225
|
+
failed?: "true" | "false" | undefined;
|
|
1226
|
+
supplierId?: string | undefined;
|
|
1227
|
+
page?: number | undefined;
|
|
1228
|
+
pageSize?: number | undefined;
|
|
1229
|
+
from?: string | undefined;
|
|
1230
|
+
to?: string | undefined;
|
|
1231
|
+
orderId?: string | undefined;
|
|
1232
|
+
}>;
|
|
1233
|
+
type ListReceiptsQuery = z.output<typeof listReceiptsQuerySchema>;
|
|
1234
|
+
declare const priceHistoryQuerySchema: z.ZodEffects<z.ZodObject<{
|
|
1235
|
+
itemRef: z.ZodOptional<z.ZodString>;
|
|
1236
|
+
supplierItemId: z.ZodOptional<z.ZodString>;
|
|
1237
|
+
supplierId: z.ZodOptional<z.ZodString>;
|
|
1238
|
+
from: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1239
|
+
to: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1240
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
1241
|
+
pageSize: z.ZodDefault<z.ZodNumber>;
|
|
1242
|
+
}, "strip", z.ZodTypeAny, {
|
|
1243
|
+
page: number;
|
|
1244
|
+
pageSize: number;
|
|
1245
|
+
supplierId?: string | undefined;
|
|
1246
|
+
itemRef?: string | undefined;
|
|
1247
|
+
supplierItemId?: string | undefined;
|
|
1248
|
+
from?: string | undefined;
|
|
1249
|
+
to?: string | undefined;
|
|
1250
|
+
}, {
|
|
1251
|
+
supplierId?: string | undefined;
|
|
1252
|
+
page?: number | undefined;
|
|
1253
|
+
pageSize?: number | undefined;
|
|
1254
|
+
itemRef?: string | undefined;
|
|
1255
|
+
supplierItemId?: string | undefined;
|
|
1256
|
+
from?: string | undefined;
|
|
1257
|
+
to?: string | undefined;
|
|
1258
|
+
}>, {
|
|
1259
|
+
page: number;
|
|
1260
|
+
pageSize: number;
|
|
1261
|
+
supplierId?: string | undefined;
|
|
1262
|
+
itemRef?: string | undefined;
|
|
1263
|
+
supplierItemId?: string | undefined;
|
|
1264
|
+
from?: string | undefined;
|
|
1265
|
+
to?: string | undefined;
|
|
1266
|
+
}, {
|
|
1267
|
+
supplierId?: string | undefined;
|
|
1268
|
+
page?: number | undefined;
|
|
1269
|
+
pageSize?: number | undefined;
|
|
1270
|
+
itemRef?: string | undefined;
|
|
1271
|
+
supplierItemId?: string | undefined;
|
|
1272
|
+
from?: string | undefined;
|
|
1273
|
+
to?: string | undefined;
|
|
1274
|
+
}>;
|
|
1275
|
+
type PriceHistoryQuery = z.output<typeof priceHistoryQuerySchema>;
|
|
1276
|
+
declare const itemRefsLookupSchema: z.ZodObject<{
|
|
1277
|
+
itemRefs: z.ZodArray<z.ZodString, "many">;
|
|
1278
|
+
}, "strip", z.ZodTypeAny, {
|
|
1279
|
+
itemRefs: string[];
|
|
1280
|
+
}, {
|
|
1281
|
+
itemRefs: string[];
|
|
1282
|
+
}>;
|
|
1283
|
+
type ItemRefsLookupData = z.output<typeof itemRefsLookupSchema>;
|
|
1284
|
+
declare const suggestionQuerySchema: z.ZodObject<{
|
|
1285
|
+
supplierId: z.ZodOptional<z.ZodString>;
|
|
1286
|
+
}, "strip", z.ZodTypeAny, {
|
|
1287
|
+
supplierId?: string | undefined;
|
|
1288
|
+
}, {
|
|
1289
|
+
supplierId?: string | undefined;
|
|
1290
|
+
}>;
|
|
1291
|
+
type SuggestionQuery = z.output<typeof suggestionQuerySchema>;
|
|
1292
|
+
declare const ordersFromSuggestionSchema: z.ZodObject<{
|
|
1293
|
+
/** Ausente: um rascunho por fornecedor sugerido. */
|
|
1294
|
+
supplierIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1295
|
+
expectedAt: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
|
|
1296
|
+
}, "strip", z.ZodTypeAny, {
|
|
1297
|
+
expectedAt?: string | null | undefined;
|
|
1298
|
+
supplierIds?: string[] | undefined;
|
|
1299
|
+
}, {
|
|
1300
|
+
expectedAt?: string | null | undefined;
|
|
1301
|
+
supplierIds?: string[] | undefined;
|
|
1302
|
+
}>;
|
|
1303
|
+
type OrdersFromSuggestionData = z.output<typeof ordersFromSuggestionSchema>;
|
|
1304
|
+
declare const nfePreviewSchema: z.ZodObject<{
|
|
1305
|
+
xml: z.ZodString;
|
|
1306
|
+
/** Casa os itens da nota com as linhas pendentes deste pedido. */
|
|
1307
|
+
orderId: z.ZodOptional<z.ZodString>;
|
|
1308
|
+
}, "strip", z.ZodTypeAny, {
|
|
1309
|
+
xml: string;
|
|
1310
|
+
orderId?: string | undefined;
|
|
1311
|
+
}, {
|
|
1312
|
+
xml: string;
|
|
1313
|
+
orderId?: string | undefined;
|
|
1314
|
+
}>;
|
|
1315
|
+
type NfePreviewData = z.output<typeof nfePreviewSchema>;
|
|
1316
|
+
declare const REPORT_GROUP: {
|
|
1317
|
+
readonly SUPPLIER: "supplier";
|
|
1318
|
+
readonly ITEM: "item";
|
|
1319
|
+
readonly MONTH: "month";
|
|
1320
|
+
};
|
|
1321
|
+
type ReportGroup = (typeof REPORT_GROUP)[keyof typeof REPORT_GROUP];
|
|
1322
|
+
declare const REPORT_GROUPS: readonly ReportGroup[];
|
|
1323
|
+
declare const spendReportQuerySchema: z.ZodEffects<z.ZodObject<{
|
|
1324
|
+
from: z.ZodEffects<z.ZodString, string, string>;
|
|
1325
|
+
to: z.ZodEffects<z.ZodString, string, string>;
|
|
1326
|
+
groupBy: z.ZodDefault<z.ZodEnum<[ReportGroup, ...ReportGroup[]]>>;
|
|
1327
|
+
supplierId: z.ZodOptional<z.ZodString>;
|
|
1328
|
+
itemRef: z.ZodOptional<z.ZodString>;
|
|
1329
|
+
}, "strip", z.ZodTypeAny, {
|
|
1330
|
+
from: string;
|
|
1331
|
+
to: string;
|
|
1332
|
+
groupBy: ReportGroup;
|
|
1333
|
+
supplierId?: string | undefined;
|
|
1334
|
+
itemRef?: string | undefined;
|
|
1335
|
+
}, {
|
|
1336
|
+
from: string;
|
|
1337
|
+
to: string;
|
|
1338
|
+
supplierId?: string | undefined;
|
|
1339
|
+
itemRef?: string | undefined;
|
|
1340
|
+
groupBy?: ReportGroup | undefined;
|
|
1341
|
+
}>, {
|
|
1342
|
+
from: string;
|
|
1343
|
+
to: string;
|
|
1344
|
+
groupBy: ReportGroup;
|
|
1345
|
+
supplierId?: string | undefined;
|
|
1346
|
+
itemRef?: string | undefined;
|
|
1347
|
+
}, {
|
|
1348
|
+
from: string;
|
|
1349
|
+
to: string;
|
|
1350
|
+
supplierId?: string | undefined;
|
|
1351
|
+
itemRef?: string | undefined;
|
|
1352
|
+
groupBy?: ReportGroup | undefined;
|
|
1353
|
+
}>;
|
|
1354
|
+
type SpendReportQuery = z.output<typeof spendReportQuerySchema>;
|
|
1355
|
+
declare const supplierPerformanceQuerySchema: z.ZodEffects<z.ZodObject<{
|
|
1356
|
+
from: z.ZodEffects<z.ZodString, string, string>;
|
|
1357
|
+
to: z.ZodEffects<z.ZodString, string, string>;
|
|
1358
|
+
}, "strip", z.ZodTypeAny, {
|
|
1359
|
+
from: string;
|
|
1360
|
+
to: string;
|
|
1361
|
+
}, {
|
|
1362
|
+
from: string;
|
|
1363
|
+
to: string;
|
|
1364
|
+
}>, {
|
|
1365
|
+
from: string;
|
|
1366
|
+
to: string;
|
|
1367
|
+
}, {
|
|
1368
|
+
from: string;
|
|
1369
|
+
to: string;
|
|
1370
|
+
}>;
|
|
1371
|
+
type SupplierPerformanceQuery = z.output<typeof supplierPerformanceQuerySchema>;
|
|
1372
|
+
declare const exportFormatSchema: z.ZodObject<{
|
|
1373
|
+
format: z.ZodDefault<z.ZodEnum<["csv", "xlsx"]>>;
|
|
1374
|
+
}, "strip", z.ZodTypeAny, {
|
|
1375
|
+
format: "csv" | "xlsx";
|
|
1376
|
+
}, {
|
|
1377
|
+
format?: "csv" | "xlsx" | undefined;
|
|
1378
|
+
}>;
|
|
1379
|
+
type ExportFormatQuery = z.output<typeof exportFormatSchema>;
|
|
1380
|
+
|
|
1381
|
+
/**
|
|
1382
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
1383
|
+
*/
|
|
1384
|
+
|
|
1385
|
+
type SpendRow = {
|
|
1386
|
+
/** Id do fornecedor, `itemRef` (ou nome do item livre) ou `aaaa-mm`, conforme o agrupamento. */
|
|
1387
|
+
readonly key: string;
|
|
1388
|
+
readonly label: string;
|
|
1389
|
+
readonly receiptCount: number;
|
|
1390
|
+
readonly lineCount: number;
|
|
1391
|
+
/** Soma das linhas mais o rateio de frete e desconto (o que saiu do caixa). */
|
|
1392
|
+
readonly total: string;
|
|
1393
|
+
};
|
|
1394
|
+
type SpendReport = {
|
|
1395
|
+
readonly from: string;
|
|
1396
|
+
readonly to: string;
|
|
1397
|
+
readonly groupBy: ReportGroup;
|
|
1398
|
+
readonly rows: readonly SpendRow[];
|
|
1399
|
+
readonly total: string;
|
|
1400
|
+
readonly receiptCount: number;
|
|
1401
|
+
};
|
|
1402
|
+
type SupplierPerformanceRow = {
|
|
1403
|
+
readonly supplierId: string;
|
|
1404
|
+
readonly supplierName: string;
|
|
1405
|
+
readonly orderCount: number;
|
|
1406
|
+
/** Pedidos com previsão que chegaram (primeiro recebimento) até a data prevista. */
|
|
1407
|
+
readonly onTimeCount: number;
|
|
1408
|
+
readonly lateCount: number;
|
|
1409
|
+
/** Média de dias de atraso entre os atrasados. */
|
|
1410
|
+
readonly averageDaysLate: string | null;
|
|
1411
|
+
/** Linhas de recebimento com divergência de quantidade ou preço. */
|
|
1412
|
+
readonly divergentLineCount: number;
|
|
1413
|
+
readonly receivedLineCount: number;
|
|
1414
|
+
readonly total: string;
|
|
1415
|
+
};
|
|
1416
|
+
type SupplierPerformanceReport = {
|
|
1417
|
+
readonly from: string;
|
|
1418
|
+
readonly to: string;
|
|
1419
|
+
readonly rows: readonly SupplierPerformanceRow[];
|
|
1420
|
+
};
|
|
1421
|
+
|
|
1422
|
+
/**
|
|
1423
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
1424
|
+
*
|
|
1425
|
+
* Mesma forma dos erros dos outros módulos (`statusCode`, `code`, `publicDetails`): o filtro do `module-http`
|
|
1426
|
+
* reconhece pela forma.
|
|
1427
|
+
*/
|
|
1428
|
+
declare class PurchaseError extends Error {
|
|
1429
|
+
readonly statusCode: number;
|
|
1430
|
+
readonly code: string;
|
|
1431
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
1432
|
+
readonly publicDetails?: Readonly<Record<string, unknown>> | undefined;
|
|
1433
|
+
constructor(message: string, statusCode: number, code: string, details?: Record<string, unknown> | undefined, publicDetails?: Readonly<Record<string, unknown>> | undefined);
|
|
1434
|
+
}
|
|
1435
|
+
declare const PURCHASE_ERROR_CODES: {
|
|
1436
|
+
readonly DISABLED: "PURCHASE_DISABLED";
|
|
1437
|
+
readonly UNAUTHENTICATED: "PURCHASE_UNAUTHENTICATED";
|
|
1438
|
+
readonly CONFIG_MISSING: "PURCHASE_CONFIG_MISSING";
|
|
1439
|
+
readonly SUPPLIER_NOT_FOUND: "PURCHASE_SUPPLIER_NOT_FOUND";
|
|
1440
|
+
readonly SUPPLIER_INACTIVE: "PURCHASE_SUPPLIER_INACTIVE";
|
|
1441
|
+
readonly SUPPLIER_DOCUMENT_TAKEN: "PURCHASE_SUPPLIER_DOCUMENT_TAKEN";
|
|
1442
|
+
readonly SUPPLIER_IN_USE: "PURCHASE_SUPPLIER_IN_USE";
|
|
1443
|
+
readonly SUPPLIER_ITEM_NOT_FOUND: "PURCHASE_SUPPLIER_ITEM_NOT_FOUND";
|
|
1444
|
+
readonly SUPPLIER_ITEM_TAKEN: "PURCHASE_SUPPLIER_ITEM_TAKEN";
|
|
1445
|
+
readonly ITEM_NOT_FOUND: "PURCHASE_ITEM_NOT_FOUND";
|
|
1446
|
+
readonly ORDER_NOT_FOUND: "PURCHASE_ORDER_NOT_FOUND";
|
|
1447
|
+
readonly ORDER_LINE_NOT_FOUND: "PURCHASE_ORDER_LINE_NOT_FOUND";
|
|
1448
|
+
readonly INVALID_TRANSITION: "PURCHASE_INVALID_TRANSITION";
|
|
1449
|
+
readonly SELF_APPROVAL: "PURCHASE_SELF_APPROVAL";
|
|
1450
|
+
readonly RECEIPT_NOT_FOUND: "PURCHASE_RECEIPT_NOT_FOUND";
|
|
1451
|
+
readonly INVOICE_ALREADY_RECEIVED: "PURCHASE_INVOICE_ALREADY_RECEIVED";
|
|
1452
|
+
readonly INSTALLMENTS_MISMATCH: "PURCHASE_INSTALLMENTS_MISMATCH";
|
|
1453
|
+
readonly DISPATCH_UNAVAILABLE: "PURCHASE_DISPATCH_UNAVAILABLE";
|
|
1454
|
+
readonly NO_CONTACT: "PURCHASE_SUPPLIER_NO_CONTACT";
|
|
1455
|
+
readonly NFE_INVALID: "PURCHASE_NFE_INVALID";
|
|
1456
|
+
readonly REPORT_RANGE_TOO_LONG: "PURCHASE_REPORT_RANGE_TOO_LONG";
|
|
1457
|
+
};
|
|
1458
|
+
declare class PurchaseDisabledError extends PurchaseError {
|
|
1459
|
+
constructor();
|
|
1460
|
+
}
|
|
1461
|
+
declare class PurchaseUnauthenticatedError extends PurchaseError {
|
|
1462
|
+
constructor();
|
|
1463
|
+
}
|
|
1464
|
+
declare class PurchaseConfigMissingError extends PurchaseError {
|
|
1465
|
+
constructor(field: string);
|
|
1466
|
+
}
|
|
1467
|
+
declare class SupplierNotFoundError extends PurchaseError {
|
|
1468
|
+
constructor(supplierId: string);
|
|
1469
|
+
}
|
|
1470
|
+
declare class SupplierInactiveError extends PurchaseError {
|
|
1471
|
+
constructor(supplierId: string);
|
|
1472
|
+
}
|
|
1473
|
+
declare class SupplierDocumentTakenError extends PurchaseError {
|
|
1474
|
+
constructor();
|
|
1475
|
+
}
|
|
1476
|
+
declare class SupplierInUseError extends PurchaseError {
|
|
1477
|
+
constructor(supplierId: string);
|
|
1478
|
+
}
|
|
1479
|
+
declare class SupplierItemNotFoundError extends PurchaseError {
|
|
1480
|
+
constructor(supplierItemId: string);
|
|
1481
|
+
}
|
|
1482
|
+
declare class SupplierItemTakenError extends PurchaseError {
|
|
1483
|
+
constructor();
|
|
1484
|
+
}
|
|
1485
|
+
declare class PurchaseItemNotFoundError extends PurchaseError {
|
|
1486
|
+
constructor(itemRef: string);
|
|
1487
|
+
}
|
|
1488
|
+
declare class OrderNotFoundError extends PurchaseError {
|
|
1489
|
+
constructor(orderId: string);
|
|
1490
|
+
}
|
|
1491
|
+
declare class OrderLineNotFoundError extends PurchaseError {
|
|
1492
|
+
constructor(orderLineId: string);
|
|
1493
|
+
}
|
|
1494
|
+
declare class InvalidOrderTransitionError extends PurchaseError {
|
|
1495
|
+
constructor(params: {
|
|
1496
|
+
readonly status: string;
|
|
1497
|
+
readonly action: string;
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
declare class SelfApprovalError extends PurchaseError {
|
|
1501
|
+
constructor();
|
|
1502
|
+
}
|
|
1503
|
+
declare class ReceiptNotFoundError extends PurchaseError {
|
|
1504
|
+
constructor(receiptId: string);
|
|
1505
|
+
}
|
|
1506
|
+
declare class InvoiceAlreadyReceivedError extends PurchaseError {
|
|
1507
|
+
constructor(receiptId: string);
|
|
1508
|
+
}
|
|
1509
|
+
declare class InstallmentsMismatchError extends PurchaseError {
|
|
1510
|
+
constructor(params: {
|
|
1511
|
+
readonly total: string;
|
|
1512
|
+
readonly installments: string;
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
declare class DispatchUnavailableError extends PurchaseError {
|
|
1516
|
+
constructor(channel: string);
|
|
1517
|
+
}
|
|
1518
|
+
declare class SupplierNoContactError extends PurchaseError {
|
|
1519
|
+
constructor(channel: string);
|
|
1520
|
+
}
|
|
1521
|
+
declare class NfeInvalidError extends PurchaseError {
|
|
1522
|
+
constructor(reason: string);
|
|
1523
|
+
}
|
|
1524
|
+
declare class ReportRangeTooLongError extends PurchaseError {
|
|
1525
|
+
constructor(maxDays: number);
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
/**
|
|
1529
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
1530
|
+
*
|
|
1531
|
+
* Sugestão de pedido: falta = max(necessidade − saldo, mínimo − saldo) − a caminho. A falta vira unidades de compra
|
|
1532
|
+
* do fornecedor preferido, arredondadas para cima (não se compra meia caixa), e o resultado é agrupado por fornecedor.
|
|
1533
|
+
*/
|
|
1534
|
+
|
|
1535
|
+
type DemandRow = {
|
|
1536
|
+
readonly itemRef: string;
|
|
1537
|
+
readonly itemName: string;
|
|
1538
|
+
readonly stockUnit: RecipeUnit;
|
|
1539
|
+
/** Necessidade prevista (ficha técnica × reservas/pedidos); `'0'` quando só o mínimo importa. */
|
|
1540
|
+
readonly neededQuantity: string;
|
|
1541
|
+
readonly onHandQuantity: string | null;
|
|
1542
|
+
readonly minimumQuantity: string | null;
|
|
1543
|
+
};
|
|
1544
|
+
type SuggestionSupplierItem = {
|
|
1545
|
+
readonly id: string;
|
|
1546
|
+
readonly supplierId: string;
|
|
1547
|
+
readonly itemRef: string | null;
|
|
1548
|
+
readonly purchaseUnit: string;
|
|
1549
|
+
readonly unitsPerPurchase: string;
|
|
1550
|
+
readonly lastPrice: string | null;
|
|
1551
|
+
readonly priority: number;
|
|
1552
|
+
readonly isActive: boolean;
|
|
1553
|
+
};
|
|
1554
|
+
type SuggestionSupplier = {
|
|
1555
|
+
readonly id: string;
|
|
1556
|
+
readonly name: string;
|
|
1557
|
+
readonly minimumOrderAmount: string | null;
|
|
1558
|
+
readonly isActive: boolean;
|
|
1559
|
+
};
|
|
1560
|
+
declare function shortageOf(row: DemandRow & {
|
|
1561
|
+
readonly incomingQuantity: string;
|
|
1562
|
+
}): string;
|
|
1563
|
+
/** Unidades de compra para cobrir a falta: `ceil(falta ÷ unidadesPorCompra)`. */
|
|
1564
|
+
declare function packsFor(shortage: string, unitsPerPurchase: string): string;
|
|
1565
|
+
declare function buildSuggestion(params: {
|
|
1566
|
+
readonly demand: readonly DemandRow[];
|
|
1567
|
+
readonly incoming: ReadonlyMap<string, string>;
|
|
1568
|
+
readonly supplierItems: readonly SuggestionSupplierItem[];
|
|
1569
|
+
readonly suppliers: ReadonlyMap<string, SuggestionSupplier>;
|
|
1570
|
+
/** Só este fornecedor (sugestão para um pedido já aberto). */
|
|
1571
|
+
readonly supplierId?: string;
|
|
1572
|
+
}): SuggestionGroup[];
|
|
1573
|
+
/** Para mostrar a falta em unidade de compra na tela: `quantidade × unidadesPorCompra`. */
|
|
1574
|
+
declare function stockQuantityOf(quantity: string, unitsPerPurchase: string): string;
|
|
1575
|
+
|
|
1576
|
+
/**
|
|
1577
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
1578
|
+
*
|
|
1579
|
+
* Portas que o host implementa. Todas opcionais: sem nenhuma, Compras funciona sozinho (itens livres, recebimento
|
|
1580
|
+
* só registrado, sem conta a pagar, envio por "copiar texto"). Cada porta liga um outro módulo sem que este pacote
|
|
1581
|
+
* dependa dele; a implementação natural de cada uma está no comentário.
|
|
1582
|
+
*/
|
|
1583
|
+
|
|
1584
|
+
type LogMeta = Readonly<Record<string, unknown>>;
|
|
1585
|
+
interface LoggerPort {
|
|
1586
|
+
debug(message: string, meta?: LogMeta): void;
|
|
1587
|
+
info(message: string, meta?: LogMeta): void;
|
|
1588
|
+
warn(message: string, meta?: LogMeta): void;
|
|
1589
|
+
error(message: string, meta?: LogMeta): void;
|
|
1590
|
+
}
|
|
1591
|
+
interface ClockPort {
|
|
1592
|
+
now(): Date;
|
|
1593
|
+
}
|
|
1594
|
+
type CatalogItem = {
|
|
1595
|
+
readonly itemRef: string;
|
|
1596
|
+
readonly name: string;
|
|
1597
|
+
readonly unit: RecipeUnit;
|
|
1598
|
+
};
|
|
1599
|
+
/**
|
|
1600
|
+
* Itens do catálogo ligado. Com a porta, `itemRef` de linha e de item do fornecedor é conferido (de outra empresa
|
|
1601
|
+
* = 404) e o nome/unidade vêm de lá. Sem ela, `itemRef` é aceito como veio (opaco).
|
|
1602
|
+
* Natural: `recipeModule` (`ingredients.findByIds`) ou o cadastro de produtos do host.
|
|
1603
|
+
*/
|
|
1604
|
+
interface ItemCatalogPort {
|
|
1605
|
+
findItems(params: {
|
|
1606
|
+
readonly companyId: string;
|
|
1607
|
+
readonly itemRefs: readonly string[];
|
|
1608
|
+
}): Promise<readonly CatalogItem[]>;
|
|
1609
|
+
}
|
|
1610
|
+
/**
|
|
1611
|
+
* Entrada no estoque, uma chamada por linha recebida com `itemRef` e unidade de estoque. Precisa ser idempotente por
|
|
1612
|
+
* `sourceKey`: o módulo reenvia a mesma chave quando reprocessa um recebimento que falhou.
|
|
1613
|
+
* Natural: `stockModule.useCases.receiveBatch.execute({ ..., input: { ..., sourceKey } })`.
|
|
1614
|
+
*/
|
|
1615
|
+
interface StockReceiptPort {
|
|
1616
|
+
receive(params: {
|
|
1617
|
+
readonly companyId: string;
|
|
1618
|
+
readonly actorId?: string;
|
|
1619
|
+
readonly sourceKey: string;
|
|
1620
|
+
readonly itemRef: string;
|
|
1621
|
+
/** Em unidade de estoque (já convertida da unidade de compra). */
|
|
1622
|
+
readonly quantity: string;
|
|
1623
|
+
readonly unit: RecipeUnit;
|
|
1624
|
+
readonly batchCode: string;
|
|
1625
|
+
readonly costPerUnit: string | null;
|
|
1626
|
+
/** ISO com fuso (fim do dia da validade) ou `null`. */
|
|
1627
|
+
readonly expiresAt: string | null;
|
|
1628
|
+
readonly supplierId: string;
|
|
1629
|
+
readonly reason: string;
|
|
1630
|
+
}): Promise<void>;
|
|
1631
|
+
}
|
|
1632
|
+
/**
|
|
1633
|
+
* Necessidade por item para a sugestão de pedido. Natural: os níveis do `stock-module` (saldo e mínimo) somados à
|
|
1634
|
+
* lista de compras do `recipe-module` (ficha técnica × pedidos/reservas previstos).
|
|
1635
|
+
*/
|
|
1636
|
+
interface DemandSourcePort {
|
|
1637
|
+
getDemand(params: {
|
|
1638
|
+
readonly companyId: string;
|
|
1639
|
+
}): Promise<readonly DemandRow[]>;
|
|
1640
|
+
}
|
|
1641
|
+
type PayableRequest = {
|
|
1642
|
+
readonly companyId: string;
|
|
1643
|
+
readonly actorId?: string;
|
|
1644
|
+
/** Idempotência: `purchase-receipt:<receiptId>`. Reenviar a mesma chave não cria outra conta. */
|
|
1645
|
+
readonly sourceRef: string;
|
|
1646
|
+
readonly supplier: {
|
|
1647
|
+
readonly id: string;
|
|
1648
|
+
readonly name: string;
|
|
1649
|
+
readonly document: string | null;
|
|
1650
|
+
};
|
|
1651
|
+
readonly description: string;
|
|
1652
|
+
readonly total: string;
|
|
1653
|
+
readonly installments: readonly Installment[];
|
|
1654
|
+
readonly invoiceNumber: string | null;
|
|
1655
|
+
readonly invoiceKey: string | null;
|
|
1656
|
+
readonly receiptId: string;
|
|
1657
|
+
readonly orderId: string | null;
|
|
1658
|
+
};
|
|
1659
|
+
/**
|
|
1660
|
+
* Conta a pagar do recebimento. Natural: `expense-module` (`createExpense` com `installments` e `sourceRef`, 0.2+).
|
|
1661
|
+
* Devolve a referência da conta, guardada no recebimento.
|
|
1662
|
+
*/
|
|
1663
|
+
interface PayablesPort {
|
|
1664
|
+
createPayable(params: PayableRequest): Promise<{
|
|
1665
|
+
readonly payableRef: string;
|
|
1666
|
+
}>;
|
|
1667
|
+
}
|
|
1668
|
+
/**
|
|
1669
|
+
* Envio do pedido ao fornecedor. Natural: `meta-whatsapp-module` (mensagem de texto; fora da janela de 24 h, um
|
|
1670
|
+
* modelo aprovado) e `email-provider`. Sem a porta, só o canal `manual` (o painel mostra o texto para copiar).
|
|
1671
|
+
*/
|
|
1672
|
+
interface OrderDispatchPort {
|
|
1673
|
+
readonly channels: readonly DispatchChannel[];
|
|
1674
|
+
dispatch(params: {
|
|
1675
|
+
readonly companyId: string;
|
|
1676
|
+
readonly actorId?: string;
|
|
1677
|
+
readonly channel: DispatchChannel;
|
|
1678
|
+
readonly orderId: string;
|
|
1679
|
+
readonly orderNumber: number;
|
|
1680
|
+
readonly to: {
|
|
1681
|
+
readonly name: string;
|
|
1682
|
+
readonly phone: string | null;
|
|
1683
|
+
readonly email: string | null;
|
|
1684
|
+
};
|
|
1685
|
+
readonly text: string;
|
|
1686
|
+
}): Promise<{
|
|
1687
|
+
readonly messageRef?: string;
|
|
1688
|
+
}>;
|
|
1689
|
+
}
|
|
1690
|
+
type ReceiptPostedLine = {
|
|
1691
|
+
readonly itemRef: string | null;
|
|
1692
|
+
readonly itemName: string;
|
|
1693
|
+
readonly stockUnit: RecipeUnit | null;
|
|
1694
|
+
/** Em unidade de estoque. */
|
|
1695
|
+
readonly stockQuantity: string;
|
|
1696
|
+
readonly landedUnitCost: string | null;
|
|
1697
|
+
/** Média ponderada do item na janela da configuração, já contando este recebimento. */
|
|
1698
|
+
readonly averageCost: string | null;
|
|
1699
|
+
};
|
|
1700
|
+
type PurchaseHooks = {
|
|
1701
|
+
readonly onOrderStatusChanged?: (event: {
|
|
1702
|
+
readonly companyId: string;
|
|
1703
|
+
readonly actorId?: string;
|
|
1704
|
+
readonly orderId: string;
|
|
1705
|
+
readonly number: number;
|
|
1706
|
+
readonly from: OrderStatus;
|
|
1707
|
+
readonly to: OrderStatus;
|
|
1708
|
+
}) => void | Promise<void>;
|
|
1709
|
+
/** Pedido acima do limite esperando aprovação (avisar quem aprova). */
|
|
1710
|
+
readonly onApprovalRequested?: (event: {
|
|
1711
|
+
readonly companyId: string;
|
|
1712
|
+
readonly orderId: string;
|
|
1713
|
+
readonly number: number;
|
|
1714
|
+
readonly total: string;
|
|
1715
|
+
readonly requestedBy?: string;
|
|
1716
|
+
}) => void | Promise<void>;
|
|
1717
|
+
/**
|
|
1718
|
+
* Depois do recebimento gravado. Natural, com ficha técnica: atualizar o `costPerUnit` do insumo
|
|
1719
|
+
* (`landedUnitCost` ou `averageCost`, política do host) para o custo do prato acompanhar a compra.
|
|
1720
|
+
*/
|
|
1721
|
+
readonly onReceiptPosted?: (event: {
|
|
1722
|
+
readonly companyId: string;
|
|
1723
|
+
readonly actorId?: string;
|
|
1724
|
+
readonly receiptId: string;
|
|
1725
|
+
readonly orderId: string | null;
|
|
1726
|
+
readonly supplierId: string;
|
|
1727
|
+
readonly total: string;
|
|
1728
|
+
readonly lines: readonly ReceiptPostedLine[];
|
|
1729
|
+
}) => void | Promise<void>;
|
|
1730
|
+
/** Pedidos atrasados, por empresa, a cada rodada de `scanLateOrders`. */
|
|
1731
|
+
readonly onOrdersLate?: (event: {
|
|
1732
|
+
readonly companyId: string;
|
|
1733
|
+
readonly orders: readonly {
|
|
1734
|
+
readonly orderId: string;
|
|
1735
|
+
readonly number: number;
|
|
1736
|
+
readonly supplierId: string;
|
|
1737
|
+
readonly supplierName: string | null;
|
|
1738
|
+
readonly expectedAt: string;
|
|
1739
|
+
readonly daysLate: number;
|
|
1740
|
+
}[];
|
|
1741
|
+
}) => void | Promise<void>;
|
|
1742
|
+
};
|
|
1743
|
+
declare const DEFAULT_PURCHASE_SCOPES: {
|
|
1744
|
+
readonly read: readonly ["purchase:read"];
|
|
1745
|
+
readonly write: readonly ["purchase:write"];
|
|
1746
|
+
readonly approve: readonly ["purchase:approve"];
|
|
1747
|
+
readonly service: readonly ["purchase:service"];
|
|
1748
|
+
};
|
|
1749
|
+
type PurchaseScopes = {
|
|
1750
|
+
readonly read?: readonly string[];
|
|
1751
|
+
readonly write?: readonly string[];
|
|
1752
|
+
readonly approve?: readonly string[];
|
|
1753
|
+
readonly service?: readonly string[];
|
|
1754
|
+
};
|
|
1755
|
+
type PurchaseModuleConfig = {
|
|
1756
|
+
readonly scopes?: PurchaseScopes;
|
|
1757
|
+
/** Liga Compras por empresa. Ausente: ligado para todas. Desligado: rotas 404. */
|
|
1758
|
+
readonly isEnabledForCompany?: (companyId: string) => boolean | Promise<boolean>;
|
|
1759
|
+
/**
|
|
1760
|
+
* Total (2 casas) acima do qual o pedido precisa de aprovação, por empresa. `null`/ausente: nunca precisa.
|
|
1761
|
+
* Aprovar exige o escopo `approve`, e quem submeteu não aprova o próprio pedido.
|
|
1762
|
+
*/
|
|
1763
|
+
readonly approvalThresholdFor?: (companyId: string) => string | null | Promise<string | null>;
|
|
1764
|
+
/** Nome que vai no texto do pedido ao fornecedor. */
|
|
1765
|
+
readonly companyNameFor?: (companyId: string) => string | Promise<string>;
|
|
1766
|
+
/** Fuso das datas civis (previsão, vencimento, atraso). Padrão: `America/Sao_Paulo`. */
|
|
1767
|
+
readonly timeZone?: string;
|
|
1768
|
+
/** Janela da média ponderada de custo. Padrão: 90 dias. */
|
|
1769
|
+
readonly averageCostWindowDays?: number;
|
|
1770
|
+
/** Diferença de preço tolerada antes de marcar divergência, em centavos. Padrão: 0. */
|
|
1771
|
+
readonly priceToleranceCents?: number;
|
|
1772
|
+
};
|
|
1773
|
+
|
|
1774
|
+
/**
|
|
1775
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
1776
|
+
*
|
|
1777
|
+
* Máquina de estados do pedido. Uma regra só, usada pelo módulo (para recusar) e pela tela (para esconder botão).
|
|
1778
|
+
*
|
|
1779
|
+
* draft ─submit─▶ pending_approval ─approve─▶ approved ─send─▶ sent
|
|
1780
|
+
* ▲ │ reject │ │
|
|
1781
|
+
* └─────────────────┘ └──receive──────┴─▶ partially_received ─▶ received
|
|
1782
|
+
* cancel: até o primeiro recebimento · close: encerra o saldo de um pedido recebido em parte
|
|
1783
|
+
*/
|
|
1784
|
+
|
|
1785
|
+
declare const ORDER_ACTION: {
|
|
1786
|
+
readonly EDIT: "edit";
|
|
1787
|
+
readonly SUBMIT: "submit";
|
|
1788
|
+
readonly APPROVE: "approve";
|
|
1789
|
+
readonly REJECT: "reject";
|
|
1790
|
+
readonly SEND: "send";
|
|
1791
|
+
readonly RECEIVE: "receive";
|
|
1792
|
+
readonly CLOSE: "close";
|
|
1793
|
+
readonly CANCEL: "cancel";
|
|
1794
|
+
};
|
|
1795
|
+
type OrderAction = (typeof ORDER_ACTION)[keyof typeof ORDER_ACTION];
|
|
1796
|
+
declare function canPerform(status: OrderStatus, action: OrderAction): boolean;
|
|
1797
|
+
declare function allowedActions(status: OrderStatus): OrderAction[];
|
|
1798
|
+
/** Depois do `send`, um pedido recebido em parte continua `partially_received`. */
|
|
1799
|
+
declare function statusAfterSend(status: OrderStatus): OrderStatus;
|
|
1800
|
+
/** Total acima do limite precisa de aprovação. Limite ausente = nunca precisa. */
|
|
1801
|
+
declare function requiresApproval(params: {
|
|
1802
|
+
readonly totalCents: bigint;
|
|
1803
|
+
readonly thresholdCents: bigint | null;
|
|
1804
|
+
}): boolean;
|
|
1805
|
+
/** Atrasado: aberto, com previsão, e a previsão já passou (comparação de data civil `aaaa-mm-dd`). */
|
|
1806
|
+
declare function isOrderLate(params: {
|
|
1807
|
+
readonly status: OrderStatus;
|
|
1808
|
+
readonly expectedAt: string | null;
|
|
1809
|
+
readonly today: string;
|
|
1810
|
+
}): boolean;
|
|
1811
|
+
|
|
1812
|
+
/**
|
|
1813
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
1814
|
+
*
|
|
1815
|
+
* Totais do pedido e da nota, rateio de frete e desconto e progresso do recebimento.
|
|
1816
|
+
*/
|
|
1817
|
+
|
|
1818
|
+
type PricedLine = {
|
|
1819
|
+
readonly quantity: string;
|
|
1820
|
+
readonly unitPrice: string;
|
|
1821
|
+
};
|
|
1822
|
+
type Totals = {
|
|
1823
|
+
readonly subtotal: string;
|
|
1824
|
+
readonly freight: string;
|
|
1825
|
+
readonly discount: string;
|
|
1826
|
+
readonly total: string;
|
|
1827
|
+
};
|
|
1828
|
+
/** Desconto maior que subtotal + frete não deixa total negativo (fica zero). */
|
|
1829
|
+
declare function computeTotals(params: {
|
|
1830
|
+
readonly lines: readonly PricedLine[];
|
|
1831
|
+
readonly freight?: string;
|
|
1832
|
+
readonly discount?: string;
|
|
1833
|
+
}): Totals;
|
|
1834
|
+
/**
|
|
1835
|
+
* Frete menos desconto distribuído pelas linhas na proporção do valor de cada uma, em centavos exatos: a soma do
|
|
1836
|
+
* rateio é igual ao líquido (o resto vai para as maiores frações, maior resto). Devolve o valor rateado por linha.
|
|
1837
|
+
*/
|
|
1838
|
+
declare function allocateExtras(params: {
|
|
1839
|
+
readonly lineTotals: readonly string[];
|
|
1840
|
+
readonly freight: string;
|
|
1841
|
+
readonly discount: string;
|
|
1842
|
+
}): string[];
|
|
1843
|
+
/**
|
|
1844
|
+
* Custo por unidade de estoque: (valor da linha + rateio) ÷ (quantidade × unidades por compra). 4 casas.
|
|
1845
|
+
* `null` quando a quantidade em estoque é zero.
|
|
1846
|
+
*/
|
|
1847
|
+
declare function landedUnitCost(params: {
|
|
1848
|
+
readonly lineTotal: string;
|
|
1849
|
+
readonly allocated: string;
|
|
1850
|
+
readonly quantity: string;
|
|
1851
|
+
readonly unitsPerPurchase: string;
|
|
1852
|
+
}): string | null;
|
|
1853
|
+
/** Quantidade em unidade de estoque (`2 cx × 12` = `24`). */
|
|
1854
|
+
declare function toStockQuantity(quantity: string, unitsPerPurchase: string): string;
|
|
1855
|
+
declare function pendingQuantity(params: {
|
|
1856
|
+
readonly quantity: string;
|
|
1857
|
+
readonly receivedQuantity: string;
|
|
1858
|
+
readonly canceledQuantity: string;
|
|
1859
|
+
}): string;
|
|
1860
|
+
/** Status depois de um recebimento: tudo chegou (ou foi encerrado) = `received`. */
|
|
1861
|
+
declare function statusAfterReceipt(lines: readonly {
|
|
1862
|
+
readonly quantity: string;
|
|
1863
|
+
readonly receivedQuantity: string;
|
|
1864
|
+
readonly canceledQuantity: string;
|
|
1865
|
+
}[]): OrderStatus;
|
|
1866
|
+
/** Diferença entre o pedido e o que chegou. Tolerância de preço em centavos (padrão: zero). */
|
|
1867
|
+
declare function divergenceOf(params: {
|
|
1868
|
+
readonly pendingQuantity: string | null;
|
|
1869
|
+
readonly receivedQuantity: string;
|
|
1870
|
+
readonly orderedPrice: string | null;
|
|
1871
|
+
readonly receivedPrice: string;
|
|
1872
|
+
readonly priceToleranceCents?: bigint;
|
|
1873
|
+
}): Divergence;
|
|
1874
|
+
/** Média ponderada pela quantidade (custo × quantidade ÷ quantidade). `null` sem nada para ponderar. */
|
|
1875
|
+
declare function weightedAverageCost(points: readonly {
|
|
1876
|
+
readonly cost: string;
|
|
1877
|
+
readonly quantity: string;
|
|
1878
|
+
}[]): string | null;
|
|
1879
|
+
declare const UNIT_FACTOR_ONE: string;
|
|
1880
|
+
|
|
1881
|
+
/**
|
|
1882
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
1883
|
+
*
|
|
1884
|
+
* Parcelas pela condição de pagamento do fornecedor (`[30, 60, 90]` dias a partir da data base). Centavos exatos:
|
|
1885
|
+
* a diferença do arredondamento vai na primeira parcela, como no boleto.
|
|
1886
|
+
*/
|
|
1887
|
+
|
|
1888
|
+
declare function isCivilDate(value: string): boolean;
|
|
1889
|
+
declare function addDays(date: string, days: number): string;
|
|
1890
|
+
/** Data civil de um instante num fuso (`America/Sao_Paulo`). */
|
|
1891
|
+
declare function civilDateIn(instant: Date, timeZone: string): string;
|
|
1892
|
+
declare function buildInstallments(params: {
|
|
1893
|
+
readonly total: string;
|
|
1894
|
+
readonly termDays: readonly number[];
|
|
1895
|
+
readonly baseDate: string;
|
|
1896
|
+
}): Installment[];
|
|
1897
|
+
/** `"30/60/90"`, `"30 60 90"`, `"à vista"` → `[30, 60, 90]` / `[0]`. `null` quando ilegível. */
|
|
1898
|
+
declare function parsePaymentTerms(text: string): number[] | null;
|
|
1899
|
+
declare function formatPaymentTerms(days: readonly number[]): string;
|
|
1900
|
+
|
|
1901
|
+
/**
|
|
1902
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
1903
|
+
*
|
|
1904
|
+
* Texto do pedido para o fornecedor (WhatsApp ou copiar e colar). Sem preço por padrão: o combinado fica no
|
|
1905
|
+
* sistema, o fornecedor confirma quantidade e entrega.
|
|
1906
|
+
*/
|
|
1907
|
+
type OrderMessageInput = {
|
|
1908
|
+
readonly companyName: string;
|
|
1909
|
+
readonly number: number;
|
|
1910
|
+
readonly supplierName: string;
|
|
1911
|
+
readonly expectedAt: string | null;
|
|
1912
|
+
readonly paymentTermDays: readonly number[];
|
|
1913
|
+
readonly notes: string;
|
|
1914
|
+
readonly total: string;
|
|
1915
|
+
readonly lines: readonly {
|
|
1916
|
+
readonly itemName: string;
|
|
1917
|
+
readonly supplierSku: string | null;
|
|
1918
|
+
readonly quantity: string;
|
|
1919
|
+
readonly purchaseUnit: string;
|
|
1920
|
+
readonly unitPrice: string;
|
|
1921
|
+
}[];
|
|
1922
|
+
};
|
|
1923
|
+
/** `12.5000` → `12,5`; `3.0000` → `3`. */
|
|
1924
|
+
declare function formatQuantityPt(value: string): string;
|
|
1925
|
+
declare function formatMoneyPt(value: string): string;
|
|
1926
|
+
declare function buildOrderMessage(input: OrderMessageInput, options?: {
|
|
1927
|
+
readonly withPrices?: boolean;
|
|
1928
|
+
}): string;
|
|
1929
|
+
|
|
1930
|
+
/**
|
|
1931
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
1932
|
+
*
|
|
1933
|
+
* Contas de pedido e nota sobre a aritmética exata do `recipe-contracts`: nada de ponto flutuante. Linha e total
|
|
1934
|
+
* fecham em centavos (meio para cima); custo por unidade de estoque fica com 4 casas.
|
|
1935
|
+
*/
|
|
1936
|
+
|
|
1937
|
+
declare const MONEY_SCALE = 2;
|
|
1938
|
+
declare function money(value: Rational): string;
|
|
1939
|
+
declare function quantityText(value: Rational): string;
|
|
1940
|
+
/** `quantity × unitPrice` em centavos (a linha mostrada ao fornecedor). */
|
|
1941
|
+
declare function lineTotal(quantity: string, unitPrice: string): Rational;
|
|
1942
|
+
/** Centavos exatos (arredonda meio para cima antes). */
|
|
1943
|
+
declare function centsOf(value: Rational): bigint;
|
|
1944
|
+
|
|
1945
|
+
/**
|
|
1946
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
1947
|
+
*
|
|
1948
|
+
* Lê o XML de uma NF-e modelo 55 recebida (`nfeProc` ou `NFe` sozinha) e devolve o que o recebimento precisa:
|
|
1949
|
+
* emitente, número, chave, itens (código do fornecedor, quantidade, unidade, preço, lote e validade do `rastro`),
|
|
1950
|
+
* frete, desconto e duplicatas. Não valida assinatura nem consulta a SEFAZ: é leitura para preencher a conferência.
|
|
1951
|
+
*/
|
|
1952
|
+
type NfeItem = {
|
|
1953
|
+
/** `nItem` da nota (1…990). */
|
|
1954
|
+
readonly itemNumber: number;
|
|
1955
|
+
readonly supplierSku: string;
|
|
1956
|
+
readonly ean: string | null;
|
|
1957
|
+
readonly description: string;
|
|
1958
|
+
readonly ncm: string | null;
|
|
1959
|
+
readonly cfop: string | null;
|
|
1960
|
+
/** Unidade comercial (`CX`, `UN`, `KG`), como veio. */
|
|
1961
|
+
readonly unit: string;
|
|
1962
|
+
readonly quantity: string;
|
|
1963
|
+
readonly unitPrice: string;
|
|
1964
|
+
readonly total: string;
|
|
1965
|
+
readonly discount: string;
|
|
1966
|
+
readonly freight: string;
|
|
1967
|
+
readonly batches: readonly {
|
|
1968
|
+
readonly batchCode: string;
|
|
1969
|
+
readonly quantity: string;
|
|
1970
|
+
readonly expiresAt: string | null;
|
|
1971
|
+
}[];
|
|
1972
|
+
};
|
|
1973
|
+
type NfeInstallment = {
|
|
1974
|
+
readonly number: string;
|
|
1975
|
+
readonly dueDate: string;
|
|
1976
|
+
readonly amount: string;
|
|
1977
|
+
};
|
|
1978
|
+
type ParsedNfe = {
|
|
1979
|
+
readonly accessKey: string;
|
|
1980
|
+
readonly number: string;
|
|
1981
|
+
readonly series: string | null;
|
|
1982
|
+
/** ISO com fuso, como na nota. */
|
|
1983
|
+
readonly issuedAt: string | null;
|
|
1984
|
+
readonly issuer: {
|
|
1985
|
+
readonly document: string | null;
|
|
1986
|
+
readonly name: string;
|
|
1987
|
+
readonly tradeName: string | null;
|
|
1988
|
+
};
|
|
1989
|
+
readonly recipientDocument: string | null;
|
|
1990
|
+
readonly items: readonly NfeItem[];
|
|
1991
|
+
readonly totals: {
|
|
1992
|
+
readonly products: string;
|
|
1993
|
+
readonly freight: string;
|
|
1994
|
+
readonly discount: string;
|
|
1995
|
+
readonly other: string;
|
|
1996
|
+
readonly total: string;
|
|
1997
|
+
};
|
|
1998
|
+
readonly installments: readonly NfeInstallment[];
|
|
1999
|
+
};
|
|
2000
|
+
declare class NfeParseError extends Error {
|
|
2001
|
+
constructor(message: string);
|
|
2002
|
+
}
|
|
2003
|
+
declare function parseNfeXml(xml: string): ParsedNfe;
|
|
2004
|
+
|
|
2005
|
+
export { type CatalogItem, type ClockPort, type CreateOrderData, type CreateOrderInput, type CreateSupplierData, type CreateSupplierInput, type CreateSupplierItemData, type CreateSupplierItemInput, DEFAULT_PURCHASE_SCOPES, DISPATCH_CHANNEL, DISPATCH_CHANNELS, DIVERGENCE, type DemandRow, type DemandSourcePort, type DispatchChannel, DispatchUnavailableError, type Divergence, type ExportFormatQuery, INTEGRATION_STATUS, type IncomingSupply, type Installment, InstallmentsMismatchError, type IntegrationStatus, InvalidOrderTransitionError, InvoiceAlreadyReceivedError, type ItemCatalogPort, type ItemCost, type ItemRefsLookupData, type ListOrdersQuery, type ListReceiptsQuery, type ListSupplierItemsQuery, type ListSuppliersQuery, type LogMeta, type LoggerPort, MONEY_SCALE, type NfeInstallment, NfeInvalidError, type NfeItem, NfeParseError, type NfePreview, type NfePreviewData, type NfePreviewLine, OPEN_ORDER_STATUSES, ORDER_ACTION, ORDER_SORTS, ORDER_STATUS, ORDER_STATUSES, type OptionalReasonData, type OrderAction, type OrderDispatchPort, type OrderLine, type OrderLineData, type OrderLineInput, OrderLineNotFoundError, type OrderMessageInput, OrderNotFoundError, type OrderSort, type OrderStatus, type OrdersFromSuggestionData, PAYMENT_STATUS, PURCHASE_ERROR_CODES, PURCHASE_LIMITS, type ParsedNfe, type PayableRequest, type PayablesPort, type PaymentStatus, type PriceHistoryQuery, type PricePoint, type PricedLine, PurchaseConfigMissingError, PurchaseDisabledError, PurchaseError, type PurchaseHooks, PurchaseItemNotFoundError, type PurchaseModuleConfig, type PurchaseOrder, type PurchaseOrderSummary, type PurchaseScopes, type PurchaseSuggestion, PurchaseUnauthenticatedError, REPORT_GROUP, REPORT_GROUPS, type ReasonData, type Receipt, type ReceiptLine, type ReceiptLineData, type ReceiptLineInput, ReceiptNotFoundError, type ReceiptPostedLine, type ReceiveData, type ReceiveInput, type ReportGroup, ReportRangeTooLongError, SORT_ORDER, SUPPLIER_SORTS, SelfApprovalError, type SendOrderData, type SortOrder, type SpendReport, type SpendReportQuery, type SpendRow, type StockReceiptPort, type SuggestionGroup, type SuggestionLine, type SuggestionQuery, type SuggestionSupplier, type SuggestionSupplierItem, type Supplier, SupplierDocumentTakenError, SupplierInUseError, SupplierInactiveError, type SupplierItem, SupplierItemNotFoundError, SupplierItemTakenError, type SupplierLookupData, SupplierNoContactError, SupplierNotFoundError, type SupplierPerformanceQuery, type SupplierPerformanceReport, type SupplierPerformanceRow, type SupplierSort, type Totals, UNIT_FACTOR_ONE, type UpdateOrderData, type UpdateSupplierData, type UpdateSupplierInput, type UpdateSupplierItemData, addDays, allocateExtras, allowedActions, buildInstallments, buildOrderMessage, buildSuggestion, canPerform, centsOf, civilDateIn, computeTotals, createOrderSchema, createSupplierItemSchema, createSupplierSchema, divergenceOf, exportFormatSchema, formatMoneyPt, formatPaymentTerms, formatQuantityPt, isCivilDate, isOrderLate, itemRefsLookupSchema, landedUnitCost, lineTotal, listOrdersQuerySchema, listReceiptsQuerySchema, listSupplierItemsQuerySchema, listSuppliersQuerySchema, money, moneySchema, nfePreviewSchema, optionalReasonSchema, orderLineInputSchema, ordersFromSuggestionSchema, packsFor, parseNfeXml, parsePaymentTerms, pendingQuantity, priceHistoryQuerySchema, quantityText, reasonSchema, receiptLineInputSchema, receiveSchema, requiresApproval, sendOrderSchema, shortageOf, spendReportQuerySchema, statusAfterReceipt, statusAfterSend, stockQuantityOf, suggestionQuerySchema, supplierLookupSchema, supplierPerformanceQuerySchema, toStockQuantity, updateOrderSchema, updateSupplierItemSchema, updateSupplierSchema, weightedAverageCost };
|