@jsdev_ninja/core 0.15.2 → 0.16.0
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.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.es.js +1198 -1128
- package/dist/core.es.js.map +1 -1
- package/dist/core.umd.js +1 -1
- package/dist/core.umd.js.map +1 -1
- package/dist/lib/entities/Order.d.ts +40 -0
- package/dist/lib/entities/Order.d.ts.map +1 -1
- package/dist/lib/entities/Order.js +13 -0
- package/dist/lib/entities/OrganizationBalance.d.ts +138 -0
- package/dist/lib/entities/OrganizationBalance.d.ts.map +1 -0
- package/dist/lib/entities/OrganizationBalance.js +65 -0
- package/dist/lib/entities/index.d.ts +1 -0
- package/dist/lib/entities/index.d.ts.map +1 -1
- package/dist/lib/entities/index.js +1 -0
- package/dist/lib/firebase-api/index.d.ts +6 -0
- package/dist/lib/firebase-api/index.d.ts.map +1 -1
- package/dist/lib/firebase-api/index.js +2 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1860,6 +1860,26 @@ export declare const OrderSchema: z.ZodObject<{
|
|
|
1860
1860
|
emailOnInvoice: z.ZodOptional<z.ZodString>;
|
|
1861
1861
|
phoneNumberOnInvoice: z.ZodOptional<z.ZodString>;
|
|
1862
1862
|
clientComment: z.ZodOptional<z.ZodString>;
|
|
1863
|
+
companyName: z.ZodOptional<z.ZodString>;
|
|
1864
|
+
companyNumber: z.ZodOptional<z.ZodString>;
|
|
1865
|
+
contact: z.ZodOptional<z.ZodObject<{
|
|
1866
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
1867
|
+
role: z.ZodOptional<z.ZodString>;
|
|
1868
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
1869
|
+
email: z.ZodOptional<z.ZodString>;
|
|
1870
|
+
}, "strip", z.ZodTypeAny, {
|
|
1871
|
+
email?: string | undefined;
|
|
1872
|
+
phone?: string | undefined;
|
|
1873
|
+
fullName?: string | undefined;
|
|
1874
|
+
role?: string | undefined;
|
|
1875
|
+
}, {
|
|
1876
|
+
email?: string | undefined;
|
|
1877
|
+
phone?: string | undefined;
|
|
1878
|
+
fullName?: string | undefined;
|
|
1879
|
+
role?: string | undefined;
|
|
1880
|
+
}>>;
|
|
1881
|
+
poNumber: z.ZodOptional<z.ZodString>;
|
|
1882
|
+
outOfStockPolicy: z.ZodOptional<z.ZodEnum<["substitute", "remove"]>>;
|
|
1863
1883
|
organizationId: z.ZodOptional<z.ZodString>;
|
|
1864
1884
|
billingAccount: z.ZodOptional<z.ZodObject<{
|
|
1865
1885
|
number: z.ZodString;
|
|
@@ -2498,6 +2518,7 @@ export declare const OrderSchema: z.ZodObject<{
|
|
|
2498
2518
|
deliveryPrice?: number | undefined;
|
|
2499
2519
|
};
|
|
2500
2520
|
deliveryDate: number;
|
|
2521
|
+
companyName?: string | undefined;
|
|
2501
2522
|
address?: {
|
|
2502
2523
|
country?: string | undefined;
|
|
2503
2524
|
city?: string | undefined;
|
|
@@ -2510,6 +2531,7 @@ export declare const OrderSchema: z.ZodObject<{
|
|
|
2510
2531
|
paymentType?: "none" | "external" | "j5" | undefined;
|
|
2511
2532
|
organizationId?: string | undefined;
|
|
2512
2533
|
nameOnInvoice?: string | undefined;
|
|
2534
|
+
companyNumber?: string | undefined;
|
|
2513
2535
|
createdBy?: "user" | "admin" | undefined;
|
|
2514
2536
|
storeOptions?: {
|
|
2515
2537
|
deliveryPrice?: number | undefined;
|
|
@@ -2548,6 +2570,14 @@ export declare const OrderSchema: z.ZodObject<{
|
|
|
2548
2570
|
emailOnInvoice?: string | undefined;
|
|
2549
2571
|
phoneNumberOnInvoice?: string | undefined;
|
|
2550
2572
|
clientComment?: string | undefined;
|
|
2573
|
+
contact?: {
|
|
2574
|
+
email?: string | undefined;
|
|
2575
|
+
phone?: string | undefined;
|
|
2576
|
+
fullName?: string | undefined;
|
|
2577
|
+
role?: string | undefined;
|
|
2578
|
+
} | undefined;
|
|
2579
|
+
poNumber?: string | undefined;
|
|
2580
|
+
outOfStockPolicy?: "substitute" | "remove" | undefined;
|
|
2551
2581
|
billingAccount?: {
|
|
2552
2582
|
number: string;
|
|
2553
2583
|
id: string;
|
|
@@ -2869,6 +2899,7 @@ export declare const OrderSchema: z.ZodObject<{
|
|
|
2869
2899
|
deliveryPrice?: number | undefined;
|
|
2870
2900
|
};
|
|
2871
2901
|
deliveryDate: number;
|
|
2902
|
+
companyName?: string | undefined;
|
|
2872
2903
|
address?: {
|
|
2873
2904
|
country?: string | undefined;
|
|
2874
2905
|
city?: string | undefined;
|
|
@@ -2881,6 +2912,7 @@ export declare const OrderSchema: z.ZodObject<{
|
|
|
2881
2912
|
paymentType?: "none" | "external" | "j5" | undefined;
|
|
2882
2913
|
organizationId?: string | undefined;
|
|
2883
2914
|
nameOnInvoice?: string | undefined;
|
|
2915
|
+
companyNumber?: string | undefined;
|
|
2884
2916
|
createdBy?: "user" | "admin" | undefined;
|
|
2885
2917
|
storeOptions?: {
|
|
2886
2918
|
deliveryPrice?: number | undefined;
|
|
@@ -2919,6 +2951,14 @@ export declare const OrderSchema: z.ZodObject<{
|
|
|
2919
2951
|
emailOnInvoice?: string | undefined;
|
|
2920
2952
|
phoneNumberOnInvoice?: string | undefined;
|
|
2921
2953
|
clientComment?: string | undefined;
|
|
2954
|
+
contact?: {
|
|
2955
|
+
email?: string | undefined;
|
|
2956
|
+
phone?: string | undefined;
|
|
2957
|
+
fullName?: string | undefined;
|
|
2958
|
+
role?: string | undefined;
|
|
2959
|
+
} | undefined;
|
|
2960
|
+
poNumber?: string | undefined;
|
|
2961
|
+
outOfStockPolicy?: "substitute" | "remove" | undefined;
|
|
2922
2962
|
billingAccount?: {
|
|
2923
2963
|
number: string;
|
|
2924
2964
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Order.d.ts","sourceRoot":"","sources":["../../../lib/entities/Order.ts"],"names":[],"mappings":"AAAA,OAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkEtB,CAAC;AAEH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -57,6 +57,19 @@ export const OrderSchema = z.object({
|
|
|
57
57
|
emailOnInvoice: z.string().email().optional(),
|
|
58
58
|
phoneNumberOnInvoice: z.string().optional(),
|
|
59
59
|
clientComment: z.string().optional(),
|
|
60
|
+
// --- B2B buyer details (optional, additive — back-compat) ---
|
|
61
|
+
companyName: z.string().optional(),
|
|
62
|
+
companyNumber: z.string().optional(), // ח.פ / עוסק מורשה (aligns with Organization.companyNumber)
|
|
63
|
+
contact: z
|
|
64
|
+
.object({
|
|
65
|
+
fullName: z.string().optional(),
|
|
66
|
+
role: z.string().optional(), // תפקיד
|
|
67
|
+
phone: z.string().optional(),
|
|
68
|
+
email: z.string().optional(),
|
|
69
|
+
})
|
|
70
|
+
.optional(),
|
|
71
|
+
poNumber: z.string().optional(), // הזמנת רכש
|
|
72
|
+
outOfStockPolicy: z.enum(["substitute", "remove"]).optional(),
|
|
60
73
|
organizationId: z.string().optional(),
|
|
61
74
|
billingAccount: BillingAccountSchema.optional(),
|
|
62
75
|
deliveryNote: DeliveryNoteSchema.optional(),
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const OrganizationBalanceEntrySchema: z.ZodObject<{
|
|
3
|
+
/** = deterministic dedup doc id */
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
organizationId: z.ZodString;
|
|
6
|
+
/** "+" increases owed (accrual), "-" decreases owed (settlement/adjustment) */
|
|
7
|
+
sign: z.ZodEnum<["+", "-"]>;
|
|
8
|
+
kind: z.ZodEnum<["accrual", "settlement", "adjustment"]>;
|
|
9
|
+
/** Integer agorot, always positive; sign carries direction */
|
|
10
|
+
amount: z.ZodNumber;
|
|
11
|
+
currency: z.ZodLiteral<"ILS">;
|
|
12
|
+
source: z.ZodEnum<["delivery_note", "ledger_payment", "manual", "order_reversal"]>;
|
|
13
|
+
/** Present for document-sourced accruals */
|
|
14
|
+
document: z.ZodOptional<z.ZodObject<{
|
|
15
|
+
type: z.ZodEnum<["delivery_note", "invoice"]>;
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
number: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
type: "invoice" | "delivery_note";
|
|
20
|
+
id: string;
|
|
21
|
+
number?: string | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
type: "invoice" | "delivery_note";
|
|
24
|
+
id: string;
|
|
25
|
+
number?: string | undefined;
|
|
26
|
+
}>>;
|
|
27
|
+
/** Order id (accrual), ledger txId (settlement), or manual ref */
|
|
28
|
+
reference: z.ZodOptional<z.ZodObject<{
|
|
29
|
+
type: z.ZodEnum<["order", "transaction", "manual"]>;
|
|
30
|
+
id: z.ZodString;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
type: "order" | "manual" | "transaction";
|
|
33
|
+
id: string;
|
|
34
|
+
}, {
|
|
35
|
+
type: "order" | "manual" | "transaction";
|
|
36
|
+
id: string;
|
|
37
|
+
}>>;
|
|
38
|
+
/** Optional sub-grouping within an org */
|
|
39
|
+
billingAccountId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
40
|
+
/** Deterministic dedup key; doc id is derived from this */
|
|
41
|
+
dedupKey: z.ZodString;
|
|
42
|
+
/** Event id when source is event-driven */
|
|
43
|
+
causedByEventId: z.ZodOptional<z.ZodString>;
|
|
44
|
+
/** Epoch millis — used for date-range queries */
|
|
45
|
+
createdAt: z.ZodNumber;
|
|
46
|
+
companyId: z.ZodString;
|
|
47
|
+
storeId: z.ZodString;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
id: string;
|
|
50
|
+
companyId: string;
|
|
51
|
+
storeId: string;
|
|
52
|
+
currency: "ILS";
|
|
53
|
+
amount: number;
|
|
54
|
+
organizationId: string;
|
|
55
|
+
createdAt: number;
|
|
56
|
+
source: "manual" | "delivery_note" | "ledger_payment" | "order_reversal";
|
|
57
|
+
sign: "+" | "-";
|
|
58
|
+
kind: "accrual" | "settlement" | "adjustment";
|
|
59
|
+
dedupKey: string;
|
|
60
|
+
billingAccountId?: string | null | undefined;
|
|
61
|
+
causedByEventId?: string | undefined;
|
|
62
|
+
document?: {
|
|
63
|
+
type: "invoice" | "delivery_note";
|
|
64
|
+
id: string;
|
|
65
|
+
number?: string | undefined;
|
|
66
|
+
} | undefined;
|
|
67
|
+
reference?: {
|
|
68
|
+
type: "order" | "manual" | "transaction";
|
|
69
|
+
id: string;
|
|
70
|
+
} | undefined;
|
|
71
|
+
}, {
|
|
72
|
+
id: string;
|
|
73
|
+
companyId: string;
|
|
74
|
+
storeId: string;
|
|
75
|
+
currency: "ILS";
|
|
76
|
+
amount: number;
|
|
77
|
+
organizationId: string;
|
|
78
|
+
createdAt: number;
|
|
79
|
+
source: "manual" | "delivery_note" | "ledger_payment" | "order_reversal";
|
|
80
|
+
sign: "+" | "-";
|
|
81
|
+
kind: "accrual" | "settlement" | "adjustment";
|
|
82
|
+
dedupKey: string;
|
|
83
|
+
billingAccountId?: string | null | undefined;
|
|
84
|
+
causedByEventId?: string | undefined;
|
|
85
|
+
document?: {
|
|
86
|
+
type: "invoice" | "delivery_note";
|
|
87
|
+
id: string;
|
|
88
|
+
number?: string | undefined;
|
|
89
|
+
} | undefined;
|
|
90
|
+
reference?: {
|
|
91
|
+
type: "order" | "manual" | "transaction";
|
|
92
|
+
id: string;
|
|
93
|
+
} | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
export type TOrganizationBalanceEntry = z.infer<typeof OrganizationBalanceEntrySchema>;
|
|
96
|
+
export declare const OrganizationBalanceRollupSchema: z.ZodObject<{
|
|
97
|
+
/** = doc id */
|
|
98
|
+
organizationId: z.ZodString;
|
|
99
|
+
/** Σ(+) − Σ(−), clamped ≥ 0; integer agorot. Non-zero only when totalAccrued > totalSettled. */
|
|
100
|
+
owed: z.ZodNumber;
|
|
101
|
+
/**
|
|
102
|
+
* Overpayment credit: max(0, totalSettled − totalAccrued); integer agorot, ≥ 0.
|
|
103
|
+
* Non-zero only when org has paid MORE than it has accrued.
|
|
104
|
+
* Visibility only — not client-spendable. At most one of {owed, credit} is non-zero.
|
|
105
|
+
*/
|
|
106
|
+
credit: z.ZodNumber;
|
|
107
|
+
/** Lifetime Σ(+); integer agorot */
|
|
108
|
+
totalAccrued: z.ZodNumber;
|
|
109
|
+
/** Lifetime Σ(−); integer agorot */
|
|
110
|
+
totalSettled: z.ZodNumber;
|
|
111
|
+
currency: z.ZodLiteral<"ILS">;
|
|
112
|
+
/** Epoch millis */
|
|
113
|
+
updatedAt: z.ZodNumber;
|
|
114
|
+
companyId: z.ZodString;
|
|
115
|
+
storeId: z.ZodString;
|
|
116
|
+
}, "strip", z.ZodTypeAny, {
|
|
117
|
+
companyId: string;
|
|
118
|
+
storeId: string;
|
|
119
|
+
currency: "ILS";
|
|
120
|
+
organizationId: string;
|
|
121
|
+
updatedAt: number;
|
|
122
|
+
owed: number;
|
|
123
|
+
credit: number;
|
|
124
|
+
totalAccrued: number;
|
|
125
|
+
totalSettled: number;
|
|
126
|
+
}, {
|
|
127
|
+
companyId: string;
|
|
128
|
+
storeId: string;
|
|
129
|
+
currency: "ILS";
|
|
130
|
+
organizationId: string;
|
|
131
|
+
updatedAt: number;
|
|
132
|
+
owed: number;
|
|
133
|
+
credit: number;
|
|
134
|
+
totalAccrued: number;
|
|
135
|
+
totalSettled: number;
|
|
136
|
+
}>;
|
|
137
|
+
export type TOrganizationBalanceRollup = z.infer<typeof OrganizationBalanceRollupSchema>;
|
|
138
|
+
//# sourceMappingURL=OrganizationBalance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrganizationBalance.d.ts","sourceRoot":"","sources":["../../../lib/entities/OrganizationBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,8BAA8B;IAC1C,mCAAmC;;;IAGnC,+EAA+E;;;IAG/E,8DAA8D;;;;IAI9D,4CAA4C;;;;;;;;;;;;;;IAQ5C,kEAAkE;;;;;;;;;;;IAOlE,0CAA0C;;IAE1C,2DAA2D;;IAE3D,2CAA2C;;IAE3C,iDAAiD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIhD,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAMvF,eAAO,MAAM,+BAA+B;IAC3C,eAAe;;IAEf,gGAAgG;;IAEhG;;;;OAIG;;IAEH,oCAAoC;;IAEpC,oCAAoC;;;IAGpC,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;EAIlB,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// ---------------------------------------------------------------------------
|
|
3
|
+
// Append-only AR entry ledger document
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
export const OrganizationBalanceEntrySchema = z.object({
|
|
6
|
+
/** = deterministic dedup doc id */
|
|
7
|
+
id: z.string().min(1),
|
|
8
|
+
organizationId: z.string().min(1),
|
|
9
|
+
/** "+" increases owed (accrual), "-" decreases owed (settlement/adjustment) */
|
|
10
|
+
sign: z.enum(["+", "-"]),
|
|
11
|
+
kind: z.enum(["accrual", "settlement", "adjustment"]),
|
|
12
|
+
/** Integer agorot, always positive; sign carries direction */
|
|
13
|
+
amount: z.number().int().positive(),
|
|
14
|
+
currency: z.literal("ILS"),
|
|
15
|
+
source: z.enum(["delivery_note", "ledger_payment", "manual", "order_reversal"]),
|
|
16
|
+
/** Present for document-sourced accruals */
|
|
17
|
+
document: z
|
|
18
|
+
.object({
|
|
19
|
+
type: z.enum(["delivery_note", "invoice"]),
|
|
20
|
+
id: z.string().min(1),
|
|
21
|
+
number: z.string().optional(),
|
|
22
|
+
})
|
|
23
|
+
.optional(),
|
|
24
|
+
/** Order id (accrual), ledger txId (settlement), or manual ref */
|
|
25
|
+
reference: z
|
|
26
|
+
.object({
|
|
27
|
+
type: z.enum(["order", "transaction", "manual"]),
|
|
28
|
+
id: z.string().min(1),
|
|
29
|
+
})
|
|
30
|
+
.optional(),
|
|
31
|
+
/** Optional sub-grouping within an org */
|
|
32
|
+
billingAccountId: z.string().nullable().optional(),
|
|
33
|
+
/** Deterministic dedup key; doc id is derived from this */
|
|
34
|
+
dedupKey: z.string().min(1),
|
|
35
|
+
/** Event id when source is event-driven */
|
|
36
|
+
causedByEventId: z.string().optional(),
|
|
37
|
+
/** Epoch millis — used for date-range queries */
|
|
38
|
+
createdAt: z.number().int().positive(),
|
|
39
|
+
companyId: z.string().min(1),
|
|
40
|
+
storeId: z.string().min(1),
|
|
41
|
+
});
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
// Per-org rollup cache (O(1) balance reads)
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
export const OrganizationBalanceRollupSchema = z.object({
|
|
46
|
+
/** = doc id */
|
|
47
|
+
organizationId: z.string().min(1),
|
|
48
|
+
/** Σ(+) − Σ(−), clamped ≥ 0; integer agorot. Non-zero only when totalAccrued > totalSettled. */
|
|
49
|
+
owed: z.number().int(),
|
|
50
|
+
/**
|
|
51
|
+
* Overpayment credit: max(0, totalSettled − totalAccrued); integer agorot, ≥ 0.
|
|
52
|
+
* Non-zero only when org has paid MORE than it has accrued.
|
|
53
|
+
* Visibility only — not client-spendable. At most one of {owed, credit} is non-zero.
|
|
54
|
+
*/
|
|
55
|
+
credit: z.number().int(),
|
|
56
|
+
/** Lifetime Σ(+); integer agorot */
|
|
57
|
+
totalAccrued: z.number().int(),
|
|
58
|
+
/** Lifetime Σ(−); integer agorot */
|
|
59
|
+
totalSettled: z.number().int(),
|
|
60
|
+
currency: z.literal("ILS"),
|
|
61
|
+
/** Epoch millis */
|
|
62
|
+
updatedAt: z.number().int().positive(),
|
|
63
|
+
companyId: z.string().min(1),
|
|
64
|
+
storeId: z.string().min(1),
|
|
65
|
+
});
|
|
@@ -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,UAAU,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,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC"}
|
|
@@ -28,6 +28,8 @@ export declare const storeCollections: {
|
|
|
28
28
|
readonly transactions: "transactions";
|
|
29
29
|
readonly paymentLinks: "paymentLinks";
|
|
30
30
|
readonly duplicateChargeAlerts: "duplicateChargeAlerts";
|
|
31
|
+
readonly organizationBalance: "organizationBalance";
|
|
32
|
+
readonly organizationBalanceRollup: "organizationBalanceRollup";
|
|
31
33
|
};
|
|
32
34
|
export declare const FirestoreApi: {
|
|
33
35
|
systemCollections: {
|
|
@@ -60,6 +62,8 @@ export declare const FirestoreApi: {
|
|
|
60
62
|
readonly transactions: "transactions";
|
|
61
63
|
readonly paymentLinks: "paymentLinks";
|
|
62
64
|
readonly duplicateChargeAlerts: "duplicateChargeAlerts";
|
|
65
|
+
readonly organizationBalance: "organizationBalance";
|
|
66
|
+
readonly organizationBalanceRollup: "organizationBalanceRollup";
|
|
63
67
|
};
|
|
64
68
|
getPath: ({ companyId, storeId, collectionName, id, }: {
|
|
65
69
|
companyId: string;
|
|
@@ -110,6 +114,8 @@ export declare const FirebaseAPI: {
|
|
|
110
114
|
readonly transactions: "transactions";
|
|
111
115
|
readonly paymentLinks: "paymentLinks";
|
|
112
116
|
readonly duplicateChargeAlerts: "duplicateChargeAlerts";
|
|
117
|
+
readonly organizationBalance: "organizationBalance";
|
|
118
|
+
readonly organizationBalanceRollup: "organizationBalanceRollup";
|
|
113
119
|
};
|
|
114
120
|
getPath: ({ companyId, storeId, collectionName, id, }: {
|
|
115
121
|
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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BnB,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,OAAO,gBAAgB;wCAIzC,MAAM,OAAO,gBAAgB,MACzC,MAAM,qBACS,MAAM,OAAO,gBAAgB;;CAQjD,CAAC"}
|
|
@@ -28,6 +28,8 @@ export const storeCollections = {
|
|
|
28
28
|
transactions: "transactions",
|
|
29
29
|
paymentLinks: "paymentLinks",
|
|
30
30
|
duplicateChargeAlerts: "duplicateChargeAlerts",
|
|
31
|
+
organizationBalance: "organizationBalance",
|
|
32
|
+
organizationBalanceRollup: "organizationBalanceRollup",
|
|
31
33
|
};
|
|
32
34
|
export const FirestoreApi = {
|
|
33
35
|
systemCollections,
|