@jsdev_ninja/core 0.14.7 → 0.14.9

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/core.es.js CHANGED
@@ -2978,14 +2978,14 @@ const Se = s.object({
2978
2978
  floor: s.string().optional(),
2979
2979
  apartmentEnterNumber: s.string().optional(),
2980
2980
  apartmentNumber: s.string().optional()
2981
- }), R = s.string().min(1, { message: "שדה חובה" }), Rn = s.string().regex(/^\d+$/, "Must be a numeric string"), $n = s.object({ url: s.string().url(), id: s.string() });
2982
- function Mn(n) {
2981
+ }), R = s.string().min(1, { message: "שדה חובה" }), Mn = s.string().regex(/^\d+$/, "Must be a numeric string"), Vn = s.object({ url: s.string().url(), id: s.string() });
2982
+ function zn(n) {
2983
2983
  return !!(n != null && n.url);
2984
2984
  }
2985
2985
  const ne = s.object({
2986
2986
  lang: s.enum(["he"]),
2987
2987
  value: s.string()
2988
- }), Vn = s.array(ne), Je = s.object({
2988
+ }), Fn = s.array(ne), Je = s.object({
2989
2989
  id: s.string().min(1),
2990
2990
  companyId: s.string().min(1),
2991
2991
  storeId: s.string().min(1),
@@ -2995,7 +2995,7 @@ const ne = s.object({
2995
2995
  depth: s.number()
2996
2996
  }), Ee = Je.extend({
2997
2997
  children: s.lazy(() => Ee.array())
2998
- }), zn = Je.extend({
2998
+ }), Un = Je.extend({
2999
2999
  index: s.number(),
3000
3000
  depth: s.number(),
3001
3001
  collapsed: s.boolean().optional(),
@@ -3057,7 +3057,7 @@ const ne = s.object({
3057
3057
  }).optional(),
3058
3058
  // @deprecated
3059
3059
  categoryNames: s.array(s.string()).optional()
3060
- }), Fn = He.extend({
3060
+ }), Ln = He.extend({
3061
3061
  image: s.instanceof(File).optional()
3062
3062
  }), Ke = s.object({
3063
3063
  product: He,
@@ -3065,7 +3065,7 @@ const ne = s.object({
3065
3065
  finalPrice: s.number().optional(),
3066
3066
  finalDiscount: s.number().optional(),
3067
3067
  amount: s.number().positive({ message: "Quantity must be a positive number." })
3068
- }), Un = s.object({
3068
+ }), qn = s.object({
3069
3069
  type: s.literal("Cart"),
3070
3070
  id: s.string().uuid(),
3071
3071
  companyId: s.string().uuid(),
@@ -3073,11 +3073,11 @@ const ne = s.object({
3073
3073
  userId: s.string().uuid(),
3074
3074
  status: s.enum(["active", "draft", "completed"]),
3075
3075
  items: s.array(Ke)
3076
- }), Ln = s.object({
3076
+ }), Bn = s.object({
3077
3077
  id: s.string(),
3078
3078
  name: s.string(),
3079
3079
  websiteDomains: s.array(s.string())
3080
- }), qn = s.object({
3080
+ }), Wn = s.object({
3081
3081
  type: s.literal("FavoriteProduct"),
3082
3082
  id: s.string().uuid(),
3083
3083
  companyId: s.string().uuid(),
@@ -3169,7 +3169,7 @@ const ne = s.object({
3169
3169
  companyNumber: s.string().optional(),
3170
3170
  address: Se.optional(),
3171
3171
  groupId: s.string().optional()
3172
- }), Bn = xn.omit({ id: !0 }), kn = s.object({
3172
+ }), Qn = xn.omit({ id: !0 }), kn = s.object({
3173
3173
  doc_uuid: s.string().uuid("Document UUID must be a valid UUID"),
3174
3174
  pdf_link: s.string().url("PDF link must be a valid URL"),
3175
3175
  pdf_link_copy: s.string().url("PDF copy link must be a valid URL"),
@@ -3209,7 +3209,7 @@ const ne = s.object({
3209
3209
  total: s.number().min(1, "Total is required").optional(),
3210
3210
  vat: s.number().min(1, "VAT is required").optional(),
3211
3211
  link: s.string().url("Link must be a valid URL").optional()
3212
- }), Wn = s.object({
3212
+ }), Yn = s.object({
3213
3213
  type: s.literal("Order"),
3214
3214
  createdBy: s.enum(["user", "admin"]).optional(),
3215
3215
  id: R,
@@ -3265,7 +3265,7 @@ const ne = s.object({
3265
3265
  invoice: wn.optional(),
3266
3266
  ezInvoice: kn.optional(),
3267
3267
  ezDeliveryNote: _n.optional()
3268
- }), Tn = s.enum(["individual", "company"]), Qn = s.object({
3268
+ }), Tn = s.enum(["individual", "company"]), Xn = s.object({
3269
3269
  id: s.string(),
3270
3270
  companyId: s.string(),
3271
3271
  name: s.string(),
@@ -3296,7 +3296,7 @@ const ne = s.object({
3296
3296
  bundlePrice: s.number().positive()
3297
3297
  // Total price for the bundle (e.g., $25)
3298
3298
  })
3299
- ]), Yn = s.object({
3299
+ ]), Gn = s.object({
3300
3300
  type: s.literal("Discount"),
3301
3301
  storeId: s.string().min(1),
3302
3302
  companyId: s.string().min(1),
@@ -3378,7 +3378,7 @@ class nt {
3378
3378
  Re(nt, "strategies", /* @__PURE__ */ new Map([
3379
3379
  ["bundle", new Nn()]
3380
3380
  ]));
3381
- class Xn {
3381
+ class Jn {
3382
3382
  static calculateDiscounts(e, t, r) {
3383
3383
  var d, f;
3384
3384
  const a = {
@@ -3444,13 +3444,13 @@ class Xn {
3444
3444
  function rt(n) {
3445
3445
  return Number(n.toFixed(2));
3446
3446
  }
3447
- function Gn(n) {
3447
+ function Hn(n) {
3448
3448
  return n.toFixed(2);
3449
3449
  }
3450
- function Jn(n) {
3450
+ function Kn(n) {
3451
3451
  return Math.max(0, rt(n));
3452
3452
  }
3453
- function Hn(n, e) {
3453
+ function er(n, e) {
3454
3454
  if (n <= 0) return 0;
3455
3455
  const t = n - e;
3456
3456
  return rt(t / n * 100);
@@ -3458,13 +3458,13 @@ function Hn(n, e) {
3458
3458
  const An = s.object({
3459
3459
  id: s.string(),
3460
3460
  name: s.string()
3461
- }), Kn = An.omit({ id: !0 }), st = s.object({
3461
+ }), tr = An.omit({ id: !0 }), st = s.object({
3462
3462
  type: s.literal("Supplier"),
3463
3463
  id: s.string(),
3464
3464
  name: s.string(),
3465
3465
  code: s.string()
3466
3466
  // supplier code number
3467
- }), er = st.omit({ id: !0 }), Cn = s.object({
3467
+ }), nr = st.omit({ id: !0 }), Cn = s.object({
3468
3468
  type: s.literal("SupplierInvoice"),
3469
3469
  id: s.string(),
3470
3470
  supplier: st,
@@ -3505,7 +3505,7 @@ const An = s.object({
3505
3505
  total: s.number().optional(),
3506
3506
  totalBeforeVat: s.number().optional(),
3507
3507
  vat: s.number().optional()
3508
- }), tr = Cn.omit({ id: !0 }), nr = s.object({
3508
+ }), rr = Cn.omit({ id: !0 }), sr = s.object({
3509
3509
  type: s.literal("ChatSession"),
3510
3510
  id: s.string(),
3511
3511
  storeId: s.string(),
@@ -3517,7 +3517,7 @@ const An = s.object({
3517
3517
  updatedAt: s.number(),
3518
3518
  messageCount: s.number(),
3519
3519
  status: s.enum(["active", "archived"])
3520
- }), rr = s.discriminatedUnion("type", [
3520
+ }), ar = s.discriminatedUnion("type", [
3521
3521
  s.object({
3522
3522
  type: s.literal("message"),
3523
3523
  id: s.string(),
@@ -3539,14 +3539,66 @@ const An = s.object({
3539
3539
  result: s.any(),
3540
3540
  timestamp: s.number()
3541
3541
  })
3542
- ]), De = {
3542
+ ]), jn = s.enum([
3543
+ "delivery_note",
3544
+ "payment_received",
3545
+ "credit_note",
3546
+ "debit_note",
3547
+ "order_created",
3548
+ // legacy — no longer used for new transactions
3549
+ "order_cancelled",
3550
+ // legacy
3551
+ "order_refunded"
3552
+ // legacy
3553
+ ]), Zn = s.enum(["check", "bank_transfer", "cash", "credit_card", "other"]), ir = s.object({
3554
+ id: s.string(),
3555
+ type: jn,
3556
+ // positive = debt added (delivery note / debit note), negative = debt reduced (payment / credit)
3557
+ debt: s.number(),
3558
+ runningBalance: s.number(),
3559
+ // order reference
3560
+ orderId: s.string().nullable(),
3561
+ orderTotal: s.number().nullable(),
3562
+ // delivery note reference (for delivery_note type)
3563
+ deliveryNoteId: s.string().nullable(),
3564
+ deliveryNoteNumber: s.string().nullable(),
3565
+ // billing account snapshot (if order had one)
3566
+ billingAccountId: s.string().nullable(),
3567
+ billingAccountName: s.string().nullable(),
3568
+ billingAccountNumber: s.string().nullable(),
3569
+ // payment details (for payment_received type — entered by admin)
3570
+ paymentReference: s.string().nullable(),
3571
+ // check number, bank transfer ref, etc.
3572
+ paymentDate: s.number().nullable(),
3573
+ // timestamp
3574
+ paymentMethod: Zn.nullable(),
3575
+ note: s.string().nullable(),
3576
+ createdAt: s.number(),
3577
+ createdBy: s.string()
3578
+ // userId or "system"
3579
+ }), or = s.object({
3580
+ id: s.string(),
3581
+ // organizationId
3582
+ organizationId: s.string(),
3583
+ organizationName: s.string(),
3584
+ companyId: s.string(),
3585
+ storeId: s.string(),
3586
+ totalDebits: s.number(),
3587
+ // sum of delivery note amounts
3588
+ totalCredits: s.number(),
3589
+ // sum of payments received
3590
+ balance: s.number(),
3591
+ // totalDebits - totalCredits (positive = owes money)
3592
+ currency: s.literal("ILS"),
3593
+ updatedAt: s.number()
3594
+ }), De = {
3543
3595
  VAT: 18
3544
3596
  };
3545
- function jn(n, e) {
3597
+ function On(n, e) {
3546
3598
  var t, r;
3547
3599
  return ((t = n.discount) == null ? void 0 : t.type) === "percent" ? n.price * (n.discount.value ?? 100) / 100 : ((r = n.discount) == null ? void 0 : r.type) === "number" ? n.discount.value ?? 0 : 0;
3548
3600
  }
3549
- function Zn(n, e) {
3601
+ function Dn(n, e) {
3550
3602
  var r, a;
3551
3603
  const t = e && n.vat ? n.price + n.price * De.VAT / 100 : n.price;
3552
3604
  if (((r = n.discount) == null ? void 0 : r.type) === "percent") {
@@ -3555,7 +3607,7 @@ function Zn(n, e) {
3555
3607
  }
3556
3608
  return ((a = n.discount) == null ? void 0 : a.type) === "number" ? t - n.discount.value : t;
3557
3609
  }
3558
- function sr({
3610
+ function cr({
3559
3611
  cart: n,
3560
3612
  discounts: e,
3561
3613
  deliveryPrice: t = 0,
@@ -3566,8 +3618,8 @@ function sr({
3566
3618
  amount: o.amount,
3567
3619
  product: { ...o.product },
3568
3620
  originalPrice: o.product.price,
3569
- finalPrice: Zn(o.product, a),
3570
- finalDiscount: jn(o.product)
3621
+ finalPrice: Dn(o.product, a),
3622
+ finalDiscount: On(o.product)
3571
3623
  })), c = i.reduce(
3572
3624
  (o, l) => {
3573
3625
  const { product: d, amount: f, finalPrice: x, finalDiscount: T } = l;
@@ -3595,10 +3647,10 @@ function sr({
3595
3647
  );
3596
3648
  return c.deliveryPrice && c.productsCost >= r ? c.deliveryPrice = 0 : c.finalCost += c.deliveryPrice, { items: i, ...c };
3597
3649
  }
3598
- const On = {
3650
+ const Pn = {
3599
3651
  stores: "STORES",
3600
3652
  companies: "COMPANIES"
3601
- }, Dn = {
3653
+ }, En = {
3602
3654
  products: "products",
3603
3655
  "favorite-products": "favorite-products",
3604
3656
  profiles: "profiles",
@@ -3617,10 +3669,12 @@ const On = {
3617
3669
  supplierInvoices: "supplierInvoices",
3618
3670
  chatSessions: "chatSessions",
3619
3671
  chatSessionMessages: "chatSessionMessages",
3620
- contactSubmissions: "contactSubmissions"
3621
- }, Pn = {
3622
- systemCollections: On,
3623
- storeCollections: Dn,
3672
+ contactSubmissions: "contactSubmissions",
3673
+ budgetAccounts: "budgetAccounts",
3674
+ budgetTransactions: "budgetTransactions"
3675
+ }, Rn = {
3676
+ systemCollections: Pn,
3677
+ storeCollections: En,
3624
3678
  // for client and server
3625
3679
  getPath: ({
3626
3680
  companyId: n,
@@ -3639,14 +3693,14 @@ const On = {
3639
3693
  // for firestore events
3640
3694
  getDocPath: (n) => `{companyId}/{storeId}/${n}/{id}`,
3641
3695
  getSubDocPath: (n, e, t) => `{companyId}/{storeId}/${n}/${e}/${t}/{id}`
3642
- }, ar = {
3643
- firestore: Pn
3696
+ }, ur = {
3697
+ firestore: Rn
3644
3698
  }, ze = {
3645
3699
  round: (n, e = 2) => {
3646
3700
  const t = 10 ** e;
3647
3701
  return Math.round((n + Number.EPSILON) * t) / t;
3648
3702
  }
3649
- }, ir = {
3703
+ }, dr = {
3650
3704
  calcSalePriceFromMargin: (n, e) => n <= 0 || e <= 0 || n >= 100 ? e : ze.round(e / (1 - n / 100)),
3651
3705
  calcMarginFromSalePrice: (n, e) => n <= 0 || e <= 0 ? 0 : ze.round((n - e) / n * 100)
3652
3706
  };
@@ -3654,51 +3708,55 @@ export {
3654
3708
  Se as AddressSchema,
3655
3709
  Je as BaseCategorySchema,
3656
3710
  tt as BillingAccountSchema,
3711
+ or as BudgetAccountSchema,
3712
+ ir as BudgetTransactionSchema,
3713
+ jn as BudgetTransactionTypeSchema,
3657
3714
  Nn as BundleDiscountStrategy,
3658
3715
  et as CalculatedDataSchema,
3659
3716
  Ke as CartItemProductSchema,
3660
- Un as CartSchema,
3717
+ qn as CartSchema,
3661
3718
  Ee as CategorySchema,
3662
- rr as ChatSessionMessageSchema,
3663
- nr as ChatSessionSchema,
3664
- Ln as CompanySchema,
3719
+ ar as ChatSessionMessageSchema,
3720
+ sr as ChatSessionSchema,
3721
+ Bn as CompanySchema,
3665
3722
  bn as DeliveryNoteSchema,
3666
3723
  Sn as DiscountConditionsSchema,
3667
- Xn as DiscountEngine,
3668
- Yn as DiscountSchema,
3724
+ Jn as DiscountEngine,
3725
+ Gn as DiscountSchema,
3669
3726
  nt as DiscountStrategyFactory,
3670
3727
  In as DiscountVariantSchema,
3671
3728
  _n as EzDeliveryNoteSchema,
3672
- qn as FavoriteProductSchema,
3673
- $n as FileSchema,
3674
- ar as FirebaseAPI,
3729
+ Wn as FavoriteProductSchema,
3730
+ Vn as FileSchema,
3731
+ ur as FirebaseAPI,
3675
3732
  ne as LocaleSchema,
3676
- Vn as LocaleValueSchema,
3677
- Kn as NewOrganizationGroupSchema,
3678
- Bn as NewOrganizationSchema,
3679
- Fn as NewProductSchema,
3680
- tr as NewSupplierInvoiceSchema,
3681
- er as NewSupplierSchema,
3682
- Wn as OrderSchema,
3733
+ Fn as LocaleValueSchema,
3734
+ tr as NewOrganizationGroupSchema,
3735
+ Qn as NewOrganizationSchema,
3736
+ Ln as NewProductSchema,
3737
+ rr as NewSupplierInvoiceSchema,
3738
+ nr as NewSupplierSchema,
3739
+ Yn as OrderSchema,
3683
3740
  An as OrganizationGroupSchema,
3684
3741
  xn as OrganizationSchema,
3742
+ Zn as PaymentMethodSchema,
3685
3743
  Ie as PaymentTypeSchema,
3686
3744
  He as ProductSchema,
3687
3745
  vn as ProfileSchema,
3688
- Qn as StoreSchema,
3746
+ Xn as StoreSchema,
3689
3747
  Cn as SupplierInvoiceSchema,
3690
3748
  st as SupplierSchema,
3691
- zn as TFlattenCategorySchema,
3692
- Hn as calculatePercentageDiscount,
3749
+ Un as TFlattenCategorySchema,
3750
+ er as calculatePercentageDiscount,
3693
3751
  Tn as clientTypesSchema,
3694
- Jn as ensureNonNegative,
3752
+ Kn as ensureNonNegative,
3695
3753
  rt as formatCurrency,
3696
- Gn as formatCurrencyString,
3697
- sr as getCartCost,
3698
- Mn as isFile,
3754
+ Hn as formatCurrencyString,
3755
+ cr as getCartCost,
3756
+ zn as isFile,
3699
3757
  ze as math,
3700
3758
  R as notEmptyTextSchema,
3701
- Rn as numericTextSchema,
3702
- ir as storeCalculator
3759
+ Mn as numericTextSchema,
3760
+ dr as storeCalculator
3703
3761
  };
3704
3762
  //# sourceMappingURL=core.es.js.map