@marmot-systems/common 2.0.21 → 2.0.22
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 +68 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +131 -1
- package/dist/index.d.ts +131 -1
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,11 +20,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
AnyInvoiceSchema: () => AnyInvoiceSchema,
|
|
24
|
+
CreditInvoiceSchema: () => CreditInvoiceSchema,
|
|
23
25
|
CustomerFormSchema: () => CustomerFormSchema,
|
|
24
26
|
INVOICE_STATUS: () => INVOICE_STATUS,
|
|
25
27
|
INVOICE_TYPE: () => INVOICE_TYPE,
|
|
26
28
|
ProductFormSchema: () => ProductFormSchema,
|
|
29
|
+
PurchaseInvoiceSchema: () => PurchaseInvoiceSchema,
|
|
27
30
|
RegisterFormSchema: () => RegisterFormSchema,
|
|
31
|
+
SalesInvoiceSchema: () => SalesInvoiceSchema,
|
|
28
32
|
formatMoneyCurrency: () => formatMoneyCurrency,
|
|
29
33
|
getCurrencyFromCountry: () => getCurrencyFromCountry,
|
|
30
34
|
handleZodCurrency: () => handleZodCurrency,
|
|
@@ -209,13 +213,77 @@ var INVOICE_STATUS = ["finalized", "voided"];
|
|
|
209
213
|
// src/types/shared_types.ts
|
|
210
214
|
var import_zod5 = require("zod");
|
|
211
215
|
var uuidSchema = import_zod5.z.uuid();
|
|
216
|
+
|
|
217
|
+
// src/domains/invoices/invoices_schemas.ts
|
|
218
|
+
var import_zod6 = require("zod");
|
|
219
|
+
var YmdDateSchema = import_zod6.z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Use YYYY-MM-DD");
|
|
220
|
+
var BaseInvoice = import_zod6.z.object({
|
|
221
|
+
invoice_type: import_zod6.z.enum(INVOICE_TYPE),
|
|
222
|
+
invoice_date: YmdDateSchema,
|
|
223
|
+
due_date: YmdDateSchema,
|
|
224
|
+
tax_rate: import_zod6.z.number().default(0),
|
|
225
|
+
tax_amount: import_zod6.z.number().default(0),
|
|
226
|
+
warehouse_id: import_zod6.z.uuid().optional(),
|
|
227
|
+
invoice_status: import_zod6.z.enum(INVOICE_STATUS).default("finalized")
|
|
228
|
+
}).superRefine(({ invoice_date, due_date }, ctx) => {
|
|
229
|
+
if (due_date < invoice_date) {
|
|
230
|
+
ctx.addIssue({
|
|
231
|
+
code: "custom",
|
|
232
|
+
message: "Due date can't be earlier than the invoice date.",
|
|
233
|
+
path: ["due_date"]
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
var LineItemBase = import_zod6.z.object({
|
|
238
|
+
invoice_id: import_zod6.z.uuid().optional(),
|
|
239
|
+
product_id: import_zod6.z.uuid({ error: "Select a product" }),
|
|
240
|
+
quantity: handleZodCurrency(0.01, 99999.99)
|
|
241
|
+
});
|
|
242
|
+
var SalesItem = LineItemBase.safeExtend({
|
|
243
|
+
price: handleZodCurrency(0, 99999.99),
|
|
244
|
+
credit_type: import_zod6.z.undefined()
|
|
245
|
+
});
|
|
246
|
+
var CreditItem = LineItemBase.safeExtend({
|
|
247
|
+
price: handleZodCurrency(0, 99999.99),
|
|
248
|
+
credit_type: import_zod6.z.enum(["dump", "return"], {
|
|
249
|
+
error: "Select a credit type"
|
|
250
|
+
})
|
|
251
|
+
});
|
|
252
|
+
var PurchaseItem = LineItemBase.safeExtend({
|
|
253
|
+
price: handleZodCurrency(0, 99999.99),
|
|
254
|
+
credit_type: import_zod6.z.undefined()
|
|
255
|
+
});
|
|
256
|
+
var SalesInvoiceSchema = BaseInvoice.safeExtend({
|
|
257
|
+
invoice_type: import_zod6.z.literal("sales"),
|
|
258
|
+
party_id: import_zod6.z.uuid({ message: "Select a customer" }),
|
|
259
|
+
invoice_items: import_zod6.z.array(SalesItem).min(1, "Add at least one invoice item")
|
|
260
|
+
});
|
|
261
|
+
var CreditInvoiceSchema = BaseInvoice.safeExtend({
|
|
262
|
+
invoice_type: import_zod6.z.literal("credit"),
|
|
263
|
+
party_id: import_zod6.z.uuid({ message: "Select a customer" }),
|
|
264
|
+
invoice_items: import_zod6.z.array(CreditItem).min(1, "Add at least one invoice item")
|
|
265
|
+
});
|
|
266
|
+
var PurchaseInvoiceSchema = BaseInvoice.safeExtend({
|
|
267
|
+
invoice_type: import_zod6.z.literal("purchase"),
|
|
268
|
+
party_id: import_zod6.z.uuid({ message: "Select a vendor" }),
|
|
269
|
+
invoice_items: import_zod6.z.array(PurchaseItem).min(1, "Add at least one invoice item")
|
|
270
|
+
});
|
|
271
|
+
var AnyInvoiceSchema = import_zod6.z.discriminatedUnion("invoice_type", [
|
|
272
|
+
SalesInvoiceSchema,
|
|
273
|
+
PurchaseInvoiceSchema,
|
|
274
|
+
CreditInvoiceSchema
|
|
275
|
+
]);
|
|
212
276
|
// Annotate the CommonJS export names for ESM import in node:
|
|
213
277
|
0 && (module.exports = {
|
|
278
|
+
AnyInvoiceSchema,
|
|
279
|
+
CreditInvoiceSchema,
|
|
214
280
|
CustomerFormSchema,
|
|
215
281
|
INVOICE_STATUS,
|
|
216
282
|
INVOICE_TYPE,
|
|
217
283
|
ProductFormSchema,
|
|
284
|
+
PurchaseInvoiceSchema,
|
|
218
285
|
RegisterFormSchema,
|
|
286
|
+
SalesInvoiceSchema,
|
|
219
287
|
formatMoneyCurrency,
|
|
220
288
|
getCurrencyFromCountry,
|
|
221
289
|
handleZodCurrency,
|
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/utils/types.ts","../src/utils/utils.ts","../src/schemas/customer_schemas.ts","../src/schemas/product_schemas.ts","../src/types/invoices_types.ts","../src/types/shared_types.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 * from \"./types/invoices_types\";\nexport { CreatedLocation, UUID } from \"./types/shared_types\";\nexport { SyncInvoice } from \"./types/sync_types\";\nexport * from \"./types/customers_types\";\nexport * from \"./types/vendors_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\ntype RoundType = \"half_up\";\n\nexport interface ToFixedOptions {\n roundType?: RoundType;\n}\n\nexport type WhitespaceMode = \"normalize\" | \"remove\";\n\nexport type IsoCurrencyCode = \"USD\" | \"HNL\";\n\nexport const countryToCurrency: Record<IsoCountryCode, IsoCurrencyCode> = {\n US: \"USD\",\n HN: \"HNL\",\n};\n","import * as GlobalTypes from \"./types\";\nimport { IsoCountryCode } from \"../types/company_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): GlobalTypes.IsoCurrencyCode {\n return GlobalTypes.countryToCurrency[country];\n}\n\nexport function formatMoneyCurrency(\n value: number,\n cur: GlobalTypes.IsoCurrencyCode\n) {\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: cur,\n }).format(value);\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 tax_rate: GlobalUtils.handleZodCurrency(0, 100),\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","export 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","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"],"mappings":";;;;;;;;;;;;;;;;;;;;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;;;ACQrC,IAAM,oBAA6D;AAAA,EACxE,IAAI;AAAA,EACJ,IAAI;AACN;;;ACZA,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,OAA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,MAAM,WAAW,KAAK,CAAC,GAAG;AAAA,IAC7C,OAAO;AAAA,EACT,CAAC,EACA,UAAsB,+BAA+B,EACrD,SAAS;AAAA,EAEZ,cAAc,cAAE,KAAK,CAAC,QAAQ,UAAU,MAAM,GAAG;AAAA,IAC/C,OAAO;AAAA,EACT,CAAC;AAAA,EAED,aAAa,cAAE,WAAW,CAAC,MAAM;AAC/B,QAAI,MAAM,GAAI,QAAO;AACrB,QAAI,OAAO,MAAM,SAAU,QAAO,EAAE,KAAK,EAAE,YAAY;AACvD,WAAO;AAAA,EACT,GAAG,cAAE,KAAK,CAAC,MAAM,MAAM,KAAK,IAAI,CAAC,EAAE,SAAS,CAAC;AAAA,EAE7C,OAAmB,kBAAkB,GAAG,QAAS;AAAA,EACjD,MAAkB,kBAAkB,GAAG,QAAS;AAClD,CAAC,EAEA,YAAY,CAAC,MAAM,QAAQ;AAC1B,MAAI,KAAK,iBAAiB,YAAY,CAAC,KAAK,aAAa;AACvD,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM,CAAC,aAAa;AAAA,IACtB,CAAC;AAAA,EACH;AAEA,MACE,KAAK,iBAAiB,YACtB,OAAO,KAAK,gBAAgB,aAC5B;AACA,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM,CAAC,aAAa;AAAA,IACtB,CAAC;AAAA,EACH;AACF,CAAC;;;ACpFI,IAAM,eAAe,CAAC,SAAS,UAAU,UAAU;AAInD,IAAM,iBAAiB,CAAC,aAAa,QAAQ;;;ACJpD,IAAAC,cAAkB;AAQX,IAAM,aAAa,cAAE,KAAK;","names":["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/utils/types.ts","../src/utils/utils.ts","../src/schemas/customer_schemas.ts","../src/schemas/product_schemas.ts","../src/types/invoices_types.ts","../src/types/shared_types.ts","../src/domains/invoices/invoices_schemas.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 * from \"./types/invoices_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\";\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\ntype RoundType = \"half_up\";\n\nexport interface ToFixedOptions {\n roundType?: RoundType;\n}\n\nexport type WhitespaceMode = \"normalize\" | \"remove\";\n\nexport type IsoCurrencyCode = \"USD\" | \"HNL\";\n\nexport const countryToCurrency: Record<IsoCountryCode, IsoCurrencyCode> = {\n US: \"USD\",\n HN: \"HNL\",\n};\n","import * as GlobalTypes from \"./types\";\nimport { IsoCountryCode } from \"../types/company_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): GlobalTypes.IsoCurrencyCode {\n return GlobalTypes.countryToCurrency[country];\n}\n\nexport function formatMoneyCurrency(\n value: number,\n cur: GlobalTypes.IsoCurrencyCode\n) {\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: cur,\n }).format(value);\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 tax_rate: GlobalUtils.handleZodCurrency(0, 100),\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","export 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","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 { INVOICE_STATUS, INVOICE_TYPE } from \"../../types/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),\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 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([\"dump\", \"return\"], {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;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;;;ACQrC,IAAM,oBAA6D;AAAA,EACxE,IAAI;AAAA,EACJ,IAAI;AACN;;;ACZA,iBAAkB;AAUX,SAAS,kBAAkB,WAAmB,WAAmB;AACtE,QAAM,aAAa,aAChB,OAAO;AAAA,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,qBAAqB,YAAY,WAAW;AAAA,EACvD,cAAc,cAAE,QAAQ,OAAO;AAAA,EAC/B,UAAU,cAAE,KAAK,EAAE,SAAS,oBAAoB,CAAC;AAAA,EACjD,eAAe,cAAE,MAAM,SAAS,EAAE,IAAI,GAAG,+BAA+B;AAC1E,CAAC;AAEM,IAAM,sBAAsB,YAAY,WAAW;AAAA,EACxD,cAAc,cAAE,QAAQ,QAAQ;AAAA,EAChC,UAAU,cAAE,KAAK,EAAE,SAAS,oBAAoB,CAAC;AAAA,EACjD,eAAe,cAAE,MAAM,UAAU,EAAE,IAAI,GAAG,+BAA+B;AAC3E,CAAC;AAEM,IAAM,wBAAwB,YAAY,WAAW;AAAA,EAC1D,cAAc,cAAE,QAAQ,UAAU;AAAA,EAClC,UAAU,cAAE,KAAK,EAAE,SAAS,kBAAkB,CAAC;AAAA,EAC/C,eAAe,cAAE,MAAM,YAAY,EAAE,IAAI,GAAG,+BAA+B;AAC7E,CAAC;AAEM,IAAM,mBAAmB,cAAE,mBAAmB,gBAAgB;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AACF,CAAC;","names":["import_zod","import_zod","import_zod","import_zod","import_zod"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -166,4 +166,134 @@ type MappedVendors = {
|
|
|
166
166
|
tax_rate: number;
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
declare const SalesInvoiceSchema: z.ZodObject<{
|
|
170
|
+
invoice_date: z.ZodString;
|
|
171
|
+
due_date: z.ZodString;
|
|
172
|
+
tax_rate: z.ZodDefault<z.ZodNumber>;
|
|
173
|
+
tax_amount: z.ZodDefault<z.ZodNumber>;
|
|
174
|
+
warehouse_id: z.ZodOptional<z.ZodUUID>;
|
|
175
|
+
invoice_status: z.ZodDefault<z.ZodEnum<{
|
|
176
|
+
finalized: "finalized";
|
|
177
|
+
voided: "voided";
|
|
178
|
+
}>>;
|
|
179
|
+
invoice_type: z.ZodLiteral<"sales">;
|
|
180
|
+
party_id: z.ZodUUID;
|
|
181
|
+
invoice_items: z.ZodArray<z.ZodObject<{
|
|
182
|
+
invoice_id: z.ZodOptional<z.ZodUUID>;
|
|
183
|
+
product_id: z.ZodUUID;
|
|
184
|
+
quantity: 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>>;
|
|
185
|
+
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>>;
|
|
186
|
+
credit_type: z.ZodUndefined;
|
|
187
|
+
}, z.core.$strip>>;
|
|
188
|
+
}, z.core.$strip>;
|
|
189
|
+
declare const CreditInvoiceSchema: z.ZodObject<{
|
|
190
|
+
invoice_date: z.ZodString;
|
|
191
|
+
due_date: z.ZodString;
|
|
192
|
+
tax_rate: z.ZodDefault<z.ZodNumber>;
|
|
193
|
+
tax_amount: z.ZodDefault<z.ZodNumber>;
|
|
194
|
+
warehouse_id: z.ZodOptional<z.ZodUUID>;
|
|
195
|
+
invoice_status: z.ZodDefault<z.ZodEnum<{
|
|
196
|
+
finalized: "finalized";
|
|
197
|
+
voided: "voided";
|
|
198
|
+
}>>;
|
|
199
|
+
invoice_type: z.ZodLiteral<"credit">;
|
|
200
|
+
party_id: z.ZodUUID;
|
|
201
|
+
invoice_items: z.ZodArray<z.ZodObject<{
|
|
202
|
+
invoice_id: z.ZodOptional<z.ZodUUID>;
|
|
203
|
+
product_id: z.ZodUUID;
|
|
204
|
+
quantity: 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>>;
|
|
205
|
+
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>>;
|
|
206
|
+
credit_type: z.ZodEnum<{
|
|
207
|
+
dump: "dump";
|
|
208
|
+
return: "return";
|
|
209
|
+
}>;
|
|
210
|
+
}, z.core.$strip>>;
|
|
211
|
+
}, z.core.$strip>;
|
|
212
|
+
declare const PurchaseInvoiceSchema: z.ZodObject<{
|
|
213
|
+
invoice_date: z.ZodString;
|
|
214
|
+
due_date: z.ZodString;
|
|
215
|
+
tax_rate: z.ZodDefault<z.ZodNumber>;
|
|
216
|
+
tax_amount: z.ZodDefault<z.ZodNumber>;
|
|
217
|
+
warehouse_id: z.ZodOptional<z.ZodUUID>;
|
|
218
|
+
invoice_status: z.ZodDefault<z.ZodEnum<{
|
|
219
|
+
finalized: "finalized";
|
|
220
|
+
voided: "voided";
|
|
221
|
+
}>>;
|
|
222
|
+
invoice_type: z.ZodLiteral<"purchase">;
|
|
223
|
+
party_id: z.ZodUUID;
|
|
224
|
+
invoice_items: z.ZodArray<z.ZodObject<{
|
|
225
|
+
invoice_id: z.ZodOptional<z.ZodUUID>;
|
|
226
|
+
product_id: z.ZodUUID;
|
|
227
|
+
quantity: 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>>;
|
|
228
|
+
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>>;
|
|
229
|
+
credit_type: z.ZodUndefined;
|
|
230
|
+
}, z.core.$strip>>;
|
|
231
|
+
}, z.core.$strip>;
|
|
232
|
+
declare const AnyInvoiceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
233
|
+
invoice_date: z.ZodString;
|
|
234
|
+
due_date: z.ZodString;
|
|
235
|
+
tax_rate: z.ZodDefault<z.ZodNumber>;
|
|
236
|
+
tax_amount: z.ZodDefault<z.ZodNumber>;
|
|
237
|
+
warehouse_id: z.ZodOptional<z.ZodUUID>;
|
|
238
|
+
invoice_status: z.ZodDefault<z.ZodEnum<{
|
|
239
|
+
finalized: "finalized";
|
|
240
|
+
voided: "voided";
|
|
241
|
+
}>>;
|
|
242
|
+
invoice_type: z.ZodLiteral<"sales">;
|
|
243
|
+
party_id: z.ZodUUID;
|
|
244
|
+
invoice_items: z.ZodArray<z.ZodObject<{
|
|
245
|
+
invoice_id: z.ZodOptional<z.ZodUUID>;
|
|
246
|
+
product_id: z.ZodUUID;
|
|
247
|
+
quantity: 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>>;
|
|
248
|
+
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>>;
|
|
249
|
+
credit_type: z.ZodUndefined;
|
|
250
|
+
}, z.core.$strip>>;
|
|
251
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
252
|
+
invoice_date: z.ZodString;
|
|
253
|
+
due_date: z.ZodString;
|
|
254
|
+
tax_rate: z.ZodDefault<z.ZodNumber>;
|
|
255
|
+
tax_amount: z.ZodDefault<z.ZodNumber>;
|
|
256
|
+
warehouse_id: z.ZodOptional<z.ZodUUID>;
|
|
257
|
+
invoice_status: z.ZodDefault<z.ZodEnum<{
|
|
258
|
+
finalized: "finalized";
|
|
259
|
+
voided: "voided";
|
|
260
|
+
}>>;
|
|
261
|
+
invoice_type: z.ZodLiteral<"purchase">;
|
|
262
|
+
party_id: z.ZodUUID;
|
|
263
|
+
invoice_items: z.ZodArray<z.ZodObject<{
|
|
264
|
+
invoice_id: z.ZodOptional<z.ZodUUID>;
|
|
265
|
+
product_id: z.ZodUUID;
|
|
266
|
+
quantity: 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>>;
|
|
267
|
+
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>>;
|
|
268
|
+
credit_type: z.ZodUndefined;
|
|
269
|
+
}, z.core.$strip>>;
|
|
270
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
271
|
+
invoice_date: z.ZodString;
|
|
272
|
+
due_date: z.ZodString;
|
|
273
|
+
tax_rate: z.ZodDefault<z.ZodNumber>;
|
|
274
|
+
tax_amount: z.ZodDefault<z.ZodNumber>;
|
|
275
|
+
warehouse_id: z.ZodOptional<z.ZodUUID>;
|
|
276
|
+
invoice_status: z.ZodDefault<z.ZodEnum<{
|
|
277
|
+
finalized: "finalized";
|
|
278
|
+
voided: "voided";
|
|
279
|
+
}>>;
|
|
280
|
+
invoice_type: z.ZodLiteral<"credit">;
|
|
281
|
+
party_id: z.ZodUUID;
|
|
282
|
+
invoice_items: z.ZodArray<z.ZodObject<{
|
|
283
|
+
invoice_id: z.ZodOptional<z.ZodUUID>;
|
|
284
|
+
product_id: z.ZodUUID;
|
|
285
|
+
quantity: 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>>;
|
|
286
|
+
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>>;
|
|
287
|
+
credit_type: z.ZodEnum<{
|
|
288
|
+
dump: "dump";
|
|
289
|
+
return: "return";
|
|
290
|
+
}>;
|
|
291
|
+
}, z.core.$strip>>;
|
|
292
|
+
}, z.core.$strip>], "invoice_type">;
|
|
293
|
+
|
|
294
|
+
type SalesInvoice = z.infer<typeof SalesInvoiceSchema>;
|
|
295
|
+
type CreditInvoice = z.infer<typeof CreditInvoiceSchema>;
|
|
296
|
+
type PurchaseInvoice = z.infer<typeof PurchaseInvoiceSchema>;
|
|
297
|
+
type AnyInvoiceOut = z.output<typeof AnyInvoiceSchema>;
|
|
298
|
+
|
|
299
|
+
export { type AnyInvoiceOut, AnyInvoiceSchema, type CreatedLocation, type CreditInvoice, CreditInvoiceSchema, CustomerFormSchema, INVOICE_STATUS, INVOICE_TYPE, type InventorySystem, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type MappedCustomers, type MappedVendors, ProductFormSchema, type PurchaseInvoice, PurchaseInvoiceSchema, RegisterFormSchema, type SalesInvoice, SalesInvoiceSchema, type SyncInvoice, type UUID, type UserRole, formatMoneyCurrency, getCurrencyFromCountry, handleZodCurrency, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, transformEmptyStringToUndefined };
|
package/dist/index.d.ts
CHANGED
|
@@ -166,4 +166,134 @@ type MappedVendors = {
|
|
|
166
166
|
tax_rate: number;
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
declare const SalesInvoiceSchema: z.ZodObject<{
|
|
170
|
+
invoice_date: z.ZodString;
|
|
171
|
+
due_date: z.ZodString;
|
|
172
|
+
tax_rate: z.ZodDefault<z.ZodNumber>;
|
|
173
|
+
tax_amount: z.ZodDefault<z.ZodNumber>;
|
|
174
|
+
warehouse_id: z.ZodOptional<z.ZodUUID>;
|
|
175
|
+
invoice_status: z.ZodDefault<z.ZodEnum<{
|
|
176
|
+
finalized: "finalized";
|
|
177
|
+
voided: "voided";
|
|
178
|
+
}>>;
|
|
179
|
+
invoice_type: z.ZodLiteral<"sales">;
|
|
180
|
+
party_id: z.ZodUUID;
|
|
181
|
+
invoice_items: z.ZodArray<z.ZodObject<{
|
|
182
|
+
invoice_id: z.ZodOptional<z.ZodUUID>;
|
|
183
|
+
product_id: z.ZodUUID;
|
|
184
|
+
quantity: 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>>;
|
|
185
|
+
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>>;
|
|
186
|
+
credit_type: z.ZodUndefined;
|
|
187
|
+
}, z.core.$strip>>;
|
|
188
|
+
}, z.core.$strip>;
|
|
189
|
+
declare const CreditInvoiceSchema: z.ZodObject<{
|
|
190
|
+
invoice_date: z.ZodString;
|
|
191
|
+
due_date: z.ZodString;
|
|
192
|
+
tax_rate: z.ZodDefault<z.ZodNumber>;
|
|
193
|
+
tax_amount: z.ZodDefault<z.ZodNumber>;
|
|
194
|
+
warehouse_id: z.ZodOptional<z.ZodUUID>;
|
|
195
|
+
invoice_status: z.ZodDefault<z.ZodEnum<{
|
|
196
|
+
finalized: "finalized";
|
|
197
|
+
voided: "voided";
|
|
198
|
+
}>>;
|
|
199
|
+
invoice_type: z.ZodLiteral<"credit">;
|
|
200
|
+
party_id: z.ZodUUID;
|
|
201
|
+
invoice_items: z.ZodArray<z.ZodObject<{
|
|
202
|
+
invoice_id: z.ZodOptional<z.ZodUUID>;
|
|
203
|
+
product_id: z.ZodUUID;
|
|
204
|
+
quantity: 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>>;
|
|
205
|
+
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>>;
|
|
206
|
+
credit_type: z.ZodEnum<{
|
|
207
|
+
dump: "dump";
|
|
208
|
+
return: "return";
|
|
209
|
+
}>;
|
|
210
|
+
}, z.core.$strip>>;
|
|
211
|
+
}, z.core.$strip>;
|
|
212
|
+
declare const PurchaseInvoiceSchema: z.ZodObject<{
|
|
213
|
+
invoice_date: z.ZodString;
|
|
214
|
+
due_date: z.ZodString;
|
|
215
|
+
tax_rate: z.ZodDefault<z.ZodNumber>;
|
|
216
|
+
tax_amount: z.ZodDefault<z.ZodNumber>;
|
|
217
|
+
warehouse_id: z.ZodOptional<z.ZodUUID>;
|
|
218
|
+
invoice_status: z.ZodDefault<z.ZodEnum<{
|
|
219
|
+
finalized: "finalized";
|
|
220
|
+
voided: "voided";
|
|
221
|
+
}>>;
|
|
222
|
+
invoice_type: z.ZodLiteral<"purchase">;
|
|
223
|
+
party_id: z.ZodUUID;
|
|
224
|
+
invoice_items: z.ZodArray<z.ZodObject<{
|
|
225
|
+
invoice_id: z.ZodOptional<z.ZodUUID>;
|
|
226
|
+
product_id: z.ZodUUID;
|
|
227
|
+
quantity: 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>>;
|
|
228
|
+
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>>;
|
|
229
|
+
credit_type: z.ZodUndefined;
|
|
230
|
+
}, z.core.$strip>>;
|
|
231
|
+
}, z.core.$strip>;
|
|
232
|
+
declare const AnyInvoiceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
233
|
+
invoice_date: z.ZodString;
|
|
234
|
+
due_date: z.ZodString;
|
|
235
|
+
tax_rate: z.ZodDefault<z.ZodNumber>;
|
|
236
|
+
tax_amount: z.ZodDefault<z.ZodNumber>;
|
|
237
|
+
warehouse_id: z.ZodOptional<z.ZodUUID>;
|
|
238
|
+
invoice_status: z.ZodDefault<z.ZodEnum<{
|
|
239
|
+
finalized: "finalized";
|
|
240
|
+
voided: "voided";
|
|
241
|
+
}>>;
|
|
242
|
+
invoice_type: z.ZodLiteral<"sales">;
|
|
243
|
+
party_id: z.ZodUUID;
|
|
244
|
+
invoice_items: z.ZodArray<z.ZodObject<{
|
|
245
|
+
invoice_id: z.ZodOptional<z.ZodUUID>;
|
|
246
|
+
product_id: z.ZodUUID;
|
|
247
|
+
quantity: 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>>;
|
|
248
|
+
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>>;
|
|
249
|
+
credit_type: z.ZodUndefined;
|
|
250
|
+
}, z.core.$strip>>;
|
|
251
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
252
|
+
invoice_date: z.ZodString;
|
|
253
|
+
due_date: z.ZodString;
|
|
254
|
+
tax_rate: z.ZodDefault<z.ZodNumber>;
|
|
255
|
+
tax_amount: z.ZodDefault<z.ZodNumber>;
|
|
256
|
+
warehouse_id: z.ZodOptional<z.ZodUUID>;
|
|
257
|
+
invoice_status: z.ZodDefault<z.ZodEnum<{
|
|
258
|
+
finalized: "finalized";
|
|
259
|
+
voided: "voided";
|
|
260
|
+
}>>;
|
|
261
|
+
invoice_type: z.ZodLiteral<"purchase">;
|
|
262
|
+
party_id: z.ZodUUID;
|
|
263
|
+
invoice_items: z.ZodArray<z.ZodObject<{
|
|
264
|
+
invoice_id: z.ZodOptional<z.ZodUUID>;
|
|
265
|
+
product_id: z.ZodUUID;
|
|
266
|
+
quantity: 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>>;
|
|
267
|
+
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>>;
|
|
268
|
+
credit_type: z.ZodUndefined;
|
|
269
|
+
}, z.core.$strip>>;
|
|
270
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
271
|
+
invoice_date: z.ZodString;
|
|
272
|
+
due_date: z.ZodString;
|
|
273
|
+
tax_rate: z.ZodDefault<z.ZodNumber>;
|
|
274
|
+
tax_amount: z.ZodDefault<z.ZodNumber>;
|
|
275
|
+
warehouse_id: z.ZodOptional<z.ZodUUID>;
|
|
276
|
+
invoice_status: z.ZodDefault<z.ZodEnum<{
|
|
277
|
+
finalized: "finalized";
|
|
278
|
+
voided: "voided";
|
|
279
|
+
}>>;
|
|
280
|
+
invoice_type: z.ZodLiteral<"credit">;
|
|
281
|
+
party_id: z.ZodUUID;
|
|
282
|
+
invoice_items: z.ZodArray<z.ZodObject<{
|
|
283
|
+
invoice_id: z.ZodOptional<z.ZodUUID>;
|
|
284
|
+
product_id: z.ZodUUID;
|
|
285
|
+
quantity: 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>>;
|
|
286
|
+
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>>;
|
|
287
|
+
credit_type: z.ZodEnum<{
|
|
288
|
+
dump: "dump";
|
|
289
|
+
return: "return";
|
|
290
|
+
}>;
|
|
291
|
+
}, z.core.$strip>>;
|
|
292
|
+
}, z.core.$strip>], "invoice_type">;
|
|
293
|
+
|
|
294
|
+
type SalesInvoice = z.infer<typeof SalesInvoiceSchema>;
|
|
295
|
+
type CreditInvoice = z.infer<typeof CreditInvoiceSchema>;
|
|
296
|
+
type PurchaseInvoice = z.infer<typeof PurchaseInvoiceSchema>;
|
|
297
|
+
type AnyInvoiceOut = z.output<typeof AnyInvoiceSchema>;
|
|
298
|
+
|
|
299
|
+
export { type AnyInvoiceOut, AnyInvoiceSchema, type CreatedLocation, type CreditInvoice, CreditInvoiceSchema, CustomerFormSchema, INVOICE_STATUS, INVOICE_TYPE, type InventorySystem, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type MappedCustomers, type MappedVendors, ProductFormSchema, type PurchaseInvoice, PurchaseInvoiceSchema, RegisterFormSchema, type SalesInvoice, SalesInvoiceSchema, type SyncInvoice, type UUID, type UserRole, formatMoneyCurrency, getCurrencyFromCountry, handleZodCurrency, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, transformEmptyStringToUndefined };
|
package/dist/index.js
CHANGED
|
@@ -171,12 +171,76 @@ var INVOICE_STATUS = ["finalized", "voided"];
|
|
|
171
171
|
// src/types/shared_types.ts
|
|
172
172
|
import { z as z5 } from "zod";
|
|
173
173
|
var uuidSchema = z5.uuid();
|
|
174
|
+
|
|
175
|
+
// src/domains/invoices/invoices_schemas.ts
|
|
176
|
+
import { z as z6 } from "zod";
|
|
177
|
+
var YmdDateSchema = z6.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Use YYYY-MM-DD");
|
|
178
|
+
var BaseInvoice = z6.object({
|
|
179
|
+
invoice_type: z6.enum(INVOICE_TYPE),
|
|
180
|
+
invoice_date: YmdDateSchema,
|
|
181
|
+
due_date: YmdDateSchema,
|
|
182
|
+
tax_rate: z6.number().default(0),
|
|
183
|
+
tax_amount: z6.number().default(0),
|
|
184
|
+
warehouse_id: z6.uuid().optional(),
|
|
185
|
+
invoice_status: z6.enum(INVOICE_STATUS).default("finalized")
|
|
186
|
+
}).superRefine(({ invoice_date, due_date }, ctx) => {
|
|
187
|
+
if (due_date < invoice_date) {
|
|
188
|
+
ctx.addIssue({
|
|
189
|
+
code: "custom",
|
|
190
|
+
message: "Due date can't be earlier than the invoice date.",
|
|
191
|
+
path: ["due_date"]
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
var LineItemBase = z6.object({
|
|
196
|
+
invoice_id: z6.uuid().optional(),
|
|
197
|
+
product_id: z6.uuid({ error: "Select a product" }),
|
|
198
|
+
quantity: handleZodCurrency(0.01, 99999.99)
|
|
199
|
+
});
|
|
200
|
+
var SalesItem = LineItemBase.safeExtend({
|
|
201
|
+
price: handleZodCurrency(0, 99999.99),
|
|
202
|
+
credit_type: z6.undefined()
|
|
203
|
+
});
|
|
204
|
+
var CreditItem = LineItemBase.safeExtend({
|
|
205
|
+
price: handleZodCurrency(0, 99999.99),
|
|
206
|
+
credit_type: z6.enum(["dump", "return"], {
|
|
207
|
+
error: "Select a credit type"
|
|
208
|
+
})
|
|
209
|
+
});
|
|
210
|
+
var PurchaseItem = LineItemBase.safeExtend({
|
|
211
|
+
price: handleZodCurrency(0, 99999.99),
|
|
212
|
+
credit_type: z6.undefined()
|
|
213
|
+
});
|
|
214
|
+
var SalesInvoiceSchema = BaseInvoice.safeExtend({
|
|
215
|
+
invoice_type: z6.literal("sales"),
|
|
216
|
+
party_id: z6.uuid({ message: "Select a customer" }),
|
|
217
|
+
invoice_items: z6.array(SalesItem).min(1, "Add at least one invoice item")
|
|
218
|
+
});
|
|
219
|
+
var CreditInvoiceSchema = BaseInvoice.safeExtend({
|
|
220
|
+
invoice_type: z6.literal("credit"),
|
|
221
|
+
party_id: z6.uuid({ message: "Select a customer" }),
|
|
222
|
+
invoice_items: z6.array(CreditItem).min(1, "Add at least one invoice item")
|
|
223
|
+
});
|
|
224
|
+
var PurchaseInvoiceSchema = BaseInvoice.safeExtend({
|
|
225
|
+
invoice_type: z6.literal("purchase"),
|
|
226
|
+
party_id: z6.uuid({ message: "Select a vendor" }),
|
|
227
|
+
invoice_items: z6.array(PurchaseItem).min(1, "Add at least one invoice item")
|
|
228
|
+
});
|
|
229
|
+
var AnyInvoiceSchema = z6.discriminatedUnion("invoice_type", [
|
|
230
|
+
SalesInvoiceSchema,
|
|
231
|
+
PurchaseInvoiceSchema,
|
|
232
|
+
CreditInvoiceSchema
|
|
233
|
+
]);
|
|
174
234
|
export {
|
|
235
|
+
AnyInvoiceSchema,
|
|
236
|
+
CreditInvoiceSchema,
|
|
175
237
|
CustomerFormSchema,
|
|
176
238
|
INVOICE_STATUS,
|
|
177
239
|
INVOICE_TYPE,
|
|
178
240
|
ProductFormSchema,
|
|
241
|
+
PurchaseInvoiceSchema,
|
|
179
242
|
RegisterFormSchema,
|
|
243
|
+
SalesInvoiceSchema,
|
|
180
244
|
formatMoneyCurrency,
|
|
181
245
|
getCurrencyFromCountry,
|
|
182
246
|
handleZodCurrency,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/companies_schemas.ts","../src/types/company_types.ts","../src/utils/types.ts","../src/utils/utils.ts","../src/schemas/customer_schemas.ts","../src/schemas/product_schemas.ts","../src/types/invoices_types.ts","../src/types/shared_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\ntype RoundType = \"half_up\";\n\nexport interface ToFixedOptions {\n roundType?: RoundType;\n}\n\nexport type WhitespaceMode = \"normalize\" | \"remove\";\n\nexport type IsoCurrencyCode = \"USD\" | \"HNL\";\n\nexport const countryToCurrency: Record<IsoCountryCode, IsoCurrencyCode> = {\n US: \"USD\",\n HN: \"HNL\",\n};\n","import * as GlobalTypes from \"./types\";\nimport { IsoCountryCode } from \"../types/company_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): GlobalTypes.IsoCurrencyCode {\n return GlobalTypes.countryToCurrency[country];\n}\n\nexport function formatMoneyCurrency(\n value: number,\n cur: GlobalTypes.IsoCurrencyCode\n) {\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: cur,\n }).format(value);\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 tax_rate: GlobalUtils.handleZodCurrency(0, 100),\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","export 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","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"],"mappings":";AAAA,SAAS,KAAAA,UAAS;;;ACAX,IAAM,oBAAoB,CAAC,MAAM,IAAI;AAIrC,IAAM,aAAa,CAAC,SAAS,QAAQ;;;ACQrC,IAAM,oBAA6D;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AAA,MACX,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM,CAAC,aAAa;AAAA,IACtB,CAAC;AAAA,EACH;AACF,CAAC;;;ACpFI,IAAM,eAAe,CAAC,SAAS,UAAU,UAAU;AAInD,IAAM,iBAAiB,CAAC,aAAa,QAAQ;;;ACJpD,SAAS,KAAAC,UAAS;AAQX,IAAM,aAAaC,GAAE,KAAK;","names":["z","z","z","z","z","z","z","z"]}
|
|
1
|
+
{"version":3,"sources":["../src/schemas/companies_schemas.ts","../src/types/company_types.ts","../src/utils/types.ts","../src/utils/utils.ts","../src/schemas/customer_schemas.ts","../src/schemas/product_schemas.ts","../src/types/invoices_types.ts","../src/types/shared_types.ts","../src/domains/invoices/invoices_schemas.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\ntype RoundType = \"half_up\";\n\nexport interface ToFixedOptions {\n roundType?: RoundType;\n}\n\nexport type WhitespaceMode = \"normalize\" | \"remove\";\n\nexport type IsoCurrencyCode = \"USD\" | \"HNL\";\n\nexport const countryToCurrency: Record<IsoCountryCode, IsoCurrencyCode> = {\n US: \"USD\",\n HN: \"HNL\",\n};\n","import * as GlobalTypes from \"./types\";\nimport { IsoCountryCode } from \"../types/company_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): GlobalTypes.IsoCurrencyCode {\n return GlobalTypes.countryToCurrency[country];\n}\n\nexport function formatMoneyCurrency(\n value: number,\n cur: GlobalTypes.IsoCurrencyCode\n) {\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: cur,\n }).format(value);\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 tax_rate: GlobalUtils.handleZodCurrency(0, 100),\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","export 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","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 { INVOICE_STATUS, INVOICE_TYPE } from \"../../types/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),\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 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([\"dump\", \"return\"], {\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"],"mappings":";AAAA,SAAS,KAAAA,UAAS;;;ACAX,IAAM,oBAAoB,CAAC,MAAM,IAAI;AAIrC,IAAM,aAAa,CAAC,SAAS,QAAQ;;;ACQrC,IAAM,oBAA6D;AAAA,EACxE,IAAI;AAAA,EACJ,IAAI;AACN;;;ACZA,SAAS,SAAS;AAUX,SAAS,kBAAkB,WAAmB,WAAmB;AACtE,QAAM,aAAa,EAChB,OAAO;AAAA,IACN,OAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC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