@deepintel-ltd/farmpro-contracts 1.25.2 → 1.27.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/routes/farm-enterprises.routes.d.ts +44 -44
- package/dist/routes/farms.routes.d.ts +9 -9
- package/dist/routes/geofences.routes.d.ts +2 -2
- package/dist/routes/livestock-groups.routes.d.ts +724 -54
- package/dist/routes/livestock-groups.routes.d.ts.map +1 -1
- package/dist/routes/livestock-groups.routes.js +17 -1
- package/dist/routes/livestock.routes.d.ts +3505 -42
- package/dist/routes/livestock.routes.d.ts.map +1 -1
- package/dist/routes/livestock.routes.js +111 -1
- package/dist/routes/organizations.routes.d.ts +112 -14
- package/dist/routes/organizations.routes.d.ts.map +1 -1
- package/dist/routes/team.routes.d.ts +44 -44
- package/dist/routes/trade-cash-events.routes.d.ts +7711 -559
- package/dist/routes/trade-cash-events.routes.d.ts.map +1 -1
- package/dist/routes/trade-cash-events.routes.js +148 -2
- package/dist/schemas/farm-enterprises.schemas.d.ts +58 -58
- package/dist/schemas/farm-enterprises.schemas.d.ts.map +1 -1
- package/dist/schemas/farm-enterprises.schemas.js +1 -0
- package/dist/schemas/farms.schemas.d.ts +12 -12
- package/dist/schemas/farms.schemas.js +1 -1
- package/dist/schemas/geofences.schemas.d.ts +4 -4
- package/dist/schemas/livestock-groups.schemas.d.ts +166 -40
- package/dist/schemas/livestock-groups.schemas.d.ts.map +1 -1
- package/dist/schemas/livestock-groups.schemas.js +25 -0
- package/dist/schemas/livestock.schemas.d.ts +1796 -36
- package/dist/schemas/livestock.schemas.d.ts.map +1 -1
- package/dist/schemas/livestock.schemas.js +129 -0
- package/dist/schemas/organizations.schemas.d.ts +104 -16
- package/dist/schemas/organizations.schemas.d.ts.map +1 -1
- package/dist/schemas/organizations.schemas.js +8 -1
- package/dist/schemas/team.schemas.d.ts +43 -43
- package/dist/schemas/team.schemas.d.ts.map +1 -1
- package/dist/schemas/team.schemas.js +1 -0
- package/dist/schemas/trade-cash-events.schemas.d.ts +2645 -68
- package/dist/schemas/trade-cash-events.schemas.d.ts.map +1 -1
- package/dist/schemas/trade-cash-events.schemas.js +210 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trade-cash-events.schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/trade-cash-events.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,wBAAwB,
|
|
1
|
+
{"version":3,"file":"trade-cash-events.schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/trade-cash-events.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,wBAAwB,mMAWnC,CAAC;AAEH,eAAO,MAAM,wBAAwB,qFAQnC,CAAC;AAEH,eAAO,MAAM,yBAAyB,6DAKpC,CAAC;AAEH,eAAO,MAAM,gCAAgC,+EAM3C,CAAC;AAEH,eAAO,MAAM,oCAAoC,2CAI/C,CAAC;AAEH,eAAO,MAAM,8BAA8B,8DAKzC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBjB,CAAC;AAE3B,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;IAa/C,oFAAoF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKpF,CAAC;AAEH,eAAO,MAAM,kCAAkC;;;;;;EAE7C,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGxC,CAAC;AAEF,eAAO,MAA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AAC;AACF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AACtF,MAAM,MAAM,iCAAiC,GAAG,CAAC,CAAC,KAAK,CACrD,OAAO,uCAAuC,CAC/C,CAAC;AACF,MAAM,MAAM,kCAAkC,GAAG,CAAC,CAAC,KAAK,CACtD,OAAO,wCAAwC,CAChD,CAAC;AACF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AACxF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
|
|
@@ -6,6 +6,11 @@ export const tradeCashEventTypeSchema = z.enum([
|
|
|
6
6
|
'commission_payout',
|
|
7
7
|
'supplier_payment',
|
|
8
8
|
'buyer_receipt',
|
|
9
|
+
'advance_disburse',
|
|
10
|
+
'advance_handoff',
|
|
11
|
+
'advance_settle',
|
|
12
|
+
'advance_return',
|
|
13
|
+
'advance_writeoff',
|
|
9
14
|
]);
|
|
10
15
|
export const tradeCashPartyTypeSchema = z.enum([
|
|
11
16
|
'investor',
|
|
@@ -14,6 +19,31 @@ export const tradeCashPartyTypeSchema = z.enum([
|
|
|
14
19
|
'buyer',
|
|
15
20
|
'broker',
|
|
16
21
|
'other',
|
|
22
|
+
'company',
|
|
23
|
+
]);
|
|
24
|
+
export const tradeCashFunderTypeSchema = z.enum([
|
|
25
|
+
'company',
|
|
26
|
+
'staff',
|
|
27
|
+
'investor',
|
|
28
|
+
'unattributed',
|
|
29
|
+
]);
|
|
30
|
+
export const tradeSourcingAdvanceStatusSchema = z.enum([
|
|
31
|
+
'pending_receipt',
|
|
32
|
+
'open',
|
|
33
|
+
'settled',
|
|
34
|
+
'written_off',
|
|
35
|
+
'cancelled',
|
|
36
|
+
]);
|
|
37
|
+
export const tradeSourcingAdvanceHolderTypeSchema = z.enum([
|
|
38
|
+
'staff',
|
|
39
|
+
'supplier',
|
|
40
|
+
'other',
|
|
41
|
+
]);
|
|
42
|
+
export const advanceSettlementOutcomeSchema = z.enum([
|
|
43
|
+
'spent',
|
|
44
|
+
'returned',
|
|
45
|
+
'written_off',
|
|
46
|
+
'overspend',
|
|
17
47
|
]);
|
|
18
48
|
export const tradeCashEventAttributesSchema = z
|
|
19
49
|
.object({
|
|
@@ -30,6 +60,13 @@ export const tradeCashEventAttributesSchema = z
|
|
|
30
60
|
dealId: z.string().uuid().nullable().optional(),
|
|
31
61
|
invoiceId: z.string().uuid().nullable().optional(),
|
|
32
62
|
notes: z.string().nullable().optional(),
|
|
63
|
+
funderType: tradeCashFunderTypeSchema.optional().default('unattributed'),
|
|
64
|
+
funderId: z.string().max(100).nullable().optional(),
|
|
65
|
+
funderName: z.string().max(200).nullable().optional(),
|
|
66
|
+
advanceId: z.string().uuid().nullable().optional(),
|
|
67
|
+
voidedAt: z.string().datetime().nullable().optional(),
|
|
68
|
+
voidedById: z.string().uuid().nullable().optional(),
|
|
69
|
+
voidReason: z.string().nullable().optional(),
|
|
33
70
|
})
|
|
34
71
|
.merge(timestampsSchema);
|
|
35
72
|
export const createTradeCashEventAttributesSchema = z.object({
|
|
@@ -45,6 +82,14 @@ export const createTradeCashEventAttributesSchema = z.object({
|
|
|
45
82
|
dealId: z.string().uuid().optional().nullable(),
|
|
46
83
|
invoiceId: z.string().uuid().optional().nullable(),
|
|
47
84
|
notes: z.string().optional().nullable(),
|
|
85
|
+
/** Required for supplier_payment and advance events; derived for capital_in/out. */
|
|
86
|
+
funderType: tradeCashFunderTypeSchema.optional(),
|
|
87
|
+
funderId: z.string().max(100).optional().nullable(),
|
|
88
|
+
funderName: z.string().max(200).optional().nullable(),
|
|
89
|
+
advanceId: z.string().uuid().optional().nullable(),
|
|
90
|
+
});
|
|
91
|
+
export const voidTradeCashEventAttributesSchema = z.object({
|
|
92
|
+
reason: z.string().min(1).max(500),
|
|
48
93
|
});
|
|
49
94
|
export const tradeCashEventResourceSchema = createJsonApiResourceSchema('trade-cash-events', tradeCashEventAttributesSchema);
|
|
50
95
|
export const tradeCashEventResponseSchema = jsonApiSingleResponseSchema(tradeCashEventResourceSchema);
|
|
@@ -53,12 +98,20 @@ export const createTradeCashEventSchema = z.object({
|
|
|
53
98
|
type: z.literal('trade-cash-events'),
|
|
54
99
|
attributes: createTradeCashEventAttributesSchema,
|
|
55
100
|
});
|
|
101
|
+
export const voidTradeCashEventSchema = z.object({
|
|
102
|
+
type: z.literal('trade-cash-events'),
|
|
103
|
+
attributes: voidTradeCashEventAttributesSchema,
|
|
104
|
+
});
|
|
56
105
|
export const investorBalanceAttributesSchema = z.object({
|
|
57
106
|
partyId: z.string(),
|
|
58
107
|
partyName: z.string().nullable().optional(),
|
|
59
108
|
capitalIn: z.number(),
|
|
60
109
|
capitalOut: z.number(),
|
|
61
110
|
balance: z.number(),
|
|
111
|
+
/** Earliest non-voided capital_in occurredAt — for fund performance dating. */
|
|
112
|
+
firstCapitalInAt: z.string().datetime().nullable().optional(),
|
|
113
|
+
/** Most recent non-voided capital_in occurredAt. */
|
|
114
|
+
lastCapitalInAt: z.string().datetime().nullable().optional(),
|
|
62
115
|
dealCount: z.number().optional(),
|
|
63
116
|
});
|
|
64
117
|
export const investorBalancesResponseSchema = z.object({
|
|
@@ -70,6 +123,67 @@ export const investorBalancesResponseSchema = z.object({
|
|
|
70
123
|
}),
|
|
71
124
|
}),
|
|
72
125
|
});
|
|
126
|
+
export const funderBreakdownSchema = z.object({
|
|
127
|
+
funderType: tradeCashFunderTypeSchema,
|
|
128
|
+
funderId: z.string().nullable().optional(),
|
|
129
|
+
funderName: z.string().nullable().optional(),
|
|
130
|
+
amount: z.number(),
|
|
131
|
+
});
|
|
132
|
+
export const advancePositionSchema = z.object({
|
|
133
|
+
advanceId: z.string().uuid(),
|
|
134
|
+
holderType: tradeSourcingAdvanceHolderTypeSchema,
|
|
135
|
+
holderId: z.string().nullable().optional(),
|
|
136
|
+
holderName: z.string(),
|
|
137
|
+
funderType: tradeCashFunderTypeSchema,
|
|
138
|
+
funderId: z.string().nullable().optional(),
|
|
139
|
+
funderName: z.string().nullable().optional(),
|
|
140
|
+
remaining: z.number(),
|
|
141
|
+
amount: z.number(),
|
|
142
|
+
status: tradeSourcingAdvanceStatusSchema,
|
|
143
|
+
openedAt: z.string().datetime(),
|
|
144
|
+
expectedSettleBy: z.string().datetime().nullable().optional(),
|
|
145
|
+
overdue: z.boolean(),
|
|
146
|
+
ageDays: z.number(),
|
|
147
|
+
});
|
|
148
|
+
export const tradeTreasuryAttributesSchema = z.object({
|
|
149
|
+
asOf: z.string().datetime(),
|
|
150
|
+
computedAt: z.string().datetime(),
|
|
151
|
+
currency: z.string().length(3),
|
|
152
|
+
received: z.number(),
|
|
153
|
+
returnedToFunders: z.number(),
|
|
154
|
+
available: z.number(),
|
|
155
|
+
inSourcing: z.number(),
|
|
156
|
+
unallocatedSpend: z.number(),
|
|
157
|
+
goodsNotDelivered: z.number(),
|
|
158
|
+
deliveredUnpaid: z.number(),
|
|
159
|
+
/** Landed cost recovered on deals that are paid (and typically delivered). */
|
|
160
|
+
deliveredPaid: z.number().optional(),
|
|
161
|
+
receivable: z.number(),
|
|
162
|
+
capitalOutstanding: z.number(),
|
|
163
|
+
buyerReceipts: z.number(),
|
|
164
|
+
/** received − returned vs available + capitalOutstanding */
|
|
165
|
+
reconciliation: z.object({
|
|
166
|
+
capitalBase: z.number(),
|
|
167
|
+
deployedAndHeld: z.number(),
|
|
168
|
+
profitLossAndCostsRetained: z.number(),
|
|
169
|
+
}),
|
|
170
|
+
byFunder: z.object({
|
|
171
|
+
received: z.array(funderBreakdownSchema),
|
|
172
|
+
returned: z.array(funderBreakdownSchema),
|
|
173
|
+
inSourcing: z.array(funderBreakdownSchema),
|
|
174
|
+
unallocatedSpend: z.array(funderBreakdownSchema),
|
|
175
|
+
goodsNotDelivered: z.array(funderBreakdownSchema),
|
|
176
|
+
deliveredUnpaid: z.array(funderBreakdownSchema),
|
|
177
|
+
}),
|
|
178
|
+
openAdvances: z.array(advancePositionSchema),
|
|
179
|
+
});
|
|
180
|
+
export const tradeTreasuryResponseSchema = z.object({
|
|
181
|
+
data: z.object({
|
|
182
|
+
type: z.literal('trade-treasury'),
|
|
183
|
+
id: z.string(),
|
|
184
|
+
attributes: tradeTreasuryAttributesSchema,
|
|
185
|
+
}),
|
|
186
|
+
});
|
|
73
187
|
export const tradeControlBoardResponseSchema = z.object({
|
|
74
188
|
data: z.object({
|
|
75
189
|
type: z.literal('trade-control-board'),
|
|
@@ -130,3 +244,99 @@ export const createInvoicePaymentSchema = z.object({
|
|
|
130
244
|
type: z.literal('invoice-payments'),
|
|
131
245
|
attributes: createInvoicePaymentAttributesSchema,
|
|
132
246
|
});
|
|
247
|
+
// ── Sourcing advances ────────────────────────────────────────────────────────
|
|
248
|
+
export const tradeSourcingAdvanceAttributesSchema = z
|
|
249
|
+
.object({
|
|
250
|
+
organizationId: z.string().uuid(),
|
|
251
|
+
holderType: tradeSourcingAdvanceHolderTypeSchema,
|
|
252
|
+
holderId: z.string().max(100).nullable().optional(),
|
|
253
|
+
holderName: z.string().max(200),
|
|
254
|
+
funderType: tradeCashFunderTypeSchema,
|
|
255
|
+
funderId: z.string().max(100).nullable().optional(),
|
|
256
|
+
funderName: z.string().max(200).nullable().optional(),
|
|
257
|
+
parentAdvanceId: z.string().uuid().nullable().optional(),
|
|
258
|
+
amount: z.number().positive(),
|
|
259
|
+
remaining: z.number(),
|
|
260
|
+
currency: z.string().length(3).default('NGN'),
|
|
261
|
+
status: tradeSourcingAdvanceStatusSchema,
|
|
262
|
+
expectedSettleBy: z.string().datetime().nullable().optional(),
|
|
263
|
+
dealId: z.string().uuid().nullable().optional(),
|
|
264
|
+
purchaseOrderId: z.string().uuid().nullable().optional(),
|
|
265
|
+
purpose: z.string().max(500).nullable().optional(),
|
|
266
|
+
notes: z.string().nullable().optional(),
|
|
267
|
+
confirmedAt: z.string().datetime().nullable().optional(),
|
|
268
|
+
overdue: z.boolean().optional(),
|
|
269
|
+
})
|
|
270
|
+
.merge(timestampsSchema);
|
|
271
|
+
export const createSourcingAdvanceAttributesSchema = z.object({
|
|
272
|
+
holderType: tradeSourcingAdvanceHolderTypeSchema,
|
|
273
|
+
holderId: z.string().max(100).optional().nullable(),
|
|
274
|
+
holderName: z.string().min(1).max(200),
|
|
275
|
+
funderType: z.enum(['company', 'staff', 'investor']),
|
|
276
|
+
funderId: z.string().max(100).optional().nullable(),
|
|
277
|
+
funderName: z.string().max(200).optional().nullable(),
|
|
278
|
+
amount: z.number().positive(),
|
|
279
|
+
currency: z.string().length(3).optional().default('NGN'),
|
|
280
|
+
occurredAt: z.string().datetime(),
|
|
281
|
+
expectedSettleBy: z.string().datetime().optional().nullable(),
|
|
282
|
+
dealId: z.string().uuid().optional().nullable(),
|
|
283
|
+
purchaseOrderId: z.string().uuid().optional().nullable(),
|
|
284
|
+
purpose: z.string().max(500).optional().nullable(),
|
|
285
|
+
notes: z.string().optional().nullable(),
|
|
286
|
+
method: z.string().max(100).optional().nullable(),
|
|
287
|
+
reference: z.string().max(200).optional().nullable(),
|
|
288
|
+
});
|
|
289
|
+
export const handoffAdvanceAttributesSchema = z.object({
|
|
290
|
+
amount: z.number().positive(),
|
|
291
|
+
holderType: tradeSourcingAdvanceHolderTypeSchema,
|
|
292
|
+
holderId: z.string().max(100).optional().nullable(),
|
|
293
|
+
holderName: z.string().min(1).max(200),
|
|
294
|
+
occurredAt: z.string().datetime(),
|
|
295
|
+
notes: z.string().optional().nullable(),
|
|
296
|
+
});
|
|
297
|
+
export const advanceSettlementLineSchema = z.object({
|
|
298
|
+
outcome: advanceSettlementOutcomeSchema,
|
|
299
|
+
amount: z.number().positive(),
|
|
300
|
+
supplierName: z.string().max(200).optional().nullable(),
|
|
301
|
+
supplierId: z.string().max(100).optional().nullable(),
|
|
302
|
+
dealId: z.string().uuid().optional().nullable(),
|
|
303
|
+
purchaseOrderId: z.string().uuid().optional().nullable(),
|
|
304
|
+
proofRef: z.string().max(200).optional().nullable(),
|
|
305
|
+
notes: z.string().optional().nullable(),
|
|
306
|
+
});
|
|
307
|
+
export const submitAdvanceSettlementAttributesSchema = z.object({
|
|
308
|
+
lines: z.array(advanceSettlementLineSchema).min(1),
|
|
309
|
+
notes: z.string().optional().nullable(),
|
|
310
|
+
});
|
|
311
|
+
export const approveAdvanceSettlementAttributesSchema = z.object({
|
|
312
|
+
occurredAt: z.string().datetime(),
|
|
313
|
+
notes: z.string().optional().nullable(),
|
|
314
|
+
});
|
|
315
|
+
export const writeoffAdvanceAttributesSchema = z.object({
|
|
316
|
+
amount: z.number().positive(),
|
|
317
|
+
reason: z.string().min(1).max(500),
|
|
318
|
+
occurredAt: z.string().datetime(),
|
|
319
|
+
});
|
|
320
|
+
export const tradeSourcingAdvanceResourceSchema = createJsonApiResourceSchema('trade-sourcing-advances', tradeSourcingAdvanceAttributesSchema);
|
|
321
|
+
export const tradeSourcingAdvanceResponseSchema = jsonApiSingleResponseSchema(tradeSourcingAdvanceResourceSchema);
|
|
322
|
+
export const tradeSourcingAdvanceListResponseSchema = jsonApiCollectionResponseSchema(tradeSourcingAdvanceResourceSchema);
|
|
323
|
+
export const createSourcingAdvanceSchema = z.object({
|
|
324
|
+
type: z.literal('trade-sourcing-advances'),
|
|
325
|
+
attributes: createSourcingAdvanceAttributesSchema,
|
|
326
|
+
});
|
|
327
|
+
export const handoffAdvanceSchema = z.object({
|
|
328
|
+
type: z.literal('trade-sourcing-advances'),
|
|
329
|
+
attributes: handoffAdvanceAttributesSchema,
|
|
330
|
+
});
|
|
331
|
+
export const submitAdvanceSettlementSchema = z.object({
|
|
332
|
+
type: z.literal('trade-sourcing-settlement-requests'),
|
|
333
|
+
attributes: submitAdvanceSettlementAttributesSchema,
|
|
334
|
+
});
|
|
335
|
+
export const approveAdvanceSettlementSchema = z.object({
|
|
336
|
+
type: z.literal('trade-sourcing-settlement-requests'),
|
|
337
|
+
attributes: approveAdvanceSettlementAttributesSchema,
|
|
338
|
+
});
|
|
339
|
+
export const writeoffAdvanceSchema = z.object({
|
|
340
|
+
type: z.literal('trade-sourcing-advances'),
|
|
341
|
+
attributes: writeoffAdvanceAttributesSchema,
|
|
342
|
+
});
|