@marmot-systems/common 2.0.84 → 2.0.86

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 CHANGED
@@ -24,7 +24,6 @@ __export(index_exports, {
24
24
  CREDIT_TYPE: () => CREDIT_TYPE,
25
25
  CompanyFormSchema: () => CompanyFormSchema,
26
26
  CreditApplicationSchema: () => CreditApplicationSchema,
27
- CustomerFormSchema: () => CustomerFormSchema,
28
27
  INVOICE_STATUS: () => INVOICE_STATUS,
29
28
  INVOICE_TYPE: () => INVOICE_TYPE,
30
29
  ISO_COUNTRY_CODES: () => ISO_COUNTRY_CODES,
@@ -32,7 +31,6 @@ __export(index_exports, {
32
31
  PAYMENT_METHOD: () => PAYMENT_METHOD,
33
32
  POS_INVOICE_TYPE: () => POS_INVOICE_TYPE,
34
33
  PaymentFormSchema: () => PaymentFormSchema,
35
- ProductFormSchema: () => ProductFormSchema,
36
34
  RegisterFormSchema: () => RegisterFormSchema,
37
35
  USER_ROLES: () => USER_ROLES,
38
36
  YmdDateSchema: () => YmdDateSchema,
@@ -46,8 +44,10 @@ __export(index_exports, {
46
44
  getErrorMessage: () => getErrorMessage,
47
45
  handleZodCurrency: () => handleZodCurrency,
48
46
  localDateFromYmd: () => localDateFromYmd,
47
+ makeCustomerSchemas: () => makeCustomerSchemas,
49
48
  makeInvoiceSchemas: () => makeInvoiceSchemas,
50
49
  makePosSchemas: () => makePosSchemas,
50
+ makeProductSchemas: () => makeProductSchemas,
51
51
  mapInvoiceProducts: () => mapInvoiceProducts,
52
52
  normalizeSpaces: () => normalizeSpaces,
53
53
  removeAllWhitespace: () => removeAllWhitespace,
@@ -218,64 +218,69 @@ var CompanyFormSchema = RegisterFormSchema.shape.companyData.safeExtend({
218
218
 
219
219
  // src/domains/customers/customer_schemas.ts
220
220
  var import_zod5 = require("zod");
221
- var CustomerFormSchema = import_zod5.z.strictObject({
222
- customer_name: import_zod5.z.string().transform(normalizeSpaces).pipe(
223
- import_zod5.z.string().min(1, "Customer name is required").max(50, "Customer name must be at most 50 characters.")
224
- ),
225
- customer_address: import_zod5.z.string().transform(normalizeSpaces).pipe(
226
- import_zod5.z.string().max(100, "Customer address must be at most 100 characters.")
227
- ).transform(transformEmptyStringToUndefined).optional(),
228
- customer_phone_number: import_zod5.z.string().transform(removeAllWhitespace).transform(removeDashesAndPlusSign).refine((s) => s === "" || /^\d{4,15}$/.test(s), {
229
- error: "Phone number must be from 4 to 15 digits."
230
- }).transform(transformEmptyStringToUndefined).optional(),
231
- customer_email_address: import_zod5.z.string().transform(removeAllWhitespace).transform(transformEmptyStringToUndefined).pipe(
232
- import_zod5.z.email().max(254, "Customer email must be at most 254 characters.").transform((email) => email.toLowerCase()).optional()
233
- ).optional()
234
- });
221
+ function makeCustomerSchemas(t) {
222
+ const CustomerFormSchema = import_zod5.z.strictObject({
223
+ customer_name: import_zod5.z.string().transform(normalizeSpaces).pipe(
224
+ import_zod5.z.string().min(1, t("customer_name_required")).max(50, t("customer_name_max"))
225
+ ),
226
+ customer_address: import_zod5.z.string().transform(normalizeSpaces).pipe(import_zod5.z.string().max(100, t("customer_address_max"))).transform(transformEmptyStringToUndefined).optional(),
227
+ customer_phone_number: import_zod5.z.string().transform(removeAllWhitespace).transform(removeDashesAndPlusSign).refine((s) => s === "" || /^\d{4,15}$/.test(s), {
228
+ error: t("customer_phone_number")
229
+ }).transform(transformEmptyStringToUndefined).optional(),
230
+ customer_email_address: import_zod5.z.string().transform(removeAllWhitespace).transform(transformEmptyStringToUndefined).pipe(
231
+ import_zod5.z.email().max(254, t("customer_email_max")).transform((email) => email.toLowerCase()).optional()
232
+ ).optional()
233
+ });
234
+ return { CustomerFormSchema };
235
+ }
235
236
 
236
237
  // src/domains/products/product_schemas.ts
237
238
  var import_zod6 = require("zod");
238
- var ProductFormSchema = import_zod6.z.strictObject({
239
- product_name: import_zod6.z.string().transform(normalizeSpaces).pipe(
240
- import_zod6.z.string().min(1, "Product name is required").max(50, "Product name must be at most 50 characters.")
241
- ),
242
- product_description: import_zod6.z.string().transform(normalizeSpaces).pipe(
243
- import_zod6.z.string().max(100, "Product desription must be at most 100 characters.")
244
- ).transform(transformEmptyStringToUndefined).optional(),
245
- 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(),
246
- product_upc: import_zod6.z.string().transform(removeAllWhitespace).refine((s) => s === "" || /^\d{12}$/.test(s), {
247
- error: "UPC must be exactly 12 digits"
248
- }).transform(transformEmptyStringToUndefined).optional(),
249
- country_tax_rule_id: import_zod6.z.number().optional(),
250
- product_gtin_14: import_zod6.z.string().transform(removeAllWhitespace).refine((s) => s === "" || /^\d{14}$/.test(s), {
251
- error: "GTIN14 must be exactly 14 digits"
252
- }).transform(transformEmptyStringToUndefined).optional(),
253
- product_type: import_zod6.z.enum(["unit", "weight", "case"], {
254
- error: "Product type must be unit, weight, or case."
255
- }),
256
- weight_unit: import_zod6.z.preprocess((v) => {
257
- if (v === "") return void 0;
258
- if (typeof v === "string") return v.trim().toLowerCase();
259
- return v;
260
- }, import_zod6.z.enum(["kg", "lb", "g", "oz"]).optional()),
261
- price: handleZodCurrency(0, 99999.99),
262
- cost: handleZodCurrency(0, 99999.99)
263
- }).superRefine((data, ctx) => {
264
- if (data.product_type === "weight" && !data.weight_unit) {
265
- ctx.addIssue({
266
- code: "custom",
267
- error: "Weight unit is required.",
268
- path: ["weight_unit"]
269
- });
270
- }
271
- if (data.product_type !== "weight" && typeof data.weight_unit !== "undefined") {
272
- ctx.addIssue({
273
- code: "custom",
274
- error: "Weight unit must be empty",
275
- path: ["weight_unit"]
276
- });
277
- }
278
- });
239
+ function makeProductSchemas(t) {
240
+ const ProductFormSchema = import_zod6.z.strictObject({
241
+ product_name: import_zod6.z.string().transform(normalizeSpaces).pipe(
242
+ import_zod6.z.string().min(1, t("product_name_required")).max(50, t("product_name_max"))
243
+ ),
244
+ product_description: import_zod6.z.string().transform(normalizeSpaces).pipe(import_zod6.z.string().max(100, t("product_descr_max"))).transform(transformEmptyStringToUndefined).optional(),
245
+ product_sku: import_zod6.z.string().transform(normalizeSpaces).pipe(import_zod6.z.string().max(30, t("product_sku_max"))).transform(transformEmptyStringToUndefined).optional(),
246
+ product_upc: import_zod6.z.string().transform(removeAllWhitespace).refine((s) => s === "" || /^\d{12}$/.test(s), {
247
+ error: t("product_upc_test")
248
+ }).transform(transformEmptyStringToUndefined).optional(),
249
+ country_tax_rule_id: import_zod6.z.number().optional(),
250
+ product_gtin_14: import_zod6.z.string().transform(removeAllWhitespace).refine((s) => s === "" || /^\d{14}$/.test(s), {
251
+ error: "GTIN14 must be exactly 14 digits"
252
+ }).transform(transformEmptyStringToUndefined).optional(),
253
+ product_type: import_zod6.z.enum(["unit", "weight", "case"], {
254
+ error: t("product_type_validation")
255
+ }),
256
+ weight_unit: import_zod6.z.preprocess(
257
+ (v) => {
258
+ if (v === "") return void 0;
259
+ if (typeof v === "string") return v.trim().toLowerCase();
260
+ return v;
261
+ },
262
+ import_zod6.z.enum(["kg", "lb", "g", "oz"]).optional()
263
+ ),
264
+ price: handleZodCurrency(0, 99999.99, t),
265
+ cost: handleZodCurrency(0, 99999.99, t)
266
+ }).superRefine((data, ctx) => {
267
+ if (data.product_type === "weight" && !data.weight_unit) {
268
+ ctx.addIssue({
269
+ code: "custom",
270
+ error: t("weight_unit_required"),
271
+ path: ["weight_unit"]
272
+ });
273
+ }
274
+ if (data.product_type !== "weight" && typeof data.weight_unit !== "undefined") {
275
+ ctx.addIssue({
276
+ code: "custom",
277
+ error: t("weight_unit_empty"),
278
+ path: ["weight_unit"]
279
+ });
280
+ }
281
+ });
282
+ return { ProductFormSchema };
283
+ }
279
284
 
280
285
  // src/domains/invoices/invoices_schemas.ts
281
286
  var import_zod7 = require("zod");
@@ -554,7 +559,6 @@ function makePosSchemas(t) {
554
559
  CREDIT_TYPE,
555
560
  CompanyFormSchema,
556
561
  CreditApplicationSchema,
557
- CustomerFormSchema,
558
562
  INVOICE_STATUS,
559
563
  INVOICE_TYPE,
560
564
  ISO_COUNTRY_CODES,
@@ -562,7 +566,6 @@ function makePosSchemas(t) {
562
566
  PAYMENT_METHOD,
563
567
  POS_INVOICE_TYPE,
564
568
  PaymentFormSchema,
565
- ProductFormSchema,
566
569
  RegisterFormSchema,
567
570
  USER_ROLES,
568
571
  YmdDateSchema,
@@ -576,8 +579,10 @@ function makePosSchemas(t) {
576
579
  getErrorMessage,
577
580
  handleZodCurrency,
578
581
  localDateFromYmd,
582
+ makeCustomerSchemas,
579
583
  makeInvoiceSchemas,
580
584
  makePosSchemas,
585
+ makeProductSchemas,
581
586
  mapInvoiceProducts,
582
587
  normalizeSpaces,
583
588
  removeAllWhitespace,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/types/money_types.ts","../src/utils/utils.ts","../src/types/shared_types.ts","../src/domains/auth/login/login_schemas.ts","../src/domains/companies/companies_schemas.ts","../src/domains/companies/companies_types.ts","../src/domains/customers/customer_schemas.ts","../src/domains/products/product_schemas.ts","../src/domains/invoices/invoices_schemas.ts","../src/domains/invoices/invoices_types.ts","../src/domains/invoice_items/invoice_items_mappers.ts","../src/domains/credit_applications/credit_applications_schemas.ts","../src/domains/payments/payments_schemas.ts","../src/domains/payments/payments_types.ts","../src/utils/money_utils.ts","../src/utils/date_utils.ts","../src/utils/errors_utils.ts","../src/domains/point_of_sales/point_of_sales_schemas.ts","../src/domains/point_of_sales/point_of_sales_types.ts"],"sourcesContent":["export * from \"./utils/utils\";\n\nexport { CreatedLocation, UUID } from \"./types/shared_types\";\n\n//Login\nexport * from \"./domains/auth/login/login_schemas\";\n\n//Company\nexport * from \"./domains/companies/companies_schemas\";\nexport * from \"./domains/companies/companies_types\";\n\n//Users\nexport * from \"./domains/users/users_types\";\n\n//Customers\nexport * from \"./domains/customers/customer_schemas\";\nexport * from \"./domains/customers/customers_types\";\n\n//Vendors\nexport * from \"./domains/vendors/vendors_types\";\n\n// Products\nexport * from \"./domains/products/product_schemas\";\nexport * from \"./domains/products/products_types\";\n\n//Warehouses\nexport * from \"./domains/warehouses/warehouses_types\";\n\n//Inventory\nexport * from \"./domains/inventory/inventory_locations/inventory_locations_types\";\nexport * from \"./domains/inventory/inventory_balances/inventory_balances_type\";\n\n//Invoices\nexport * from \"./domains/invoices/invoices_schemas\";\nexport * from \"./domains/invoices/invoices_types\";\n\n//Invoice Items\nexport * from \"./domains/invoice_items/invoice_items_types\";\nexport * from \"./domains/invoice_items/invoice_items_mappers\";\n\n//Credit Applications\nexport * from \"./domains/credit_applications/credit_applications_schemas\";\nexport * from \"./domains/credit_applications/credit_applications_types\";\n\n//Payments\nexport * from \"./domains/payments/payments_schemas\";\nexport * from \"./domains/payments/payments_types\";\n\n//Drivers\nexport * from \"./domains/drivers/driver_customers/driver_customers_types\";\nexport * from \"./domains/drivers/driver_settings/driver_settings_types\";\n\n//Sync\nexport * from \"./domains/sync/sync_types\";\n\n// Money\nexport * from \"./utils/money_utils\";\nexport * from \"./types/money_types\";\n\n//Date\nexport * from \"./utils/date_utils\";\n\n//Errors\nexport * from \"./utils/errors_utils\";\n\n//Audit Events\nexport * from \"./domains/audit_events/audit_events_types\";\n\n//Country Tax Rules\nexport * from \"./domains/country_tax_rules/country_tax_rules_types\";\n\n//Point of sales\nexport * from \"./domains/point_of_sales/point_of_sales_schemas\";\nexport * from \"./domains/point_of_sales/point_of_sales_types\";\n","import { IsoCountryCode } from \"../domains/companies/companies_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 \"../domains/companies/companies_types\";\nimport {\n IsoCurrencyCode,\n countryToCurrency,\n currencyToLocale,\n} from \"../types/money_types\";\n\nimport { z } from \"zod\";\nimport { SchemaT } from \"../domains/invoices/invoices_types\";\n\n/**\n * Validates zod currency with precision.\n *\n *\n * @param minAmount\n * @param maxAmount\n * @returns\n */\nexport function handleZodCurrency(\n minAmount: number,\n maxAmount: number,\n t?: SchemaT,\n) {\n if (!t) {\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 at least ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `Exceeds allowed limit ${maxAmount}`,\n });\n }\n\n const fromString = z\n .string({\n error: t(\"enter_a_valid_number\"),\n })\n .refine((s) => s.trim().length > 0, {\n error: t(\"enter_a_valid_number\"),\n })\n .transform((s) => s.replace(/[,\\s]/g, \"\"))\n .refine((s) => s !== \"\" && !Number.isNaN(Number(s)), {\n error: t(\"enter_a_valid_number\"),\n })\n .refine((s) => Number.isFinite(Number(s)), {\n error: t(\"enter_a_valid_number\"),\n })\n .refine((s) => Number(s) >= 0, {\n error: t(\"enter_a_positive_number\"),\n })\n .transform((s) => Number(s));\n\n const fromNumber = z\n .number()\n .refine((n) => Number.isFinite(n), {\n error: t(\"enter_a_valid_number\"),\n })\n .refine((n) => n >= 0, {\n error: t(\"enter_a_positive_number\"),\n });\n\n return z\n .union([fromString, fromNumber])\n .transform((n) => roundWithPrecision(n, 2))\n .refine((n) => n >= minAmount, {\n error: `${t(\"must_be_at_least\")} ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `${t(\"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\";\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\nexport type status = \"active\" | \"inactive\";\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../../utils/utils\";\n\nexport const LoginFormSchema = z.strictObject({\n user_email: z\n .string({ error: \"Email required\" })\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({ error: \"Password required\" })\n .min(1, { error: \"Password required\" }),\n});\n","import { z } from \"zod\";\nimport { COMPANY_LANGUAGES, ISO_COUNTRY_CODES } from \"./companies_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\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({ error: \"Please select a country.\" })\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\nexport const CompanyFormSchema =\n RegisterFormSchema.shape.companyData.safeExtend({\n company_email: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .email(\"Invalid company email.\")\n .max(254, \"Company email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n ),\n rtn: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(z.string().max(100, \"RTN must be at most 100 characters.\"))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n web_language: z.enum(COMPANY_LANGUAGES, {\n error: \"Please select a web portal language.\",\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\nexport type CompanySnapshot = {\n company_id: number;\n company_name: string;\n company_address: string;\n company_phone_number: string;\n company_email: string;\n inventory_system: InventorySystem;\n iso_country_code: IsoCountryCode;\n rtn: string | null;\n};\n\nexport const COMPANY_LANGUAGES = [\"es\", \"en\"] as const;\n\nexport type CompanyLanguages = (typeof COMPANY_LANGUAGES)[number];\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(GlobalUtils.removeAllWhitespace)\n .refine((s) => s === \"\" || /^\\d{12}$/.test(s), {\n error: \"UPC must be exactly 12 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n country_tax_rule_id: z.number().optional(),\n\n product_gtin_14: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\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 {\n CREDIT_TYPE,\n INVOICE_STATUS,\n INVOICE_TYPE,\n SchemaT,\n} from \"./invoices_types\";\nimport { handleZodCurrency } from \"../../utils/utils\";\n\nexport const YmdDateSchema = z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\n///////////////////////////////////////////////////////////////////////\n//English / Spanish implementation\n\nexport function makeInvoiceSchemas(t: SchemaT) {\n const YmdDateSchema = z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\n const BaseInvoice = z\n .object({\n invoice_type: z.enum(INVOICE_TYPE, {\n error: t(\"invoice_type_not_found\"),\n }),\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\n const LineItemBase = z.object({\n invoice_id: z.uuid().optional(),\n product_id: z.uuid({\n error: t(\"select_product\"),\n }),\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, t),\n country_tax_rule_id: z.number().optional(),\n tax_percentage: z.number().optional(),\n });\n\n const SalesItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99, t),\n credit_type: z.undefined(),\n });\n\n const CreditItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99, t),\n credit_type: z.enum(CREDIT_TYPE, {\n error: t(\"select_credit_type\"),\n }),\n });\n\n const PurchaseItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99, t),\n credit_type: z.undefined(),\n });\n\n const SalesInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"sales\"),\n party_id: z.uuid({\n error: t(\"select_customer\"),\n }),\n invoice_items: z.array(SalesItem).min(1, t(\"add_one_invoice_item\")),\n });\n\n const CreditInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"credit\"),\n party_id: z.uuid({\n error: t(\"select_customer\"),\n }),\n invoice_items: z.array(CreditItem).min(1, t(\"add_one_invoice_item\")),\n });\n\n const PurchaseInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"purchase\"),\n party_id: z.uuid({\n error: t(\"select_vendor\"),\n }),\n invoice_items: z.array(PurchaseItem).min(1, t(\"add_one_invoice_item\")),\n });\n\n const AnyInvoiceSchema = z.discriminatedUnion(\"invoice_type\", [\n SalesInvoiceSchema,\n PurchaseInvoiceSchema,\n CreditInvoiceSchema,\n ]);\n\n return {\n YmdDateSchema,\n SalesInvoiceSchema,\n CreditInvoiceSchema,\n PurchaseInvoiceSchema,\n AnyInvoiceSchema,\n };\n}\n\nexport type InvoiceSchemas = ReturnType<typeof makeInvoiceSchemas>;\n","import { z } from \"zod\";\nimport * as InvoiceSchemas from \"./invoices_schemas\";\nimport { IntBool, UUID } from \"../../types/shared_types\";\n\nexport type SchemaT = (key: string, params?: Record<string, any>) => string;\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\nexport type InvoiceSchemaSet = ReturnType<\n typeof InvoiceSchemas.makeInvoiceSchemas\n>;\nexport type AnyInvoiceOut = z.output<InvoiceSchemaSet[\"AnyInvoiceSchema\"]>;\n\nexport type InvoiceSnapshot = {\n invoice_id: UUID;\n invoice_type: InvoiceType;\n subtotal: string;\n tax_amount: string;\n total_amount: string;\n remaining_balance: string;\n due_date: string;\n tax_rate: string;\n is_admin_reviewed: IntBool;\n customer_id: UUID;\n company_id: number;\n short_invoice_id: string;\n invoice_date: string;\n invoice_status: InvoiceStatus;\n occurred_at_ms: string;\n cai: string | null;\n invoice_number_start_range: string | null;\n invoice_number_end_range: string | null;\n issuance_date: string | null;\n issuance_deadline: string | null;\n};\n\nexport type InvoiceSnapshotMobile = InvoiceSnapshot & {\n signature: string | null;\n};\n","import * as InvoiceItemsTypes from \"./invoice_items_types\";\n\nexport function mapInvoiceProducts(\n row: InvoiceItemsTypes.InvoiceItemResponse\n): InvoiceItemsTypes.MappedInvoiceItem {\n return {\n invoice_item_id: row.invoice_item_id,\n product_id: row.product_id,\n quantity: Number(row.quantity),\n price: Number(row.price),\n amount: Number(row.amount),\n credit_type: row.credit_type ?? undefined,\n product_name: row.product_name,\n product_description: row.product_description ?? undefined,\n product_type: row.product_type,\n weight_unit: row.weight_unit ?? undefined,\n product_upc: row.product_upc ?? undefined,\n rule_name: row.rule_name ?? undefined,\n tax_percentage:\n row.tax_percentage === null ? undefined : Number(row.tax_percentage),\n };\n}\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../utils/utils\";\n\nexport const CreditApplicationSchema = z.strictObject({\n credit_invoice_id: z.uuid({ error: \"Select a credit\" }),\n applied_amount: GlobalUtils.handleZodCurrency(0.01, 999_999.99),\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","import { IntBool, UUID } from \"../../types/shared_types\";\n\nexport 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\nexport type PaymentStatus = \"finalized\" | \"voided\";\n\nexport type PaymentSnapshot = {\n payment_id: UUID;\n invoice_id: UUID;\n payment_amount: string;\n payment_date: string;\n payment_method: PaymentMethod;\n check_number: string | null;\n is_admin_reviewed: IntBool;\n company_id: number;\n short_invoice_id: string;\n payment_status: PaymentStatus;\n occurred_at_ms: string;\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","// \"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","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../utils/utils\";\nimport { YmdDateSchema } from \"../invoices/invoices_schemas\";\nimport { POS_INVOICE_TYPE } from \"./point_of_sales_types\";\nimport { SchemaT } from \"../invoices/invoices_types\";\n\nexport function makePosSchemas(t: SchemaT) {\n const HN_INVOICE_REGEX = /^\\d{3}-\\d{3}-\\d{2}-\\d{8}$/;\n\n const InvoiceNumberSchema = z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .string()\n .min(19, t(\"must_be_in_format\"))\n .max(19, t(\"must_be_in_format\"))\n .regex(HN_INVOICE_REGEX, {\n error: t(\"must_be_in_format\"),\n }),\n );\n\n const PointOfSalesSchema = z\n .strictObject({\n cai: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(z.string().min(1, t(\"cai_is_required\")).max(50, t(\"cai_max\"))),\n\n pos_invoice_type: z.enum(POS_INVOICE_TYPE, t(\"select_invoice_type\")),\n\n invoice_number_start_range: InvoiceNumberSchema,\n invoice_number_end_range: InvoiceNumberSchema,\n next_invoice_number: InvoiceNumberSchema,\n\n issuance_date: YmdDateSchema,\n issuance_deadline: YmdDateSchema,\n })\n .superRefine(\n (\n {\n issuance_date,\n issuance_deadline,\n invoice_number_start_range: start,\n invoice_number_end_range: end,\n next_invoice_number: next,\n },\n\n ctx,\n ) => {\n if (issuance_deadline < issuance_date) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"issuance_deadline\"),\n path: [\"issuance_deadline\"],\n });\n }\n\n const prefix = (s: string) => s.slice(0, 10); // \"NNN-NNN-NN\"\n\n if (prefix(start) !== prefix(end)) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"start_end_numbers\"),\n path: [\"invoice_number_end_range\"],\n });\n }\n\n if (prefix(start) !== prefix(next)) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"start_next_numbers\"),\n path: [\"next_invoice_number\"],\n });\n }\n\n if (!(next >= start && next <= end)) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"next_invoice_number\"),\n path: [\"next_invoice_number\"],\n });\n }\n\n if (end < start) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"end_invoice_number\"),\n path: [\"invoice_number_end_range\"],\n });\n }\n },\n );\n\n return {\n PointOfSalesSchema,\n };\n}\n","export type MappedPointOfSales = {\n point_of_sales_id: number;\n cai: string;\n pos_invoice_type: PosInvoiceType;\n invoice_number_start_range: string;\n invoice_number_end_range: string;\n next_invoice_number: string;\n issuance_date: string;\n issuance_deadline: string;\n};\n\nexport const POS_INVOICE_TYPE = [\"sales\", \"credit\"] as const;\n\nexport type PosInvoiceType = (typeof POS_INV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EAAE,QAAQ,SAAS,QAAQ,MAAM;AACnC,YAAI,SAAS;AAAA,UACX,MAAM;AAAA,UACN,SAAS,EAAE,qBAAqB;AAAA,UAChC,MAAM,CAAC,qBAAqB;AAAA,QAC9B,CAAC;AAAA,MACH;AAEA,UAAI,MAAM,OAAO;AACf,YAAI,SAAS;AAAA,UACX,MAAM;AAAA,UACN,SAAS,EAAE,oBAAoB;AAAA,UAC/B,MAAM,CAAC,0BAA0B;AAAA,QACnC,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":["fromString","fromNumber","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","YmdDateSchema","import_zod","import_zod","import_zod"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/types/money_types.ts","../src/utils/utils.ts","../src/types/shared_types.ts","../src/domains/auth/login/login_schemas.ts","../src/domains/companies/companies_schemas.ts","../src/domains/companies/companies_types.ts","../src/domains/customers/customer_schemas.ts","../src/domains/products/product_schemas.ts","../src/domains/invoices/invoices_schemas.ts","../src/domains/invoices/invoices_types.ts","../src/domains/invoice_items/invoice_items_mappers.ts","../src/domains/credit_applications/credit_applications_schemas.ts","../src/domains/payments/payments_schemas.ts","../src/domains/payments/payments_types.ts","../src/utils/money_utils.ts","../src/utils/date_utils.ts","../src/utils/errors_utils.ts","../src/domains/point_of_sales/point_of_sales_schemas.ts","../src/domains/point_of_sales/point_of_sales_types.ts"],"sourcesContent":["export * from \"./utils/utils\";\n\nexport { CreatedLocation, UUID } from \"./types/shared_types\";\n\n//Login\nexport * from \"./domains/auth/login/login_schemas\";\n\n//Company\nexport * from \"./domains/companies/companies_schemas\";\nexport * from \"./domains/companies/companies_types\";\n\n//Users\nexport * from \"./domains/users/users_types\";\n\n//Customers\nexport * from \"./domains/customers/customer_schemas\";\nexport * from \"./domains/customers/customers_types\";\n\n//Vendors\nexport * from \"./domains/vendors/vendors_types\";\n\n// Products\nexport * from \"./domains/products/product_schemas\";\nexport * from \"./domains/products/products_types\";\n\n//Warehouses\nexport * from \"./domains/warehouses/warehouses_types\";\n\n//Inventory\nexport * from \"./domains/inventory/inventory_locations/inventory_locations_types\";\nexport * from \"./domains/inventory/inventory_balances/inventory_balances_type\";\n\n//Invoices\nexport * from \"./domains/invoices/invoices_schemas\";\nexport * from \"./domains/invoices/invoices_types\";\n\n//Invoice Items\nexport * from \"./domains/invoice_items/invoice_items_types\";\nexport * from \"./domains/invoice_items/invoice_items_mappers\";\n\n//Credit Applications\nexport * from \"./domains/credit_applications/credit_applications_schemas\";\nexport * from \"./domains/credit_applications/credit_applications_types\";\n\n//Payments\nexport * from \"./domains/payments/payments_schemas\";\nexport * from \"./domains/payments/payments_types\";\n\n//Drivers\nexport * from \"./domains/drivers/driver_customers/driver_customers_types\";\nexport * from \"./domains/drivers/driver_settings/driver_settings_types\";\n\n//Sync\nexport * from \"./domains/sync/sync_types\";\n\n// Money\nexport * from \"./utils/money_utils\";\nexport * from \"./types/money_types\";\n\n//Date\nexport * from \"./utils/date_utils\";\n\n//Errors\nexport * from \"./utils/errors_utils\";\n\n//Audit Events\nexport * from \"./domains/audit_events/audit_events_types\";\n\n//Country Tax Rules\nexport * from \"./domains/country_tax_rules/country_tax_rules_types\";\n\n//Point of sales\nexport * from \"./domains/point_of_sales/point_of_sales_schemas\";\nexport * from \"./domains/point_of_sales/point_of_sales_types\";\n","import { IsoCountryCode } from \"../domains/companies/companies_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 \"../domains/companies/companies_types\";\nimport {\n IsoCurrencyCode,\n countryToCurrency,\n currencyToLocale,\n} from \"../types/money_types\";\n\nimport { z } from \"zod\";\nimport { SchemaT } from \"../domains/invoices/invoices_types\";\n\n/**\n * Validates zod currency with precision.\n *\n *\n * @param minAmount\n * @param maxAmount\n * @returns\n */\nexport function handleZodCurrency(\n minAmount: number,\n maxAmount: number,\n t?: SchemaT,\n) {\n if (!t) {\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 at least ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `Exceeds allowed limit ${maxAmount}`,\n });\n }\n\n const fromString = z\n .string({\n error: t(\"enter_a_valid_number\"),\n })\n .refine((s) => s.trim().length > 0, {\n error: t(\"enter_a_valid_number\"),\n })\n .transform((s) => s.replace(/[,\\s]/g, \"\"))\n .refine((s) => s !== \"\" && !Number.isNaN(Number(s)), {\n error: t(\"enter_a_valid_number\"),\n })\n .refine((s) => Number.isFinite(Number(s)), {\n error: t(\"enter_a_valid_number\"),\n })\n .refine((s) => Number(s) >= 0, {\n error: t(\"enter_a_positive_number\"),\n })\n .transform((s) => Number(s));\n\n const fromNumber = z\n .number()\n .refine((n) => Number.isFinite(n), {\n error: t(\"enter_a_valid_number\"),\n })\n .refine((n) => n >= 0, {\n error: t(\"enter_a_positive_number\"),\n });\n\n return z\n .union([fromString, fromNumber])\n .transform((n) => roundWithPrecision(n, 2))\n .refine((n) => n >= minAmount, {\n error: `${t(\"must_be_at_least\")} ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `${t(\"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\";\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\nexport type status = \"active\" | \"inactive\";\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../../utils/utils\";\n\nexport const LoginFormSchema = z.strictObject({\n user_email: z\n .string({ error: \"Email required\" })\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({ error: \"Password required\" })\n .min(1, { error: \"Password required\" }),\n});\n","import { z } from \"zod\";\nimport { COMPANY_LANGUAGES, ISO_COUNTRY_CODES } from \"./companies_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\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({ error: \"Please select a country.\" })\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\nexport const CompanyFormSchema =\n RegisterFormSchema.shape.companyData.safeExtend({\n company_email: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .email(\"Invalid company email.\")\n .max(254, \"Company email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n ),\n rtn: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(z.string().max(100, \"RTN must be at most 100 characters.\"))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n web_language: z.enum(COMPANY_LANGUAGES, {\n error: \"Please select a web portal language.\",\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\nexport type CompanySnapshot = {\n company_id: number;\n company_name: string;\n company_address: string;\n company_phone_number: string;\n company_email: string;\n inventory_system: InventorySystem;\n iso_country_code: IsoCountryCode;\n rtn: string | null;\n};\n\nexport const COMPANY_LANGUAGES = [\"es\", \"en\"] as const;\n\nexport type CompanyLanguages = (typeof COMPANY_LANGUAGES)[number];\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../utils/utils\";\nimport { SchemaT } from \"../invoices/invoices_types\";\n\nexport function makeCustomerSchemas(t: SchemaT) {\n const CustomerFormSchema = z.strictObject({\n customer_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, t(\"customer_name_required\"))\n .max(50, t(\"customer_name_max\")),\n ),\n\n customer_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(z.string().max(100, t(\"customer_address_max\")))\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: t(\"customer_phone_number\"),\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, t(\"customer_email_max\"))\n .transform((email) => email.toLowerCase())\n .optional(),\n )\n .optional(),\n });\n\n return { CustomerFormSchema };\n}\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../utils/utils\";\nimport { SchemaT } from \"../invoices/invoices_types\";\n\nexport function makeProductSchemas(t: SchemaT) {\n const ProductFormSchema = z\n .strictObject({\n product_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, t(\"product_name_required\"))\n .max(50, t(\"product_name_max\")),\n ),\n\n product_description: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(z.string().max(100, t(\"product_descr_max\")))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_sku: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(z.string().max(30, t(\"product_sku_max\")))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_upc: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .refine((s) => s === \"\" || /^\\d{12}$/.test(s), {\n error: t(\"product_upc_test\"),\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n country_tax_rule_id: z.number().optional(),\n\n product_gtin_14: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\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: t(\"product_type_validation\"),\n }),\n\n weight_unit: z.preprocess(\n (v) => {\n if (v === \"\") return undefined;\n if (typeof v === \"string\") return v.trim().toLowerCase();\n return v;\n },\n z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional(),\n ),\n\n price: GlobalUtils.handleZodCurrency(0, 99_999.99, t),\n cost: GlobalUtils.handleZodCurrency(0, 99_999.99, t),\n })\n\n .superRefine((data, ctx) => {\n if (data.product_type === \"weight\" && !data.weight_unit) {\n ctx.addIssue({\n code: \"custom\",\n error: t(\"weight_unit_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: t(\"weight_unit_empty\"),\n path: [\"weight_unit\"],\n });\n }\n });\n\n return { ProductFormSchema };\n}\n","import { z } from \"zod\";\nimport {\n CREDIT_TYPE,\n INVOICE_STATUS,\n INVOICE_TYPE,\n SchemaT,\n} from \"./invoices_types\";\nimport { handleZodCurrency } from \"../../utils/utils\";\n\nexport const YmdDateSchema = z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\n///////////////////////////////////////////////////////////////////////\n//English / Spanish implementation\n\nexport function makeInvoiceSchemas(t: SchemaT) {\n const YmdDateSchema = z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\n const BaseInvoice = z\n .object({\n invoice_type: z.enum(INVOICE_TYPE, {\n error: t(\"invoice_type_not_found\"),\n }),\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\n const LineItemBase = z.object({\n invoice_id: z.uuid().optional(),\n product_id: z.uuid({\n error: t(\"select_product\"),\n }),\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, t),\n country_tax_rule_id: z.number().optional(),\n tax_percentage: z.number().optional(),\n });\n\n const SalesItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99, t),\n credit_type: z.undefined(),\n });\n\n const CreditItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99, t),\n credit_type: z.enum(CREDIT_TYPE, {\n error: t(\"select_credit_type\"),\n }),\n });\n\n const PurchaseItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99, t),\n credit_type: z.undefined(),\n });\n\n const SalesInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"sales\"),\n party_id: z.uuid({\n error: t(\"select_customer\"),\n }),\n invoice_items: z.array(SalesItem).min(1, t(\"add_one_invoice_item\")),\n });\n\n const CreditInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"credit\"),\n party_id: z.uuid({\n error: t(\"select_customer\"),\n }),\n invoice_items: z.array(CreditItem).min(1, t(\"add_one_invoice_item\")),\n });\n\n const PurchaseInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"purchase\"),\n party_id: z.uuid({\n error: t(\"select_vendor\"),\n }),\n invoice_items: z.array(PurchaseItem).min(1, t(\"add_one_invoice_item\")),\n });\n\n const AnyInvoiceSchema = z.discriminatedUnion(\"invoice_type\", [\n SalesInvoiceSchema,\n PurchaseInvoiceSchema,\n CreditInvoiceSchema,\n ]);\n\n return {\n YmdDateSchema,\n SalesInvoiceSchema,\n CreditInvoiceSchema,\n PurchaseInvoiceSchema,\n AnyInvoiceSchema,\n };\n}\n\nexport type InvoiceSchemas = ReturnType<typeof makeInvoiceSchemas>;\n","import { z } from \"zod\";\nimport * as InvoiceSchemas from \"./invoices_schemas\";\nimport { IntBool, UUID } from \"../../types/shared_types\";\n\nexport type SchemaT = (key: string, params?: Record<string, any>) => string;\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\nexport type InvoiceSchemaSet = ReturnType<\n typeof InvoiceSchemas.makeInvoiceSchemas\n>;\nexport type AnyInvoiceOut = z.output<InvoiceSchemaSet[\"AnyInvoiceSchema\"]>;\n\nexport type InvoiceSnapshot = {\n invoice_id: UUID;\n invoice_type: InvoiceType;\n subtotal: string;\n tax_amount: string;\n total_amount: string;\n remaining_balance: string;\n due_date: string;\n tax_rate: string;\n is_admin_reviewed: IntBool;\n customer_id: UUID;\n company_id: number;\n short_invoice_id: string;\n invoice_date: string;\n invoice_status: InvoiceStatus;\n occurred_at_ms: string;\n cai: string | null;\n invoice_number_start_range: string | null;\n invoice_number_end_range: string | null;\n issuance_date: string | null;\n issuance_deadline: string | null;\n};\n\nexport type InvoiceSnapshotMobile = InvoiceSnapshot & {\n signature: string | null;\n};\n","import * as InvoiceItemsTypes from \"./invoice_items_types\";\n\nexport function mapInvoiceProducts(\n row: InvoiceItemsTypes.InvoiceItemResponse\n): InvoiceItemsTypes.MappedInvoiceItem {\n return {\n invoice_item_id: row.invoice_item_id,\n product_id: row.product_id,\n quantity: Number(row.quantity),\n price: Number(row.price),\n amount: Number(row.amount),\n credit_type: row.credit_type ?? undefined,\n product_name: row.product_name,\n product_description: row.product_description ?? undefined,\n product_type: row.product_type,\n weight_unit: row.weight_unit ?? undefined,\n product_upc: row.product_upc ?? undefined,\n rule_name: row.rule_name ?? undefined,\n tax_percentage:\n row.tax_percentage === null ? undefined : Number(row.tax_percentage),\n };\n}\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../utils/utils\";\n\nexport const CreditApplicationSchema = z.strictObject({\n credit_invoice_id: z.uuid({ error: \"Select a credit\" }),\n applied_amount: GlobalUtils.handleZodCurrency(0.01, 999_999.99),\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","import { IntBool, UUID } from \"../../types/shared_types\";\n\nexport 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\nexport type PaymentStatus = \"finalized\" | \"voided\";\n\nexport type PaymentSnapshot = {\n payment_id: UUID;\n invoice_id: UUID;\n payment_amount: string;\n payment_date: string;\n payment_method: PaymentMethod;\n check_number: string | null;\n is_admin_reviewed: IntBool;\n company_id: number;\n short_invoice_id: string;\n payment_status: PaymentStatus;\n occurred_at_ms: string;\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","// \"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","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../utils/utils\";\nimport { YmdDateSchema } from \"../invoices/invoices_schemas\";\nimport { POS_INVOICE_TYPE } from \"./point_of_sales_types\";\nimport { SchemaT } from \"../invoices/invoices_types\";\n\nexport function makePosSchemas(t: SchemaT) {\n const HN_INVOICE_REGEX = /^\\d{3}-\\d{3}-\\d{2}-\\d{8}$/;\n\n const InvoiceNumberSchema = z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .string()\n .min(19, t(\"must_be_in_format\"))\n .max(19, t(\"must_be_in_format\"))\n .regex(HN_INVOICE_REGEX, {\n error: t(\"must_be_in_format\"),\n }),\n );\n\n const PointOfSalesSchema = z\n .strictObject({\n cai: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(z.string().min(1, t(\"cai_is_required\")).max(50, t(\"cai_max\"))),\n\n pos_invoice_type: z.enum(POS_INVOICE_TYPE, t(\"select_invoice_type\")),\n\n invoice_number_start_range: InvoiceNumberSchema,\n invoice_number_end_range: InvoiceNumberSchema,\n next_invoice_number: InvoiceNumberSchema,\n\n issuance_date: YmdDateSchema,\n issuance_deadline: YmdDateSchema,\n })\n .superRefine(\n (\n {\n issuance_date,\n issuance_deadline,\n invoice_number_start_range: start,\n invoice_number_end_range: end,\n next_invoice_number: next,\n },\n\n ctx,\n ) => {\n if (issuance_deadline < issuance_date) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"issuance_deadline\"),\n path: [\"issuance_deadline\"],\n });\n }\n\n const prefix = (s: string) => s.slice(0, 10); // \"NNN-NNN-NN\"\n\n if (prefix(start) !== prefix(end)) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"start_end_numbers\"),\n path: [\"invoice_number_end_range\"],\n });\n }\n\n if (prefix(start) !== prefix(next)) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"start_next_numbers\"),\n path: [\"next_invoice_number\"],\n });\n }\n\n if (!(next >= start && next <= end)) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"next_invoice_number\"),\n path: [\"next_invoice_number\"],\n });\n }\n\n if (end < start) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"end_invoice_number\"),\n path: [\"invoice_number_end_range\"],\n });\n }\n },\n );\n\n return {\n PointOfSalesSchema,\n };\n}\n","export type MappedPointOfSales = {\n point_of_sales_id: number;\n cai: string;\n pos_invoice_type: PosInvoiceType;\n invoice_number_start_range: string;\n invoice_number_end_range: string;\n next_invoice_number: string;\n issuance_date: string;\n issuance_deadline: string;\n};\n\n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EAAE,MAAM,GAAG,EAAE;AAE3C,UAAI,OAAO,KAAK,MAAM,OAAO,GAAG,GAAG;AACjC,YAAI,SAAS;AAAA,UACX,MAAM;AAAA,UACN,SAAS,EAAE,mBAAmB;AAAA,UAC9B,MAAM,CAAC,0BAA0B;AAAA,QACnC,CAAC;AAAA,MACH;AAEA,UAAI,OAAO,KAAK,MAAM,OAAO,IAAI,GAAG;AAClC,YAAI,SAAS;AAAA,UACX,MAAM;AAAA,UACN,SAAS,EAAE,oBAAoB;AAAA,UAC/B,MAAM,CAAC,qBAAqB;AAAA,QAC9B,CAAC;AAAA,MACH;AAEA,UAAI,EAAE,QAAQ,SAAS,QAAQ,MAAM;AACnC,YAAI,SAAS;AAAA,UACX,MAAM;AAAA,UACN,SAAS,EAAE,qBAAqB;AAAA,UAChC,MAAM,CAAC,qBAAqB;AAAA,QAC9B,CAAC;AAAA,MACH;AAEA,UAAI,MAAM,OAAO;AACf,YAAI,SAAS;AAAA,UACX,MAAM;AAAA,UACN,SAAS,EAAE,oBAAoB;AAAA,UAC/B,MAAM,CAAC,0BAA0B;AAAA,QACnC,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":["fromString","fromNumber","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","YmdDateSchema","import_zod","import_zod","import_zod"]}
package/dist/index.d.cts CHANGED
@@ -404,12 +404,14 @@ type UsersSnapshot = {
404
404
  company_id: number;
405
405
  };
406
406
 
407
- declare const CustomerFormSchema: z.ZodObject<{
408
- customer_name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
409
- customer_address: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
410
- customer_phone_number: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
411
- 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>>>>>;
412
- }, z.core.$strict>;
407
+ declare function makeCustomerSchemas(t: SchemaT): {
408
+ CustomerFormSchema: z.ZodObject<{
409
+ customer_name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
410
+ customer_address: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
411
+ customer_phone_number: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
412
+ 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>>>>>;
413
+ }, z.core.$strict>;
414
+ };
413
415
 
414
416
  type CustomerSnapshot = {
415
417
  customer_id: UUID;
@@ -438,27 +440,29 @@ type MappedVendors = {
438
440
  tax_rate: number;
439
441
  };
440
442
 
441
- declare const ProductFormSchema: z.ZodObject<{
442
- product_name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
443
- product_description: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
444
- product_sku: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
445
- product_upc: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
446
- country_tax_rule_id: z.ZodOptional<z.ZodNumber>;
447
- product_gtin_14: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
448
- product_type: z.ZodEnum<{
449
- unit: "unit";
450
- weight: "weight";
451
- case: "case";
452
- }>;
453
- weight_unit: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodEnum<{
454
- kg: "kg";
455
- lb: "lb";
456
- g: "g";
457
- oz: "oz";
458
- }>>>;
459
- 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>>;
460
- 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>>;
461
- }, z.core.$strict>;
443
+ declare function makeProductSchemas(t: SchemaT): {
444
+ ProductFormSchema: z.ZodObject<{
445
+ product_name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
446
+ product_description: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
447
+ product_sku: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
448
+ product_upc: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
449
+ country_tax_rule_id: z.ZodOptional<z.ZodNumber>;
450
+ product_gtin_14: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
451
+ product_type: z.ZodEnum<{
452
+ unit: "unit";
453
+ weight: "weight";
454
+ case: "case";
455
+ }>;
456
+ weight_unit: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodEnum<{
457
+ kg: "kg";
458
+ lb: "lb";
459
+ g: "g";
460
+ oz: "oz";
461
+ }>>>;
462
+ 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>>;
463
+ 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>>;
464
+ }, z.core.$strict>;
465
+ };
462
466
 
463
467
  type ProductType = "unit" | "weight" | "case";
464
468
  type WeightUnit = "kg" | "lb" | "g" | "oz";
@@ -710,4 +714,4 @@ type MappedPointOfSales = {
710
714
  declare const POS_INVOICE_TYPE: readonly ["sales", "credit"];
711
715
  type PosInvoiceType = (typeof POS_INVOICE_TYPE)[number];
712
716
 
713
- export { type AnyInvoiceOut, type AppLanguage, type AuditEventsSnapshot, COMPANY_LANGUAGES, CREDIT_TYPE, CompanyFormSchema, type CompanyLanguages, type CompanySnapshot, type CountryTaxRuleSnapshot, type CreatedLocation, CreditApplicationSchema, type CreditApplicationSnapshot, type CreditApplicationStatus, type CreditType, type CustomerFilter, CustomerFormSchema, type CustomerSnapshot, type DriverCustomerSnapshot, type DriverSettingSnapshot, type EntityAction, type EntityType, INVOICE_STATUS, INVOICE_TYPE, ISO_COUNTRY_CODES, type InventoryBalanceSnapshot, type InventoryLocationSnapshot, type InventorySystem, type InvoiceFilter, type InvoiceItemResponse, type InvoiceItemSnapshot, type InvoiceItemStatus, type InvoiceSchemaSet, type InvoiceSchemas, type InvoiceSnapshot, type InvoiceSnapshotMobile, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type IsoCurrencyCode, LoginFormSchema, type MappedCustomers, type MappedInvoiceItem, type MappedPointOfSales, type MappedVendors, PAYMENT_METHOD, POS_INVOICE_TYPE, type PaymentFilter, PaymentFormSchema, type PaymentMethod, type PaymentSnapshot, type PaymentStatus, type PosInvoiceType, ProductFormSchema, type ProductSnapshot, type ProductType, RegisterFormSchema, type SchemaT, type ServerSyncIds, type ServerSyncLogIds, USER_ROLES, type UUID, type UserRole, type UsersSnapshot, type WarehouseSnapshot, type WeightUnit, YmdDateSchema, addDaysLocalYmd, countryToCurrency, currencyToLocale, exceedsTwoDecimals, formatMoneyCurrency, formatYmdLong, getCurrencyFromCountry, getErrorMessage, handleZodCurrency, localDateFromYmd, makeInvoiceSchemas, makePosSchemas, mapInvoiceProducts, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, todayLocalYmd, transformEmptyStringToUndefined, ymdFromLocalDate };
717
+ export { type AnyInvoiceOut, type AppLanguage, type AuditEventsSnapshot, COMPANY_LANGUAGES, CREDIT_TYPE, CompanyFormSchema, type CompanyLanguages, type CompanySnapshot, type CountryTaxRuleSnapshot, type CreatedLocation, CreditApplicationSchema, type CreditApplicationSnapshot, type CreditApplicationStatus, type CreditType, type CustomerFilter, type CustomerSnapshot, type DriverCustomerSnapshot, type DriverSettingSnapshot, type EntityAction, type EntityType, INVOICE_STATUS, INVOICE_TYPE, ISO_COUNTRY_CODES, type InventoryBalanceSnapshot, type InventoryLocationSnapshot, type InventorySystem, type InvoiceFilter, type InvoiceItemResponse, type InvoiceItemSnapshot, type InvoiceItemStatus, type InvoiceSchemaSet, type InvoiceSchemas, type InvoiceSnapshot, type InvoiceSnapshotMobile, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type IsoCurrencyCode, LoginFormSchema, type MappedCustomers, type MappedInvoiceItem, type MappedPointOfSales, type MappedVendors, PAYMENT_METHOD, POS_INVOICE_TYPE, type PaymentFilter, PaymentFormSchema, type PaymentMethod, type PaymentSnapshot, type PaymentStatus, type PosInvoiceType, type ProductSnapshot, type ProductType, RegisterFormSchema, type SchemaT, type ServerSyncIds, type ServerSyncLogIds, USER_ROLES, type UUID, type UserRole, type UsersSnapshot, type WarehouseSnapshot, type WeightUnit, YmdDateSchema, addDaysLocalYmd, countryToCurrency, currencyToLocale, exceedsTwoDecimals, formatMoneyCurrency, formatYmdLong, getCurrencyFromCountry, getErrorMessage, handleZodCurrency, localDateFromYmd, makeCustomerSchemas, makeInvoiceSchemas, makePosSchemas, makeProductSchemas, mapInvoiceProducts, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, todayLocalYmd, transformEmptyStringToUndefined, ymdFromLocalDate };
package/dist/index.d.ts CHANGED
@@ -404,12 +404,14 @@ type UsersSnapshot = {
404
404
  company_id: number;
405
405
  };
406
406
 
407
- declare const CustomerFormSchema: z.ZodObject<{
408
- customer_name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
409
- customer_address: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
410
- customer_phone_number: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
411
- 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>>>>>;
412
- }, z.core.$strict>;
407
+ declare function makeCustomerSchemas(t: SchemaT): {
408
+ CustomerFormSchema: z.ZodObject<{
409
+ customer_name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
410
+ customer_address: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
411
+ customer_phone_number: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
412
+ 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>>>>>;
413
+ }, z.core.$strict>;
414
+ };
413
415
 
414
416
  type CustomerSnapshot = {
415
417
  customer_id: UUID;
@@ -438,27 +440,29 @@ type MappedVendors = {
438
440
  tax_rate: number;
439
441
  };
440
442
 
441
- declare const ProductFormSchema: z.ZodObject<{
442
- product_name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
443
- product_description: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
444
- product_sku: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
445
- product_upc: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
446
- country_tax_rule_id: z.ZodOptional<z.ZodNumber>;
447
- product_gtin_14: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
448
- product_type: z.ZodEnum<{
449
- unit: "unit";
450
- weight: "weight";
451
- case: "case";
452
- }>;
453
- weight_unit: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodEnum<{
454
- kg: "kg";
455
- lb: "lb";
456
- g: "g";
457
- oz: "oz";
458
- }>>>;
459
- 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>>;
460
- 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>>;
461
- }, z.core.$strict>;
443
+ declare function makeProductSchemas(t: SchemaT): {
444
+ ProductFormSchema: z.ZodObject<{
445
+ product_name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
446
+ product_description: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
447
+ product_sku: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>, z.ZodTransform<string | undefined, string>>>;
448
+ product_upc: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
449
+ country_tax_rule_id: z.ZodOptional<z.ZodNumber>;
450
+ product_gtin_14: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<string | undefined, string>>>;
451
+ product_type: z.ZodEnum<{
452
+ unit: "unit";
453
+ weight: "weight";
454
+ case: "case";
455
+ }>;
456
+ weight_unit: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodEnum<{
457
+ kg: "kg";
458
+ lb: "lb";
459
+ g: "g";
460
+ oz: "oz";
461
+ }>>>;
462
+ 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>>;
463
+ 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>>;
464
+ }, z.core.$strict>;
465
+ };
462
466
 
463
467
  type ProductType = "unit" | "weight" | "case";
464
468
  type WeightUnit = "kg" | "lb" | "g" | "oz";
@@ -710,4 +714,4 @@ type MappedPointOfSales = {
710
714
  declare const POS_INVOICE_TYPE: readonly ["sales", "credit"];
711
715
  type PosInvoiceType = (typeof POS_INVOICE_TYPE)[number];
712
716
 
713
- export { type AnyInvoiceOut, type AppLanguage, type AuditEventsSnapshot, COMPANY_LANGUAGES, CREDIT_TYPE, CompanyFormSchema, type CompanyLanguages, type CompanySnapshot, type CountryTaxRuleSnapshot, type CreatedLocation, CreditApplicationSchema, type CreditApplicationSnapshot, type CreditApplicationStatus, type CreditType, type CustomerFilter, CustomerFormSchema, type CustomerSnapshot, type DriverCustomerSnapshot, type DriverSettingSnapshot, type EntityAction, type EntityType, INVOICE_STATUS, INVOICE_TYPE, ISO_COUNTRY_CODES, type InventoryBalanceSnapshot, type InventoryLocationSnapshot, type InventorySystem, type InvoiceFilter, type InvoiceItemResponse, type InvoiceItemSnapshot, type InvoiceItemStatus, type InvoiceSchemaSet, type InvoiceSchemas, type InvoiceSnapshot, type InvoiceSnapshotMobile, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type IsoCurrencyCode, LoginFormSchema, type MappedCustomers, type MappedInvoiceItem, type MappedPointOfSales, type MappedVendors, PAYMENT_METHOD, POS_INVOICE_TYPE, type PaymentFilter, PaymentFormSchema, type PaymentMethod, type PaymentSnapshot, type PaymentStatus, type PosInvoiceType, ProductFormSchema, type ProductSnapshot, type ProductType, RegisterFormSchema, type SchemaT, type ServerSyncIds, type ServerSyncLogIds, USER_ROLES, type UUID, type UserRole, type UsersSnapshot, type WarehouseSnapshot, type WeightUnit, YmdDateSchema, addDaysLocalYmd, countryToCurrency, currencyToLocale, exceedsTwoDecimals, formatMoneyCurrency, formatYmdLong, getCurrencyFromCountry, getErrorMessage, handleZodCurrency, localDateFromYmd, makeInvoiceSchemas, makePosSchemas, mapInvoiceProducts, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, todayLocalYmd, transformEmptyStringToUndefined, ymdFromLocalDate };
717
+ export { type AnyInvoiceOut, type AppLanguage, type AuditEventsSnapshot, COMPANY_LANGUAGES, CREDIT_TYPE, CompanyFormSchema, type CompanyLanguages, type CompanySnapshot, type CountryTaxRuleSnapshot, type CreatedLocation, CreditApplicationSchema, type CreditApplicationSnapshot, type CreditApplicationStatus, type CreditType, type CustomerFilter, type CustomerSnapshot, type DriverCustomerSnapshot, type DriverSettingSnapshot, type EntityAction, type EntityType, INVOICE_STATUS, INVOICE_TYPE, ISO_COUNTRY_CODES, type InventoryBalanceSnapshot, type InventoryLocationSnapshot, type InventorySystem, type InvoiceFilter, type InvoiceItemResponse, type InvoiceItemSnapshot, type InvoiceItemStatus, type InvoiceSchemaSet, type InvoiceSchemas, type InvoiceSnapshot, type InvoiceSnapshotMobile, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type IsoCurrencyCode, LoginFormSchema, type MappedCustomers, type MappedInvoiceItem, type MappedPointOfSales, type MappedVendors, PAYMENT_METHOD, POS_INVOICE_TYPE, type PaymentFilter, PaymentFormSchema, type PaymentMethod, type PaymentSnapshot, type PaymentStatus, type PosInvoiceType, type ProductSnapshot, type ProductType, RegisterFormSchema, type SchemaT, type ServerSyncIds, type ServerSyncLogIds, USER_ROLES, type UUID, type UserRole, type UsersSnapshot, type WarehouseSnapshot, type WeightUnit, YmdDateSchema, addDaysLocalYmd, countryToCurrency, currencyToLocale, exceedsTwoDecimals, formatMoneyCurrency, formatYmdLong, getCurrencyFromCountry, getErrorMessage, handleZodCurrency, localDateFromYmd, makeCustomerSchemas, makeInvoiceSchemas, makePosSchemas, makeProductSchemas, mapInvoiceProducts, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, todayLocalYmd, transformEmptyStringToUndefined, ymdFromLocalDate };
package/dist/index.js CHANGED
@@ -157,64 +157,69 @@ var CompanyFormSchema = RegisterFormSchema.shape.companyData.safeExtend({
157
157
 
158
158
  // src/domains/customers/customer_schemas.ts
159
159
  import { z as z5 } from "zod";
160
- var CustomerFormSchema = z5.strictObject({
161
- customer_name: z5.string().transform(normalizeSpaces).pipe(
162
- z5.string().min(1, "Customer name is required").max(50, "Customer name must be at most 50 characters.")
163
- ),
164
- customer_address: z5.string().transform(normalizeSpaces).pipe(
165
- z5.string().max(100, "Customer address must be at most 100 characters.")
166
- ).transform(transformEmptyStringToUndefined).optional(),
167
- customer_phone_number: z5.string().transform(removeAllWhitespace).transform(removeDashesAndPlusSign).refine((s) => s === "" || /^\d{4,15}$/.test(s), {
168
- error: "Phone number must be from 4 to 15 digits."
169
- }).transform(transformEmptyStringToUndefined).optional(),
170
- customer_email_address: z5.string().transform(removeAllWhitespace).transform(transformEmptyStringToUndefined).pipe(
171
- z5.email().max(254, "Customer email must be at most 254 characters.").transform((email) => email.toLowerCase()).optional()
172
- ).optional()
173
- });
160
+ function makeCustomerSchemas(t) {
161
+ const CustomerFormSchema = z5.strictObject({
162
+ customer_name: z5.string().transform(normalizeSpaces).pipe(
163
+ z5.string().min(1, t("customer_name_required")).max(50, t("customer_name_max"))
164
+ ),
165
+ customer_address: z5.string().transform(normalizeSpaces).pipe(z5.string().max(100, t("customer_address_max"))).transform(transformEmptyStringToUndefined).optional(),
166
+ customer_phone_number: z5.string().transform(removeAllWhitespace).transform(removeDashesAndPlusSign).refine((s) => s === "" || /^\d{4,15}$/.test(s), {
167
+ error: t("customer_phone_number")
168
+ }).transform(transformEmptyStringToUndefined).optional(),
169
+ customer_email_address: z5.string().transform(removeAllWhitespace).transform(transformEmptyStringToUndefined).pipe(
170
+ z5.email().max(254, t("customer_email_max")).transform((email) => email.toLowerCase()).optional()
171
+ ).optional()
172
+ });
173
+ return { CustomerFormSchema };
174
+ }
174
175
 
175
176
  // src/domains/products/product_schemas.ts
176
177
  import { z as z6 } from "zod";
177
- var ProductFormSchema = z6.strictObject({
178
- product_name: z6.string().transform(normalizeSpaces).pipe(
179
- z6.string().min(1, "Product name is required").max(50, "Product name must be at most 50 characters.")
180
- ),
181
- product_description: z6.string().transform(normalizeSpaces).pipe(
182
- z6.string().max(100, "Product desription must be at most 100 characters.")
183
- ).transform(transformEmptyStringToUndefined).optional(),
184
- product_sku: z6.string().transform(normalizeSpaces).pipe(z6.string().max(30, "Product SKU must be at most 30 characters.")).transform(transformEmptyStringToUndefined).optional(),
185
- product_upc: z6.string().transform(removeAllWhitespace).refine((s) => s === "" || /^\d{12}$/.test(s), {
186
- error: "UPC must be exactly 12 digits"
187
- }).transform(transformEmptyStringToUndefined).optional(),
188
- country_tax_rule_id: z6.number().optional(),
189
- product_gtin_14: z6.string().transform(removeAllWhitespace).refine((s) => s === "" || /^\d{14}$/.test(s), {
190
- error: "GTIN14 must be exactly 14 digits"
191
- }).transform(transformEmptyStringToUndefined).optional(),
192
- product_type: z6.enum(["unit", "weight", "case"], {
193
- error: "Product type must be unit, weight, or case."
194
- }),
195
- weight_unit: z6.preprocess((v) => {
196
- if (v === "") return void 0;
197
- if (typeof v === "string") return v.trim().toLowerCase();
198
- return v;
199
- }, z6.enum(["kg", "lb", "g", "oz"]).optional()),
200
- price: handleZodCurrency(0, 99999.99),
201
- cost: handleZodCurrency(0, 99999.99)
202
- }).superRefine((data, ctx) => {
203
- if (data.product_type === "weight" && !data.weight_unit) {
204
- ctx.addIssue({
205
- code: "custom",
206
- error: "Weight unit is required.",
207
- path: ["weight_unit"]
208
- });
209
- }
210
- if (data.product_type !== "weight" && typeof data.weight_unit !== "undefined") {
211
- ctx.addIssue({
212
- code: "custom",
213
- error: "Weight unit must be empty",
214
- path: ["weight_unit"]
215
- });
216
- }
217
- });
178
+ function makeProductSchemas(t) {
179
+ const ProductFormSchema = z6.strictObject({
180
+ product_name: z6.string().transform(normalizeSpaces).pipe(
181
+ z6.string().min(1, t("product_name_required")).max(50, t("product_name_max"))
182
+ ),
183
+ product_description: z6.string().transform(normalizeSpaces).pipe(z6.string().max(100, t("product_descr_max"))).transform(transformEmptyStringToUndefined).optional(),
184
+ product_sku: z6.string().transform(normalizeSpaces).pipe(z6.string().max(30, t("product_sku_max"))).transform(transformEmptyStringToUndefined).optional(),
185
+ product_upc: z6.string().transform(removeAllWhitespace).refine((s) => s === "" || /^\d{12}$/.test(s), {
186
+ error: t("product_upc_test")
187
+ }).transform(transformEmptyStringToUndefined).optional(),
188
+ country_tax_rule_id: z6.number().optional(),
189
+ product_gtin_14: z6.string().transform(removeAllWhitespace).refine((s) => s === "" || /^\d{14}$/.test(s), {
190
+ error: "GTIN14 must be exactly 14 digits"
191
+ }).transform(transformEmptyStringToUndefined).optional(),
192
+ product_type: z6.enum(["unit", "weight", "case"], {
193
+ error: t("product_type_validation")
194
+ }),
195
+ weight_unit: z6.preprocess(
196
+ (v) => {
197
+ if (v === "") return void 0;
198
+ if (typeof v === "string") return v.trim().toLowerCase();
199
+ return v;
200
+ },
201
+ z6.enum(["kg", "lb", "g", "oz"]).optional()
202
+ ),
203
+ price: handleZodCurrency(0, 99999.99, t),
204
+ cost: handleZodCurrency(0, 99999.99, t)
205
+ }).superRefine((data, ctx) => {
206
+ if (data.product_type === "weight" && !data.weight_unit) {
207
+ ctx.addIssue({
208
+ code: "custom",
209
+ error: t("weight_unit_required"),
210
+ path: ["weight_unit"]
211
+ });
212
+ }
213
+ if (data.product_type !== "weight" && typeof data.weight_unit !== "undefined") {
214
+ ctx.addIssue({
215
+ code: "custom",
216
+ error: t("weight_unit_empty"),
217
+ path: ["weight_unit"]
218
+ });
219
+ }
220
+ });
221
+ return { ProductFormSchema };
222
+ }
218
223
 
219
224
  // src/domains/invoices/invoices_schemas.ts
220
225
  import { z as z7 } from "zod";
@@ -492,7 +497,6 @@ export {
492
497
  CREDIT_TYPE,
493
498
  CompanyFormSchema,
494
499
  CreditApplicationSchema,
495
- CustomerFormSchema,
496
500
  INVOICE_STATUS,
497
501
  INVOICE_TYPE,
498
502
  ISO_COUNTRY_CODES,
@@ -500,7 +504,6 @@ export {
500
504
  PAYMENT_METHOD,
501
505
  POS_INVOICE_TYPE,
502
506
  PaymentFormSchema,
503
- ProductFormSchema,
504
507
  RegisterFormSchema,
505
508
  USER_ROLES,
506
509
  YmdDateSchema,
@@ -514,8 +517,10 @@ export {
514
517
  getErrorMessage,
515
518
  handleZodCurrency,
516
519
  localDateFromYmd,
520
+ makeCustomerSchemas,
517
521
  makeInvoiceSchemas,
518
522
  makePosSchemas,
523
+ makeProductSchemas,
519
524
  mapInvoiceProducts,
520
525
  normalizeSpaces,
521
526
  removeAllWhitespace,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types/money_types.ts","../src/utils/utils.ts","../src/types/shared_types.ts","../src/domains/auth/login/login_schemas.ts","../src/domains/companies/companies_schemas.ts","../src/domains/companies/companies_types.ts","../src/domains/customers/customer_schemas.ts","../src/domains/products/product_schemas.ts","../src/domains/invoices/invoices_schemas.ts","../src/domains/invoices/invoices_types.ts","../src/domains/invoice_items/invoice_items_mappers.ts","../src/domains/credit_applications/credit_applications_schemas.ts","../src/domains/payments/payments_schemas.ts","../src/domains/payments/payments_types.ts","../src/utils/money_utils.ts","../src/utils/date_utils.ts","../src/utils/errors_utils.ts","../src/domains/point_of_sales/point_of_sales_schemas.ts","../src/domains/point_of_sales/point_of_sales_types.ts"],"sourcesContent":["import { IsoCountryCode } from \"../domains/companies/companies_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 \"../domains/companies/companies_types\";\nimport {\n IsoCurrencyCode,\n countryToCurrency,\n currencyToLocale,\n} from \"../types/money_types\";\n\nimport { z } from \"zod\";\nimport { SchemaT } from \"../domains/invoices/invoices_types\";\n\n/**\n * Validates zod currency with precision.\n *\n *\n * @param minAmount\n * @param maxAmount\n * @returns\n */\nexport function handleZodCurrency(\n minAmount: number,\n maxAmount: number,\n t?: SchemaT,\n) {\n if (!t) {\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 at least ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `Exceeds allowed limit ${maxAmount}`,\n });\n }\n\n const fromString = z\n .string({\n error: t(\"enter_a_valid_number\"),\n })\n .refine((s) => s.trim().length > 0, {\n error: t(\"enter_a_valid_number\"),\n })\n .transform((s) => s.replace(/[,\\s]/g, \"\"))\n .refine((s) => s !== \"\" && !Number.isNaN(Number(s)), {\n error: t(\"enter_a_valid_number\"),\n })\n .refine((s) => Number.isFinite(Number(s)), {\n error: t(\"enter_a_valid_number\"),\n })\n .refine((s) => Number(s) >= 0, {\n error: t(\"enter_a_positive_number\"),\n })\n .transform((s) => Number(s));\n\n const fromNumber = z\n .number()\n .refine((n) => Number.isFinite(n), {\n error: t(\"enter_a_valid_number\"),\n })\n .refine((n) => n >= 0, {\n error: t(\"enter_a_positive_number\"),\n });\n\n return z\n .union([fromString, fromNumber])\n .transform((n) => roundWithPrecision(n, 2))\n .refine((n) => n >= minAmount, {\n error: `${t(\"must_be_at_least\")} ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `${t(\"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\";\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\nexport type status = \"active\" | \"inactive\";\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../../utils/utils\";\n\nexport const LoginFormSchema = z.strictObject({\n user_email: z\n .string({ error: \"Email required\" })\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({ error: \"Password required\" })\n .min(1, { error: \"Password required\" }),\n});\n","import { z } from \"zod\";\nimport { COMPANY_LANGUAGES, ISO_COUNTRY_CODES } from \"./companies_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\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({ error: \"Please select a country.\" })\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\nexport const CompanyFormSchema =\n RegisterFormSchema.shape.companyData.safeExtend({\n company_email: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .email(\"Invalid company email.\")\n .max(254, \"Company email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n ),\n rtn: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(z.string().max(100, \"RTN must be at most 100 characters.\"))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n web_language: z.enum(COMPANY_LANGUAGES, {\n error: \"Please select a web portal language.\",\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\nexport type CompanySnapshot = {\n company_id: number;\n company_name: string;\n company_address: string;\n company_phone_number: string;\n company_email: string;\n inventory_system: InventorySystem;\n iso_country_code: IsoCountryCode;\n rtn: string | null;\n};\n\nexport const COMPANY_LANGUAGES = [\"es\", \"en\"] as const;\n\nexport type CompanyLanguages = (typeof COMPANY_LANGUAGES)[number];\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(GlobalUtils.removeAllWhitespace)\n .refine((s) => s === \"\" || /^\\d{12}$/.test(s), {\n error: \"UPC must be exactly 12 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n country_tax_rule_id: z.number().optional(),\n\n product_gtin_14: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\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 {\n CREDIT_TYPE,\n INVOICE_STATUS,\n INVOICE_TYPE,\n SchemaT,\n} from \"./invoices_types\";\nimport { handleZodCurrency } from \"../../utils/utils\";\n\nexport const YmdDateSchema = z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\n///////////////////////////////////////////////////////////////////////\n//English / Spanish implementation\n\nexport function makeInvoiceSchemas(t: SchemaT) {\n const YmdDateSchema = z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\n const BaseInvoice = z\n .object({\n invoice_type: z.enum(INVOICE_TYPE, {\n error: t(\"invoice_type_not_found\"),\n }),\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\n const LineItemBase = z.object({\n invoice_id: z.uuid().optional(),\n product_id: z.uuid({\n error: t(\"select_product\"),\n }),\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, t),\n country_tax_rule_id: z.number().optional(),\n tax_percentage: z.number().optional(),\n });\n\n const SalesItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99, t),\n credit_type: z.undefined(),\n });\n\n const CreditItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99, t),\n credit_type: z.enum(CREDIT_TYPE, {\n error: t(\"select_credit_type\"),\n }),\n });\n\n const PurchaseItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99, t),\n credit_type: z.undefined(),\n });\n\n const SalesInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"sales\"),\n party_id: z.uuid({\n error: t(\"select_customer\"),\n }),\n invoice_items: z.array(SalesItem).min(1, t(\"add_one_invoice_item\")),\n });\n\n const CreditInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"credit\"),\n party_id: z.uuid({\n error: t(\"select_customer\"),\n }),\n invoice_items: z.array(CreditItem).min(1, t(\"add_one_invoice_item\")),\n });\n\n const PurchaseInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"purchase\"),\n party_id: z.uuid({\n error: t(\"select_vendor\"),\n }),\n invoice_items: z.array(PurchaseItem).min(1, t(\"add_one_invoice_item\")),\n });\n\n const AnyInvoiceSchema = z.discriminatedUnion(\"invoice_type\", [\n SalesInvoiceSchema,\n PurchaseInvoiceSchema,\n CreditInvoiceSchema,\n ]);\n\n return {\n YmdDateSchema,\n SalesInvoiceSchema,\n CreditInvoiceSchema,\n PurchaseInvoiceSchema,\n AnyInvoiceSchema,\n };\n}\n\nexport type InvoiceSchemas = ReturnType<typeof makeInvoiceSchemas>;\n","import { z } from \"zod\";\nimport * as InvoiceSchemas from \"./invoices_schemas\";\nimport { IntBool, UUID } from \"../../types/shared_types\";\n\nexport type SchemaT = (key: string, params?: Record<string, any>) => string;\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\nexport type InvoiceSchemaSet = ReturnType<\n typeof InvoiceSchemas.makeInvoiceSchemas\n>;\nexport type AnyInvoiceOut = z.output<InvoiceSchemaSet[\"AnyInvoiceSchema\"]>;\n\nexport type InvoiceSnapshot = {\n invoice_id: UUID;\n invoice_type: InvoiceType;\n subtotal: string;\n tax_amount: string;\n total_amount: string;\n remaining_balance: string;\n due_date: string;\n tax_rate: string;\n is_admin_reviewed: IntBool;\n customer_id: UUID;\n company_id: number;\n short_invoice_id: string;\n invoice_date: string;\n invoice_status: InvoiceStatus;\n occurred_at_ms: string;\n cai: string | null;\n invoice_number_start_range: string | null;\n invoice_number_end_range: string | null;\n issuance_date: string | null;\n issuance_deadline: string | null;\n};\n\nexport type InvoiceSnapshotMobile = InvoiceSnapshot & {\n signature: string | null;\n};\n","import * as InvoiceItemsTypes from \"./invoice_items_types\";\n\nexport function mapInvoiceProducts(\n row: InvoiceItemsTypes.InvoiceItemResponse\n): InvoiceItemsTypes.MappedInvoiceItem {\n return {\n invoice_item_id: row.invoice_item_id,\n product_id: row.product_id,\n quantity: Number(row.quantity),\n price: Number(row.price),\n amount: Number(row.amount),\n credit_type: row.credit_type ?? undefined,\n product_name: row.product_name,\n product_description: row.product_description ?? undefined,\n product_type: row.product_type,\n weight_unit: row.weight_unit ?? undefined,\n product_upc: row.product_upc ?? undefined,\n rule_name: row.rule_name ?? undefined,\n tax_percentage:\n row.tax_percentage === null ? undefined : Number(row.tax_percentage),\n };\n}\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../utils/utils\";\n\nexport const CreditApplicationSchema = z.strictObject({\n credit_invoice_id: z.uuid({ error: \"Select a credit\" }),\n applied_amount: GlobalUtils.handleZodCurrency(0.01, 999_999.99),\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","import { IntBool, UUID } from \"../../types/shared_types\";\n\nexport 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\nexport type PaymentStatus = \"finalized\" | \"voided\";\n\nexport type PaymentSnapshot = {\n payment_id: UUID;\n invoice_id: UUID;\n payment_amount: string;\n payment_date: string;\n payment_method: PaymentMethod;\n check_number: string | null;\n is_admin_reviewed: IntBool;\n company_id: number;\n short_invoice_id: string;\n payment_status: PaymentStatus;\n occurred_at_ms: string;\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","// \"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","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../utils/utils\";\nimport { YmdDateSchema } from \"../invoices/invoices_schemas\";\nimport { POS_INVOICE_TYPE } from \"./point_of_sales_types\";\nimport { SchemaT } from \"../invoices/invoices_types\";\n\nexport function makePosSchemas(t: SchemaT) {\n const HN_INVOICE_REGEX = /^\\d{3}-\\d{3}-\\d{2}-\\d{8}$/;\n\n const InvoiceNumberSchema = z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .string()\n .min(19, t(\"must_be_in_format\"))\n .max(19, t(\"must_be_in_format\"))\n .regex(HN_INVOICE_REGEX, {\n error: t(\"must_be_in_format\"),\n }),\n );\n\n const PointOfSalesSchema = z\n .strictObject({\n cai: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(z.string().min(1, t(\"cai_is_required\")).max(50, t(\"cai_max\"))),\n\n pos_invoice_type: z.enum(POS_INVOICE_TYPE, t(\"select_invoice_type\")),\n\n invoice_number_start_range: InvoiceNumberSchema,\n invoice_number_end_range: InvoiceNumberSchema,\n next_invoice_number: InvoiceNumberSchema,\n\n issuance_date: YmdDateSchema,\n issuance_deadline: YmdDateSchema,\n })\n .superRefine(\n (\n {\n issuance_date,\n issuance_deadline,\n invoice_number_start_range: start,\n invoice_number_end_range: end,\n next_invoice_number: next,\n },\n\n ctx,\n ) => {\n if (issuance_deadline < issuance_date) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"issuance_deadline\"),\n path: [\"issuance_deadline\"],\n });\n }\n\n const prefix = (s: string) => s.slice(0, 10); // \"NNN-NNN-NN\"\n\n if (prefix(start) !== prefix(end)) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"start_end_numbers\"),\n path: [\"invoice_number_end_range\"],\n });\n }\n\n if (prefix(start) !== prefix(next)) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"start_next_numbers\"),\n path: [\"next_invoice_number\"],\n });\n }\n\n if (!(next >= start && next <= end)) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"next_invoice_number\"),\n path: [\"next_invoice_number\"],\n });\n }\n\n if (end < start) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"end_invoice_number\"),\n path: [\"invoice_number_end_range\"],\n });\n }\n },\n );\n\n return {\n PointOfSalesSchema,\n };\n}\n","export type MappedPointOfSales = {\n point_of_sales_id: number;\n cai: string;\n pos_invoice_type: PosInvoiceType;\n invoice_number_start_range: string;\n invoice_number_end_range: string;\n next_invoice_number: string;\n issuance_date: string;\n issuance_deadline: string;\n};\n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C,YAAI,SAAS;AAAA,UACX,MAAM;AAAA,UACN,SAAS,EAAE,qBAAqB;AAAA,UAChC,MAAM,CAAC,qBAAqB;AAAA,QAC9B,CAAC;AAAA,MACH;AAEA,UAAI,MAAM,OAAO;AACf,YAAI,SAAS;AAAA,UACX,MAAM;AAAA,UACN,SAAS,EAAE,oBAAoB;AAAA,UAC/B,MAAM,CAAC,0BAA0B;AAAA,QACnC,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":["fromString","fromNumber","z","z","z","z","z","z","z","z","z","z","z","z","YmdDateSchema","z","z","z","z","z","z"]}
1
+ {"version":3,"sources":["../src/types/money_types.ts","../src/utils/utils.ts","../src/types/shared_types.ts","../src/domains/auth/login/login_schemas.ts","../src/domains/companies/companies_schemas.ts","../src/domains/companies/companies_types.ts","../src/domains/customers/customer_schemas.ts","../src/domains/products/product_schemas.ts","../src/domains/invoices/invoices_schemas.ts","../src/domains/invoices/invoices_types.ts","../src/domains/invoice_items/invoice_items_mappers.ts","../src/domains/credit_applications/credit_applications_schemas.ts","../src/domains/payments/payments_schemas.ts","../src/domains/payments/payments_types.ts","../src/utils/money_utils.ts","../src/utils/date_utils.ts","../src/utils/errors_utils.ts","../src/domains/point_of_sales/point_of_sales_schemas.ts","../src/domains/point_of_sales/point_of_sales_types.ts"],"sourcesContent":["import { IsoCountryCode } from \"../domains/companies/companies_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 \"../domains/companies/companies_types\";\nimport {\n IsoCurrencyCode,\n countryToCurrency,\n currencyToLocale,\n} from \"../types/money_types\";\n\nimport { z } from \"zod\";\nimport { SchemaT } from \"../domains/invoices/invoices_types\";\n\n/**\n * Validates zod currency with precision.\n *\n *\n * @param minAmount\n * @param maxAmount\n * @returns\n */\nexport function handleZodCurrency(\n minAmount: number,\n maxAmount: number,\n t?: SchemaT,\n) {\n if (!t) {\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 at least ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `Exceeds allowed limit ${maxAmount}`,\n });\n }\n\n const fromString = z\n .string({\n error: t(\"enter_a_valid_number\"),\n })\n .refine((s) => s.trim().length > 0, {\n error: t(\"enter_a_valid_number\"),\n })\n .transform((s) => s.replace(/[,\\s]/g, \"\"))\n .refine((s) => s !== \"\" && !Number.isNaN(Number(s)), {\n error: t(\"enter_a_valid_number\"),\n })\n .refine((s) => Number.isFinite(Number(s)), {\n error: t(\"enter_a_valid_number\"),\n })\n .refine((s) => Number(s) >= 0, {\n error: t(\"enter_a_positive_number\"),\n })\n .transform((s) => Number(s));\n\n const fromNumber = z\n .number()\n .refine((n) => Number.isFinite(n), {\n error: t(\"enter_a_valid_number\"),\n })\n .refine((n) => n >= 0, {\n error: t(\"enter_a_positive_number\"),\n });\n\n return z\n .union([fromString, fromNumber])\n .transform((n) => roundWithPrecision(n, 2))\n .refine((n) => n >= minAmount, {\n error: `${t(\"must_be_at_least\")} ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `${t(\"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\";\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\nexport type status = \"active\" | \"inactive\";\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../../utils/utils\";\n\nexport const LoginFormSchema = z.strictObject({\n user_email: z\n .string({ error: \"Email required\" })\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({ error: \"Password required\" })\n .min(1, { error: \"Password required\" }),\n});\n","import { z } from \"zod\";\nimport { COMPANY_LANGUAGES, ISO_COUNTRY_CODES } from \"./companies_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\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({ error: \"Please select a country.\" })\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\nexport const CompanyFormSchema =\n RegisterFormSchema.shape.companyData.safeExtend({\n company_email: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .email(\"Invalid company email.\")\n .max(254, \"Company email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n ),\n rtn: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(z.string().max(100, \"RTN must be at most 100 characters.\"))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n web_language: z.enum(COMPANY_LANGUAGES, {\n error: \"Please select a web portal language.\",\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\nexport type CompanySnapshot = {\n company_id: number;\n company_name: string;\n company_address: string;\n company_phone_number: string;\n company_email: string;\n inventory_system: InventorySystem;\n iso_country_code: IsoCountryCode;\n rtn: string | null;\n};\n\nexport const COMPANY_LANGUAGES = [\"es\", \"en\"] as const;\n\nexport type CompanyLanguages = (typeof COMPANY_LANGUAGES)[number];\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../utils/utils\";\nimport { SchemaT } from \"../invoices/invoices_types\";\n\nexport function makeCustomerSchemas(t: SchemaT) {\n const CustomerFormSchema = z.strictObject({\n customer_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, t(\"customer_name_required\"))\n .max(50, t(\"customer_name_max\")),\n ),\n\n customer_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(z.string().max(100, t(\"customer_address_max\")))\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: t(\"customer_phone_number\"),\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, t(\"customer_email_max\"))\n .transform((email) => email.toLowerCase())\n .optional(),\n )\n .optional(),\n });\n\n return { CustomerFormSchema };\n}\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../utils/utils\";\nimport { SchemaT } from \"../invoices/invoices_types\";\n\nexport function makeProductSchemas(t: SchemaT) {\n const ProductFormSchema = z\n .strictObject({\n product_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, t(\"product_name_required\"))\n .max(50, t(\"product_name_max\")),\n ),\n\n product_description: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(z.string().max(100, t(\"product_descr_max\")))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_sku: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(z.string().max(30, t(\"product_sku_max\")))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_upc: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .refine((s) => s === \"\" || /^\\d{12}$/.test(s), {\n error: t(\"product_upc_test\"),\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n country_tax_rule_id: z.number().optional(),\n\n product_gtin_14: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\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: t(\"product_type_validation\"),\n }),\n\n weight_unit: z.preprocess(\n (v) => {\n if (v === \"\") return undefined;\n if (typeof v === \"string\") return v.trim().toLowerCase();\n return v;\n },\n z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional(),\n ),\n\n price: GlobalUtils.handleZodCurrency(0, 99_999.99, t),\n cost: GlobalUtils.handleZodCurrency(0, 99_999.99, t),\n })\n\n .superRefine((data, ctx) => {\n if (data.product_type === \"weight\" && !data.weight_unit) {\n ctx.addIssue({\n code: \"custom\",\n error: t(\"weight_unit_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: t(\"weight_unit_empty\"),\n path: [\"weight_unit\"],\n });\n }\n });\n\n return { ProductFormSchema };\n}\n","import { z } from \"zod\";\nimport {\n CREDIT_TYPE,\n INVOICE_STATUS,\n INVOICE_TYPE,\n SchemaT,\n} from \"./invoices_types\";\nimport { handleZodCurrency } from \"../../utils/utils\";\n\nexport const YmdDateSchema = z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\n///////////////////////////////////////////////////////////////////////\n//English / Spanish implementation\n\nexport function makeInvoiceSchemas(t: SchemaT) {\n const YmdDateSchema = z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\n const BaseInvoice = z\n .object({\n invoice_type: z.enum(INVOICE_TYPE, {\n error: t(\"invoice_type_not_found\"),\n }),\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\n const LineItemBase = z.object({\n invoice_id: z.uuid().optional(),\n product_id: z.uuid({\n error: t(\"select_product\"),\n }),\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, t),\n country_tax_rule_id: z.number().optional(),\n tax_percentage: z.number().optional(),\n });\n\n const SalesItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99, t),\n credit_type: z.undefined(),\n });\n\n const CreditItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99, t),\n credit_type: z.enum(CREDIT_TYPE, {\n error: t(\"select_credit_type\"),\n }),\n });\n\n const PurchaseItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99, t),\n credit_type: z.undefined(),\n });\n\n const SalesInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"sales\"),\n party_id: z.uuid({\n error: t(\"select_customer\"),\n }),\n invoice_items: z.array(SalesItem).min(1, t(\"add_one_invoice_item\")),\n });\n\n const CreditInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"credit\"),\n party_id: z.uuid({\n error: t(\"select_customer\"),\n }),\n invoice_items: z.array(CreditItem).min(1, t(\"add_one_invoice_item\")),\n });\n\n const PurchaseInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"purchase\"),\n party_id: z.uuid({\n error: t(\"select_vendor\"),\n }),\n invoice_items: z.array(PurchaseItem).min(1, t(\"add_one_invoice_item\")),\n });\n\n const AnyInvoiceSchema = z.discriminatedUnion(\"invoice_type\", [\n SalesInvoiceSchema,\n PurchaseInvoiceSchema,\n CreditInvoiceSchema,\n ]);\n\n return {\n YmdDateSchema,\n SalesInvoiceSchema,\n CreditInvoiceSchema,\n PurchaseInvoiceSchema,\n AnyInvoiceSchema,\n };\n}\n\nexport type InvoiceSchemas = ReturnType<typeof makeInvoiceSchemas>;\n","import { z } from \"zod\";\nimport * as InvoiceSchemas from \"./invoices_schemas\";\nimport { IntBool, UUID } from \"../../types/shared_types\";\n\nexport type SchemaT = (key: string, params?: Record<string, any>) => string;\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\nexport type InvoiceSchemaSet = ReturnType<\n typeof InvoiceSchemas.makeInvoiceSchemas\n>;\nexport type AnyInvoiceOut = z.output<InvoiceSchemaSet[\"AnyInvoiceSchema\"]>;\n\nexport type InvoiceSnapshot = {\n invoice_id: UUID;\n invoice_type: InvoiceType;\n subtotal: string;\n tax_amount: string;\n total_amount: string;\n remaining_balance: string;\n due_date: string;\n tax_rate: string;\n is_admin_reviewed: IntBool;\n customer_id: UUID;\n company_id: number;\n short_invoice_id: string;\n invoice_date: string;\n invoice_status: InvoiceStatus;\n occurred_at_ms: string;\n cai: string | null;\n invoice_number_start_range: string | null;\n invoice_number_end_range: string | null;\n issuance_date: string | null;\n issuance_deadline: string | null;\n};\n\nexport type InvoiceSnapshotMobile = InvoiceSnapshot & {\n signature: string | null;\n};\n","import * as InvoiceItemsTypes from \"./invoice_items_types\";\n\nexport function mapInvoiceProducts(\n row: InvoiceItemsTypes.InvoiceItemResponse\n): InvoiceItemsTypes.MappedInvoiceItem {\n return {\n invoice_item_id: row.invoice_item_id,\n product_id: row.product_id,\n quantity: Number(row.quantity),\n price: Number(row.price),\n amount: Number(row.amount),\n credit_type: row.credit_type ?? undefined,\n product_name: row.product_name,\n product_description: row.product_description ?? undefined,\n product_type: row.product_type,\n weight_unit: row.weight_unit ?? undefined,\n product_upc: row.product_upc ?? undefined,\n rule_name: row.rule_name ?? undefined,\n tax_percentage:\n row.tax_percentage === null ? undefined : Number(row.tax_percentage),\n };\n}\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../utils/utils\";\n\nexport const CreditApplicationSchema = z.strictObject({\n credit_invoice_id: z.uuid({ error: \"Select a credit\" }),\n applied_amount: GlobalUtils.handleZodCurrency(0.01, 999_999.99),\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","import { IntBool, UUID } from \"../../types/shared_types\";\n\nexport 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\nexport type PaymentStatus = \"finalized\" | \"voided\";\n\nexport type PaymentSnapshot = {\n payment_id: UUID;\n invoice_id: UUID;\n payment_amount: string;\n payment_date: string;\n payment_method: PaymentMethod;\n check_number: string | null;\n is_admin_reviewed: IntBool;\n company_id: number;\n short_invoice_id: string;\n payment_status: PaymentStatus;\n occurred_at_ms: string;\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","// \"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","import { z } from \"zod\";\nimport * as GlobalUtils from \"../../utils/utils\";\nimport { YmdDateSchema } from \"../invoices/invoices_schemas\";\nimport { POS_INVOICE_TYPE } from \"./point_of_sales_types\";\nimport { SchemaT } from \"../invoices/invoices_types\";\n\nexport function makePosSchemas(t: SchemaT) {\n const HN_INVOICE_REGEX = /^\\d{3}-\\d{3}-\\d{2}-\\d{8}$/;\n\n const InvoiceNumberSchema = z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .string()\n .min(19, t(\"must_be_in_format\"))\n .max(19, t(\"must_be_in_format\"))\n .regex(HN_INVOICE_REGEX, {\n error: t(\"must_be_in_format\"),\n }),\n );\n\n const PointOfSalesSchema = z\n .strictObject({\n cai: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(z.string().min(1, t(\"cai_is_required\")).max(50, t(\"cai_max\"))),\n\n pos_invoice_type: z.enum(POS_INVOICE_TYPE, t(\"select_invoice_type\")),\n\n invoice_number_start_range: InvoiceNumberSchema,\n invoice_number_end_range: InvoiceNumberSchema,\n next_invoice_number: InvoiceNumberSchema,\n\n issuance_date: YmdDateSchema,\n issuance_deadline: YmdDateSchema,\n })\n .superRefine(\n (\n {\n issuance_date,\n issuance_deadline,\n invoice_number_start_range: start,\n invoice_number_end_range: end,\n next_invoice_number: next,\n },\n\n ctx,\n ) => {\n if (issuance_deadline < issuance_date) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"issuance_deadline\"),\n path: [\"issuance_deadline\"],\n });\n }\n\n const prefix = (s: string) => s.slice(0, 10); // \"NNN-NNN-NN\"\n\n if (prefix(start) !== prefix(end)) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"start_end_numbers\"),\n path: [\"invoice_number_end_range\"],\n });\n }\n\n if (prefix(start) !== prefix(next)) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"start_next_numbers\"),\n path: [\"next_invoice_number\"],\n });\n }\n\n if (!(next >= start && next <= end)) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"next_invoice_number\"),\n path: [\"next_invoice_number\"],\n });\n }\n\n if (end < start) {\n ctx.addIssue({\n code: \"custom\",\n message: t(\"end_invoice_number\"),\n path: [\"invoice_number_end_range\"],\n });\n }\n },\n );\n\n return {\n PointOfSalesSchema,\n };\n}\n","export type MappedPointOfSales = {\n point_of_sales_id: number;\n cai: string;\n pos_invoice_type: PosInvoiceType;\n invoice_number_start_range: string;\n invoice_number_end_range: string;\n next_invoice_number: string;\n issuance_date: string;\n issuance_deadline: string;\n};\n\nexport const PO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UACN,SAAS,EAAE,mBAAmB;AAAA,UAC9B,MAAM,CAAC,0BAA0B;AAAA,QACnC,CAAC;AAAA,MACH;AAEA,UAAI,OAAO,KAAK,MAAM,OAAO,IAAI,GAAG;AAClC,YAAI,SAAS;AAAA,UACX,MAAM;AAAA,UACN,SAAS,EAAE,oBAAoB;AAAA,UAC/B,MAAM,CAAC,qBAAqB;AAAA,QAC9B,CAAC;AAAA,MACH;AAEA,UAAI,EAAE,QAAQ,SAAS,QAAQ,MAAM;AACnC,YAAI,SAAS;AAAA,UACX,MAAM;AAAA,UACN,SAAS,EAAE,qBAAqB;AAAA,UAChC,MAAM,CAAC,qBAAqB;AAAA,QAC9B,CAAC;AAAA,MACH;AAEA,UAAI,MAAM,OAAO;AACf,YAAI,SAAS;AAAA,UACX,MAAM;AAAA,UACN,SAAS,EAAE,oBAAoB;AAAA,UAC/B,MAAM,CAAC,0BAA0B;AAAA,QACnC,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":["fromString","fromNumber","z","z","z","z","z","z","z","z","z","z","z","z","YmdDateSchema","z","z","z","z","z","z"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marmot-systems/common",
3
- "version": "2.0.84",
3
+ "version": "2.0.86",
4
4
  "description": "Schemas and utils shared across Marmot apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",