@jsdev_ninja/core 0.14.6 → 0.14.8

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.
@@ -0,0 +1,91 @@
1
+ import { z } from "zod";
2
+ export declare const BudgetTransactionTypeSchema: z.ZodEnum<["order_created", "payment_received", "order_cancelled", "order_refunded", "credit_note", "debit_note"]>;
3
+ export declare const PaymentMethodSchema: z.ZodEnum<["check", "bank_transfer", "cash", "credit_card", "other"]>;
4
+ export declare const BudgetTransactionSchema: z.ZodObject<{
5
+ id: z.ZodString;
6
+ type: z.ZodEnum<["order_created", "payment_received", "order_cancelled", "order_refunded", "credit_note", "debit_note"]>;
7
+ debt: z.ZodNumber;
8
+ runningBalance: z.ZodNumber;
9
+ orderId: z.ZodNullable<z.ZodString>;
10
+ orderTotal: z.ZodNullable<z.ZodNumber>;
11
+ billingAccountId: z.ZodNullable<z.ZodString>;
12
+ billingAccountName: z.ZodNullable<z.ZodString>;
13
+ billingAccountNumber: z.ZodNullable<z.ZodString>;
14
+ paymentReference: z.ZodNullable<z.ZodString>;
15
+ paymentDate: z.ZodNullable<z.ZodNumber>;
16
+ paymentMethod: z.ZodNullable<z.ZodEnum<["check", "bank_transfer", "cash", "credit_card", "other"]>>;
17
+ note: z.ZodNullable<z.ZodString>;
18
+ createdAt: z.ZodNumber;
19
+ createdBy: z.ZodString;
20
+ }, "strip", z.ZodTypeAny, {
21
+ type: "order_created" | "payment_received" | "order_cancelled" | "order_refunded" | "credit_note" | "debit_note";
22
+ id: string;
23
+ createdAt: number;
24
+ createdBy: string;
25
+ debt: number;
26
+ runningBalance: number;
27
+ orderId: string | null;
28
+ orderTotal: number | null;
29
+ billingAccountId: string | null;
30
+ billingAccountName: string | null;
31
+ billingAccountNumber: string | null;
32
+ paymentReference: string | null;
33
+ paymentDate: number | null;
34
+ paymentMethod: "check" | "bank_transfer" | "cash" | "credit_card" | "other" | null;
35
+ note: string | null;
36
+ }, {
37
+ type: "order_created" | "payment_received" | "order_cancelled" | "order_refunded" | "credit_note" | "debit_note";
38
+ id: string;
39
+ createdAt: number;
40
+ createdBy: string;
41
+ debt: number;
42
+ runningBalance: number;
43
+ orderId: string | null;
44
+ orderTotal: number | null;
45
+ billingAccountId: string | null;
46
+ billingAccountName: string | null;
47
+ billingAccountNumber: string | null;
48
+ paymentReference: string | null;
49
+ paymentDate: number | null;
50
+ paymentMethod: "check" | "bank_transfer" | "cash" | "credit_card" | "other" | null;
51
+ note: string | null;
52
+ }>;
53
+ export declare const BudgetAccountSchema: z.ZodObject<{
54
+ id: z.ZodString;
55
+ organizationId: z.ZodString;
56
+ organizationName: z.ZodString;
57
+ companyId: z.ZodString;
58
+ storeId: z.ZodString;
59
+ totalDebits: z.ZodNumber;
60
+ totalCredits: z.ZodNumber;
61
+ balance: z.ZodNumber;
62
+ currency: z.ZodLiteral<"ILS">;
63
+ updatedAt: z.ZodNumber;
64
+ }, "strip", z.ZodTypeAny, {
65
+ id: string;
66
+ companyId: string;
67
+ storeId: string;
68
+ currency: "ILS";
69
+ organizationId: string;
70
+ updatedAt: number;
71
+ organizationName: string;
72
+ totalDebits: number;
73
+ totalCredits: number;
74
+ balance: number;
75
+ }, {
76
+ id: string;
77
+ companyId: string;
78
+ storeId: string;
79
+ currency: "ILS";
80
+ organizationId: string;
81
+ updatedAt: number;
82
+ organizationName: string;
83
+ totalDebits: number;
84
+ totalCredits: number;
85
+ balance: number;
86
+ }>;
87
+ export type TBudgetTransactionType = z.infer<typeof BudgetTransactionTypeSchema>;
88
+ export type TPaymentMethod = z.infer<typeof PaymentMethodSchema>;
89
+ export type TBudgetTransaction = z.infer<typeof BudgetTransactionSchema>;
90
+ export type TBudgetAccount = z.infer<typeof BudgetAccountSchema>;
91
+ //# sourceMappingURL=Budget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Budget.d.ts","sourceRoot":"","sources":["../../../lib/entities/Budget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,2BAA2B,oHAOtC,CAAC;AAEH,eAAO,MAAM,mBAAmB,uEAAqE,CAAC;AAEtG,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BlC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAa9B,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AACjF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACjE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACzE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+ export const BudgetTransactionTypeSchema = z.enum([
3
+ "order_created",
4
+ "payment_received",
5
+ "order_cancelled",
6
+ "order_refunded",
7
+ "credit_note",
8
+ "debit_note",
9
+ ]);
10
+ export const PaymentMethodSchema = z.enum(["check", "bank_transfer", "cash", "credit_card", "other"]);
11
+ export const BudgetTransactionSchema = z.object({
12
+ id: z.string(),
13
+ type: BudgetTransactionTypeSchema,
14
+ // positive = debt added (order/debit note), negative = debt reduced (payment/cancellation)
15
+ debt: z.number(),
16
+ runningBalance: z.number(),
17
+ // order reference
18
+ orderId: z.string().nullable(),
19
+ orderTotal: z.number().nullable(),
20
+ // billing account snapshot (if order had one)
21
+ billingAccountId: z.string().nullable(),
22
+ billingAccountName: z.string().nullable(),
23
+ billingAccountNumber: z.string().nullable(),
24
+ // payment details (for payment_received type — entered by admin)
25
+ paymentReference: z.string().nullable(), // check number, bank transfer ref, etc.
26
+ paymentDate: z.number().nullable(), // timestamp
27
+ paymentMethod: PaymentMethodSchema.nullable(),
28
+ note: z.string().nullable(),
29
+ createdAt: z.number(),
30
+ createdBy: z.string(), // userId or "system"
31
+ });
32
+ export const BudgetAccountSchema = z.object({
33
+ id: z.string(), // organizationId
34
+ organizationId: z.string(),
35
+ organizationName: z.string(),
36
+ companyId: z.string(),
37
+ storeId: z.string(),
38
+ totalDebits: z.number(), // sum of order amounts
39
+ totalCredits: z.number(), // sum of payments received
40
+ balance: z.number(), // totalDebits - totalCredits (positive = owes money)
41
+ currency: z.literal("ILS"),
42
+ updatedAt: z.number(),
43
+ });
@@ -17,4 +17,5 @@ export * from "./Payment";
17
17
  export * from "./Supplier";
18
18
  export * from "./SupplierInvoice";
19
19
  export * from "./Chatbot";
20
+ export * from "./Budget";
20
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/entities/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/entities/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
@@ -17,3 +17,4 @@ export * from "./Payment";
17
17
  export * from "./Supplier";
18
18
  export * from "./SupplierInvoice";
19
19
  export * from "./Chatbot";
20
+ export * from "./Budget";
@@ -21,6 +21,8 @@ export declare const storeCollections: {
21
21
  readonly chatSessions: "chatSessions";
22
22
  readonly chatSessionMessages: "chatSessionMessages";
23
23
  readonly contactSubmissions: "contactSubmissions";
24
+ readonly budgetAccounts: "budgetAccounts";
25
+ readonly budgetTransactions: "budgetTransactions";
24
26
  };
25
27
  export declare const FirestoreApi: {
26
28
  systemCollections: {
@@ -46,6 +48,8 @@ export declare const FirestoreApi: {
46
48
  readonly chatSessions: "chatSessions";
47
49
  readonly chatSessionMessages: "chatSessionMessages";
48
50
  readonly contactSubmissions: "contactSubmissions";
51
+ readonly budgetAccounts: "budgetAccounts";
52
+ readonly budgetTransactions: "budgetTransactions";
49
53
  };
50
54
  getPath: ({ companyId, storeId, collectionName, id, }: {
51
55
  companyId: string;
@@ -89,6 +93,8 @@ export declare const FirebaseAPI: {
89
93
  readonly chatSessions: "chatSessions";
90
94
  readonly chatSessionMessages: "chatSessionMessages";
91
95
  readonly contactSubmissions: "contactSubmissions";
96
+ readonly budgetAccounts: "budgetAccounts";
97
+ readonly budgetTransactions: "budgetTransactions";
92
98
  };
93
99
  getPath: ({ companyId, storeId, collectionName, id, }: {
94
100
  companyId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/firebase-api/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB;;;CAGpB,CAAC;AAEX,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;CAmBnB,CAAC;AAEX,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;2DASrB;QACF,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,MAAM,OAAO,gBAAgB,CAAC;QAC9C,EAAE,CAAC,EAAE,MAAM,CAAC;KACZ;wFAUE;QACF,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,MAAM,OAAO,gBAAgB,CAAC;QAC9C,iBAAiB,EAAE,MAAM,OAAO,gBAAgB,CAAC;QACjD,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,CAAC,EAAE,MAAM,CAAC;KACf;iCAI4B,MAAM,OAAO,gBAAgB;oCAIzC,MAAM,OAAO,gBAAgB,MACzC,MAAM,qBACS,MAAM,OAAO,gBAAgB;CAIjD,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;+DAtCpB;YACF,SAAS,EAAE,MAAM,CAAC;YAClB,OAAO,EAAE,MAAM,CAAC;YAChB,cAAc,EAAE,MAAM,OAAO,gBAAgB,CAAC;YAC9C,EAAE,CAAC,EAAE,MAAM,CAAC;SACZ;4FAUE;YACF,SAAS,EAAE,MAAM,CAAC;YAClB,OAAO,EAAE,MAAM,CAAC;YAChB,cAAc,EAAE,MAAM,OAAO,gBAAgB,CAAC;YAC9C,iBAAiB,EAAE,MAAM,OAAO,gBAAgB,CAAC;YACjD,EAAE,EAAE,MAAM,CAAC;YACX,KAAK,CAAC,EAAE,MAAM,CAAC;SACf;qCAI4B,MAAM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YACX,KAAK,CAAC,EAAE,MAAM,CAAC;SACf;qCAI4B,MAAM,OAAO,gBAAgB;wCAIzC,MAAM,OAAO,gBAAgB,MACzC,MAAM,qBACS,MAAM,OAAO,gBAAgB;;CAQjD,CAAC"}
@@ -21,6 +21,8 @@ export const storeCollections = {
21
21
  chatSessions: "chatSessions",
22
22
  chatSessionMessages: "chatSessionMessages",
23
23
  contactSubmissions: "contactSubmissions",
24
+ budgetAccounts: "budgetAccounts",
25
+ budgetTransactions: "budgetTransactions",
24
26
  };
25
27
  export const FirestoreApi = {
26
28
  systemCollections,
@@ -34,6 +34,9 @@ describe("storeCalculator", () => {
34
34
  test("return 0 when sale price is 0", () => {
35
35
  expect(storeCalculator.calcMarginFromSalePrice(0, 100)).toBe(0);
36
36
  });
37
+ test("return 24.53 when sale price is less than purchase price", () => {
38
+ expect(storeCalculator.calcMarginFromSalePrice(10.6, 8)).toBe(24.53);
39
+ });
37
40
  test("return 0 when purchase price is 0", () => {
38
41
  expect(storeCalculator.calcMarginFromSalePrice(100, 0)).toBe(0);
39
42
  });