@managemint-solutions/entities 1.36.0 → 1.46.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.
Files changed (39) hide show
  1. package/dist/audit-trail/enum/index.d.ts +13 -3
  2. package/dist/audit-trail/enum/index.js +10 -0
  3. package/dist/audit-trail/index.d.ts +14 -1
  4. package/dist/clients/dto/index.d.ts +5 -2
  5. package/dist/clients/index.d.ts +17 -1
  6. package/dist/documents/dto/index.d.ts +148 -0
  7. package/dist/documents/dto/index.js +2 -0
  8. package/dist/documents/enum/index.d.ts +127 -0
  9. package/dist/documents/enum/index.js +140 -0
  10. package/dist/documents/index.d.ts +390 -0
  11. package/dist/documents/index.js +2 -0
  12. package/dist/leads/index.d.ts +2 -0
  13. package/dist/notifications/enum/index.d.ts +4 -0
  14. package/dist/notifications/enum/index.js +4 -0
  15. package/dist/organization/payouts/dto/index.d.ts +15 -0
  16. package/dist/organization/payouts/dto/index.js +2 -0
  17. package/dist/organization/payouts/enum/index.d.ts +11 -0
  18. package/dist/organization/payouts/enum/index.js +16 -0
  19. package/dist/organization/payouts/index.d.ts +21 -0
  20. package/dist/organization/payouts/index.js +2 -0
  21. package/dist/payments/enum/index.d.ts +22 -0
  22. package/dist/payments/enum/index.js +29 -0
  23. package/dist/payments/index.d.ts +25 -0
  24. package/dist/payments/index.js +2 -0
  25. package/dist/paystack/enum/index.d.ts +8 -0
  26. package/dist/paystack/enum/index.js +11 -1
  27. package/dist/paystack/index.d.ts +63 -6
  28. package/dist/paystack/webhook/index.d.ts +9 -2
  29. package/dist/projects/index.d.ts +2 -0
  30. package/dist/tasks/index.d.ts +2 -0
  31. package/dist/users/index.d.ts +1 -0
  32. package/dist/users/permissions/dto/index.d.ts +4 -0
  33. package/dist/visibility/dto/index.d.ts +13 -0
  34. package/dist/visibility/dto/index.js +2 -0
  35. package/dist/visibility/enum/index.d.ts +17 -0
  36. package/dist/visibility/enum/index.js +22 -0
  37. package/dist/visibility/index.d.ts +13 -0
  38. package/dist/visibility/index.js +2 -0
  39. package/package.json +1 -1
@@ -0,0 +1,390 @@
1
+ import type { UUID } from 'crypto';
2
+ import type { ClientIdentity } from '../clients';
3
+ import type { OrganizationIdentity } from '../organization';
4
+ import type { Payment } from '../payments';
5
+ import type { UserIdentity } from '../users';
6
+ import type { VisibilityRole } from '../visibility/enum';
7
+ import { DocumentBlockType, DocumentChangeKind, DocumentPaymentStatus, DocumentPayStatus, DocumentRepeat, DocumentStatus, DocumentVariableType, DocumentVisibility } from './enum';
8
+ /**
9
+ * A filled-in value: text and dates (YYYY-MM-DD) as strings, numbers as numbers, money as
10
+ * integer cents.
11
+ */
12
+ export type DocumentVariableValue = string | number;
13
+ /**
14
+ * One input a template asks for. Blocks refer to it by `key`: `{{key}}` inside plain text
15
+ * (fields, table cells, line descriptions, signer labels) and a variable node inside rich text.
16
+ * Keys are lower snake_case and unique within the template.
17
+ */
18
+ export type DocumentVariable = {
19
+ key: string;
20
+ label: string;
21
+ type: DocumentVariableType;
22
+ /** A document cannot be issued while a required variable has no value. */
23
+ required: boolean;
24
+ /** Prefills the input when a document is created from the template. */
25
+ default_value: DocumentVariableValue | null;
26
+ };
27
+ /**
28
+ * A document's filled-in values, by variable key: its template variables, and once it is
29
+ * issued the system variables too (DocumentSystemVariable), frozen at issue.
30
+ */
31
+ export type DocumentVariableValues = Record<string, DocumentVariableValue>;
32
+ /** What every block carries: a stable id (kept across edits and reorders) and its type. */
33
+ type DocumentBlockBase<T extends DocumentBlockType> = {
34
+ id: string;
35
+ type: T;
36
+ };
37
+ /**
38
+ * Rich text in the editor's own JSON (ProseMirror): paragraphs, headings, bullet and numbered
39
+ * lists, bold, italic, underline, links, and `{ "type": "variable", "attrs": { "key": "..." } }`
40
+ * nodes. Only those node and mark types are accepted; the sdk refuses anything else.
41
+ */
42
+ export type DocumentRichText = {
43
+ type: 'doc';
44
+ content: unknown[];
45
+ };
46
+ export type DocumentTextBlock = DocumentBlockBase<DocumentBlockType.TEXT> & {
47
+ content: DocumentRichText;
48
+ };
49
+ export type DocumentFieldsBlock = DocumentBlockBase<DocumentBlockType.FIELDS> & {
50
+ fields: {
51
+ label: string;
52
+ value: string;
53
+ }[];
54
+ };
55
+ /** A number written into the line, or the key of a number or money variable to take it from. */
56
+ export type DocumentLineAmount = number | {
57
+ variable: string;
58
+ };
59
+ export type DocumentLineItem = {
60
+ description: string;
61
+ quantity: DocumentLineAmount;
62
+ /** Integer cents, or a money variable. */
63
+ unit_price_minor: DocumentLineAmount;
64
+ /** 0 to 100. */
65
+ discount_percent: number;
66
+ /** 0 to 100. */
67
+ tax_rate: number;
68
+ };
69
+ /** Prints its lines and their totals; a document's totals are the sum of its line items blocks. */
70
+ export type DocumentLineItemsBlock = DocumentBlockBase<DocumentBlockType.LINE_ITEMS> & {
71
+ items: DocumentLineItem[];
72
+ };
73
+ export type DocumentTableBlock = DocumentBlockBase<DocumentBlockType.TABLE> & {
74
+ /** The header row. */
75
+ columns: string[];
76
+ /** One array of cells per row, each as long as `columns`. */
77
+ rows: string[][];
78
+ };
79
+ export type DocumentSignatureBlock = DocumentBlockBase<DocumentBlockType.SIGNATURE> & {
80
+ /** One signature line per party, labelled, e.g. "Client" or "{{organization_name}}". */
81
+ signers: {
82
+ label: string;
83
+ }[];
84
+ };
85
+ export type DocumentImageBlock = DocumentBlockBase<DocumentBlockType.IMAGE> & {
86
+ /**
87
+ * The uploaded file's storage path inside the organization's folder, as the upload target
88
+ * returned it (`documents/images/<id>.png`); empty until an image is uploaded.
89
+ */
90
+ path: string;
91
+ alt: string;
92
+ };
93
+ /** Where the browser puts an image block's file, and the `path` the block then stores. */
94
+ export type DocumentImageUploadTarget = {
95
+ path: string;
96
+ /** A signed upload URL for one PUT of the file's bytes. */
97
+ url: string;
98
+ };
99
+ export type DocumentPageBreakBlock = DocumentBlockBase<DocumentBlockType.PAGE_BREAK>;
100
+ /**
101
+ * Two or three columns side by side - "Bill from" and "Bill to" on an invoice. Each is a heading
102
+ * and plain text with `{{key}}` variables and its line breaks kept; the text's first line prints
103
+ * as a name.
104
+ */
105
+ export type DocumentColumnsBlock = DocumentBlockBase<DocumentBlockType.COLUMNS> & {
106
+ columns: {
107
+ heading: string;
108
+ text: string;
109
+ }[];
110
+ };
111
+ /**
112
+ * Text repeated on every PDF page, wherever the block sits in the list - the renderer takes it
113
+ * out of the flow. Either side may be empty. Plain text with `{{key}}` variables, and the only
114
+ * place `{{page_number}}` and `{{page_count}}` may be used. At most one header and one footer.
115
+ */
116
+ type DocumentBandBlock<T extends DocumentBlockType.HEADER | DocumentBlockType.FOOTER> = DocumentBlockBase<T> & {
117
+ left: string;
118
+ right: string;
119
+ };
120
+ export type DocumentHeaderBlock = DocumentBandBlock<DocumentBlockType.HEADER>;
121
+ export type DocumentFooterBlock = DocumentBandBlock<DocumentBlockType.FOOTER>;
122
+ export type DocumentBlock = DocumentTextBlock | DocumentFieldsBlock | DocumentLineItemsBlock | DocumentTableBlock | DocumentSignatureBlock | DocumentImageBlock | DocumentPageBreakBlock | DocumentHeaderBlock | DocumentFooterBlock | DocumentColumnsBlock;
123
+ export type DocumentTemplateIdentity = {
124
+ mms_id: UUID;
125
+ name: string;
126
+ };
127
+ export type DocumentTemplateSummary = {
128
+ mms_id: UUID;
129
+ created_at: Date;
130
+ name: string;
131
+ category: string;
132
+ number_prefix: string;
133
+ archived: boolean;
134
+ visibility: DocumentVisibility;
135
+ /** Present on staff reads only. */
136
+ organization?: OrganizationIdentity;
137
+ };
138
+ /**
139
+ * A reusable layout: an ordered list of blocks and the variables they use. Editing a template
140
+ * never changes a document already made from it - each document keeps its own copy.
141
+ */
142
+ export type DocumentTemplateEntity = {
143
+ mms_id: UUID;
144
+ created_at: Date;
145
+ created_by: UserIdentity | null;
146
+ updated_at: Date | null;
147
+ last_updated_by: UserIdentity | null;
148
+ name: string;
149
+ /** The organization's own word for grouping and filtering (Invoice, Service Agreement). */
150
+ category: string;
151
+ /** Copied onto each document made from the template; documents are numbered per prefix. */
152
+ number_prefix: string;
153
+ variables: DocumentVariable[];
154
+ blocks: DocumentBlock[];
155
+ /** Which version of the block shapes `blocks` was written in. */
156
+ blocks_version: number;
157
+ archived: boolean;
158
+ archived_at: Date | null;
159
+ archived_by: UserIdentity | null;
160
+ visibility: DocumentVisibility;
161
+ /**
162
+ * What the caller may do with it, worked out by the api: the creator and an admin share are
163
+ * ADMIN; on an organization-visible record it follows the documents permissions.
164
+ */
165
+ my_role: VisibilityRole;
166
+ /** Present on staff reads only. */
167
+ organization?: OrganizationIdentity;
168
+ };
169
+ /** A document as another one names it - a draft's recurring parent. */
170
+ export type DocumentIdentity = {
171
+ mms_id: UUID;
172
+ title: string;
173
+ };
174
+ /**
175
+ * The email a document is sent in by the daily cron: on a recurring parent (copied onto each
176
+ * draft it makes) or on any draft with an `issue_at`. `subject` and `message` may use `{{key}}`
177
+ * variables - `{{document_number}}` included - filled from the document's values when it is sent.
178
+ */
179
+ export type DocumentEmail = {
180
+ /** 1 to 5 addresses. */
181
+ to: string[];
182
+ /** 0 to 5 addresses. */
183
+ cc?: string[];
184
+ subject: string;
185
+ message: string;
186
+ /** Honoured only when the document is payable on the day. */
187
+ pay_now: boolean;
188
+ };
189
+ /**
190
+ * The repeat and schedule columns a summary and an entity share. A recurring parent has
191
+ * `repeat`; a draft it made has `repeat_from` and `issue_at`.
192
+ */
193
+ export type DocumentSchedule = {
194
+ /** Set on a recurring parent only; null on every other document. */
195
+ repeat: DocumentRepeat | null;
196
+ /** The next issue date the parent drafts for (its draft is made three days before); null once ended. */
197
+ repeat_next_at: string | null;
198
+ /** The last date a draft may be issued on; null runs on. */
199
+ repeat_until: string | null;
200
+ repeat_paused: boolean;
201
+ /** On a draft the cron made: the parent it came from. */
202
+ repeat_from: DocumentIdentity | null;
203
+ /** A draft the cron issues and sends on this date (YYYY-MM-DD, Africa/Johannesburg). */
204
+ issue_at: string | null;
205
+ };
206
+ export type DocumentSummary = DocumentSchedule & {
207
+ mms_id: UUID;
208
+ created_at: Date;
209
+ title: string;
210
+ category: string;
211
+ status: DocumentStatus;
212
+ /** What prints, e.g. INV-0042; null until issued. */
213
+ number: string | null;
214
+ client: ClientIdentity | null;
215
+ /** Null when the document has no line items. */
216
+ currency: string | null;
217
+ total_minor: number;
218
+ issued_at: Date | null;
219
+ visibility: DocumentVisibility;
220
+ /** Null unless issued with a total above zero; then unpaid, paid or paid twice. */
221
+ payment_status: DocumentPaymentStatus | null;
222
+ /** Present on staff reads only. */
223
+ organization?: OrganizationIdentity;
224
+ };
225
+ /**
226
+ * A document is its blocks plus its values: printing always combines the two the same way.
227
+ * A draft is edited freely; issuing gives it a number, freezes the system variables into
228
+ * `variable_values`, and it never changes again - it can only be voided.
229
+ */
230
+ export type DocumentEntity = DocumentSchedule & {
231
+ mms_id: UUID;
232
+ created_at: Date;
233
+ created_by: UserIdentity | null;
234
+ updated_at: Date | null;
235
+ last_updated_by: UserIdentity | null;
236
+ /** The template it was made from; null for a blank document or once that template is deleted. */
237
+ template: DocumentTemplateIdentity | null;
238
+ client: ClientIdentity | null;
239
+ category: string;
240
+ title: string;
241
+ status: DocumentStatus;
242
+ number_prefix: string;
243
+ number: string | null;
244
+ currency: string | null;
245
+ /** The definitions copied from the template, so a later template edit cannot break a draft. */
246
+ variables: DocumentVariable[];
247
+ variable_values: DocumentVariableValues;
248
+ blocks: DocumentBlock[];
249
+ blocks_version: number;
250
+ /** Worked out from the line items blocks; all zero for a document without any. */
251
+ subtotal_minor: number;
252
+ discount_minor: number;
253
+ tax_minor: number;
254
+ total_minor: number;
255
+ issued_at: Date | null;
256
+ issued_by: UserIdentity | null;
257
+ voided_at: Date | null;
258
+ voided_by: UserIdentity | null;
259
+ void_reason: string | null;
260
+ visibility: DocumentVisibility;
261
+ /**
262
+ * The money received for it, oldest first: empty while unpaid, one payment once paid in full,
263
+ * two when two people paid at once (the owner refunds one). Read by the api beside the document.
264
+ */
265
+ payments: Payment[];
266
+ /** The same as on the summary, from `payments`. */
267
+ payment_status: DocumentPaymentStatus | null;
268
+ /** What the cron sends it in; null when there is none. */
269
+ email: DocumentEmail | null;
270
+ /** On a recurring parent: how many drafts it has made; null on every other document. */
271
+ issued_count: number | null;
272
+ /**
273
+ * Whether a send may carry Pay now, worked out by the api: in rands, a total above zero, not
274
+ * void, no payment yet, and the organization's payouts set up. On a draft: once it is issued.
275
+ * The send form starts with Pay now on when this is true.
276
+ */
277
+ pay_now_available: boolean;
278
+ /**
279
+ * What the caller may do with it, worked out by the api: the creator and an admin share are
280
+ * ADMIN; on an organization-visible record it follows the documents permissions.
281
+ */
282
+ my_role: VisibilityRole;
283
+ /** Present on staff reads only. */
284
+ organization?: OrganizationIdentity;
285
+ };
286
+ /**
287
+ * One email a document went out in, newest first on `GET /documents/:id/sends` - read from the
288
+ * document's history, where each send is an audit event (`AuditTrailAction.SEND`).
289
+ */
290
+ export type DocumentSend = {
291
+ mms_id: UUID;
292
+ created_at: Date;
293
+ created_by: UserIdentity | null;
294
+ recipients: string[];
295
+ cc: string[];
296
+ /** As sent, its variables filled in. */
297
+ subject: string;
298
+ /** Whether the email carried the pay link. */
299
+ pay_now: boolean;
300
+ };
301
+ /** What the public pay page shows - nothing that is not on the PDF itself, bar how to reach the sender. */
302
+ export type PublicDocumentPayment = {
303
+ organization_name: string;
304
+ /** Where the client's questions go; null when the organization has none on file. */
305
+ organization_email: string | null;
306
+ organization_phone: string | null;
307
+ title: string;
308
+ number: string;
309
+ /** The date it was issued, YYYY-MM-DD, as frozen on it. */
310
+ issue_date: string | null;
311
+ /** Who it is billed to; null without a client. */
312
+ client_name: string | null;
313
+ /** Integer cents. Subtotal and tax are null when the document has no line items. */
314
+ subtotal_minor: number | null;
315
+ tax_minor: number | null;
316
+ total_minor: number;
317
+ currency: string | null;
318
+ status: DocumentPayStatus;
319
+ /** Prefills the payer's email; null when the document has no client email. */
320
+ client_email: string | null;
321
+ };
322
+ /** Where the payer goes next: Paystack's hosted checkout. */
323
+ export type DocumentCheckout = {
324
+ authorization_url: string;
325
+ };
326
+ /** One side of a recorded change: plain text, a number (money in integer cents), a flag, or nothing. */
327
+ export type DocumentChangeValue = string | number | boolean | null;
328
+ /**
329
+ * One printable part of a block before and after a save, stored whole however long it is.
330
+ * `path` says where in the block it sits: the block's property, then for a list the entry's
331
+ * 0-based index (in the newer list; in the older one for an entry that was removed), then the
332
+ * entry's property or, in a table row, the cell's 0-based column:
333
+ *
334
+ * ['content'] a text block's text, as plain text with `{{key}}` for variables
335
+ * ['fields', 1, 'value'] a fields block's second value
336
+ * ['items', 0, 'quantity'] a line's quantity (`unit_price_minor` in cents; a variable amount as `{{key}}`)
337
+ * ['columns', 2] a table's third column heading
338
+ * ['rows', 0, 3] a table's first row, fourth cell
339
+ * ['columns', 0, 'heading'] a columns block's first heading (`text` for its text)
340
+ * ['signers', 1, 'label'] a signature block's second signer
341
+ * ['left'], ['right'] a header's or footer's sides
342
+ * ['alt'], ['path'] an image's alt text and file
343
+ */
344
+ export type DocumentBlockPartChange = {
345
+ path: (string | number)[];
346
+ old: DocumentChangeValue;
347
+ new: DocumentChangeValue;
348
+ };
349
+ /**
350
+ * One block a save touched. `from` and `to` are 1-based places in the list before and after
351
+ * (null on the side it was not in). An added block lists every part it holds with `old: null`;
352
+ * a removed one every part with `new: null`; a moved one no parts; a changed one the parts that
353
+ * changed, and its `from` and `to` differ when it also moved. A block that only shifted because
354
+ * another was added or removed above it is not recorded.
355
+ */
356
+ export type DocumentBlockChange = {
357
+ id: string;
358
+ type: DocumentBlockType;
359
+ kind: DocumentChangeKind;
360
+ from: number | null;
361
+ to: number | null;
362
+ parts: DocumentBlockPartChange[];
363
+ };
364
+ /**
365
+ * One variable definition a save touched, by key. `label` is its label now (as it was, when
366
+ * removed). An added variable lists every property with `old: null`, a removed one with
367
+ * `new: null`, a changed one the properties that changed. Order changes are not recorded.
368
+ */
369
+ export type DocumentVariableChange = {
370
+ key: string;
371
+ label: string;
372
+ kind: DocumentChangeKind;
373
+ parts: {
374
+ field: 'label' | 'type' | 'required' | 'default_value';
375
+ old: DocumentChangeValue;
376
+ new: DocumentChangeValue;
377
+ }[];
378
+ };
379
+ /**
380
+ * One filled-in value a save changed, by key, with the variable's label and type at the time
381
+ * (both null for a system variable frozen at issue). Money is integer cents, a date YYYY-MM-DD.
382
+ */
383
+ export type DocumentValueChange = {
384
+ key: string;
385
+ label: string | null;
386
+ type: DocumentVariableType | null;
387
+ old: DocumentVariableValue | null;
388
+ new: DocumentVariableValue | null;
389
+ };
390
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -61,4 +61,6 @@ export type LeadEntity = {
61
61
  deleted_by: UserIdentity | null;
62
62
  restored_at: Date | null;
63
63
  restored_by: UserIdentity | null;
64
+ /** Present on staff reads only. */
65
+ organization?: OrganizationIdentity;
64
66
  };
@@ -21,6 +21,10 @@ export declare enum NotificationType {
21
21
  TIMESHEET_SUBMITTED = "timesheet_submitted",
22
22
  TIMESHEET_APPROVED = "timesheet_approved",
23
23
  TIMESHEET_REJECTED = "timesheet_rejected",
24
+ DOCUMENT_PAID = "document_paid",
25
+ DOCUMENT_DRAFT_READY = "document_draft_ready",
26
+ DOCUMENT_ISSUED_AUTOMATICALLY = "document_issued_automatically",
27
+ DOCUMENT_ISSUE_FAILED = "document_issue_failed",
24
28
  SIGNUP_CONFIRMATION = "signup_confirmation",
25
29
  PASSWORD_RECOVERY = "password_recovery"
26
30
  }
@@ -29,6 +29,10 @@ var NotificationType;
29
29
  NotificationType["TIMESHEET_SUBMITTED"] = "timesheet_submitted";
30
30
  NotificationType["TIMESHEET_APPROVED"] = "timesheet_approved";
31
31
  NotificationType["TIMESHEET_REJECTED"] = "timesheet_rejected";
32
+ NotificationType["DOCUMENT_PAID"] = "document_paid";
33
+ NotificationType["DOCUMENT_DRAFT_READY"] = "document_draft_ready";
34
+ NotificationType["DOCUMENT_ISSUED_AUTOMATICALLY"] = "document_issued_automatically";
35
+ NotificationType["DOCUMENT_ISSUE_FAILED"] = "document_issue_failed";
32
36
  NotificationType["SIGNUP_CONFIRMATION"] = "signup_confirmation";
33
37
  NotificationType["PASSWORD_RECOVERY"] = "password_recovery";
34
38
  })(NotificationType || (exports.NotificationType = NotificationType = {}));
@@ -0,0 +1,15 @@
1
+ import { PayoutAccountType, PayoutDocumentType } from '../enum';
2
+ /**
3
+ * Sets up payouts, or changes the account: Paystack checks the account against the holder's
4
+ * identity document first, then the organization's subaccount is created or updated.
5
+ */
6
+ export type UpdateOrganizationPayoutsDto = {
7
+ /** The account holder's name as the bank has it; also the name Paystack settles under. */
8
+ business_name: string;
9
+ account_type: PayoutAccountType;
10
+ /** A `PayoutBank.code`. */
11
+ bank_code: string;
12
+ account_number: string;
13
+ document_type: PayoutDocumentType;
14
+ document_number: string;
15
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ /** Whose bank account the payouts go to, as Paystack's account check names it. */
2
+ export declare enum PayoutAccountType {
3
+ PERSONAL = "personal",
4
+ BUSINESS = "business"
5
+ }
6
+ /** The identity document Paystack checks the account holder against. */
7
+ export declare enum PayoutDocumentType {
8
+ IDENTITY_NUMBER = "identityNumber",
9
+ PASSPORT_NUMBER = "passportNumber",
10
+ BUSINESS_REGISTRATION_NUMBER = "businessRegistrationNumber"
11
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PayoutDocumentType = exports.PayoutAccountType = void 0;
4
+ /** Whose bank account the payouts go to, as Paystack's account check names it. */
5
+ var PayoutAccountType;
6
+ (function (PayoutAccountType) {
7
+ PayoutAccountType["PERSONAL"] = "personal";
8
+ PayoutAccountType["BUSINESS"] = "business";
9
+ })(PayoutAccountType || (exports.PayoutAccountType = PayoutAccountType = {}));
10
+ /** The identity document Paystack checks the account holder against. */
11
+ var PayoutDocumentType;
12
+ (function (PayoutDocumentType) {
13
+ PayoutDocumentType["IDENTITY_NUMBER"] = "identityNumber";
14
+ PayoutDocumentType["PASSPORT_NUMBER"] = "passportNumber";
15
+ PayoutDocumentType["BUSINESS_REGISTRATION_NUMBER"] = "businessRegistrationNumber";
16
+ })(PayoutDocumentType || (exports.PayoutDocumentType = PayoutDocumentType = {}));
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Where an organization's Pay now money settles, as the organization page shows it: the bank
3
+ * and the account's last four digits, never the whole number. Pay now runs on the platform's
4
+ * Paystack account through a subaccount per organization; `enabled` is whether it has one.
5
+ */
6
+ export type OrganizationPayouts = {
7
+ enabled: boolean;
8
+ business_name: string | null;
9
+ bank_name: string | null;
10
+ account_last4: string | null;
11
+ /**
12
+ * The platform's cut of each Pay now payment, in percent (0 when there is none) - on top of
13
+ * Paystack's own fee, which the organization bears. What the page says about fees reads this.
14
+ */
15
+ platform_fee_percent: number;
16
+ };
17
+ /** A South African bank payouts can settle to; `code` is what the form sends back. */
18
+ export type PayoutBank = {
19
+ code: string;
20
+ name: string;
21
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,22 @@
1
+ /** Which way the money went. Stored as plain text; TypeScript is the value set. */
2
+ export declare enum PaymentDirection {
3
+ /** Received by the organization - a client paying a document. */
4
+ INCOMING = "incoming"
5
+ }
6
+ /** What a payment is for: the record's own table, as `payments.entity_type` stores it. */
7
+ export declare enum PaymentEntityType {
8
+ DOCUMENTS = "documents"
9
+ }
10
+ /** How the money arrived. */
11
+ export declare enum PaymentMethod {
12
+ /** Paystack checkout on the platform account, settled to the organization's subaccount. */
13
+ PAYSTACK = "paystack",
14
+ /** A bank transfer the organization received and marked paid by hand. */
15
+ EFT = "eft"
16
+ }
17
+ /** Where a payment is in its life. Stored as plain text. */
18
+ export declare enum PaymentStatus {
19
+ /** A checkout is under way: every Pay now click reopens it until it is paid or fails. */
20
+ OPEN = "open",
21
+ PAID = "paid"
22
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PaymentStatus = exports.PaymentMethod = exports.PaymentEntityType = exports.PaymentDirection = void 0;
4
+ /** Which way the money went. Stored as plain text; TypeScript is the value set. */
5
+ var PaymentDirection;
6
+ (function (PaymentDirection) {
7
+ /** Received by the organization - a client paying a document. */
8
+ PaymentDirection["INCOMING"] = "incoming";
9
+ })(PaymentDirection || (exports.PaymentDirection = PaymentDirection = {}));
10
+ /** What a payment is for: the record's own table, as `payments.entity_type` stores it. */
11
+ var PaymentEntityType;
12
+ (function (PaymentEntityType) {
13
+ PaymentEntityType["DOCUMENTS"] = "documents";
14
+ })(PaymentEntityType || (exports.PaymentEntityType = PaymentEntityType = {}));
15
+ /** How the money arrived. */
16
+ var PaymentMethod;
17
+ (function (PaymentMethod) {
18
+ /** Paystack checkout on the platform account, settled to the organization's subaccount. */
19
+ PaymentMethod["PAYSTACK"] = "paystack";
20
+ /** A bank transfer the organization received and marked paid by hand. */
21
+ PaymentMethod["EFT"] = "eft";
22
+ })(PaymentMethod || (exports.PaymentMethod = PaymentMethod = {}));
23
+ /** Where a payment is in its life. Stored as plain text. */
24
+ var PaymentStatus;
25
+ (function (PaymentStatus) {
26
+ /** A checkout is under way: every Pay now click reopens it until it is paid or fails. */
27
+ PaymentStatus["OPEN"] = "open";
28
+ PaymentStatus["PAID"] = "paid";
29
+ })(PaymentStatus || (exports.PaymentStatus = PaymentStatus = {}));
@@ -0,0 +1,25 @@
1
+ import type { UUID } from 'crypto';
2
+ import type { UserIdentity } from '../users';
3
+ import { PaymentDirection, PaymentMethod, PaymentStatus } from './enum';
4
+ /**
5
+ * Money received for a record (a document, today), written by the api alone: an open Paystack
6
+ * checkout, then the settled payment - or an EFT the organization marked paid by hand. A second
7
+ * payment for the same record is a second row.
8
+ */
9
+ export type Payment = {
10
+ mms_id: UUID;
11
+ created_at: Date;
12
+ /** Who marked it paid by hand; null for a payment Paystack settled. */
13
+ created_by: UserIdentity | null;
14
+ direction: PaymentDirection;
15
+ status: PaymentStatus;
16
+ /** Integer cents. */
17
+ amount_minor: number;
18
+ currency: string;
19
+ method: PaymentMethod;
20
+ /** Paystack's reference (unique), or the organization's own bank reference for an EFT. */
21
+ reference: string | null;
22
+ payer_email: string | null;
23
+ /** Null while open. */
24
+ paid_at: Date | null;
25
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -37,3 +37,11 @@ export declare enum PaystackTransactionStatus {
37
37
  SEND_OTP = "send_otp",
38
38
  ABANDONED = "abandoned"
39
39
  }
40
+ /**
41
+ * What a charge the api initialized is for, carried as `metadata.kind`. Subscription charges
42
+ * carry `transactionId` instead.
43
+ */
44
+ export declare enum PaystackChargeKind {
45
+ /** A document's Pay now checkout, settled to the organization's subaccount. */
46
+ DOCUMENT_PAYMENT = "document_payment"
47
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PaystackTransactionStatus = exports.PaystackSubscriptionStatus = exports.PaystackWebhookEvent = void 0;
3
+ exports.PaystackChargeKind = exports.PaystackTransactionStatus = exports.PaystackSubscriptionStatus = exports.PaystackWebhookEvent = void 0;
4
4
  var PaystackWebhookEvent;
5
5
  (function (PaystackWebhookEvent) {
6
6
  PaystackWebhookEvent["INVOICE_CREATED"] = "invoice.create";
@@ -46,3 +46,13 @@ var PaystackTransactionStatus;
46
46
  PaystackTransactionStatus["ABANDONED"] = "abandoned";
47
47
  })(PaystackTransactionStatus || (exports.PaystackTransactionStatus = PaystackTransactionStatus = {}));
48
48
  ;
49
+ /**
50
+ * What a charge the api initialized is for, carried as `metadata.kind`. Subscription charges
51
+ * carry `transactionId` instead.
52
+ */
53
+ var PaystackChargeKind;
54
+ (function (PaystackChargeKind) {
55
+ /** A document's Pay now checkout, settled to the organization's subaccount. */
56
+ PaystackChargeKind["DOCUMENT_PAYMENT"] = "document_payment";
57
+ })(PaystackChargeKind || (exports.PaystackChargeKind = PaystackChargeKind = {}));
58
+ ;