@marmot-systems/common 2.0.34 → 2.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +100 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -25
- package/dist/index.d.ts +39 -25
- package/dist/index.js +98 -74
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,8 @@ __export(index_exports, {
|
|
|
26
26
|
CustomerFormSchema: () => CustomerFormSchema,
|
|
27
27
|
INVOICE_STATUS: () => INVOICE_STATUS,
|
|
28
28
|
INVOICE_TYPE: () => INVOICE_TYPE,
|
|
29
|
+
PAYMENT_METHOD: () => PAYMENT_METHOD,
|
|
30
|
+
PaymentFormSchema: () => PaymentFormSchema,
|
|
29
31
|
ProductFormSchema: () => ProductFormSchema,
|
|
30
32
|
PurchaseInvoiceSchema: () => PurchaseInvoiceSchema,
|
|
31
33
|
RegisterFormSchema: () => RegisterFormSchema,
|
|
@@ -181,55 +183,12 @@ var CustomerFormSchema = import_zod3.z.strictObject({
|
|
|
181
183
|
).optional()
|
|
182
184
|
});
|
|
183
185
|
|
|
184
|
-
// src/schemas/product_schemas.ts
|
|
185
|
-
var import_zod4 = require("zod");
|
|
186
|
-
var ProductFormSchema = import_zod4.z.strictObject({
|
|
187
|
-
product_name: import_zod4.z.string().transform(normalizeSpaces).pipe(
|
|
188
|
-
import_zod4.z.string().min(1, "Product name is required").max(50, "Product name must be at most 50 characters.")
|
|
189
|
-
),
|
|
190
|
-
product_description: import_zod4.z.string().transform(normalizeSpaces).pipe(
|
|
191
|
-
import_zod4.z.string().max(100, "Product desription must be at most 100 characters.")
|
|
192
|
-
).transform(transformEmptyStringToUndefined).optional(),
|
|
193
|
-
product_sku: import_zod4.z.string().transform(normalizeSpaces).pipe(import_zod4.z.string().max(30, "Product SKU must be at most 30 characters.")).transform(transformEmptyStringToUndefined).optional(),
|
|
194
|
-
product_upc: import_zod4.z.string().transform((s) => s.replace(/\s+/g, "")).refine((s) => s === "" || /^\d{12}$/.test(s), {
|
|
195
|
-
error: "UPC must be exactly 12 digits"
|
|
196
|
-
}).transform(transformEmptyStringToUndefined).optional(),
|
|
197
|
-
product_gtin_14: import_zod4.z.string().transform((s) => s.replace(/\s+/g, "")).refine((s) => s === "" || /^\d{14}$/.test(s), {
|
|
198
|
-
error: "GTIN14 must be exactly 14 digits"
|
|
199
|
-
}).transform(transformEmptyStringToUndefined).optional(),
|
|
200
|
-
product_type: import_zod4.z.enum(["unit", "weight", "case"], {
|
|
201
|
-
error: "Product type must be unit, weight, or case."
|
|
202
|
-
}),
|
|
203
|
-
weight_unit: import_zod4.z.preprocess((v) => {
|
|
204
|
-
if (v === "") return void 0;
|
|
205
|
-
if (typeof v === "string") return v.trim().toLowerCase();
|
|
206
|
-
return v;
|
|
207
|
-
}, import_zod4.z.enum(["kg", "lb", "g", "oz"]).optional()),
|
|
208
|
-
price: handleZodCurrency(0, 99999.99),
|
|
209
|
-
cost: handleZodCurrency(0, 99999.99)
|
|
210
|
-
}).superRefine((data, ctx) => {
|
|
211
|
-
if (data.product_type === "weight" && !data.weight_unit) {
|
|
212
|
-
ctx.addIssue({
|
|
213
|
-
code: "custom",
|
|
214
|
-
error: "Weight unit is required.",
|
|
215
|
-
path: ["weight_unit"]
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
if (data.product_type !== "weight" && typeof data.weight_unit !== "undefined") {
|
|
219
|
-
ctx.addIssue({
|
|
220
|
-
code: "custom",
|
|
221
|
-
error: "Weight unit must be empty",
|
|
222
|
-
path: ["weight_unit"]
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
|
|
227
186
|
// src/types/shared_types.ts
|
|
228
|
-
var
|
|
229
|
-
var uuidSchema =
|
|
187
|
+
var import_zod4 = require("zod");
|
|
188
|
+
var uuidSchema = import_zod4.z.uuid();
|
|
230
189
|
|
|
231
190
|
// src/domains/invoices/invoices_schemas.ts
|
|
232
|
-
var
|
|
191
|
+
var import_zod5 = require("zod");
|
|
233
192
|
|
|
234
193
|
// src/domains/invoices/invoices_types.ts
|
|
235
194
|
var INVOICE_TYPE = ["sales", "credit", "purchase"];
|
|
@@ -237,15 +196,15 @@ var INVOICE_STATUS = ["finalized", "voided"];
|
|
|
237
196
|
var CREDIT_TYPE = ["dump", "return"];
|
|
238
197
|
|
|
239
198
|
// src/domains/invoices/invoices_schemas.ts
|
|
240
|
-
var YmdDateSchema =
|
|
241
|
-
var BaseInvoice =
|
|
242
|
-
invoice_type:
|
|
199
|
+
var YmdDateSchema = import_zod5.z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Use YYYY-MM-DD");
|
|
200
|
+
var BaseInvoice = import_zod5.z.object({
|
|
201
|
+
invoice_type: import_zod5.z.enum(INVOICE_TYPE, { error: "Invoice type not found." }),
|
|
243
202
|
invoice_date: YmdDateSchema,
|
|
244
203
|
due_date: YmdDateSchema,
|
|
245
|
-
tax_rate:
|
|
246
|
-
tax_amount:
|
|
247
|
-
warehouse_id:
|
|
248
|
-
invoice_status:
|
|
204
|
+
tax_rate: import_zod5.z.number().default(0),
|
|
205
|
+
tax_amount: import_zod5.z.number().default(0),
|
|
206
|
+
warehouse_id: import_zod5.z.uuid().optional(),
|
|
207
|
+
invoice_status: import_zod5.z.enum(INVOICE_STATUS).default("finalized")
|
|
249
208
|
}).superRefine(({ invoice_date, due_date }, ctx) => {
|
|
250
209
|
if (due_date < invoice_date) {
|
|
251
210
|
ctx.addIssue({
|
|
@@ -255,46 +214,46 @@ var BaseInvoice = import_zod6.z.object({
|
|
|
255
214
|
});
|
|
256
215
|
}
|
|
257
216
|
});
|
|
258
|
-
var LineItemBase =
|
|
259
|
-
invoice_id:
|
|
260
|
-
product_id:
|
|
261
|
-
product_name:
|
|
262
|
-
product_description:
|
|
263
|
-
product_type:
|
|
264
|
-
product_upc:
|
|
265
|
-
weight_unit:
|
|
217
|
+
var LineItemBase = import_zod5.z.object({
|
|
218
|
+
invoice_id: import_zod5.z.uuid().optional(),
|
|
219
|
+
product_id: import_zod5.z.uuid({ error: "Select a product" }),
|
|
220
|
+
product_name: import_zod5.z.string().optional(),
|
|
221
|
+
product_description: import_zod5.z.string().optional(),
|
|
222
|
+
product_type: import_zod5.z.enum(["unit", "weight", "case"]).optional(),
|
|
223
|
+
product_upc: import_zod5.z.string().optional(),
|
|
224
|
+
weight_unit: import_zod5.z.enum(["kg", "lb", "g", "oz"]).optional(),
|
|
266
225
|
quantity: handleZodCurrency(0.01, 99999.99)
|
|
267
226
|
});
|
|
268
227
|
var SalesItem = LineItemBase.safeExtend({
|
|
269
228
|
price: handleZodCurrency(0, 99999.99),
|
|
270
|
-
credit_type:
|
|
229
|
+
credit_type: import_zod5.z.undefined()
|
|
271
230
|
});
|
|
272
231
|
var CreditItem = LineItemBase.safeExtend({
|
|
273
232
|
price: handleZodCurrency(0, 99999.99),
|
|
274
|
-
credit_type:
|
|
233
|
+
credit_type: import_zod5.z.enum(CREDIT_TYPE, {
|
|
275
234
|
error: "Select a credit type"
|
|
276
235
|
})
|
|
277
236
|
});
|
|
278
237
|
var PurchaseItem = LineItemBase.safeExtend({
|
|
279
238
|
price: handleZodCurrency(0, 99999.99),
|
|
280
|
-
credit_type:
|
|
239
|
+
credit_type: import_zod5.z.undefined()
|
|
281
240
|
});
|
|
282
241
|
var SalesInvoiceSchema = BaseInvoice.safeExtend({
|
|
283
|
-
invoice_type:
|
|
284
|
-
party_id:
|
|
285
|
-
invoice_items:
|
|
242
|
+
invoice_type: import_zod5.z.literal("sales"),
|
|
243
|
+
party_id: import_zod5.z.uuid({ message: "Select a customer" }),
|
|
244
|
+
invoice_items: import_zod5.z.array(SalesItem).min(1, "Add at least one invoice item")
|
|
286
245
|
});
|
|
287
246
|
var CreditInvoiceSchema = BaseInvoice.safeExtend({
|
|
288
|
-
invoice_type:
|
|
289
|
-
party_id:
|
|
290
|
-
invoice_items:
|
|
247
|
+
invoice_type: import_zod5.z.literal("credit"),
|
|
248
|
+
party_id: import_zod5.z.uuid({ message: "Select a customer" }),
|
|
249
|
+
invoice_items: import_zod5.z.array(CreditItem).min(1, "Add at least one invoice item")
|
|
291
250
|
});
|
|
292
251
|
var PurchaseInvoiceSchema = BaseInvoice.safeExtend({
|
|
293
|
-
invoice_type:
|
|
294
|
-
party_id:
|
|
295
|
-
invoice_items:
|
|
252
|
+
invoice_type: import_zod5.z.literal("purchase"),
|
|
253
|
+
party_id: import_zod5.z.uuid({ message: "Select a vendor" }),
|
|
254
|
+
invoice_items: import_zod5.z.array(PurchaseItem).min(1, "Add at least one invoice item")
|
|
296
255
|
});
|
|
297
|
-
var AnyInvoiceSchema =
|
|
256
|
+
var AnyInvoiceSchema = import_zod5.z.discriminatedUnion("invoice_type", [
|
|
298
257
|
SalesInvoiceSchema,
|
|
299
258
|
PurchaseInvoiceSchema,
|
|
300
259
|
CreditInvoiceSchema
|
|
@@ -355,6 +314,71 @@ var exceedsTwoDecimals = (raw) => {
|
|
|
355
314
|
const digitsAfter = ((_a = after.match(/\d/g)) != null ? _a : []).length;
|
|
356
315
|
return digitsAfter > 2;
|
|
357
316
|
};
|
|
317
|
+
|
|
318
|
+
// src/domains/products/product_schemas.ts
|
|
319
|
+
var import_zod6 = require("zod");
|
|
320
|
+
var ProductFormSchema = import_zod6.z.strictObject({
|
|
321
|
+
product_name: import_zod6.z.string().transform(normalizeSpaces).pipe(
|
|
322
|
+
import_zod6.z.string().min(1, "Product name is required").max(50, "Product name must be at most 50 characters.")
|
|
323
|
+
),
|
|
324
|
+
product_description: import_zod6.z.string().transform(normalizeSpaces).pipe(
|
|
325
|
+
import_zod6.z.string().max(100, "Product desription must be at most 100 characters.")
|
|
326
|
+
).transform(transformEmptyStringToUndefined).optional(),
|
|
327
|
+
product_sku: import_zod6.z.string().transform(normalizeSpaces).pipe(import_zod6.z.string().max(30, "Product SKU must be at most 30 characters.")).transform(transformEmptyStringToUndefined).optional(),
|
|
328
|
+
product_upc: import_zod6.z.string().transform((s) => s.replace(/\s+/g, "")).refine((s) => s === "" || /^\d{12}$/.test(s), {
|
|
329
|
+
error: "UPC must be exactly 12 digits"
|
|
330
|
+
}).transform(transformEmptyStringToUndefined).optional(),
|
|
331
|
+
product_gtin_14: import_zod6.z.string().transform((s) => s.replace(/\s+/g, "")).refine((s) => s === "" || /^\d{14}$/.test(s), {
|
|
332
|
+
error: "GTIN14 must be exactly 14 digits"
|
|
333
|
+
}).transform(transformEmptyStringToUndefined).optional(),
|
|
334
|
+
product_type: import_zod6.z.enum(["unit", "weight", "case"], {
|
|
335
|
+
error: "Product type must be unit, weight, or case."
|
|
336
|
+
}),
|
|
337
|
+
weight_unit: import_zod6.z.preprocess((v) => {
|
|
338
|
+
if (v === "") return void 0;
|
|
339
|
+
if (typeof v === "string") return v.trim().toLowerCase();
|
|
340
|
+
return v;
|
|
341
|
+
}, import_zod6.z.enum(["kg", "lb", "g", "oz"]).optional()),
|
|
342
|
+
price: handleZodCurrency(0, 99999.99),
|
|
343
|
+
cost: handleZodCurrency(0, 99999.99)
|
|
344
|
+
}).superRefine((data, ctx) => {
|
|
345
|
+
if (data.product_type === "weight" && !data.weight_unit) {
|
|
346
|
+
ctx.addIssue({
|
|
347
|
+
code: "custom",
|
|
348
|
+
error: "Weight unit is required.",
|
|
349
|
+
path: ["weight_unit"]
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
if (data.product_type !== "weight" && typeof data.weight_unit !== "undefined") {
|
|
353
|
+
ctx.addIssue({
|
|
354
|
+
code: "custom",
|
|
355
|
+
error: "Weight unit must be empty",
|
|
356
|
+
path: ["weight_unit"]
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
// src/domains/payments/payments_schemas.ts
|
|
362
|
+
var import_zod7 = require("zod");
|
|
363
|
+
|
|
364
|
+
// src/domains/payments/payments_types.ts
|
|
365
|
+
var PAYMENT_METHOD = [
|
|
366
|
+
"check",
|
|
367
|
+
"cash",
|
|
368
|
+
"bank_transfer",
|
|
369
|
+
"digital_wallet"
|
|
370
|
+
];
|
|
371
|
+
|
|
372
|
+
// src/domains/payments/payments_schemas.ts
|
|
373
|
+
var PaymentFormSchema = import_zod7.z.strictObject({
|
|
374
|
+
payment_method: import_zod7.z.enum(PAYMENT_METHOD, {
|
|
375
|
+
error: "Payment method is required."
|
|
376
|
+
}),
|
|
377
|
+
check_number: import_zod7.z.string().transform(normalizeSpaces).pipe(
|
|
378
|
+
import_zod7.z.string().max(50, "Payment check number must be at most 50 characters.")
|
|
379
|
+
).transform(transformEmptyStringToUndefined).optional(),
|
|
380
|
+
payment_amount: handleZodCurrency(0.01, 999999.99)
|
|
381
|
+
});
|
|
358
382
|
// Annotate the CommonJS export names for ESM import in node:
|
|
359
383
|
0 && (module.exports = {
|
|
360
384
|
AnyInvoiceSchema,
|
|
@@ -363,6 +387,8 @@ var exceedsTwoDecimals = (raw) => {
|
|
|
363
387
|
CustomerFormSchema,
|
|
364
388
|
INVOICE_STATUS,
|
|
365
389
|
INVOICE_TYPE,
|
|
390
|
+
PAYMENT_METHOD,
|
|
391
|
+
PaymentFormSchema,
|
|
366
392
|
ProductFormSchema,
|
|
367
393
|
PurchaseInvoiceSchema,
|
|
368
394
|
RegisterFormSchema,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/schemas/companies_schemas.ts","../src/types/company_types.ts","../src/types/money_types.ts","../src/utils/utils.ts","../src/schemas/customer_schemas.ts","../src/schemas/product_schemas.ts","../src/types/shared_types.ts","../src/domains/invoices/invoices_schemas.ts","../src/domains/invoices/invoices_types.ts","../src/utils/date_utils.ts","../src/utils/errors_utils.ts","../src/utils/money_utils.ts"],"sourcesContent":["export * from \"./schemas/companies_schemas\";\nexport * from \"./schemas/customer_schemas\";\nexport * from \"./schemas/product_schemas\";\nexport * from \"./utils/utils\";\nexport {\n UserRole,\n IsoCountryCode,\n InventorySystem,\n} from \"./types/company_types\";\nexport { CreatedLocation, UUID } from \"./types/shared_types\";\nexport { SyncInvoice } from \"./types/sync_types\";\nexport * from \"./types/customers_types\";\nexport * from \"./types/vendors_types\";\nexport * from \"./domains/invoices/invoices_schemas\";\nexport * from \"./domains/invoices/invoices_types\";\nexport * from \"./domains/products/products_types\";\nexport * from \"./utils/date_utils\";\nexport * from \"./utils/errors_utils\";\n\n// Money\nexport * from \"./utils/money_utils\";\nexport * from \"./types/money_types\";\n","import { z } from \"zod\";\nimport { ISO_COUNTRY_CODES, USER_ROLES } from \"../types/company_types\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nconst iso_country_code = z.enum(ISO_COUNTRY_CODES, {\n error: \"Country code not supported.\",\n});\n\nconst user_role = z.enum(USER_ROLES, {\n error: \"User role not supported.\",\n});\n\nexport const RegisterFormSchema = z.strictObject({\n companyData: z.strictObject({\n company_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company name is required\")\n .max(50, \"Company name must be at most 50 characters.\")\n ),\n company_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company address is required\")\n .max(100, \"Company address must be at most 100 characters.\")\n ),\n company_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => /^\\d{4,15}$/.test(s), {\n error: \"Phone number required and must be from 4 to 15 digits.\",\n }),\n iso_country_code: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform((s) => s.toUpperCase())\n .pipe(iso_country_code),\n }),\n adminUserData: z.strictObject({\n user_first_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"First name is required\")\n .max(50, \"First name must be at most 50 characters.\")\n ),\n user_last_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Last name is required\")\n .max(50, \"Last name must be at most 50 characters.\")\n ),\n user_email: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n ),\n password: z\n .string()\n .min(8, \"Password must be at least 8 characters\")\n .max(25, \"Password must be at most 25 characters\")\n .regex(/[A-Z]/, \"Password must contain at least one uppercase letter\")\n .regex(/[a-z]/, \"Password must contain at least one lowercase letter\")\n .regex(/\\d/, \"Password must contain at least one number\")\n .regex(\n /[@$!%*?&#^_+=-]/,\n \"Password must contain at least one special character\"\n )\n .regex(/^\\S*$/, \"Password cannot contain spaces or other whitespace.\"),\n }),\n});\n","export const ISO_COUNTRY_CODES = [\"US\", \"HN\"] as const;\n\nexport type IsoCountryCode = (typeof ISO_COUNTRY_CODES)[number];\n\nexport const USER_ROLES = [\"admin\", \"driver\"] as const;\n\nexport type UserRole = (typeof USER_ROLES)[number];\n\nexport type InventorySystem = \"warehouse_only\" | \"dsd\";\n","import { IsoCountryCode } from \"../types/company_types\";\n\nexport type IsoCurrencyCode = \"USD\" | \"HNL\";\ntype Locale = \"en-US\" | \"es-HN\";\n\nexport const countryToCurrency: Record<IsoCountryCode, IsoCurrencyCode> = {\n US: \"USD\",\n HN: \"HNL\",\n};\n\nexport const currencyToLocale: Record<IsoCurrencyCode, Locale> = {\n USD: \"en-US\",\n HNL: \"es-HN\",\n};\n","import * as GlobalTypes from \"./types\";\nimport { IsoCountryCode } from \"../types/company_types\";\nimport {\n IsoCurrencyCode,\n countryToCurrency,\n currencyToLocale,\n} from \"../types/money_types\";\n\nimport { z } from \"zod\";\n\n/**\n * Validates zod currency with precision.\n *\n *\n * @param minAmount\n * @param maxAmount\n * @returns\n */\nexport function handleZodCurrency(minAmount: number, maxAmount: number) {\n const fromString = z\n .string({\n error: \"Enter a valid number\",\n })\n .refine((s) => s.trim().length > 0, { error: \"Enter a valid number\" })\n .transform((s) => s.replace(/[,\\s]/g, \"\"))\n .refine((s) => s !== \"\" && !Number.isNaN(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number.isFinite(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number(s) >= 0, { error: \"Enter a positive number\" })\n .transform((s) => Number(s));\n\n const fromNumber = z\n .number()\n .refine((n) => Number.isFinite(n), { error: \"Enter a valid number\" })\n .refine((n) => n >= 0, { error: \"Enter a positive number\" });\n\n return z\n .union([fromString, fromNumber])\n .transform((n) => roundWithPrecision(n, 2))\n .refine((n) => n >= minAmount, {\n error: `Must be greater than ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `Exceeds allowed limit ${maxAmount}`,\n });\n}\n\n/**\n * Trims any leading or trailing spaces\n * Transforms empty strings into undefined.\n *\n * @param s\n * @returns\n */\nexport const transformEmptyStringToUndefined = (s: string) =>\n s.trim() === \"\" ? undefined : s;\n\n/**\n * - Collapses any run of whitespace in a string (spaces, tabs, newlines, nbspb, and other weird unicode spaces etc.)\n * into a single ASCII space.\n * - Trims leading and trailing whitespace.\n * \" Jared \\n Gomez \\t Driver\\t \" -> \"Jared Gomez Driver\"\n *\n * @param s\n * @returns\n */\nexport const normalizeSpaces = (s: string) => whitespace(s, \"normalize\");\n\n/**\n * Removes all whitespace from a string\n * @param s\n * @returns\n */\nexport const removeAllWhitespace = (s: string) => whitespace(s, \"remove\");\n\nconst whitespace = (s: string, mode: GlobalTypes.WhitespaceMode) => {\n if (mode === \"remove\") {\n return s.replace(/\\s+/g, \"\");\n }\n\n return s.replace(/\\s+/g, \" \").trim();\n};\n\n/**\n * Removes all dashes and + signs from a string\n * +1-305-555-0123 -> \"13055550123\"\n * 305-555-0123 -> \"3055550123\"\n *\n * @param s\n * @returns\n */\nexport const removeDashesAndPlusSign = (s: string): string =>\n s.replace(/[+-]/g, \"\");\n\n/**\n * Rounds a number to a certain precision.\n * Contract:\n * 1. Number must be finite and non negative.\n * 2. Precision must be finite nonnegative and an integer.\n * 3. Precision must be <= Max precision\n * 4. Returns a number >= 0\n * Default is round half up.\n *\n * @param num\n * @param precision\n * @param opts\n * @returns\n */\nexport function roundWithPrecision(\n num: number,\n precision: number,\n opts?: GlobalTypes.ToFixedOptions\n): number {\n const MAX_PRECISION = 2;\n const { roundType = \"half_up\" } = opts ?? {};\n\n if (!Number.isFinite(num) || num < 0) {\n throw new RangeError(\"Number must be finite and greater than 0.\");\n }\n\n if (\n !Number.isFinite(precision) ||\n !Number.isInteger(precision) ||\n precision < 1\n ) {\n throw new RangeError(\"Precision must be a finite integer greater than 0.\");\n }\n\n if (precision > MAX_PRECISION) {\n throw new RangeError(\"Max precision allowed is 2.\");\n }\n\n return Number(\n (+(Math.round(+(num + \"e\" + precision)) + \"e\" + -precision)).toFixed(\n precision\n )\n );\n}\n\nexport function getCurrencyFromCountry(\n country: IsoCountryCode\n): IsoCurrencyCode {\n return countryToCurrency[country];\n}\n\nexport function formatMoneyCurrency(value: number, currency: IsoCurrencyCode) {\n const locale =\n currency in currencyToLocale ? currencyToLocale[currency] : \"en-US\";\n\n const formatted = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: currency,\n }).format(value);\n\n return sanitizeSpaces(formatted);\n}\n\nfunction sanitizeSpaces(str: string): string {\n return str\n .replace(/\\u00A0/g, \" \")\n .replace(/\\u202F/g, \" \")\n .replace(/[^\\x20-\\x7E]/g, \"\");\n}\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nexport const CustomerFormSchema = z.strictObject({\n customer_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Customer name is required\")\n .max(50, \"Customer name must be at most 50 characters.\")\n ),\n\n customer_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z.string().max(100, \"Customer address must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => s === \"\" || /^\\d{4,15}$/.test(s), {\n error: \"Phone number must be from 4 to 15 digits.\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_email_address: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n .optional()\n )\n .optional(),\n});\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nexport const ProductFormSchema = z\n .strictObject({\n product_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Product name is required\")\n .max(50, \"Product name must be at most 50 characters.\")\n ),\n\n product_description: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .max(100, \"Product desription must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_sku: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(z.string().max(30, \"Product SKU must be at most 30 characters.\"))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_upc: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{12}$/.test(s), {\n error: \"UPC must be exactly 12 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_gtin_14: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{14}$/.test(s), {\n error: \"GTIN14 must be exactly 14 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_type: z.enum([\"unit\", \"weight\", \"case\"], {\n error: \"Product type must be unit, weight, or case.\",\n }),\n\n weight_unit: z.preprocess((v) => {\n if (v === \"\") return undefined;\n if (typeof v === \"string\") return v.trim().toLowerCase();\n return v;\n }, z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional()),\n\n price: GlobalUtils.handleZodCurrency(0, 99_999.99),\n cost: GlobalUtils.handleZodCurrency(0, 99_999.99),\n })\n\n .superRefine((data, ctx) => {\n if (data.product_type === \"weight\" && !data.weight_unit) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit is required.\",\n path: [\"weight_unit\"],\n });\n }\n\n if (\n data.product_type !== \"weight\" &&\n typeof data.weight_unit !== \"undefined\"\n ) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit must be empty\",\n path: [\"weight_unit\"],\n });\n }\n });\n","import { z } from \"zod\";\n\nexport const CREATED_LOCATION = [\"web\", \"mobile\"] as const;\n\nexport type CreatedLocation = (typeof CREATED_LOCATION)[number];\n\nexport type IntBool = 0 | 1;\n\nexport const uuidSchema = z.uuid();\nexport type UUID = z.infer<typeof uuidSchema>;\n","import { z } from \"zod\";\nimport { CREDIT_TYPE, INVOICE_STATUS, INVOICE_TYPE } from \"./invoices_types\";\nimport { handleZodCurrency } from \"../../utils/utils\";\n\nconst YmdDateSchema = z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\nconst BaseInvoice = z\n .object({\n invoice_type: z.enum(INVOICE_TYPE, { error: \"Invoice type not found.\" }),\n invoice_date: YmdDateSchema,\n due_date: YmdDateSchema,\n tax_rate: z.number().default(0),\n tax_amount: z.number().default(0),\n warehouse_id: z.uuid().optional(),\n invoice_status: z.enum(INVOICE_STATUS).default(\"finalized\"),\n })\n .superRefine(({ invoice_date, due_date }, ctx) => {\n if (due_date < invoice_date) {\n ctx.addIssue({\n code: \"custom\",\n message: \"Due date can't be earlier than the invoice date.\",\n path: [\"due_date\"],\n });\n }\n });\n\nconst LineItemBase = z.object({\n invoice_id: z.uuid().optional(),\n product_id: z.uuid({ error: \"Select a product\" }),\n product_name: z.string().optional(),\n product_description: z.string().optional(),\n product_type: z.enum([\"unit\", \"weight\", \"case\"]).optional(),\n product_upc: z.string().optional(),\n weight_unit: z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional(),\n quantity: handleZodCurrency(0.01, 99_999.99),\n});\n\nconst SalesItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nconst CreditItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.enum(CREDIT_TYPE, {\n error: \"Select a credit type\",\n }),\n});\n\nconst PurchaseItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nexport const SalesInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"sales\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(SalesItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const CreditInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"credit\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(CreditItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const PurchaseInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"purchase\"),\n party_id: z.uuid({ message: \"Select a vendor\" }),\n invoice_items: z.array(PurchaseItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const AnyInvoiceSchema = z.discriminatedUnion(\"invoice_type\", [\n SalesInvoiceSchema,\n PurchaseInvoiceSchema,\n CreditInvoiceSchema,\n]);\n","import { z } from \"zod\";\nimport * as InvoiceSchemas from \"./invoices_schemas\";\n\nexport type SalesInvoice = z.infer<typeof InvoiceSchemas.SalesInvoiceSchema>;\nexport type CreditInvoice = z.infer<typeof InvoiceSchemas.CreditInvoiceSchema>;\nexport type PurchaseInvoice = z.infer<\n typeof InvoiceSchemas.PurchaseInvoiceSchema\n>;\nexport type AnyInvoiceOut = z.output<typeof InvoiceSchemas.AnyInvoiceSchema>;\n\nexport const INVOICE_TYPE = [\"sales\", \"credit\", \"purchase\"] as const;\n\nexport type InvoiceType = (typeof INVOICE_TYPE)[number];\n\nexport const INVOICE_STATUS = [\"finalized\", \"voided\"] as const;\n\nexport type InvoiceStatus = (typeof INVOICE_STATUS)[number];\n\nexport const CREDIT_TYPE = [\"dump\", \"return\"] as const;\n\nexport type CreditType = (typeof CREDIT_TYPE)[number];\n","// \"Today\" in the user's LOCAL timezone as YMD\nexport function todayLocalYmd(): string {\n const now = new Date();\n const y = now.getFullYear();\n const m = String(now.getMonth() + 1).padStart(2, \"0\");\n const d = String(now.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\n// Add days in LOCAL time (no drift)\nexport function addDaysLocalYmd(ymd: string, days: number): string {\n const dt = localDateFromYmd(ymd);\n dt.setDate(dt.getDate() + days);\n return ymdFromLocalDate(dt);\n}\n\nexport function formatYmdLong(ymd: string, locale = \"en-US\"): string {\n const { y, m, d } = parseYmd(ymd);\n const utcDate = new Date(Date.UTC(y, m - 1, d)); // 00:00Z\n return new Intl.DateTimeFormat(locale, {\n dateStyle: \"long\",\n timeZone: \"UTC\",\n }).format(utcDate);\n}\n\nexport function localDateFromYmd(ymd: string): Date {\n const { y, m, d } = parseYmd(ymd);\n return new Date(y, m - 1, d); // LOCAL midnight\n}\n\nexport function ymdFromLocalDate(dt: Date): string {\n const y = dt.getFullYear();\n const m = String(dt.getMonth() + 1).padStart(2, \"0\");\n const d = String(dt.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\nfunction parseYmd(ymd: string): { y: number; m: number; d: number } {\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(ymd);\n if (!m) throw new Error(\"Bad YMD\");\n return { y: Number(m[1]), m: Number(m[2]), d: Number(m[3]) };\n}\n","import type { FieldError, FieldErrorsImpl, Merge } from \"react-hook-form\";\n\ntype RHFError =\n | string\n | FieldError\n | Merge<FieldError, FieldErrorsImpl<any>>\n | undefined;\n\nexport const getErrorMessage = (err: RHFError): string | undefined => {\n if (!err) return undefined;\n if (typeof err === \"string\") return err;\n // FieldError has .message (string | undefined)\n const msg = (err as FieldError).message as string | undefined;\n return typeof msg === \"string\" ? msg : undefined;\n};\n","export const exceedsTwoDecimals = (raw: string) => {\n const s = String(raw ?? \"\").replace(/[,\\s]/g, \"\");\n const dot = s.indexOf(\".\");\n if (dot === -1) return false;\n const after = s.slice(dot + 1);\n const digitsAfter = (after.match(/\\d/g) ?? []).length;\n return digitsAfter > 2;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,cAAkB;;;ACAX,IAAM,oBAAoB,CAAC,MAAM,IAAI;AAIrC,IAAM,aAAa,CAAC,SAAS,QAAQ;;;ACCrC,IAAM,oBAA6D;AAAA,EACxE,IAAI;AAAA,EACJ,IAAI;AACN;AAEO,IAAM,mBAAoD;AAAA,EAC/D,KAAK;AAAA,EACL,KAAK;AACP;;;ACLA,iBAAkB;AAUX,SAAS,kBAAkB,WAAmB,WAAmB;AACtE,QAAM,aAAa,aAChB,OAAO;AAAA,IACN,OAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,EAAE,OAAO,uBAAuB,CAAC,EACpE,UAAU,CAAC,MAAM,EAAE,QAAQ,UAAU,EAAE,CAAC,EACxC,OAAO,CAAC,MAAM,MAAM,MAAM,CAAC,OAAO,MAAM,OAAO,CAAC,CAAC,GAAG;AAAA,IACnD,OAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC,GAAG;AAAA,IACzC,OAAO;AAAA,EACT,CAAC,E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,GAAG;AACzB,MAAI,QAAQ,GAAI,QAAO;AACvB,QAAM,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC7B,QAAM,gBAAe,WAAM,MAAM,KAAK,MAAjB,YAAsB,CAAC,GAAG;AAC/C,SAAO,cAAc;AACvB;","names":["import_zod","import_zod","import_zod","import_zod","import_zod"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/schemas/companies_schemas.ts","../src/types/company_types.ts","../src/types/money_types.ts","../src/utils/utils.ts","../src/schemas/customer_schemas.ts","../src/types/shared_types.ts","../src/domains/invoices/invoices_schemas.ts","../src/domains/invoices/invoices_types.ts","../src/utils/date_utils.ts","../src/utils/errors_utils.ts","../src/utils/money_utils.ts","../src/domains/products/product_schemas.ts","../src/domains/payments/payments_schemas.ts","../src/domains/payments/payments_types.ts"],"sourcesContent":["export * from \"./schemas/companies_schemas\";\nexport * from \"./schemas/customer_schemas\";\nexport * from \"./utils/utils\";\nexport {\n UserRole,\n IsoCountryCode,\n InventorySystem,\n} from \"./types/company_types\";\nexport { CreatedLocation, UUID } from \"./types/shared_types\";\nexport { SyncInvoice } from \"./types/sync_types\";\nexport * from \"./types/customers_types\";\nexport * from \"./types/vendors_types\";\nexport * from \"./domains/invoices/invoices_schemas\";\nexport * from \"./domains/invoices/invoices_types\";\nexport * from \"./utils/date_utils\";\nexport * from \"./utils/errors_utils\";\n\n// Money\nexport * from \"./utils/money_utils\";\nexport * from \"./types/money_types\";\n\n// Products\nexport * from \"./domains/products/product_schemas\";\nexport * from \"./domains/products/products_types\";\n\n//Payments\nexport * from \"./domains/payments/payments_schemas\";\nexport * from \"./domains/payments/payments_types\";\n","import { z } from \"zod\";\nimport { ISO_COUNTRY_CODES, USER_ROLES } from \"../types/company_types\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nconst iso_country_code = z.enum(ISO_COUNTRY_CODES, {\n error: \"Country code not supported.\",\n});\n\nconst user_role = z.enum(USER_ROLES, {\n error: \"User role not supported.\",\n});\n\nexport const RegisterFormSchema = z.strictObject({\n companyData: z.strictObject({\n company_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company name is required\")\n .max(50, \"Company name must be at most 50 characters.\")\n ),\n company_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company address is required\")\n .max(100, \"Company address must be at most 100 characters.\")\n ),\n company_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => /^\\d{4,15}$/.test(s), {\n error: \"Phone number required and must be from 4 to 15 digits.\",\n }),\n iso_country_code: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform((s) => s.toUpperCase())\n .pipe(iso_country_code),\n }),\n adminUserData: z.strictObject({\n user_first_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"First name is required\")\n .max(50, \"First name must be at most 50 characters.\")\n ),\n user_last_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Last name is required\")\n .max(50, \"Last name must be at most 50 characters.\")\n ),\n user_email: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n ),\n password: z\n .string()\n .min(8, \"Password must be at least 8 characters\")\n .max(25, \"Password must be at most 25 characters\")\n .regex(/[A-Z]/, \"Password must contain at least one uppercase letter\")\n .regex(/[a-z]/, \"Password must contain at least one lowercase letter\")\n .regex(/\\d/, \"Password must contain at least one number\")\n .regex(\n /[@$!%*?&#^_+=-]/,\n \"Password must contain at least one special character\"\n )\n .regex(/^\\S*$/, \"Password cannot contain spaces or other whitespace.\"),\n }),\n});\n","export const ISO_COUNTRY_CODES = [\"US\", \"HN\"] as const;\n\nexport type IsoCountryCode = (typeof ISO_COUNTRY_CODES)[number];\n\nexport const USER_ROLES = [\"admin\", \"driver\"] as const;\n\nexport type UserRole = (typeof USER_ROLES)[number];\n\nexport type InventorySystem = \"warehouse_only\" | \"dsd\";\n","import { IsoCountryCode } from \"../types/company_types\";\n\nexport type IsoCurrencyCode = \"USD\" | \"HNL\";\ntype Locale = \"en-US\" | \"es-HN\";\n\nexport const countryToCurrency: Record<IsoCountryCode, IsoCurrencyCode> = {\n US: \"USD\",\n HN: \"HNL\",\n};\n\nexport const currencyToLocale: Record<IsoCurrencyCode, Locale> = {\n USD: \"en-US\",\n HNL: \"es-HN\",\n};\n","import * as GlobalTypes from \"./types\";\nimport { IsoCountryCode } from \"../types/company_types\";\nimport {\n IsoCurrencyCode,\n countryToCurrency,\n currencyToLocale,\n} from \"../types/money_types\";\n\nimport { z } from \"zod\";\n\n/**\n * Validates zod currency with precision.\n *\n *\n * @param minAmount\n * @param maxAmount\n * @returns\n */\nexport function handleZodCurrency(minAmount: number, maxAmount: number) {\n const fromString = z\n .string({\n error: \"Enter a valid number\",\n })\n .refine((s) => s.trim().length > 0, { error: \"Enter a valid number\" })\n .transform((s) => s.replace(/[,\\s]/g, \"\"))\n .refine((s) => s !== \"\" && !Number.isNaN(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number.isFinite(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number(s) >= 0, { error: \"Enter a positive number\" })\n .transform((s) => Number(s));\n\n const fromNumber = z\n .number()\n .refine((n) => Number.isFinite(n), { error: \"Enter a valid number\" })\n .refine((n) => n >= 0, { error: \"Enter a positive number\" });\n\n return z\n .union([fromString, fromNumber])\n .transform((n) => roundWithPrecision(n, 2))\n .refine((n) => n >= minAmount, {\n error: `Must be greater than ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `Exceeds allowed limit ${maxAmount}`,\n });\n}\n\n/**\n * Trims any leading or trailing spaces\n * Transforms empty strings into undefined.\n *\n * @param s\n * @returns\n */\nexport const transformEmptyStringToUndefined = (s: string) =>\n s.trim() === \"\" ? undefined : s;\n\n/**\n * - Collapses any run of whitespace in a string (spaces, tabs, newlines, nbspb, and other weird unicode spaces etc.)\n * into a single ASCII space.\n * - Trims leading and trailing whitespace.\n * \" Jared \\n Gomez \\t Driver\\t \" -> \"Jared Gomez Driver\"\n *\n * @param s\n * @returns\n */\nexport const normalizeSpaces = (s: string) => whitespace(s, \"normalize\");\n\n/**\n * Removes all whitespace from a string\n * @param s\n * @returns\n */\nexport const removeAllWhitespace = (s: string) => whitespace(s, \"remove\");\n\nconst whitespace = (s: string, mode: GlobalTypes.WhitespaceMode) => {\n if (mode === \"remove\") {\n return s.replace(/\\s+/g, \"\");\n }\n\n return s.replace(/\\s+/g, \" \").trim();\n};\n\n/**\n * Removes all dashes and + signs from a string\n * +1-305-555-0123 -> \"13055550123\"\n * 305-555-0123 -> \"3055550123\"\n *\n * @param s\n * @returns\n */\nexport const removeDashesAndPlusSign = (s: string): string =>\n s.replace(/[+-]/g, \"\");\n\n/**\n * Rounds a number to a certain precision.\n * Contract:\n * 1. Number must be finite and non negative.\n * 2. Precision must be finite nonnegative and an integer.\n * 3. Precision must be <= Max precision\n * 4. Returns a number >= 0\n * Default is round half up.\n *\n * @param num\n * @param precision\n * @param opts\n * @returns\n */\nexport function roundWithPrecision(\n num: number,\n precision: number,\n opts?: GlobalTypes.ToFixedOptions\n): number {\n const MAX_PRECISION = 2;\n const { roundType = \"half_up\" } = opts ?? {};\n\n if (!Number.isFinite(num) || num < 0) {\n throw new RangeError(\"Number must be finite and greater than 0.\");\n }\n\n if (\n !Number.isFinite(precision) ||\n !Number.isInteger(precision) ||\n precision < 1\n ) {\n throw new RangeError(\"Precision must be a finite integer greater than 0.\");\n }\n\n if (precision > MAX_PRECISION) {\n throw new RangeError(\"Max precision allowed is 2.\");\n }\n\n return Number(\n (+(Math.round(+(num + \"e\" + precision)) + \"e\" + -precision)).toFixed(\n precision\n )\n );\n}\n\nexport function getCurrencyFromCountry(\n country: IsoCountryCode\n): IsoCurrencyCode {\n return countryToCurrency[country];\n}\n\nexport function formatMoneyCurrency(value: number, currency: IsoCurrencyCode) {\n const locale =\n currency in currencyToLocale ? currencyToLocale[currency] : \"en-US\";\n\n const formatted = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: currency,\n }).format(value);\n\n return sanitizeSpaces(formatted);\n}\n\nfunction sanitizeSpaces(str: string): string {\n return str\n .replace(/\\u00A0/g, \" \")\n .replace(/\\u202F/g, \" \")\n .replace(/[^\\x20-\\x7E]/g, \"\");\n}\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nexport const CustomerFormSchema = z.strictObject({\n customer_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Customer name is required\")\n .max(50, \"Customer name must be at most 50 characters.\")\n ),\n\n customer_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z.string().max(100, \"Customer address must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => s === \"\" || /^\\d{4,15}$/.test(s), {\n error: \"Phone number must be from 4 to 15 digits.\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_email_address: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n .optional()\n )\n .optional(),\n});\n","import { z } from \"zod\";\n\nexport const CREATED_LOCATION = [\"web\", \"mobile\"] as const;\n\nexport type CreatedLocation = (typeof CREATED_LOCATION)[number];\n\nexport type IntBool = 0 | 1;\n\nexport const uuidSchema = z.uuid();\nexport type UUID = z.infer<typeof uuidSchema>;\n","import { z } from \"zod\";\nimport { CREDIT_TYPE, INVOICE_STATUS, INVOICE_TYPE } from \"./invoices_types\";\nimport { handleZodCurrency } from \"../../utils/utils\";\n\nconst YmdDateSchema = z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\nconst BaseInvoice = z\n .object({\n invoice_type: z.enum(INVOICE_TYPE, { error: \"Invoice type not found.\" }),\n invoice_date: YmdDateSchema,\n due_date: YmdDateSchema,\n tax_rate: z.number().default(0),\n tax_amount: z.number().default(0),\n warehouse_id: z.uuid().optional(),\n invoice_status: z.enum(INVOICE_STATUS).default(\"finalized\"),\n })\n .superRefine(({ invoice_date, due_date }, ctx) => {\n if (due_date < invoice_date) {\n ctx.addIssue({\n code: \"custom\",\n message: \"Due date can't be earlier than the invoice date.\",\n path: [\"due_date\"],\n });\n }\n });\n\nconst LineItemBase = z.object({\n invoice_id: z.uuid().optional(),\n product_id: z.uuid({ error: \"Select a product\" }),\n product_name: z.string().optional(),\n product_description: z.string().optional(),\n product_type: z.enum([\"unit\", \"weight\", \"case\"]).optional(),\n product_upc: z.string().optional(),\n weight_unit: z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional(),\n quantity: handleZodCurrency(0.01, 99_999.99),\n});\n\nconst SalesItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nconst CreditItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.enum(CREDIT_TYPE, {\n error: \"Select a credit type\",\n }),\n});\n\nconst PurchaseItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nexport const SalesInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"sales\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(SalesItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const CreditInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"credit\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(CreditItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const PurchaseInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"purchase\"),\n party_id: z.uuid({ message: \"Select a vendor\" }),\n invoice_items: z.array(PurchaseItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const AnyInvoiceSchema = z.discriminatedUnion(\"invoice_type\", [\n SalesInvoiceSchema,\n PurchaseInvoiceSchema,\n CreditInvoiceSchema,\n]);\n","import { z } from \"zod\";\nimport * as InvoiceSchemas from \"./invoices_schemas\";\n\nexport type SalesInvoice = z.infer<typeof InvoiceSchemas.SalesInvoiceSchema>;\nexport type CreditInvoice = z.infer<typeof InvoiceSchemas.CreditInvoiceSchema>;\nexport type PurchaseInvoice = z.infer<\n typeof InvoiceSchemas.PurchaseInvoiceSchema\n>;\nexport type AnyInvoiceOut = z.output<typeof InvoiceSchemas.AnyInvoiceSchema>;\n\nexport const INVOICE_TYPE = [\"sales\", \"credit\", \"purchase\"] as const;\n\nexport type InvoiceType = (typeof INVOICE_TYPE)[number];\n\nexport const INVOICE_STATUS = [\"finalized\", \"voided\"] as const;\n\nexport type InvoiceStatus = (typeof INVOICE_STATUS)[number];\n\nexport const CREDIT_TYPE = [\"dump\", \"return\"] as const;\n\nexport type CreditType = (typeof CREDIT_TYPE)[number];\n","// \"Today\" in the user's LOCAL timezone as YMD\nexport function todayLocalYmd(): string {\n const now = new Date();\n const y = now.getFullYear();\n const m = String(now.getMonth() + 1).padStart(2, \"0\");\n const d = String(now.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\n// Add days in LOCAL time (no drift)\nexport function addDaysLocalYmd(ymd: string, days: number): string {\n const dt = localDateFromYmd(ymd);\n dt.setDate(dt.getDate() + days);\n return ymdFromLocalDate(dt);\n}\n\nexport function formatYmdLong(ymd: string, locale = \"en-US\"): string {\n const { y, m, d } = parseYmd(ymd);\n const utcDate = new Date(Date.UTC(y, m - 1, d)); // 00:00Z\n return new Intl.DateTimeFormat(locale, {\n dateStyle: \"long\",\n timeZone: \"UTC\",\n }).format(utcDate);\n}\n\nexport function localDateFromYmd(ymd: string): Date {\n const { y, m, d } = parseYmd(ymd);\n return new Date(y, m - 1, d); // LOCAL midnight\n}\n\nexport function ymdFromLocalDate(dt: Date): string {\n const y = dt.getFullYear();\n const m = String(dt.getMonth() + 1).padStart(2, \"0\");\n const d = String(dt.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\nfunction parseYmd(ymd: string): { y: number; m: number; d: number } {\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(ymd);\n if (!m) throw new Error(\"Bad YMD\");\n return { y: Number(m[1]), m: Number(m[2]), d: Number(m[3]) };\n}\n","import type { FieldError, FieldErrorsImpl, Merge } from \"react-hook-form\";\n\ntype RHFError =\n | string\n | FieldError\n | Merge<FieldError, FieldErrorsImpl<any>>\n | undefined;\n\nexport const getErrorMessage = (err: RHFError): string | undefined => {\n if (!err) return undefined;\n if (typeof err === \"string\") return err;\n // FieldError has .message (string | undefined)\n const msg = (err as FieldError).message as string | undefined;\n return typeof msg === \"string\" ? msg : undefined;\n};\n","export const exceedsTwoDecimals = (raw: string) => {\n const s = String(raw ?? \"\").replace(/[,\\s]/g, \"\");\n const dot = s.indexOf(\".\");\n if (dot === -1) return false;\n const after = s.slice(dot + 1);\n const digitsAfter = (after.match(/\\d/g) ?? []).length;\n return digitsAfter > 2;\n};\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../utils/utils\";\n\nexport const ProductFormSchema = z\n .strictObject({\n product_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Product name is required\")\n .max(50, \"Product name must be at most 50 characters.\")\n ),\n\n product_description: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .max(100, \"Product desription must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_sku: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(z.string().max(30, \"Product SKU must be at most 30 characters.\"))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_upc: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{12}$/.test(s), {\n error: \"UPC must be exactly 12 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_gtin_14: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{14}$/.test(s), {\n error: \"GTIN14 must be exactly 14 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_type: z.enum([\"unit\", \"weight\", \"case\"], {\n error: \"Product type must be unit, weight, or case.\",\n }),\n\n weight_unit: z.preprocess((v) => {\n if (v === \"\") return undefined;\n if (typeof v === \"string\") return v.trim().toLowerCase();\n return v;\n }, z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional()),\n\n price: GlobalUtils.handleZodCurrency(0, 99_999.99),\n cost: GlobalUtils.handleZodCurrency(0, 99_999.99),\n })\n\n .superRefine((data, ctx) => {\n if (data.product_type === \"weight\" && !data.weight_unit) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit is required.\",\n path: [\"weight_unit\"],\n });\n }\n\n if (\n data.product_type !== \"weight\" &&\n typeof data.weight_unit !== \"undefined\"\n ) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit must be empty\",\n path: [\"weight_unit\"],\n });\n }\n });\n","import { z } from \"zod\";\nimport { PAYMENT_METHOD } from \"./payments_types\";\nimport * as GlobalUtils from \"../../utils/utils\";\n\nexport const PaymentFormSchema = z.strictObject({\n payment_method: z.enum(PAYMENT_METHOD, {\n error: \"Payment method is required.\",\n }),\n check_number: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z.string().max(50, \"Payment check number must be at most 50 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n payment_amount: GlobalUtils.handleZodCurrency(0.01, 999_999.99),\n});\n","export const PAYMENT_METHOD = [\n \"check\",\n \"cash\",\n \"bank_transfer\",\n \"digital_wallet\",\n] as const;\n\nexport type PaymentMethod = (typeof PAYMENT_METHOD)[number];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,cAAkB;;;ACAX,IAAM,oBAAoB,CAAC,MAAM,IAAI;AAIrC,IAAM,aAAa,CAAC,SAAS,QAAQ;;;ACCrC,IAAM,oBAA6D;AAAA,EACxE,IAAI;AAAA,EACJ,IAAI;AACN;AAEO,IAAM,mBAAoD;AAAA,EAC/D,KAAK;AAAA,EACL,KAAK;AACP;;;ACLA,iBAAkB;AAUX,SAAS,kBAAkB,WAAmB,WAAmB;AACtE,QAAM,aAAa,aAChB,OAAO;AAAA,IACN,OAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,EAAE,OAAO,uBAAuB,CAAC,EACpE,UAAU,CAAC,MAAM,EAAE,QAAQ,UAAU,EAAE,CAAC,EACxC,OAAO,CAAC,MAAM,MAAM,MAAM,CAAC,OAAO,MAAM,OAAO,CAAC,CAAC,GAAG;AAAA,IACnD,OAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC,GAAG;AAAA,IACzC,OAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,OAAO,CAAC,KAAK,GAAG,EAAE,OAAO,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QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM,CAAC,aAAa;AAAA,IACtB,CAAC;AAAA,EACH;AACF,CAAC;;;ACpFH,IAAAC,cAAkB;;;ACAX,IAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ADDO,IAAM,oBAAoB,cAAE,aAAa;AAAA,EAC9C,gBAAgB,cAAE,KAAK,gBAAgB;AAAA,IACrC,OAAO;AAAA,EACT,CAAC;AAAA,EACD,cAAc,cACX,OAAO,EACP,UAAsB,eAAe,EACrC;AAAA,IACC,cAAE,OAAO,EAAE,IAAI,IAAI,qDAAqD;AAAA,EAC1E,EACC,UAAsB,+BAA+B,EACrD,SAAS;AAAA,EAEZ,gBAA4B,kBAAkB,MAAM,SAAU;AAChE,CAAC;","names":["import_zod","import_zod","import_zod","import_zod","import_zod","import_zod"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -26,27 +26,6 @@ declare const CustomerFormSchema: z.ZodObject<{
|
|
|
26
26
|
customer_email_address: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>, z.ZodOptional<z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>>>>;
|
|
27
27
|
}, z.core.$strict>;
|
|
28
28
|
|
|
29
|
-
declare const ProductFormSchema: z.ZodObject<{
|
|
30
|
-
product_name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
31
|
-
product_description: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
|
|
32
|
-
product_sku: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
|
|
33
|
-
product_upc: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
|
|
34
|
-
product_gtin_14: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
|
|
35
|
-
product_type: z.ZodEnum<{
|
|
36
|
-
unit: "unit";
|
|
37
|
-
weight: "weight";
|
|
38
|
-
case: "case";
|
|
39
|
-
}>;
|
|
40
|
-
weight_unit: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodEnum<{
|
|
41
|
-
kg: "kg";
|
|
42
|
-
lb: "lb";
|
|
43
|
-
g: "g";
|
|
44
|
-
oz: "oz";
|
|
45
|
-
}>>>;
|
|
46
|
-
price: z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<number, string>>, z.ZodNumber]>, z.ZodTransform<number, number>>;
|
|
47
|
-
cost: z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<number, string>>, z.ZodNumber]>, z.ZodTransform<number, number>>;
|
|
48
|
-
}, z.core.$strict>;
|
|
49
|
-
|
|
50
29
|
type RoundType = "half_up";
|
|
51
30
|
interface ToFixedOptions {
|
|
52
31
|
roundType?: RoundType;
|
|
@@ -384,9 +363,6 @@ type MappedVendors = {
|
|
|
384
363
|
tax_rate: number;
|
|
385
364
|
};
|
|
386
365
|
|
|
387
|
-
type ProductType = "unit" | "weight" | "case";
|
|
388
|
-
type WeightUnit = "kg" | "lb" | "g" | "oz";
|
|
389
|
-
|
|
390
366
|
declare function todayLocalYmd(): string;
|
|
391
367
|
declare function addDaysLocalYmd(ymd: string, days: number): string;
|
|
392
368
|
declare function formatYmdLong(ymd: string, locale?: string): string;
|
|
@@ -398,4 +374,42 @@ declare const getErrorMessage: (err: RHFError) => string | undefined;
|
|
|
398
374
|
|
|
399
375
|
declare const exceedsTwoDecimals: (raw: string) => boolean;
|
|
400
376
|
|
|
401
|
-
|
|
377
|
+
declare const ProductFormSchema: z.ZodObject<{
|
|
378
|
+
product_name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
379
|
+
product_description: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
|
|
380
|
+
product_sku: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
|
|
381
|
+
product_upc: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
|
|
382
|
+
product_gtin_14: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
|
|
383
|
+
product_type: z.ZodEnum<{
|
|
384
|
+
unit: "unit";
|
|
385
|
+
weight: "weight";
|
|
386
|
+
case: "case";
|
|
387
|
+
}>;
|
|
388
|
+
weight_unit: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodEnum<{
|
|
389
|
+
kg: "kg";
|
|
390
|
+
lb: "lb";
|
|
391
|
+
g: "g";
|
|
392
|
+
oz: "oz";
|
|
393
|
+
}>>>;
|
|
394
|
+
price: z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<number, string>>, z.ZodNumber]>, z.ZodTransform<number, number>>;
|
|
395
|
+
cost: z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<number, string>>, z.ZodNumber]>, z.ZodTransform<number, number>>;
|
|
396
|
+
}, z.core.$strict>;
|
|
397
|
+
|
|
398
|
+
type ProductType = "unit" | "weight" | "case";
|
|
399
|
+
type WeightUnit = "kg" | "lb" | "g" | "oz";
|
|
400
|
+
|
|
401
|
+
declare const PaymentFormSchema: z.ZodObject<{
|
|
402
|
+
payment_method: z.ZodEnum<{
|
|
403
|
+
check: "check";
|
|
404
|
+
cash: "cash";
|
|
405
|
+
bank_transfer: "bank_transfer";
|
|
406
|
+
digital_wallet: "digital_wallet";
|
|
407
|
+
}>;
|
|
408
|
+
check_number: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
|
|
409
|
+
payment_amount: z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<number, string>>, z.ZodNumber]>, z.ZodTransform<number, number>>;
|
|
410
|
+
}, z.core.$strict>;
|
|
411
|
+
|
|
412
|
+
declare const PAYMENT_METHOD: readonly ["check", "cash", "bank_transfer", "digital_wallet"];
|
|
413
|
+
type PaymentMethod = (typeof PAYMENT_METHOD)[number];
|
|
414
|
+
|
|
415
|
+
export { type AnyInvoiceOut, AnyInvoiceSchema, CREDIT_TYPE, type CreatedLocation, type CreditInvoice, CreditInvoiceSchema, type CreditType, CustomerFormSchema, INVOICE_STATUS, INVOICE_TYPE, type InventorySystem, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type IsoCurrencyCode, type MappedCustomers, type MappedVendors, PAYMENT_METHOD, PaymentFormSchema, type PaymentMethod, ProductFormSchema, type ProductType, type PurchaseInvoice, PurchaseInvoiceSchema, RegisterFormSchema, type SalesInvoice, SalesInvoiceSchema, type SyncInvoice, type UUID, type UserRole, type WeightUnit, addDaysLocalYmd, countryToCurrency, currencyToLocale, exceedsTwoDecimals, formatMoneyCurrency, formatYmdLong, getCurrencyFromCountry, getErrorMessage, handleZodCurrency, localDateFromYmd, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, todayLocalYmd, transformEmptyStringToUndefined, ymdFromLocalDate };
|
package/dist/index.d.ts
CHANGED
|
@@ -26,27 +26,6 @@ declare const CustomerFormSchema: z.ZodObject<{
|
|
|
26
26
|
customer_email_address: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>, z.ZodOptional<z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>>>>;
|
|
27
27
|
}, z.core.$strict>;
|
|
28
28
|
|
|
29
|
-
declare const ProductFormSchema: z.ZodObject<{
|
|
30
|
-
product_name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
31
|
-
product_description: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
|
|
32
|
-
product_sku: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
|
|
33
|
-
product_upc: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
|
|
34
|
-
product_gtin_14: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
|
|
35
|
-
product_type: z.ZodEnum<{
|
|
36
|
-
unit: "unit";
|
|
37
|
-
weight: "weight";
|
|
38
|
-
case: "case";
|
|
39
|
-
}>;
|
|
40
|
-
weight_unit: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodEnum<{
|
|
41
|
-
kg: "kg";
|
|
42
|
-
lb: "lb";
|
|
43
|
-
g: "g";
|
|
44
|
-
oz: "oz";
|
|
45
|
-
}>>>;
|
|
46
|
-
price: z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<number, string>>, z.ZodNumber]>, z.ZodTransform<number, number>>;
|
|
47
|
-
cost: z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<number, string>>, z.ZodNumber]>, z.ZodTransform<number, number>>;
|
|
48
|
-
}, z.core.$strict>;
|
|
49
|
-
|
|
50
29
|
type RoundType = "half_up";
|
|
51
30
|
interface ToFixedOptions {
|
|
52
31
|
roundType?: RoundType;
|
|
@@ -384,9 +363,6 @@ type MappedVendors = {
|
|
|
384
363
|
tax_rate: number;
|
|
385
364
|
};
|
|
386
365
|
|
|
387
|
-
type ProductType = "unit" | "weight" | "case";
|
|
388
|
-
type WeightUnit = "kg" | "lb" | "g" | "oz";
|
|
389
|
-
|
|
390
366
|
declare function todayLocalYmd(): string;
|
|
391
367
|
declare function addDaysLocalYmd(ymd: string, days: number): string;
|
|
392
368
|
declare function formatYmdLong(ymd: string, locale?: string): string;
|
|
@@ -398,4 +374,42 @@ declare const getErrorMessage: (err: RHFError) => string | undefined;
|
|
|
398
374
|
|
|
399
375
|
declare const exceedsTwoDecimals: (raw: string) => boolean;
|
|
400
376
|
|
|
401
|
-
|
|
377
|
+
declare const ProductFormSchema: z.ZodObject<{
|
|
378
|
+
product_name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
379
|
+
product_description: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
|
|
380
|
+
product_sku: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
|
|
381
|
+
product_upc: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
|
|
382
|
+
product_gtin_14: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
|
|
383
|
+
product_type: z.ZodEnum<{
|
|
384
|
+
unit: "unit";
|
|
385
|
+
weight: "weight";
|
|
386
|
+
case: "case";
|
|
387
|
+
}>;
|
|
388
|
+
weight_unit: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodEnum<{
|
|
389
|
+
kg: "kg";
|
|
390
|
+
lb: "lb";
|
|
391
|
+
g: "g";
|
|
392
|
+
oz: "oz";
|
|
393
|
+
}>>>;
|
|
394
|
+
price: z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<number, string>>, z.ZodNumber]>, z.ZodTransform<number, number>>;
|
|
395
|
+
cost: z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<number, string>>, z.ZodNumber]>, z.ZodTransform<number, number>>;
|
|
396
|
+
}, z.core.$strict>;
|
|
397
|
+
|
|
398
|
+
type ProductType = "unit" | "weight" | "case";
|
|
399
|
+
type WeightUnit = "kg" | "lb" | "g" | "oz";
|
|
400
|
+
|
|
401
|
+
declare const PaymentFormSchema: z.ZodObject<{
|
|
402
|
+
payment_method: z.ZodEnum<{
|
|
403
|
+
check: "check";
|
|
404
|
+
cash: "cash";
|
|
405
|
+
bank_transfer: "bank_transfer";
|
|
406
|
+
digital_wallet: "digital_wallet";
|
|
407
|
+
}>;
|
|
408
|
+
check_number: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
|
|
409
|
+
payment_amount: z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<number, string>>, z.ZodNumber]>, z.ZodTransform<number, number>>;
|
|
410
|
+
}, z.core.$strict>;
|
|
411
|
+
|
|
412
|
+
declare const PAYMENT_METHOD: readonly ["check", "cash", "bank_transfer", "digital_wallet"];
|
|
413
|
+
type PaymentMethod = (typeof PAYMENT_METHOD)[number];
|
|
414
|
+
|
|
415
|
+
export { type AnyInvoiceOut, AnyInvoiceSchema, CREDIT_TYPE, type CreatedLocation, type CreditInvoice, CreditInvoiceSchema, type CreditType, CustomerFormSchema, INVOICE_STATUS, INVOICE_TYPE, type InventorySystem, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type IsoCurrencyCode, type MappedCustomers, type MappedVendors, PAYMENT_METHOD, PaymentFormSchema, type PaymentMethod, ProductFormSchema, type ProductType, type PurchaseInvoice, PurchaseInvoiceSchema, RegisterFormSchema, type SalesInvoice, SalesInvoiceSchema, type SyncInvoice, type UUID, type UserRole, type WeightUnit, addDaysLocalYmd, countryToCurrency, currencyToLocale, exceedsTwoDecimals, formatMoneyCurrency, formatYmdLong, getCurrencyFromCountry, getErrorMessage, handleZodCurrency, localDateFromYmd, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, todayLocalYmd, transformEmptyStringToUndefined, ymdFromLocalDate };
|
package/dist/index.js
CHANGED
|
@@ -129,55 +129,12 @@ var CustomerFormSchema = z3.strictObject({
|
|
|
129
129
|
).optional()
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
// src/schemas/product_schemas.ts
|
|
133
|
-
import { z as z4 } from "zod";
|
|
134
|
-
var ProductFormSchema = z4.strictObject({
|
|
135
|
-
product_name: z4.string().transform(normalizeSpaces).pipe(
|
|
136
|
-
z4.string().min(1, "Product name is required").max(50, "Product name must be at most 50 characters.")
|
|
137
|
-
),
|
|
138
|
-
product_description: z4.string().transform(normalizeSpaces).pipe(
|
|
139
|
-
z4.string().max(100, "Product desription must be at most 100 characters.")
|
|
140
|
-
).transform(transformEmptyStringToUndefined).optional(),
|
|
141
|
-
product_sku: z4.string().transform(normalizeSpaces).pipe(z4.string().max(30, "Product SKU must be at most 30 characters.")).transform(transformEmptyStringToUndefined).optional(),
|
|
142
|
-
product_upc: z4.string().transform((s) => s.replace(/\s+/g, "")).refine((s) => s === "" || /^\d{12}$/.test(s), {
|
|
143
|
-
error: "UPC must be exactly 12 digits"
|
|
144
|
-
}).transform(transformEmptyStringToUndefined).optional(),
|
|
145
|
-
product_gtin_14: z4.string().transform((s) => s.replace(/\s+/g, "")).refine((s) => s === "" || /^\d{14}$/.test(s), {
|
|
146
|
-
error: "GTIN14 must be exactly 14 digits"
|
|
147
|
-
}).transform(transformEmptyStringToUndefined).optional(),
|
|
148
|
-
product_type: z4.enum(["unit", "weight", "case"], {
|
|
149
|
-
error: "Product type must be unit, weight, or case."
|
|
150
|
-
}),
|
|
151
|
-
weight_unit: z4.preprocess((v) => {
|
|
152
|
-
if (v === "") return void 0;
|
|
153
|
-
if (typeof v === "string") return v.trim().toLowerCase();
|
|
154
|
-
return v;
|
|
155
|
-
}, z4.enum(["kg", "lb", "g", "oz"]).optional()),
|
|
156
|
-
price: handleZodCurrency(0, 99999.99),
|
|
157
|
-
cost: handleZodCurrency(0, 99999.99)
|
|
158
|
-
}).superRefine((data, ctx) => {
|
|
159
|
-
if (data.product_type === "weight" && !data.weight_unit) {
|
|
160
|
-
ctx.addIssue({
|
|
161
|
-
code: "custom",
|
|
162
|
-
error: "Weight unit is required.",
|
|
163
|
-
path: ["weight_unit"]
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
if (data.product_type !== "weight" && typeof data.weight_unit !== "undefined") {
|
|
167
|
-
ctx.addIssue({
|
|
168
|
-
code: "custom",
|
|
169
|
-
error: "Weight unit must be empty",
|
|
170
|
-
path: ["weight_unit"]
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
|
|
175
132
|
// src/types/shared_types.ts
|
|
176
|
-
import { z as
|
|
177
|
-
var uuidSchema =
|
|
133
|
+
import { z as z4 } from "zod";
|
|
134
|
+
var uuidSchema = z4.uuid();
|
|
178
135
|
|
|
179
136
|
// src/domains/invoices/invoices_schemas.ts
|
|
180
|
-
import { z as
|
|
137
|
+
import { z as z5 } from "zod";
|
|
181
138
|
|
|
182
139
|
// src/domains/invoices/invoices_types.ts
|
|
183
140
|
var INVOICE_TYPE = ["sales", "credit", "purchase"];
|
|
@@ -185,15 +142,15 @@ var INVOICE_STATUS = ["finalized", "voided"];
|
|
|
185
142
|
var CREDIT_TYPE = ["dump", "return"];
|
|
186
143
|
|
|
187
144
|
// src/domains/invoices/invoices_schemas.ts
|
|
188
|
-
var YmdDateSchema =
|
|
189
|
-
var BaseInvoice =
|
|
190
|
-
invoice_type:
|
|
145
|
+
var YmdDateSchema = z5.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Use YYYY-MM-DD");
|
|
146
|
+
var BaseInvoice = z5.object({
|
|
147
|
+
invoice_type: z5.enum(INVOICE_TYPE, { error: "Invoice type not found." }),
|
|
191
148
|
invoice_date: YmdDateSchema,
|
|
192
149
|
due_date: YmdDateSchema,
|
|
193
|
-
tax_rate:
|
|
194
|
-
tax_amount:
|
|
195
|
-
warehouse_id:
|
|
196
|
-
invoice_status:
|
|
150
|
+
tax_rate: z5.number().default(0),
|
|
151
|
+
tax_amount: z5.number().default(0),
|
|
152
|
+
warehouse_id: z5.uuid().optional(),
|
|
153
|
+
invoice_status: z5.enum(INVOICE_STATUS).default("finalized")
|
|
197
154
|
}).superRefine(({ invoice_date, due_date }, ctx) => {
|
|
198
155
|
if (due_date < invoice_date) {
|
|
199
156
|
ctx.addIssue({
|
|
@@ -203,46 +160,46 @@ var BaseInvoice = z6.object({
|
|
|
203
160
|
});
|
|
204
161
|
}
|
|
205
162
|
});
|
|
206
|
-
var LineItemBase =
|
|
207
|
-
invoice_id:
|
|
208
|
-
product_id:
|
|
209
|
-
product_name:
|
|
210
|
-
product_description:
|
|
211
|
-
product_type:
|
|
212
|
-
product_upc:
|
|
213
|
-
weight_unit:
|
|
163
|
+
var LineItemBase = z5.object({
|
|
164
|
+
invoice_id: z5.uuid().optional(),
|
|
165
|
+
product_id: z5.uuid({ error: "Select a product" }),
|
|
166
|
+
product_name: z5.string().optional(),
|
|
167
|
+
product_description: z5.string().optional(),
|
|
168
|
+
product_type: z5.enum(["unit", "weight", "case"]).optional(),
|
|
169
|
+
product_upc: z5.string().optional(),
|
|
170
|
+
weight_unit: z5.enum(["kg", "lb", "g", "oz"]).optional(),
|
|
214
171
|
quantity: handleZodCurrency(0.01, 99999.99)
|
|
215
172
|
});
|
|
216
173
|
var SalesItem = LineItemBase.safeExtend({
|
|
217
174
|
price: handleZodCurrency(0, 99999.99),
|
|
218
|
-
credit_type:
|
|
175
|
+
credit_type: z5.undefined()
|
|
219
176
|
});
|
|
220
177
|
var CreditItem = LineItemBase.safeExtend({
|
|
221
178
|
price: handleZodCurrency(0, 99999.99),
|
|
222
|
-
credit_type:
|
|
179
|
+
credit_type: z5.enum(CREDIT_TYPE, {
|
|
223
180
|
error: "Select a credit type"
|
|
224
181
|
})
|
|
225
182
|
});
|
|
226
183
|
var PurchaseItem = LineItemBase.safeExtend({
|
|
227
184
|
price: handleZodCurrency(0, 99999.99),
|
|
228
|
-
credit_type:
|
|
185
|
+
credit_type: z5.undefined()
|
|
229
186
|
});
|
|
230
187
|
var SalesInvoiceSchema = BaseInvoice.safeExtend({
|
|
231
|
-
invoice_type:
|
|
232
|
-
party_id:
|
|
233
|
-
invoice_items:
|
|
188
|
+
invoice_type: z5.literal("sales"),
|
|
189
|
+
party_id: z5.uuid({ message: "Select a customer" }),
|
|
190
|
+
invoice_items: z5.array(SalesItem).min(1, "Add at least one invoice item")
|
|
234
191
|
});
|
|
235
192
|
var CreditInvoiceSchema = BaseInvoice.safeExtend({
|
|
236
|
-
invoice_type:
|
|
237
|
-
party_id:
|
|
238
|
-
invoice_items:
|
|
193
|
+
invoice_type: z5.literal("credit"),
|
|
194
|
+
party_id: z5.uuid({ message: "Select a customer" }),
|
|
195
|
+
invoice_items: z5.array(CreditItem).min(1, "Add at least one invoice item")
|
|
239
196
|
});
|
|
240
197
|
var PurchaseInvoiceSchema = BaseInvoice.safeExtend({
|
|
241
|
-
invoice_type:
|
|
242
|
-
party_id:
|
|
243
|
-
invoice_items:
|
|
198
|
+
invoice_type: z5.literal("purchase"),
|
|
199
|
+
party_id: z5.uuid({ message: "Select a vendor" }),
|
|
200
|
+
invoice_items: z5.array(PurchaseItem).min(1, "Add at least one invoice item")
|
|
244
201
|
});
|
|
245
|
-
var AnyInvoiceSchema =
|
|
202
|
+
var AnyInvoiceSchema = z5.discriminatedUnion("invoice_type", [
|
|
246
203
|
SalesInvoiceSchema,
|
|
247
204
|
PurchaseInvoiceSchema,
|
|
248
205
|
CreditInvoiceSchema
|
|
@@ -303,6 +260,71 @@ var exceedsTwoDecimals = (raw) => {
|
|
|
303
260
|
const digitsAfter = ((_a = after.match(/\d/g)) != null ? _a : []).length;
|
|
304
261
|
return digitsAfter > 2;
|
|
305
262
|
};
|
|
263
|
+
|
|
264
|
+
// src/domains/products/product_schemas.ts
|
|
265
|
+
import { z as z6 } from "zod";
|
|
266
|
+
var ProductFormSchema = z6.strictObject({
|
|
267
|
+
product_name: z6.string().transform(normalizeSpaces).pipe(
|
|
268
|
+
z6.string().min(1, "Product name is required").max(50, "Product name must be at most 50 characters.")
|
|
269
|
+
),
|
|
270
|
+
product_description: z6.string().transform(normalizeSpaces).pipe(
|
|
271
|
+
z6.string().max(100, "Product desription must be at most 100 characters.")
|
|
272
|
+
).transform(transformEmptyStringToUndefined).optional(),
|
|
273
|
+
product_sku: z6.string().transform(normalizeSpaces).pipe(z6.string().max(30, "Product SKU must be at most 30 characters.")).transform(transformEmptyStringToUndefined).optional(),
|
|
274
|
+
product_upc: z6.string().transform((s) => s.replace(/\s+/g, "")).refine((s) => s === "" || /^\d{12}$/.test(s), {
|
|
275
|
+
error: "UPC must be exactly 12 digits"
|
|
276
|
+
}).transform(transformEmptyStringToUndefined).optional(),
|
|
277
|
+
product_gtin_14: z6.string().transform((s) => s.replace(/\s+/g, "")).refine((s) => s === "" || /^\d{14}$/.test(s), {
|
|
278
|
+
error: "GTIN14 must be exactly 14 digits"
|
|
279
|
+
}).transform(transformEmptyStringToUndefined).optional(),
|
|
280
|
+
product_type: z6.enum(["unit", "weight", "case"], {
|
|
281
|
+
error: "Product type must be unit, weight, or case."
|
|
282
|
+
}),
|
|
283
|
+
weight_unit: z6.preprocess((v) => {
|
|
284
|
+
if (v === "") return void 0;
|
|
285
|
+
if (typeof v === "string") return v.trim().toLowerCase();
|
|
286
|
+
return v;
|
|
287
|
+
}, z6.enum(["kg", "lb", "g", "oz"]).optional()),
|
|
288
|
+
price: handleZodCurrency(0, 99999.99),
|
|
289
|
+
cost: handleZodCurrency(0, 99999.99)
|
|
290
|
+
}).superRefine((data, ctx) => {
|
|
291
|
+
if (data.product_type === "weight" && !data.weight_unit) {
|
|
292
|
+
ctx.addIssue({
|
|
293
|
+
code: "custom",
|
|
294
|
+
error: "Weight unit is required.",
|
|
295
|
+
path: ["weight_unit"]
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
if (data.product_type !== "weight" && typeof data.weight_unit !== "undefined") {
|
|
299
|
+
ctx.addIssue({
|
|
300
|
+
code: "custom",
|
|
301
|
+
error: "Weight unit must be empty",
|
|
302
|
+
path: ["weight_unit"]
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
// src/domains/payments/payments_schemas.ts
|
|
308
|
+
import { z as z7 } from "zod";
|
|
309
|
+
|
|
310
|
+
// src/domains/payments/payments_types.ts
|
|
311
|
+
var PAYMENT_METHOD = [
|
|
312
|
+
"check",
|
|
313
|
+
"cash",
|
|
314
|
+
"bank_transfer",
|
|
315
|
+
"digital_wallet"
|
|
316
|
+
];
|
|
317
|
+
|
|
318
|
+
// src/domains/payments/payments_schemas.ts
|
|
319
|
+
var PaymentFormSchema = z7.strictObject({
|
|
320
|
+
payment_method: z7.enum(PAYMENT_METHOD, {
|
|
321
|
+
error: "Payment method is required."
|
|
322
|
+
}),
|
|
323
|
+
check_number: z7.string().transform(normalizeSpaces).pipe(
|
|
324
|
+
z7.string().max(50, "Payment check number must be at most 50 characters.")
|
|
325
|
+
).transform(transformEmptyStringToUndefined).optional(),
|
|
326
|
+
payment_amount: handleZodCurrency(0.01, 999999.99)
|
|
327
|
+
});
|
|
306
328
|
export {
|
|
307
329
|
AnyInvoiceSchema,
|
|
308
330
|
CREDIT_TYPE,
|
|
@@ -310,6 +332,8 @@ export {
|
|
|
310
332
|
CustomerFormSchema,
|
|
311
333
|
INVOICE_STATUS,
|
|
312
334
|
INVOICE_TYPE,
|
|
335
|
+
PAYMENT_METHOD,
|
|
336
|
+
PaymentFormSchema,
|
|
313
337
|
ProductFormSchema,
|
|
314
338
|
PurchaseInvoiceSchema,
|
|
315
339
|
RegisterFormSchema,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/companies_schemas.ts","../src/types/company_types.ts","../src/types/money_types.ts","../src/utils/utils.ts","../src/schemas/customer_schemas.ts","../src/schemas/product_schemas.ts","../src/types/shared_types.ts","../src/domains/invoices/invoices_schemas.ts","../src/domains/invoices/invoices_types.ts","../src/utils/date_utils.ts","../src/utils/errors_utils.ts","../src/utils/money_utils.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { ISO_COUNTRY_CODES, USER_ROLES } from \"../types/company_types\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nconst iso_country_code = z.enum(ISO_COUNTRY_CODES, {\n error: \"Country code not supported.\",\n});\n\nconst user_role = z.enum(USER_ROLES, {\n error: \"User role not supported.\",\n});\n\nexport const RegisterFormSchema = z.strictObject({\n companyData: z.strictObject({\n company_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company name is required\")\n .max(50, \"Company name must be at most 50 characters.\")\n ),\n company_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company address is required\")\n .max(100, \"Company address must be at most 100 characters.\")\n ),\n company_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => /^\\d{4,15}$/.test(s), {\n error: \"Phone number required and must be from 4 to 15 digits.\",\n }),\n iso_country_code: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform((s) => s.toUpperCase())\n .pipe(iso_country_code),\n }),\n adminUserData: z.strictObject({\n user_first_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"First name is required\")\n .max(50, \"First name must be at most 50 characters.\")\n ),\n user_last_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Last name is required\")\n .max(50, \"Last name must be at most 50 characters.\")\n ),\n user_email: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n ),\n password: z\n .string()\n .min(8, \"Password must be at least 8 characters\")\n .max(25, \"Password must be at most 25 characters\")\n .regex(/[A-Z]/, \"Password must contain at least one uppercase letter\")\n .regex(/[a-z]/, \"Password must contain at least one lowercase letter\")\n .regex(/\\d/, \"Password must contain at least one number\")\n .regex(\n /[@$!%*?&#^_+=-]/,\n \"Password must contain at least one special character\"\n )\n .regex(/^\\S*$/, \"Password cannot contain spaces or other whitespace.\"),\n }),\n});\n","export const ISO_COUNTRY_CODES = [\"US\", \"HN\"] as const;\n\nexport type IsoCountryCode = (typeof ISO_COUNTRY_CODES)[number];\n\nexport const USER_ROLES = [\"admin\", \"driver\"] as const;\n\nexport type UserRole = (typeof USER_ROLES)[number];\n\nexport type InventorySystem = \"warehouse_only\" | \"dsd\";\n","import { IsoCountryCode } from \"../types/company_types\";\n\nexport type IsoCurrencyCode = \"USD\" | \"HNL\";\ntype Locale = \"en-US\" | \"es-HN\";\n\nexport const countryToCurrency: Record<IsoCountryCode, IsoCurrencyCode> = {\n US: \"USD\",\n HN: \"HNL\",\n};\n\nexport const currencyToLocale: Record<IsoCurrencyCode, Locale> = {\n USD: \"en-US\",\n HNL: \"es-HN\",\n};\n","import * as GlobalTypes from \"./types\";\nimport { IsoCountryCode } from \"../types/company_types\";\nimport {\n IsoCurrencyCode,\n countryToCurrency,\n currencyToLocale,\n} from \"../types/money_types\";\n\nimport { z } from \"zod\";\n\n/**\n * Validates zod currency with precision.\n *\n *\n * @param minAmount\n * @param maxAmount\n * @returns\n */\nexport function handleZodCurrency(minAmount: number, maxAmount: number) {\n const fromString = z\n .string({\n error: \"Enter a valid number\",\n })\n .refine((s) => s.trim().length > 0, { error: \"Enter a valid number\" })\n .transform((s) => s.replace(/[,\\s]/g, \"\"))\n .refine((s) => s !== \"\" && !Number.isNaN(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number.isFinite(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number(s) >= 0, { error: \"Enter a positive number\" })\n .transform((s) => Number(s));\n\n const fromNumber = z\n .number()\n .refine((n) => Number.isFinite(n), { error: \"Enter a valid number\" })\n .refine((n) => n >= 0, { error: \"Enter a positive number\" });\n\n return z\n .union([fromString, fromNumber])\n .transform((n) => roundWithPrecision(n, 2))\n .refine((n) => n >= minAmount, {\n error: `Must be greater than ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `Exceeds allowed limit ${maxAmount}`,\n });\n}\n\n/**\n * Trims any leading or trailing spaces\n * Transforms empty strings into undefined.\n *\n * @param s\n * @returns\n */\nexport const transformEmptyStringToUndefined = (s: string) =>\n s.trim() === \"\" ? undefined : s;\n\n/**\n * - Collapses any run of whitespace in a string (spaces, tabs, newlines, nbspb, and other weird unicode spaces etc.)\n * into a single ASCII space.\n * - Trims leading and trailing whitespace.\n * \" Jared \\n Gomez \\t Driver\\t \" -> \"Jared Gomez Driver\"\n *\n * @param s\n * @returns\n */\nexport const normalizeSpaces = (s: string) => whitespace(s, \"normalize\");\n\n/**\n * Removes all whitespace from a string\n * @param s\n * @returns\n */\nexport const removeAllWhitespace = (s: string) => whitespace(s, \"remove\");\n\nconst whitespace = (s: string, mode: GlobalTypes.WhitespaceMode) => {\n if (mode === \"remove\") {\n return s.replace(/\\s+/g, \"\");\n }\n\n return s.replace(/\\s+/g, \" \").trim();\n};\n\n/**\n * Removes all dashes and + signs from a string\n * +1-305-555-0123 -> \"13055550123\"\n * 305-555-0123 -> \"3055550123\"\n *\n * @param s\n * @returns\n */\nexport const removeDashesAndPlusSign = (s: string): string =>\n s.replace(/[+-]/g, \"\");\n\n/**\n * Rounds a number to a certain precision.\n * Contract:\n * 1. Number must be finite and non negative.\n * 2. Precision must be finite nonnegative and an integer.\n * 3. Precision must be <= Max precision\n * 4. Returns a number >= 0\n * Default is round half up.\n *\n * @param num\n * @param precision\n * @param opts\n * @returns\n */\nexport function roundWithPrecision(\n num: number,\n precision: number,\n opts?: GlobalTypes.ToFixedOptions\n): number {\n const MAX_PRECISION = 2;\n const { roundType = \"half_up\" } = opts ?? {};\n\n if (!Number.isFinite(num) || num < 0) {\n throw new RangeError(\"Number must be finite and greater than 0.\");\n }\n\n if (\n !Number.isFinite(precision) ||\n !Number.isInteger(precision) ||\n precision < 1\n ) {\n throw new RangeError(\"Precision must be a finite integer greater than 0.\");\n }\n\n if (precision > MAX_PRECISION) {\n throw new RangeError(\"Max precision allowed is 2.\");\n }\n\n return Number(\n (+(Math.round(+(num + \"e\" + precision)) + \"e\" + -precision)).toFixed(\n precision\n )\n );\n}\n\nexport function getCurrencyFromCountry(\n country: IsoCountryCode\n): IsoCurrencyCode {\n return countryToCurrency[country];\n}\n\nexport function formatMoneyCurrency(value: number, currency: IsoCurrencyCode) {\n const locale =\n currency in currencyToLocale ? currencyToLocale[currency] : \"en-US\";\n\n const formatted = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: currency,\n }).format(value);\n\n return sanitizeSpaces(formatted);\n}\n\nfunction sanitizeSpaces(str: string): string {\n return str\n .replace(/\\u00A0/g, \" \")\n .replace(/\\u202F/g, \" \")\n .replace(/[^\\x20-\\x7E]/g, \"\");\n}\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nexport const CustomerFormSchema = z.strictObject({\n customer_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Customer name is required\")\n .max(50, \"Customer name must be at most 50 characters.\")\n ),\n\n customer_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z.string().max(100, \"Customer address must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => s === \"\" || /^\\d{4,15}$/.test(s), {\n error: \"Phone number must be from 4 to 15 digits.\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_email_address: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n .optional()\n )\n .optional(),\n});\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nexport const ProductFormSchema = z\n .strictObject({\n product_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Product name is required\")\n .max(50, \"Product name must be at most 50 characters.\")\n ),\n\n product_description: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .max(100, \"Product desription must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_sku: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(z.string().max(30, \"Product SKU must be at most 30 characters.\"))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_upc: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{12}$/.test(s), {\n error: \"UPC must be exactly 12 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_gtin_14: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{14}$/.test(s), {\n error: \"GTIN14 must be exactly 14 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_type: z.enum([\"unit\", \"weight\", \"case\"], {\n error: \"Product type must be unit, weight, or case.\",\n }),\n\n weight_unit: z.preprocess((v) => {\n if (v === \"\") return undefined;\n if (typeof v === \"string\") return v.trim().toLowerCase();\n return v;\n }, z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional()),\n\n price: GlobalUtils.handleZodCurrency(0, 99_999.99),\n cost: GlobalUtils.handleZodCurrency(0, 99_999.99),\n })\n\n .superRefine((data, ctx) => {\n if (data.product_type === \"weight\" && !data.weight_unit) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit is required.\",\n path: [\"weight_unit\"],\n });\n }\n\n if (\n data.product_type !== \"weight\" &&\n typeof data.weight_unit !== \"undefined\"\n ) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit must be empty\",\n path: [\"weight_unit\"],\n });\n }\n });\n","import { z } from \"zod\";\n\nexport const CREATED_LOCATION = [\"web\", \"mobile\"] as const;\n\nexport type CreatedLocation = (typeof CREATED_LOCATION)[number];\n\nexport type IntBool = 0 | 1;\n\nexport const uuidSchema = z.uuid();\nexport type UUID = z.infer<typeof uuidSchema>;\n","import { z } from \"zod\";\nimport { CREDIT_TYPE, INVOICE_STATUS, INVOICE_TYPE } from \"./invoices_types\";\nimport { handleZodCurrency } from \"../../utils/utils\";\n\nconst YmdDateSchema = z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\nconst BaseInvoice = z\n .object({\n invoice_type: z.enum(INVOICE_TYPE, { error: \"Invoice type not found.\" }),\n invoice_date: YmdDateSchema,\n due_date: YmdDateSchema,\n tax_rate: z.number().default(0),\n tax_amount: z.number().default(0),\n warehouse_id: z.uuid().optional(),\n invoice_status: z.enum(INVOICE_STATUS).default(\"finalized\"),\n })\n .superRefine(({ invoice_date, due_date }, ctx) => {\n if (due_date < invoice_date) {\n ctx.addIssue({\n code: \"custom\",\n message: \"Due date can't be earlier than the invoice date.\",\n path: [\"due_date\"],\n });\n }\n });\n\nconst LineItemBase = z.object({\n invoice_id: z.uuid().optional(),\n product_id: z.uuid({ error: \"Select a product\" }),\n product_name: z.string().optional(),\n product_description: z.string().optional(),\n product_type: z.enum([\"unit\", \"weight\", \"case\"]).optional(),\n product_upc: z.string().optional(),\n weight_unit: z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional(),\n quantity: handleZodCurrency(0.01, 99_999.99),\n});\n\nconst SalesItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nconst CreditItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.enum(CREDIT_TYPE, {\n error: \"Select a credit type\",\n }),\n});\n\nconst PurchaseItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nexport const SalesInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"sales\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(SalesItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const CreditInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"credit\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(CreditItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const PurchaseInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"purchase\"),\n party_id: z.uuid({ message: \"Select a vendor\" }),\n invoice_items: z.array(PurchaseItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const AnyInvoiceSchema = z.discriminatedUnion(\"invoice_type\", [\n SalesInvoiceSchema,\n PurchaseInvoiceSchema,\n CreditInvoiceSchema,\n]);\n","import { z } from \"zod\";\nimport * as InvoiceSchemas from \"./invoices_schemas\";\n\nexport type SalesInvoice = z.infer<typeof InvoiceSchemas.SalesInvoiceSchema>;\nexport type CreditInvoice = z.infer<typeof InvoiceSchemas.CreditInvoiceSchema>;\nexport type PurchaseInvoice = z.infer<\n typeof InvoiceSchemas.PurchaseInvoiceSchema\n>;\nexport type AnyInvoiceOut = z.output<typeof InvoiceSchemas.AnyInvoiceSchema>;\n\nexport const INVOICE_TYPE = [\"sales\", \"credit\", \"purchase\"] as const;\n\nexport type InvoiceType = (typeof INVOICE_TYPE)[number];\n\nexport const INVOICE_STATUS = [\"finalized\", \"voided\"] as const;\n\nexport type InvoiceStatus = (typeof INVOICE_STATUS)[number];\n\nexport const CREDIT_TYPE = [\"dump\", \"return\"] as const;\n\nexport type CreditType = (typeof CREDIT_TYPE)[number];\n","// \"Today\" in the user's LOCAL timezone as YMD\nexport function todayLocalYmd(): string {\n const now = new Date();\n const y = now.getFullYear();\n const m = String(now.getMonth() + 1).padStart(2, \"0\");\n const d = String(now.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\n// Add days in LOCAL time (no drift)\nexport function addDaysLocalYmd(ymd: string, days: number): string {\n const dt = localDateFromYmd(ymd);\n dt.setDate(dt.getDate() + days);\n return ymdFromLocalDate(dt);\n}\n\nexport function formatYmdLong(ymd: string, locale = \"en-US\"): string {\n const { y, m, d } = parseYmd(ymd);\n const utcDate = new Date(Date.UTC(y, m - 1, d)); // 00:00Z\n return new Intl.DateTimeFormat(locale, {\n dateStyle: \"long\",\n timeZone: \"UTC\",\n }).format(utcDate);\n}\n\nexport function localDateFromYmd(ymd: string): Date {\n const { y, m, d } = parseYmd(ymd);\n return new Date(y, m - 1, d); // LOCAL midnight\n}\n\nexport function ymdFromLocalDate(dt: Date): string {\n const y = dt.getFullYear();\n const m = String(dt.getMonth() + 1).padStart(2, \"0\");\n const d = String(dt.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\nfunction parseYmd(ymd: string): { y: number; m: number; d: number } {\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(ymd);\n if (!m) throw new Error(\"Bad YMD\");\n return { y: Number(m[1]), m: Number(m[2]), d: Number(m[3]) };\n}\n","import type { FieldError, FieldErrorsImpl, Merge } from \"react-hook-form\";\n\ntype RHFError =\n | string\n | FieldError\n | Merge<FieldError, FieldErrorsImpl<any>>\n | undefined;\n\nexport const getErrorMessage = (err: RHFError): string | undefined => {\n if (!err) return undefined;\n if (typeof err === \"string\") return err;\n // FieldError has .message (string | undefined)\n const msg = (err as FieldError).message as string | undefined;\n return typeof msg === \"string\" ? msg : undefined;\n};\n","export const exceedsTwoDecimals = (raw: string) => {\n const s = String(raw ?? \"\").replace(/[,\\s]/g, \"\");\n const dot = s.indexOf(\".\");\n if (dot === -1) return false;\n const after = s.slice(dot + 1);\n const digitsAfter = (after.match(/\\d/g) ?? []).length;\n return digitsAfter > 2;\n};\n"],"mappings":";AAAA,SAAS,KAAAA,UAAS;;;ACAX,IAAM,oBAAoB,CAAC,MAAM,IAAI;AAIrC,IAAM,aAAa,CAAC,SAAS,QAAQ;;;ACCrC,IAAM,oBAA6D;AAAA,EACxE,IAAI;AAAA,EACJ,IAAI;AACN;AAEO,IAAM,mBAAoD;AAAA,EAC/D,KAAK;AAAA,EACL,KAAK;AACP;;;ACLA,SAAS,SAAS;AAUX,SAAS,kBAAkB,WAAmB,WAAmB;AACtE,QA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,GAAG;AAC9C,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,SAAS;AACjC,SAAO,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,GAAG,GAAG,OAAO,EAAE,CAAC,CAAC,GAAG,GAAG,OAAO,EAAE,CAAC,CAAC,EAAE;AAC7D;;;ACjCO,IAAM,kBAAkB,CAAC,QAAsC;AACpE,MAAI,CAAC,IAAK,QAAO;AACjB,MAAI,OAAO,QAAQ,SAAU,QAAO;AAEpC,QAAM,MAAO,IAAmB;AAChC,SAAO,OAAO,QAAQ,WAAW,MAAM;AACzC;;;ACdO,IAAM,qBAAqB,CAAC,QAAgB;AAAnD;AACE,QAAM,IAAI,OAAO,oBAAO,EAAE,EAAE,QAAQ,UAAU,EAAE;AAChD,QAAM,MAAM,EAAE,QAAQ,GAAG;AACzB,MAAI,QAAQ,GAAI,QAAO;AACvB,QAAM,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC7B,QAAM,gBAAe,WAAM,MAAM,KAAK,MAAjB,YAAsB,CAAC,GAAG;AAC/C,SAAO,cAAc;AACvB;","names":["z","z","z","z","z","z","z","z","z","z"]}
|
|
1
|
+
{"version":3,"sources":["../src/schemas/companies_schemas.ts","../src/types/company_types.ts","../src/types/money_types.ts","../src/utils/utils.ts","../src/schemas/customer_schemas.ts","../src/types/shared_types.ts","../src/domains/invoices/invoices_schemas.ts","../src/domains/invoices/invoices_types.ts","../src/utils/date_utils.ts","../src/utils/errors_utils.ts","../src/utils/money_utils.ts","../src/domains/products/product_schemas.ts","../src/domains/payments/payments_schemas.ts","../src/domains/payments/payments_types.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { ISO_COUNTRY_CODES, USER_ROLES } from \"../types/company_types\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nconst iso_country_code = z.enum(ISO_COUNTRY_CODES, {\n error: \"Country code not supported.\",\n});\n\nconst user_role = z.enum(USER_ROLES, {\n error: \"User role not supported.\",\n});\n\nexport const RegisterFormSchema = z.strictObject({\n companyData: z.strictObject({\n company_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company name is required\")\n .max(50, \"Company name must be at most 50 characters.\")\n ),\n company_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company address is required\")\n .max(100, \"Company address must be at most 100 characters.\")\n ),\n company_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => /^\\d{4,15}$/.test(s), {\n error: \"Phone number required and must be from 4 to 15 digits.\",\n }),\n iso_country_code: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform((s) => s.toUpperCase())\n .pipe(iso_country_code),\n }),\n adminUserData: z.strictObject({\n user_first_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"First name is required\")\n .max(50, \"First name must be at most 50 characters.\")\n ),\n user_last_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Last name is required\")\n .max(50, \"Last name must be at most 50 characters.\")\n ),\n user_email: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n ),\n password: z\n .string()\n .min(8, \"Password must be at least 8 characters\")\n .max(25, \"Password must be at most 25 characters\")\n .regex(/[A-Z]/, \"Password must contain at least one uppercase letter\")\n .regex(/[a-z]/, \"Password must contain at least one lowercase letter\")\n .regex(/\\d/, \"Password must contain at least one number\")\n .regex(\n /[@$!%*?&#^_+=-]/,\n \"Password must contain at least one special character\"\n )\n .regex(/^\\S*$/, \"Password cannot contain spaces or other whitespace.\"),\n }),\n});\n","export const ISO_COUNTRY_CODES = [\"US\", \"HN\"] as const;\n\nexport type IsoCountryCode = (typeof ISO_COUNTRY_CODES)[number];\n\nexport const USER_ROLES = [\"admin\", \"driver\"] as const;\n\nexport type UserRole = (typeof USER_ROLES)[number];\n\nexport type InventorySystem = \"warehouse_only\" | \"dsd\";\n","import { IsoCountryCode } from \"../types/company_types\";\n\nexport type IsoCurrencyCode = \"USD\" | \"HNL\";\ntype Locale = \"en-US\" | \"es-HN\";\n\nexport const countryToCurrency: Record<IsoCountryCode, IsoCurrencyCode> = {\n US: \"USD\",\n HN: \"HNL\",\n};\n\nexport const currencyToLocale: Record<IsoCurrencyCode, Locale> = {\n USD: \"en-US\",\n HNL: \"es-HN\",\n};\n","import * as GlobalTypes from \"./types\";\nimport { IsoCountryCode } from \"../types/company_types\";\nimport {\n IsoCurrencyCode,\n countryToCurrency,\n currencyToLocale,\n} from \"../types/money_types\";\n\nimport { z } from \"zod\";\n\n/**\n * Validates zod currency with precision.\n *\n *\n * @param minAmount\n * @param maxAmount\n * @returns\n */\nexport function handleZodCurrency(minAmount: number, maxAmount: number) {\n const fromString = z\n .string({\n error: \"Enter a valid number\",\n })\n .refine((s) => s.trim().length > 0, { error: \"Enter a valid number\" })\n .transform((s) => s.replace(/[,\\s]/g, \"\"))\n .refine((s) => s !== \"\" && !Number.isNaN(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number.isFinite(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number(s) >= 0, { error: \"Enter a positive number\" })\n .transform((s) => Number(s));\n\n const fromNumber = z\n .number()\n .refine((n) => Number.isFinite(n), { error: \"Enter a valid number\" })\n .refine((n) => n >= 0, { error: \"Enter a positive number\" });\n\n return z\n .union([fromString, fromNumber])\n .transform((n) => roundWithPrecision(n, 2))\n .refine((n) => n >= minAmount, {\n error: `Must be greater than ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `Exceeds allowed limit ${maxAmount}`,\n });\n}\n\n/**\n * Trims any leading or trailing spaces\n * Transforms empty strings into undefined.\n *\n * @param s\n * @returns\n */\nexport const transformEmptyStringToUndefined = (s: string) =>\n s.trim() === \"\" ? undefined : s;\n\n/**\n * - Collapses any run of whitespace in a string (spaces, tabs, newlines, nbspb, and other weird unicode spaces etc.)\n * into a single ASCII space.\n * - Trims leading and trailing whitespace.\n * \" Jared \\n Gomez \\t Driver\\t \" -> \"Jared Gomez Driver\"\n *\n * @param s\n * @returns\n */\nexport const normalizeSpaces = (s: string) => whitespace(s, \"normalize\");\n\n/**\n * Removes all whitespace from a string\n * @param s\n * @returns\n */\nexport const removeAllWhitespace = (s: string) => whitespace(s, \"remove\");\n\nconst whitespace = (s: string, mode: GlobalTypes.WhitespaceMode) => {\n if (mode === \"remove\") {\n return s.replace(/\\s+/g, \"\");\n }\n\n return s.replace(/\\s+/g, \" \").trim();\n};\n\n/**\n * Removes all dashes and + signs from a string\n * +1-305-555-0123 -> \"13055550123\"\n * 305-555-0123 -> \"3055550123\"\n *\n * @param s\n * @returns\n */\nexport const removeDashesAndPlusSign = (s: string): string =>\n s.replace(/[+-]/g, \"\");\n\n/**\n * Rounds a number to a certain precision.\n * Contract:\n * 1. Number must be finite and non negative.\n * 2. Precision must be finite nonnegative and an integer.\n * 3. Precision must be <= Max precision\n * 4. Returns a number >= 0\n * Default is round half up.\n *\n * @param num\n * @param precision\n * @param opts\n * @returns\n */\nexport function roundWithPrecision(\n num: number,\n precision: number,\n opts?: GlobalTypes.ToFixedOptions\n): number {\n const MAX_PRECISION = 2;\n const { roundType = \"half_up\" } = opts ?? {};\n\n if (!Number.isFinite(num) || num < 0) {\n throw new RangeError(\"Number must be finite and greater than 0.\");\n }\n\n if (\n !Number.isFinite(precision) ||\n !Number.isInteger(precision) ||\n precision < 1\n ) {\n throw new RangeError(\"Precision must be a finite integer greater than 0.\");\n }\n\n if (precision > MAX_PRECISION) {\n throw new RangeError(\"Max precision allowed is 2.\");\n }\n\n return Number(\n (+(Math.round(+(num + \"e\" + precision)) + \"e\" + -precision)).toFixed(\n precision\n )\n );\n}\n\nexport function getCurrencyFromCountry(\n country: IsoCountryCode\n): IsoCurrencyCode {\n return countryToCurrency[country];\n}\n\nexport function formatMoneyCurrency(value: number, currency: IsoCurrencyCode) {\n const locale =\n currency in currencyToLocale ? currencyToLocale[currency] : \"en-US\";\n\n const formatted = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: currency,\n }).format(value);\n\n return sanitizeSpaces(formatted);\n}\n\nfunction sanitizeSpaces(str: string): string {\n return str\n .replace(/\\u00A0/g, \" \")\n .replace(/\\u202F/g, \" \")\n .replace(/[^\\x20-\\x7E]/g, \"\");\n}\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nexport const CustomerFormSchema = z.strictObject({\n customer_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Customer name is required\")\n .max(50, \"Customer name must be at most 50 characters.\")\n ),\n\n customer_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z.string().max(100, \"Customer address must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => s === \"\" || /^\\d{4,15}$/.test(s), {\n error: \"Phone number must be from 4 to 15 digits.\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_email_address: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n .optional()\n )\n .optional(),\n});\n","import { z } from \"zod\";\n\nexport const CREATED_LOCATION = [\"web\", \"mobile\"] as const;\n\nexport type CreatedLocation = (typeof CREATED_LOCATION)[number];\n\nexport type IntBool = 0 | 1;\n\nexport const uuidSchema = z.uuid();\nexport type UUID = z.infer<typeof uuidSchema>;\n","import { z } from \"zod\";\nimport { CREDIT_TYPE, INVOICE_STATUS, INVOICE_TYPE } from \"./invoices_types\";\nimport { handleZodCurrency } from \"../../utils/utils\";\n\nconst YmdDateSchema = z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\nconst BaseInvoice = z\n .object({\n invoice_type: z.enum(INVOICE_TYPE, { error: \"Invoice type not found.\" }),\n invoice_date: YmdDateSchema,\n due_date: YmdDateSchema,\n tax_rate: z.number().default(0),\n tax_amount: z.number().default(0),\n warehouse_id: z.uuid().optional(),\n invoice_status: z.enum(INVOICE_STATUS).default(\"finalized\"),\n })\n .superRefine(({ invoice_date, due_date }, ctx) => {\n if (due_date < invoice_date) {\n ctx.addIssue({\n code: \"custom\",\n message: \"Due date can't be earlier than the invoice date.\",\n path: [\"due_date\"],\n });\n }\n });\n\nconst LineItemBase = z.object({\n invoice_id: z.uuid().optional(),\n product_id: z.uuid({ error: \"Select a product\" }),\n product_name: z.string().optional(),\n product_description: z.string().optional(),\n product_type: z.enum([\"unit\", \"weight\", \"case\"]).optional(),\n product_upc: z.string().optional(),\n weight_unit: z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional(),\n quantity: handleZodCurrency(0.01, 99_999.99),\n});\n\nconst SalesItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nconst CreditItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.enum(CREDIT_TYPE, {\n error: \"Select a credit type\",\n }),\n});\n\nconst PurchaseItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nexport const SalesInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"sales\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(SalesItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const CreditInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"credit\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(CreditItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const PurchaseInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"purchase\"),\n party_id: z.uuid({ message: \"Select a vendor\" }),\n invoice_items: z.array(PurchaseItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const AnyInvoiceSchema = z.discriminatedUnion(\"invoice_type\", [\n SalesInvoiceSchema,\n PurchaseInvoiceSchema,\n CreditInvoiceSchema,\n]);\n","import { z } from \"zod\";\nimport * as InvoiceSchemas from \"./invoices_schemas\";\n\nexport type SalesInvoice = z.infer<typeof InvoiceSchemas.SalesInvoiceSchema>;\nexport type CreditInvoice = z.infer<typeof InvoiceSchemas.CreditInvoiceSchema>;\nexport type PurchaseInvoice = z.infer<\n typeof InvoiceSchemas.PurchaseInvoiceSchema\n>;\nexport type AnyInvoiceOut = z.output<typeof InvoiceSchemas.AnyInvoiceSchema>;\n\nexport const INVOICE_TYPE = [\"sales\", \"credit\", \"purchase\"] as const;\n\nexport type InvoiceType = (typeof INVOICE_TYPE)[number];\n\nexport const INVOICE_STATUS = [\"finalized\", \"voided\"] as const;\n\nexport type InvoiceStatus = (typeof INVOICE_STATUS)[number];\n\nexport const CREDIT_TYPE = [\"dump\", \"return\"] as const;\n\nexport type CreditType = (typeof CREDIT_TYPE)[number];\n","// \"Today\" in the user's LOCAL timezone as YMD\nexport function todayLocalYmd(): string {\n const now = new Date();\n const y = now.getFullYear();\n const m = String(now.getMonth() + 1).padStart(2, \"0\");\n const d = String(now.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\n// Add days in LOCAL time (no drift)\nexport function addDaysLocalYmd(ymd: string, days: number): string {\n const dt = localDateFromYmd(ymd);\n dt.setDate(dt.getDate() + days);\n return ymdFromLocalDate(dt);\n}\n\nexport function formatYmdLong(ymd: string, locale = \"en-US\"): string {\n const { y, m, d } = parseYmd(ymd);\n const utcDate = new Date(Date.UTC(y, m - 1, d)); // 00:00Z\n return new Intl.DateTimeFormat(locale, {\n dateStyle: \"long\",\n timeZone: \"UTC\",\n }).format(utcDate);\n}\n\nexport function localDateFromYmd(ymd: string): Date {\n const { y, m, d } = parseYmd(ymd);\n return new Date(y, m - 1, d); // LOCAL midnight\n}\n\nexport function ymdFromLocalDate(dt: Date): string {\n const y = dt.getFullYear();\n const m = String(dt.getMonth() + 1).padStart(2, \"0\");\n const d = String(dt.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\nfunction parseYmd(ymd: string): { y: number; m: number; d: number } {\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(ymd);\n if (!m) throw new Error(\"Bad YMD\");\n return { y: Number(m[1]), m: Number(m[2]), d: Number(m[3]) };\n}\n","import type { FieldError, FieldErrorsImpl, Merge } from \"react-hook-form\";\n\ntype RHFError =\n | string\n | FieldError\n | Merge<FieldError, FieldErrorsImpl<any>>\n | undefined;\n\nexport const getErrorMessage = (err: RHFError): string | undefined => {\n if (!err) return undefined;\n if (typeof err === \"string\") return err;\n // FieldError has .message (string | undefined)\n const msg = (err as FieldError).message as string | undefined;\n return typeof msg === \"string\" ? msg : undefined;\n};\n","export const exceedsTwoDecimals = (raw: string) => {\n const s = String(raw ?? \"\").replace(/[,\\s]/g, \"\");\n const dot = s.indexOf(\".\");\n if (dot === -1) return false;\n const after = s.slice(dot + 1);\n const digitsAfter = (after.match(/\\d/g) ?? []).length;\n return digitsAfter > 2;\n};\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../utils/utils\";\n\nexport const ProductFormSchema = z\n .strictObject({\n product_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Product name is required\")\n .max(50, \"Product name must be at most 50 characters.\")\n ),\n\n product_description: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .max(100, \"Product desription must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_sku: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(z.string().max(30, \"Product SKU must be at most 30 characters.\"))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_upc: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{12}$/.test(s), {\n error: \"UPC must be exactly 12 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_gtin_14: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{14}$/.test(s), {\n error: \"GTIN14 must be exactly 14 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_type: z.enum([\"unit\", \"weight\", \"case\"], {\n error: \"Product type must be unit, weight, or case.\",\n }),\n\n weight_unit: z.preprocess((v) => {\n if (v === \"\") return undefined;\n if (typeof v === \"string\") return v.trim().toLowerCase();\n return v;\n }, z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional()),\n\n price: GlobalUtils.handleZodCurrency(0, 99_999.99),\n cost: GlobalUtils.handleZodCurrency(0, 99_999.99),\n })\n\n .superRefine((data, ctx) => {\n if (data.product_type === \"weight\" && !data.weight_unit) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit is required.\",\n path: [\"weight_unit\"],\n });\n }\n\n if (\n data.product_type !== \"weight\" &&\n typeof data.weight_unit !== \"undefined\"\n ) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit must be empty\",\n path: [\"weight_unit\"],\n });\n }\n });\n","import { z } from \"zod\";\nimport { PAYMENT_METHOD } from \"./payments_types\";\nimport * as GlobalUtils from \"../../utils/utils\";\n\nexport const PaymentFormSchema = z.strictObject({\n payment_method: z.enum(PAYMENT_METHOD, {\n error: \"Payment method is required.\",\n }),\n check_number: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z.string().max(50, \"Payment check number must be at most 50 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n payment_amount: GlobalUtils.handleZodCurrency(0.01, 999_999.99),\n});\n","export const PAYMENT_METHOD = [\n \"check\",\n \"cash\",\n \"bank_transfer\",\n \"digital_wallet\",\n] as const;\n\nexport type PaymentMethod = (typeof PAYMENT_METHOD)[number];\n"],"mappings":";AAAA,SAAS,KAAAA,UAAS;;;ACAX,IAAM,oBAAoB,CAAC,MAAM,IAAI;AAIrC,IAAM,aAAa,CAAC,SAAS,QAAQ;;;ACCrC,IAAM,oBAA6D;AAAA,EACxE,IAAI;AAAA,EACJ,IAAI;AACN;AAEO,IAAM,mBAAoD;AAAA,EAC/D,KAAK;AAAA,EACL,KAAK;AACP;;;ACLA,SAAS,SAAS;AAUX,SAAS,kBAAkB,WAAmB,WAAmB;AACtE,QAAM,aAAa,EAChB,OAAO;AAAA,IACN,OAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,EAAE,OAAO,uBAAuB,CAAC,EACpE,UAAU,CAAC,MAAM,EAAE,QAAQ,UAAU,EAAE,CAAC,EACxC,OAAO,CAAC,MAAM,MAAM,MAAM,CAAC,OAAO,MAAM,OAAO,CAAC,CAAC,GAAG;AAAA,IACnD,OAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC,GAAG;AAAA,IACzC,OAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,OAAO,CAAC,KAAK,GAAG,EAAE,OAAO,0BAA0B,CAAC,EAClE,UAAU,CAAC,MAAM,OAAO,CAAC,CAAC;AAE7B,QAAM,aAAa,EAChB,OAAO,EACP,OAAO,CAAC,MAAM,OAAO,SAAS,CAAC,GAAG,EAAE,OAAO,uBAAuB,CAAC,EACnE,OAAO,CAAC,MAAM,KAAK,GAAG,EAAE,OAAO,0BAA0B,CAAC;AAE7D,SAAO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