@deepintel-ltd/farmpro-contracts 1.5.19 → 1.5.21

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 @@
1
+ {"version":3,"file":"invoices.schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/invoices.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB;;GAEG;AAGH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;EAM5B,CAAC;AAGH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BV,CAAC;AAG3B,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBxC,CAAC;AAGH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAExC,CAAC;AAGH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG9B,CAAC;AAGH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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M,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AACpF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AACpF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACrE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACrE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { z } from 'zod';
2
+ import { timestampsSchema, createJsonApiResourceSchema, jsonApiSingleResponseSchema, jsonApiCollectionResponseSchema } from './common.schemas';
3
+ /**
4
+ * Invoice schemas - JSON:API compliant
5
+ */
6
+ // Invoice item schema
7
+ export const invoiceItemSchema = z.object({
8
+ description: z.string().min(1).max(500),
9
+ quantity: z.number().positive(),
10
+ unitPrice: z.number().nonnegative(),
11
+ amount: z.number().nonnegative(),
12
+ taxRate: z.number().min(0).max(100).optional(),
13
+ });
14
+ // Invoice attributes schema
15
+ export const invoiceAttributesSchema = z.object({
16
+ invoiceNumber: z.string().min(1).max(100),
17
+ issueDate: z.string().datetime(),
18
+ dueDate: z.string().datetime().optional().nullable(),
19
+ billFromName: z.string().min(1).max(200),
20
+ billFromAddress: z.string().optional().nullable(),
21
+ billFromPhone: z.string().optional().nullable(),
22
+ billFromEmail: z.string().email().optional().nullable(),
23
+ billFromTaxId: z.string().optional().nullable(),
24
+ billToName: z.string().min(1).max(200),
25
+ billToAddress: z.string().optional().nullable(),
26
+ billToPhone: z.string().optional().nullable(),
27
+ billToEmail: z.string().email().optional().nullable(),
28
+ billToTaxId: z.string().optional().nullable(),
29
+ items: z.array(invoiceItemSchema).min(1),
30
+ subtotal: z.number().nonnegative(),
31
+ taxRate: z.number().min(0).max(100).optional().nullable(),
32
+ taxAmount: z.number().nonnegative().optional().nullable(),
33
+ discount: z.number().nonnegative().optional().nullable(),
34
+ total: z.number().nonnegative(),
35
+ currency: z.string().length(3).default('NGN'),
36
+ paymentTerms: z.string().optional().nullable(),
37
+ paymentStatus: z.enum(['pending', 'paid', 'overdue', 'cancelled']).default('pending'),
38
+ paidAt: z.string().datetime().optional().nullable(),
39
+ notes: z.string().optional().nullable(),
40
+ pdfUrl: z.string().url().optional().nullable(),
41
+ organizationId: z.string().uuid(),
42
+ createdAt: z.string().datetime(),
43
+ updatedAt: z.string().datetime(),
44
+ }).merge(timestampsSchema);
45
+ // Invoice attributes for creation (input)
46
+ export const createInvoiceAttributesSchema = z.object({
47
+ issueDate: z.string().datetime().optional(),
48
+ dueDate: z.string().datetime().optional(),
49
+ billFromName: z.string().min(1).max(200),
50
+ billFromAddress: z.string().optional(),
51
+ billFromPhone: z.string().optional(),
52
+ billFromEmail: z.string().email().optional(),
53
+ billFromTaxId: z.string().optional(),
54
+ billToName: z.string().min(1).max(200),
55
+ billToAddress: z.string().optional(),
56
+ billToPhone: z.string().optional(),
57
+ billToEmail: z.string().email().optional(),
58
+ billToTaxId: z.string().optional(),
59
+ items: z.array(invoiceItemSchema).min(1),
60
+ taxRate: z.number().min(0).max(100).optional(),
61
+ discount: z.number().nonnegative().optional(),
62
+ currency: z.string().length(3).default('NGN'),
63
+ paymentTerms: z.string().optional(),
64
+ notes: z.string().optional(),
65
+ });
66
+ // Invoice attributes for update (input)
67
+ export const updateInvoiceAttributesSchema = createInvoiceAttributesSchema.partial().extend({
68
+ paymentStatus: z.enum(['pending', 'paid', 'overdue', 'cancelled']).optional(),
69
+ });
70
+ // Create invoice input (JSON:API format)
71
+ export const createInvoiceSchema = z.object({
72
+ type: z.literal('invoices'),
73
+ attributes: createInvoiceAttributesSchema,
74
+ });
75
+ // Update invoice input (JSON:API format)
76
+ export const updateInvoiceSchema = z.object({
77
+ type: z.literal('invoices'),
78
+ id: z.string().uuid(),
79
+ attributes: updateInvoiceAttributesSchema,
80
+ });
81
+ // Invoice resource (JSON:API resource object)
82
+ export const invoiceResourceSchema = createJsonApiResourceSchema('invoices', invoiceAttributesSchema);
83
+ // Invoice responses (JSON:API format)
84
+ export const invoiceResponseSchema = jsonApiSingleResponseSchema(invoiceResourceSchema);
85
+ export const invoiceListResponseSchema = jsonApiCollectionResponseSchema(invoiceResourceSchema);