@nuwah/vertical-sdk 0.0.0-stage → 0.2.0-rc.1
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/LICENSE +17 -0
- package/README.md +229 -2
- package/bin/nuwah-contract-check-rules.d.mts +41 -0
- package/bin/nuwah-contract-check-rules.mjs +333 -0
- package/bin/nuwah-contract-check.mjs +64 -0
- package/dist/accounting.d.ts +1417 -0
- package/dist/accounting.js +274 -0
- package/dist/active-org.d.ts +13 -0
- package/dist/active-org.js +59 -0
- package/dist/actors.d.ts +448 -0
- package/dist/actors.js +143 -0
- package/dist/ai.d.ts +359 -0
- package/dist/ai.js +229 -0
- package/dist/analytics.d.ts +37 -0
- package/dist/analytics.js +8 -0
- package/dist/atlas.d.ts +291 -0
- package/dist/atlas.js +78 -0
- package/dist/audit.d.ts +193 -0
- package/dist/audit.js +26 -0
- package/dist/authentication.d.ts +119 -0
- package/dist/authentication.js +83 -0
- package/dist/awards.d.ts +38 -0
- package/dist/awards.js +10 -0
- package/dist/blueprint/document.d.ts +178 -0
- package/dist/blueprint/document.js +17 -0
- package/dist/blueprint/index.d.ts +3 -0
- package/dist/blueprint/index.js +5 -0
- package/dist/blueprint/manifest.d.ts +105 -0
- package/dist/blueprint/manifest.js +11 -0
- package/dist/blueprint/validate.d.ts +14 -0
- package/dist/blueprint/validate.js +416 -0
- package/dist/bookings-directory.d.ts +118 -0
- package/dist/bookings-directory.js +289 -0
- package/dist/bookings-extra.d.ts +1448 -0
- package/dist/bookings-extra.js +582 -0
- package/dist/bookings.d.ts +1365 -0
- package/dist/bookings.js +305 -0
- package/dist/builder-code.d.ts +164 -0
- package/dist/builder-code.js +12 -0
- package/dist/builder-core-gaps.d.ts +83 -0
- package/dist/builder-core-gaps.js +8 -0
- package/dist/builder-repos.d.ts +73 -0
- package/dist/builder-repos.js +37 -0
- package/dist/builder.d.ts +730 -0
- package/dist/builder.js +105 -0
- package/dist/campaigns.d.ts +105 -0
- package/dist/campaigns.js +25 -0
- package/dist/catalogs.d.ts +188 -0
- package/dist/catalogs.js +36 -0
- package/dist/commerce-ai.d.ts +182 -0
- package/dist/commerce-ai.js +27 -0
- package/dist/connections.d.ts +278 -0
- package/dist/connections.js +96 -0
- package/dist/content-control.d.ts +121 -0
- package/dist/content-control.js +23 -0
- package/dist/contributions.d.ts +560 -0
- package/dist/contributions.js +140 -0
- package/dist/conversation-assist.d.ts +154 -0
- package/dist/conversation-assist.js +51 -0
- package/dist/conversation-info.d.ts +219 -0
- package/dist/conversation-info.js +43 -0
- package/dist/crm.d.ts +533 -0
- package/dist/crm.js +142 -0
- package/dist/dashboards.d.ts +119 -0
- package/dist/dashboards.js +22 -0
- package/dist/delegations.d.ts +161 -0
- package/dist/delegations.js +39 -0
- package/dist/docs.d.ts +289 -0
- package/dist/docs.js +49 -0
- package/dist/documents.d.ts +317 -0
- package/dist/documents.js +84 -0
- package/dist/drafts.d.ts +132 -0
- package/dist/drafts.js +56 -0
- package/dist/engagements.d.ts +133 -0
- package/dist/engagements.js +15 -0
- package/dist/event-stream.d.ts +54 -0
- package/dist/event-stream.js +228 -0
- package/dist/exchanges.d.ts +447 -0
- package/dist/exchanges.js +145 -0
- package/dist/exports.d.ts +113 -0
- package/dist/exports.js +81 -0
- package/dist/feeds.d.ts +228 -0
- package/dist/feeds.js +52 -0
- package/dist/files.d.ts +56 -0
- package/dist/files.js +55 -0
- package/dist/finance-insights.d.ts +41 -0
- package/dist/finance-insights.js +61 -0
- package/dist/fixed-assets.d.ts +155 -0
- package/dist/fixed-assets.js +28 -0
- package/dist/fulfilment-jobs.d.ts +405 -0
- package/dist/fulfilment-jobs.js +76 -0
- package/dist/fulfilment.d.ts +205 -0
- package/dist/fulfilment.js +39 -0
- package/dist/hr.d.ts +350 -0
- package/dist/hr.js +94 -0
- package/dist/http.d.ts +124 -0
- package/dist/http.js +392 -0
- package/dist/inbox.d.ts +206 -0
- package/dist/inbox.js +36 -0
- package/dist/index.d.ts +384 -0
- package/dist/index.js +294 -0
- package/dist/insights.d.ts +176 -0
- package/dist/insights.js +52 -0
- package/dist/inventory.d.ts +797 -0
- package/dist/inventory.js +120 -0
- package/dist/list-query.d.ts +211 -0
- package/dist/list-query.js +158 -0
- package/dist/listings.d.ts +381 -0
- package/dist/listings.js +173 -0
- package/dist/location-sharing.d.ts +83 -0
- package/dist/location-sharing.js +20 -0
- package/dist/marketplace.d.ts +268 -0
- package/dist/marketplace.js +59 -0
- package/dist/matching.d.ts +103 -0
- package/dist/matching.js +22 -0
- package/dist/media.d.ts +221 -0
- package/dist/media.js +239 -0
- package/dist/metrics.d.ts +125 -0
- package/dist/metrics.js +45 -0
- package/dist/moderation.d.ts +240 -0
- package/dist/moderation.js +40 -0
- package/dist/money.d.ts +41 -0
- package/dist/money.js +79 -0
- package/dist/my-data.d.ts +266 -0
- package/dist/my-data.js +32 -0
- package/dist/names.d.ts +14 -0
- package/dist/names.js +17 -0
- package/dist/occasions.d.ts +256 -0
- package/dist/occasions.js +40 -0
- package/dist/onboarding.d.ts +88 -0
- package/dist/onboarding.js +38 -0
- package/dist/pagination.d.ts +204 -0
- package/dist/pagination.js +141 -0
- package/dist/party-baseline-attributes.d.ts +245 -0
- package/dist/party-baseline-attributes.js +36 -0
- package/dist/party.d.ts +401 -0
- package/dist/party.js +56 -0
- package/dist/patient.d.ts +161 -0
- package/dist/patient.js +45 -0
- package/dist/payroll.d.ts +378 -0
- package/dist/payroll.js +60 -0
- package/dist/person-addresses.d.ts +88 -0
- package/dist/person-addresses.js +18 -0
- package/dist/person-cart.d.ts +250 -0
- package/dist/person-cart.js +63 -0
- package/dist/person-chat-assist.d.ts +47 -0
- package/dist/person-chat-assist.js +13 -0
- package/dist/person-data-webhooks.d.ts +72 -0
- package/dist/person-data-webhooks.js +86 -0
- package/dist/person-data.d.ts +212 -0
- package/dist/person-data.js +162 -0
- package/dist/person-locations.d.ts +54 -0
- package/dist/person-locations.js +6 -0
- package/dist/person-messaging.d.ts +405 -0
- package/dist/person-messaging.js +112 -0
- package/dist/person-notifications.d.ts +319 -0
- package/dist/person-notifications.js +164 -0
- package/dist/personalisation.d.ts +21 -0
- package/dist/personalisation.js +8 -0
- package/dist/platform.d.ts +63 -0
- package/dist/platform.js +45 -0
- package/dist/portfolio.d.ts +163 -0
- package/dist/portfolio.js +28 -0
- package/dist/pos.d.ts +743 -0
- package/dist/pos.js +129 -0
- package/dist/procurement.d.ts +664 -0
- package/dist/procurement.js +157 -0
- package/dist/promotions.d.ts +169 -0
- package/dist/promotions.js +39 -0
- package/dist/publications.d.ts +583 -0
- package/dist/publications.js +164 -0
- package/dist/ranking.d.ts +43 -0
- package/dist/ranking.js +34 -0
- package/dist/ratings.d.ts +293 -0
- package/dist/ratings.js +109 -0
- package/dist/reactions.d.ts +123 -0
- package/dist/reactions.js +41 -0
- package/dist/recipient-orders.d.ts +294 -0
- package/dist/recipient-orders.js +73 -0
- package/dist/relationships.d.ts +18 -0
- package/dist/relationships.js +8 -0
- package/dist/reporting.d.ts +107 -0
- package/dist/reporting.js +56 -0
- package/dist/sales.d.ts +270 -0
- package/dist/sales.js +66 -0
- package/dist/shares.d.ts +105 -0
- package/dist/shares.js +27 -0
- package/dist/shop.d.ts +993 -0
- package/dist/shop.js +215 -0
- package/dist/shopping-assistant.d.ts +65 -0
- package/dist/shopping-assistant.js +14 -0
- package/dist/spaces.d.ts +422 -0
- package/dist/spaces.js +118 -0
- package/dist/stored-value.d.ts +754 -0
- package/dist/stored-value.js +177 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.js +2 -0
- package/dist/vault.d.ts +290 -0
- package/dist/vault.js +55 -0
- package/dist/vertical-runtime.d.ts +17 -0
- package/dist/vertical-runtime.js +8 -0
- package/dist/vite/build-manifest-plugin.d.ts +42 -0
- package/dist/vite/build-manifest-plugin.js +42 -0
- package/dist/vite/first-paint-plugin.d.ts +26 -0
- package/dist/vite/first-paint-plugin.js +57 -0
- package/dist/wishlists.d.ts +591 -0
- package/dist/wishlists.js +188 -0
- package/dist/workbench.d.ts +114 -0
- package/dist/workbench.js +22 -0
- package/dist/workspace.d.ts +190 -0
- package/dist/workspace.js +41 -0
- package/package.json +52 -4
- package/templates/extension-image.Dockerfile +38 -0
- package/templates/nuwah-vertical.yml +102 -0
- package/templates/vertical-app/.env.example +34 -0
- package/templates/vertical-app/README.md +108 -0
- package/templates/vertical-app/github/workflows/ci.yml +51 -0
- package/templates/vertical-app/gitignore +5 -0
- package/templates/vertical-app/index.html +12 -0
- package/templates/vertical-app/package.json +28 -0
- package/templates/vertical-app/src/App.tsx +64 -0
- package/templates/vertical-app/src/blueprint/blueprint.ts +45 -0
- package/templates/vertical-app/src/blueprint/screens.ts +15 -0
- package/templates/vertical-app/src/env.d.ts +18 -0
- package/templates/vertical-app/src/index.css +139 -0
- package/templates/vertical-app/src/lib/i18n.ts +5 -0
- package/templates/vertical-app/src/lib/iam.ts +19 -0
- package/templates/vertical-app/src/lib/operations.ts +93 -0
- package/templates/vertical-app/src/lib/router.ts +24 -0
- package/templates/vertical-app/src/lib/sdk.ts +21 -0
- package/templates/vertical-app/src/lib/theme.ts +18 -0
- package/templates/vertical-app/src/lib/words.ts +39 -0
- package/templates/vertical-app/src/main.tsx +25 -0
- package/templates/vertical-app/src/pages/AppScreens.tsx +71 -0
- package/templates/vertical-app/src/pages/AuthCallback.tsx +44 -0
- package/templates/vertical-app/src/pages/Home.tsx +36 -0
- package/templates/vertical-app/tsconfig.json +24 -0
- package/templates/vertical-app/vite.config.ts +23 -0
- package/templates/vertical-ci.yml +192 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import type { Http } from './http.js';
|
|
2
|
+
import type { ListQuery, Paginated } from './types.js';
|
|
3
|
+
export type PayrollRunStatus = 'draft' | 'pending_approval' | 'approved' | 'posted' | 'voided';
|
|
4
|
+
/** Raw `PayrollRun` row from `runs.list`. In the list, dates are full ISO datetimes. */
|
|
5
|
+
export interface PayrollRunRow {
|
|
6
|
+
id: string;
|
|
7
|
+
tenant_id?: string;
|
|
8
|
+
name: string;
|
|
9
|
+
period_start: string;
|
|
10
|
+
period_end: string;
|
|
11
|
+
status: PayrollRunStatus;
|
|
12
|
+
currency: string;
|
|
13
|
+
total_gross: string;
|
|
14
|
+
total_deductions: string;
|
|
15
|
+
total_net: string;
|
|
16
|
+
approved_at: string | null;
|
|
17
|
+
posted_at: string | null;
|
|
18
|
+
created_at?: string | null;
|
|
19
|
+
updated_at?: string | null;
|
|
20
|
+
}
|
|
21
|
+
/** Hand-built bare object from `runs.get` — dates are `YYYY-MM-DD`. */
|
|
22
|
+
export interface PayrollRunDetail {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
period_start: string;
|
|
26
|
+
period_end: string;
|
|
27
|
+
status: PayrollRunStatus;
|
|
28
|
+
currency: string;
|
|
29
|
+
total_gross: string;
|
|
30
|
+
total_deductions: string;
|
|
31
|
+
total_net: string;
|
|
32
|
+
approved_at: string | null;
|
|
33
|
+
posted_at: string | null;
|
|
34
|
+
}
|
|
35
|
+
export interface CreatePayrollRunInput {
|
|
36
|
+
name: string;
|
|
37
|
+
period_start: string;
|
|
38
|
+
period_end: string;
|
|
39
|
+
currency?: string;
|
|
40
|
+
}
|
|
41
|
+
/** `create` returns just `{ id, status }`. */
|
|
42
|
+
export interface CreatePayrollRunResult {
|
|
43
|
+
id: string;
|
|
44
|
+
status: PayrollRunStatus;
|
|
45
|
+
}
|
|
46
|
+
/** `run` (calculate) returns `{ id, total_gross, total_net }`. */
|
|
47
|
+
export interface RunPayrollResult {
|
|
48
|
+
id: string;
|
|
49
|
+
total_gross: string;
|
|
50
|
+
total_net: string;
|
|
51
|
+
}
|
|
52
|
+
/** Generic lifecycle-action result (`submit`/`approve`/`post`/…). */
|
|
53
|
+
export interface PayrollRunActionResult {
|
|
54
|
+
id: string;
|
|
55
|
+
status: PayrollRunStatus;
|
|
56
|
+
approved_at?: string | null;
|
|
57
|
+
posted_at?: string | null;
|
|
58
|
+
}
|
|
59
|
+
export type PayslipLineType = 'base_salary' | 'allowance' | 'overtime' | 'bonus' | 'tax_deduction' | 'social_security' | 'advance_deduction' | 'benefit_deduction' | 'other';
|
|
60
|
+
/** Raw `PayslipLine` as embedded in `payslips.list`. */
|
|
61
|
+
export interface PayslipLineRow {
|
|
62
|
+
id: string;
|
|
63
|
+
tenant_id?: string;
|
|
64
|
+
payslip_id: string;
|
|
65
|
+
line_type: PayslipLineType;
|
|
66
|
+
description: string | null;
|
|
67
|
+
amount: string;
|
|
68
|
+
is_taxable: boolean;
|
|
69
|
+
sort_order: number;
|
|
70
|
+
created_at?: string | null;
|
|
71
|
+
updated_at?: string | null;
|
|
72
|
+
}
|
|
73
|
+
/** Raw `Payslip` row from `payslips.list` (with `employee` + `lines` embedded). */
|
|
74
|
+
export interface PayslipRow {
|
|
75
|
+
id: string;
|
|
76
|
+
tenant_id?: string;
|
|
77
|
+
payroll_run_id: string;
|
|
78
|
+
employee_id: string;
|
|
79
|
+
gross_pay: string;
|
|
80
|
+
total_deductions: string;
|
|
81
|
+
net_pay: string;
|
|
82
|
+
currency: string;
|
|
83
|
+
/**
|
|
84
|
+
* Settlement state. `posted_at` on a run is the ACCRUAL date, not a payment date, so
|
|
85
|
+
* these are the only fields that answer "has this person been paid".
|
|
86
|
+
* `partially_paid` is the state the club's staggered-salary case needs and a boolean
|
|
87
|
+
* cannot hold.
|
|
88
|
+
*/
|
|
89
|
+
payment_status?: PayslipPaymentStatus | null;
|
|
90
|
+
/** A decimal STRING, not a number — `decimal(19,4)`. */
|
|
91
|
+
paid_amount?: string;
|
|
92
|
+
/**
|
|
93
|
+
* `net_pay - paid_amount`. A decimal STRING: `Payslip::outstanding()` is
|
|
94
|
+
* `bcsub(…, 4)`. Typing it `number` compiles and then does string arithmetic.
|
|
95
|
+
*/
|
|
96
|
+
outstanding?: string;
|
|
97
|
+
clockify_hours: Record<string, unknown> | unknown[] | null;
|
|
98
|
+
created_at?: string | null;
|
|
99
|
+
updated_at?: string | null;
|
|
100
|
+
employee?: Record<string, unknown>;
|
|
101
|
+
lines?: PayslipLineRow[];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Whether an individual payslip has been paid. Derived from the payment lines server-side,
|
|
105
|
+
* so it cannot disagree with the money.
|
|
106
|
+
*
|
|
107
|
+
* `partially_paid` is the state the staggered-salary case needs and a boolean cannot hold.
|
|
108
|
+
*/
|
|
109
|
+
export type PayslipPaymentStatus = 'unpaid' | 'partially_paid' | 'paid';
|
|
110
|
+
/** Trimmed line shape inside `payslips.get` (no `id`/`sort_order`). */
|
|
111
|
+
export interface PayslipDetailLine {
|
|
112
|
+
line_type: PayslipLineType;
|
|
113
|
+
description: string | null;
|
|
114
|
+
amount: string;
|
|
115
|
+
is_taxable: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Which advance an `advance_deduction` line recovered. NULL on every other line type.
|
|
118
|
+
* Without it a repayment line is an unattributed negative amount: an employee asking
|
|
119
|
+
* "what was this 200 for" cannot be answered and an over-recovery is undetectable.
|
|
120
|
+
*/
|
|
121
|
+
advance_id?: string | null;
|
|
122
|
+
}
|
|
123
|
+
/** Hand-built bare object from `payslips.get` (no employee, no clockify_hours). */
|
|
124
|
+
export interface PayslipDetail {
|
|
125
|
+
id: string;
|
|
126
|
+
employee_id: string;
|
|
127
|
+
gross_pay: string;
|
|
128
|
+
total_deductions: string;
|
|
129
|
+
net_pay: string;
|
|
130
|
+
currency: string;
|
|
131
|
+
lines: PayslipDetailLine[];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* What `GET /api/payroll/status` answers BEFORE a run is attempted.
|
|
135
|
+
*
|
|
136
|
+
* The run lifecycle is draft → run → submit → approve → post, and the two ways it fails
|
|
137
|
+
* both fail at the LAST step: a run whose employees have no salary structure resolves to
|
|
138
|
+
* nothing and `post` refuses with "resolved to no non-zero ledger lines", and a run in a
|
|
139
|
+
* currency the tenant does not hold refuses with "Currency not found." Either way the
|
|
140
|
+
* operator has already clicked through four screens believing it worked.
|
|
141
|
+
*
|
|
142
|
+
* Core has computed the answer all along. It was simply never asked.
|
|
143
|
+
*/
|
|
144
|
+
/** The state of a payment BATCH. A `deferred` row is a recorded decision, not an absence. */
|
|
145
|
+
export type PayrollPaymentStatus = 'pending' | 'paid' | 'deferred' | 'void';
|
|
146
|
+
/** One payslip's share of a payment batch — this is where partial payment lives. */
|
|
147
|
+
export interface PayrollPaymentLine {
|
|
148
|
+
payslip_id: string;
|
|
149
|
+
amount: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* A payment against a posted run, or a decision not to pay it yet.
|
|
153
|
+
*
|
|
154
|
+
* A deferral carries `reason`, `expected_date` and `decided_by_person_id` and posts NO
|
|
155
|
+
* journal entry: the accrual already put the liability on the balance sheet, so an entry
|
|
156
|
+
* would double it. `journal_entry_id` is therefore null on a deferral and set on a payment.
|
|
157
|
+
*/
|
|
158
|
+
export interface PayrollPaymentRow {
|
|
159
|
+
id: string;
|
|
160
|
+
status: PayrollPaymentStatus;
|
|
161
|
+
total: string;
|
|
162
|
+
currency: string;
|
|
163
|
+
value_date: string | null;
|
|
164
|
+
expected_date: string | null;
|
|
165
|
+
reason: string | null;
|
|
166
|
+
cash_account_code: string | null;
|
|
167
|
+
decided_by_person_id: string | null;
|
|
168
|
+
journal_entry_id: string | null;
|
|
169
|
+
posted_at: string | null;
|
|
170
|
+
lines: PayrollPaymentLine[];
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Pay some or all of a posted run.
|
|
174
|
+
*
|
|
175
|
+
* `lines` maps payslip id => amount, which is what makes partial payment ordinary rather
|
|
176
|
+
* than a mode: omit a payslip and it stays unpaid, send less than it owes and it is part
|
|
177
|
+
* paid. There is no "pay everyone" flag because that is just every payslip in the map.
|
|
178
|
+
*
|
|
179
|
+
* NOTE there is no `decided_by` field. The actor comes from the verified token server-side;
|
|
180
|
+
* sending one would be ignored.
|
|
181
|
+
*/
|
|
182
|
+
export interface MakePayrollPaymentInput {
|
|
183
|
+
lines: Record<string, string | number>;
|
|
184
|
+
value_date?: string;
|
|
185
|
+
/** GL account code money leaves from. Omit for the tenant's default cash account. */
|
|
186
|
+
cash_account_code?: string | null;
|
|
187
|
+
reason?: string | null;
|
|
188
|
+
}
|
|
189
|
+
export interface MakePayrollPaymentResult {
|
|
190
|
+
id: string;
|
|
191
|
+
status: PayrollPaymentStatus;
|
|
192
|
+
total: string;
|
|
193
|
+
journal_entry_id: string | null;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Record a decision not to pay a posted run yet.
|
|
197
|
+
*
|
|
198
|
+
* `reason` is REQUIRED. A deferral with no reason is indistinguishable from a run somebody
|
|
199
|
+
* forgot, and the difference is legal rather than cosmetic: wages are due within days of
|
|
200
|
+
* period end in Jordan, so an unexplained unpaid run is an exposure with no record of who
|
|
201
|
+
* accepted it.
|
|
202
|
+
*
|
|
203
|
+
* `includes_statutory` is refused unless the tenant has enabled statutory deferral — the
|
|
204
|
+
* employer owes Social Security whether or not it paid anyone.
|
|
205
|
+
*/
|
|
206
|
+
export interface DeferPayrollPaymentInput {
|
|
207
|
+
reason: string;
|
|
208
|
+
expected_date?: string | null;
|
|
209
|
+
includes_statutory?: boolean;
|
|
210
|
+
}
|
|
211
|
+
export interface DeferPayrollPaymentResult {
|
|
212
|
+
id: string;
|
|
213
|
+
status: PayrollPaymentStatus;
|
|
214
|
+
total: string;
|
|
215
|
+
expected_date: string | null;
|
|
216
|
+
}
|
|
217
|
+
/** Why a run exists — orthogonal to its status. */
|
|
218
|
+
export type PayrollRunType = 'regular' | 'off_cycle' | 'correction' | 'bonus';
|
|
219
|
+
/**
|
|
220
|
+
* Correct a POSTED period without editing it.
|
|
221
|
+
*
|
|
222
|
+
* `deltas` maps payslip id => SIGNED gross delta; negative reduces pay. A run must be
|
|
223
|
+
* entirely an increase or entirely a reduction — the two post opposite journal entries and
|
|
224
|
+
* `acc_journal_lines` forbids a negative amount outright — so a mixed request is refused
|
|
225
|
+
* with a message saying to raise two corrections.
|
|
226
|
+
*/
|
|
227
|
+
export interface CorrectPayrollRunInput {
|
|
228
|
+
name: string;
|
|
229
|
+
reason: string;
|
|
230
|
+
deltas: Record<string, string | number>;
|
|
231
|
+
}
|
|
232
|
+
export interface CorrectPayrollRunResult {
|
|
233
|
+
id: string;
|
|
234
|
+
run_type: PayrollRunType;
|
|
235
|
+
corrects_run_id: string | null;
|
|
236
|
+
total_net: string;
|
|
237
|
+
status: PayrollRunStatus;
|
|
238
|
+
}
|
|
239
|
+
/** Result of disbursing an approved advance — the point at which it becomes an asset. */
|
|
240
|
+
export interface DisburseAdvanceResult {
|
|
241
|
+
id: string;
|
|
242
|
+
status: string;
|
|
243
|
+
disbursed_at: string | null;
|
|
244
|
+
journal_entry_id: string | null;
|
|
245
|
+
/** How many installments the repayment schedule was split into. */
|
|
246
|
+
installments: number;
|
|
247
|
+
outstanding: string;
|
|
248
|
+
}
|
|
249
|
+
/** An employee's own advance, as returned by the self-service routes. */
|
|
250
|
+
export interface OwnAdvanceRow {
|
|
251
|
+
id: string;
|
|
252
|
+
employee_id?: string;
|
|
253
|
+
amount: string;
|
|
254
|
+
currency: string;
|
|
255
|
+
status?: string;
|
|
256
|
+
reason?: string | null;
|
|
257
|
+
created_at?: string | null;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* An employee asking for an advance for themselves.
|
|
261
|
+
*
|
|
262
|
+
* There is deliberately no `employee_id`: the employment is resolved from the verified
|
|
263
|
+
* token, so the request is structurally incapable of raising an advance against a
|
|
264
|
+
* colleague. Sending one is ignored.
|
|
265
|
+
*/
|
|
266
|
+
export interface RequestOwnAdvanceInput {
|
|
267
|
+
amount: string | number;
|
|
268
|
+
currency?: string;
|
|
269
|
+
reason?: string | null;
|
|
270
|
+
repayment_date?: string | null;
|
|
271
|
+
}
|
|
272
|
+
export interface PayrollReadiness {
|
|
273
|
+
active_employee_count: number;
|
|
274
|
+
missing_salary_structure_count: number;
|
|
275
|
+
ready: boolean;
|
|
276
|
+
current_run: {
|
|
277
|
+
id: string;
|
|
278
|
+
name: string;
|
|
279
|
+
period_start: string;
|
|
280
|
+
period_end: string;
|
|
281
|
+
} | null;
|
|
282
|
+
}
|
|
283
|
+
export declare function createPayrollNamespace(http: Http): {
|
|
284
|
+
/**
|
|
285
|
+
* Pre-flight. Ask this BEFORE offering to create a run, so the two failures that
|
|
286
|
+
* only surface at `post` are visible while the operator can still act on them.
|
|
287
|
+
*/
|
|
288
|
+
status: () => Promise<PayrollReadiness>;
|
|
289
|
+
runs: {
|
|
290
|
+
/** GET /api/payroll/runs — `{data, meta}`; `status` filters, `per_page` up to 100 (default 20). */
|
|
291
|
+
list: (query?: ListQuery & {
|
|
292
|
+
status?: PayrollRunStatus;
|
|
293
|
+
}) => Promise<Paginated<PayrollRunRow>>;
|
|
294
|
+
/** GET /api/payroll/runs/{payrollRun} */
|
|
295
|
+
get: (id: string) => Promise<PayrollRunDetail>;
|
|
296
|
+
/** POST /api/payroll/runs — returns `{ id, status }`. */
|
|
297
|
+
create: (input: CreatePayrollRunInput) => Promise<CreatePayrollRunResult>;
|
|
298
|
+
/** POST /api/payroll/runs/{id}/run — calculates + generates payslips. */
|
|
299
|
+
run: (id: string) => Promise<RunPayrollResult>;
|
|
300
|
+
/** POST /api/payroll/runs/{id}/submit */
|
|
301
|
+
submit: (id: string) => Promise<PayrollRunActionResult>;
|
|
302
|
+
/** POST /api/payroll/runs/{id}/approve */
|
|
303
|
+
approve: (id: string) => Promise<PayrollRunActionResult>;
|
|
304
|
+
/** POST /api/payroll/runs/{id}/post */
|
|
305
|
+
post: (id: string) => Promise<PayrollRunActionResult>;
|
|
306
|
+
/** POST /api/payroll/runs/{id}/return-to-draft */
|
|
307
|
+
returnToDraft: (id: string) => Promise<PayrollRunActionResult>;
|
|
308
|
+
/** POST /api/payroll/runs/{id}/void */
|
|
309
|
+
void: (id: string) => Promise<PayrollRunActionResult>;
|
|
310
|
+
/**
|
|
311
|
+
* POST /api/payroll/runs/{id}/correct — raise a correction against a POSTED run.
|
|
312
|
+
*
|
|
313
|
+
* Creates a DRAFT run carrying only the delta; it still has to be submitted,
|
|
314
|
+
* approved and posted. The original period is never modified.
|
|
315
|
+
*/
|
|
316
|
+
correct: (id: string, input: CorrectPayrollRunInput) => Promise<CorrectPayrollRunResult>;
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* Settlement. `posted` is the ACCRUAL — it credits Salaries Payable; these drain it.
|
|
320
|
+
* One accrual may be settled by SEVERAL payments, which is what makes paying twelve
|
|
321
|
+
* of forty staff ordinary rather than a special case.
|
|
322
|
+
*/
|
|
323
|
+
payments: {
|
|
324
|
+
/** GET /api/payroll/runs/{id}/payments — payments AND deferrals, newest first. */
|
|
325
|
+
list: (runId: string) => Promise<{
|
|
326
|
+
data: PayrollPaymentRow[];
|
|
327
|
+
}>;
|
|
328
|
+
/** POST /api/payroll/runs/{id}/payments — pay some or all of a posted run. */
|
|
329
|
+
create: (runId: string, input: MakePayrollPaymentInput) => Promise<MakePayrollPaymentResult>;
|
|
330
|
+
/** POST /api/payroll/runs/{id}/defer — record a decision not to pay yet. */
|
|
331
|
+
defer: (runId: string, input: DeferPayrollPaymentInput) => Promise<DeferPayrollPaymentResult>;
|
|
332
|
+
};
|
|
333
|
+
advances: {
|
|
334
|
+
/**
|
|
335
|
+
* POST /api/payroll/advances/{id}/disburse — pay an approved advance and build
|
|
336
|
+
* its repayment schedule.
|
|
337
|
+
*
|
|
338
|
+
* Separate from approving, and separately permissioned: approval says the
|
|
339
|
+
* request is legitimate, disbursement moves cash and books an asset.
|
|
340
|
+
* Idempotent — a retry returns the same advance without posting twice.
|
|
341
|
+
*/
|
|
342
|
+
disburse: (id: string, input?: {
|
|
343
|
+
first_due_period?: string | null;
|
|
344
|
+
}) => Promise<DisburseAdvanceResult>;
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* An employee's OWN payroll.
|
|
348
|
+
*
|
|
349
|
+
* No id appears in any of these paths: the employment is resolved from the verified
|
|
350
|
+
* claim, so they are incapable of reaching a colleague's record rather than merely
|
|
351
|
+
* checking that they do not. A caller with no employment record gets 403, which is
|
|
352
|
+
* a different answer from an empty list.
|
|
353
|
+
*/
|
|
354
|
+
me: {
|
|
355
|
+
/** GET /api/payroll/me/payslips */
|
|
356
|
+
payslips: (query?: ListQuery) => Promise<Paginated<PayslipRow>>;
|
|
357
|
+
/** GET /api/payroll/me/payslips/{payslip} */
|
|
358
|
+
payslip: (payslipId: string) => Promise<{
|
|
359
|
+
data: PayslipRow;
|
|
360
|
+
}>;
|
|
361
|
+
/** GET /api/payroll/me/advances */
|
|
362
|
+
advances: (query?: ListQuery) => Promise<Paginated<OwnAdvanceRow>>;
|
|
363
|
+
/** POST /api/payroll/me/advances — request one for oneself. */
|
|
364
|
+
requestAdvance: (input: RequestOwnAdvanceInput) => Promise<{
|
|
365
|
+
id: string;
|
|
366
|
+
status: string;
|
|
367
|
+
}>;
|
|
368
|
+
};
|
|
369
|
+
payslips: {
|
|
370
|
+
/** GET /api/payroll/runs/{payrollRun}/payslips — `{data, meta}`; `outstanding: 1` keeps the unpaid ones. */
|
|
371
|
+
list: (runId: string, query?: ListQuery & {
|
|
372
|
+
outstanding?: 0 | 1 | boolean;
|
|
373
|
+
}) => Promise<Paginated<PayslipRow>>;
|
|
374
|
+
/** GET /api/payroll/runs/{payrollRun}/payslips/{payslip} */
|
|
375
|
+
get: (runId: string, payslipId: string) => Promise<PayslipDetail>;
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
export type PayrollNamespace = ReturnType<typeof createPayrollNamespace>;
|
package/dist/payroll.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export function createPayrollNamespace(http) {
|
|
2
|
+
return {
|
|
3
|
+
|
|
4
|
+
status: () => http.get('/api/payroll/status'),
|
|
5
|
+
runs: {
|
|
6
|
+
|
|
7
|
+
list: (query) => http.get('/api/payroll/runs', { params: query }),
|
|
8
|
+
|
|
9
|
+
get: (id) => http.get(`/api/payroll/runs/${id}`),
|
|
10
|
+
|
|
11
|
+
create: (input) => http.post('/api/payroll/runs', input),
|
|
12
|
+
|
|
13
|
+
run: (id) => http.post(`/api/payroll/runs/${id}/run`),
|
|
14
|
+
|
|
15
|
+
submit: (id) => http.post(`/api/payroll/runs/${id}/submit`),
|
|
16
|
+
|
|
17
|
+
approve: (id) => http.post(`/api/payroll/runs/${id}/approve`),
|
|
18
|
+
|
|
19
|
+
post: (id) => http.post(`/api/payroll/runs/${id}/post`),
|
|
20
|
+
|
|
21
|
+
returnToDraft: (id) => http.post(`/api/payroll/runs/${id}/return-to-draft`),
|
|
22
|
+
|
|
23
|
+
void: (id) => http.post(`/api/payroll/runs/${id}/void`),
|
|
24
|
+
|
|
25
|
+
correct: (id, input) => http.post(`/api/payroll/runs/${id}/correct`, input),
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
payments: {
|
|
29
|
+
|
|
30
|
+
list: (runId) => http.get(`/api/payroll/runs/${runId}/payments`),
|
|
31
|
+
|
|
32
|
+
create: (runId, input) => http.post(`/api/payroll/runs/${runId}/payments`, input),
|
|
33
|
+
|
|
34
|
+
defer: (runId, input) => http.post(`/api/payroll/runs/${runId}/defer`, input),
|
|
35
|
+
},
|
|
36
|
+
advances: {
|
|
37
|
+
|
|
38
|
+
disburse: (id, input) => http.post(`/api/payroll/advances/${id}/disburse`, input ?? {}),
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
me: {
|
|
42
|
+
|
|
43
|
+
payslips: (query) => http.get('/api/payroll/me/payslips', { params: query }),
|
|
44
|
+
|
|
45
|
+
payslip: (payslipId) => http.get(`/api/payroll/me/payslips/${payslipId}`),
|
|
46
|
+
|
|
47
|
+
advances: (query) => http.get('/api/payroll/me/advances', { params: query }),
|
|
48
|
+
|
|
49
|
+
requestAdvance: (input) => http.post('/api/payroll/me/advances', input),
|
|
50
|
+
},
|
|
51
|
+
payslips: {
|
|
52
|
+
|
|
53
|
+
list: (runId, query) => http.get(`/api/payroll/runs/${runId}/payslips`, {
|
|
54
|
+
params: query,
|
|
55
|
+
}),
|
|
56
|
+
|
|
57
|
+
get: (runId, payslipId) => http.get(`/api/payroll/runs/${runId}/payslips/${payslipId}`),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Person addresses — the person's own address book (core `Platform/PersonAddresses`), person
|
|
3
|
+
* plane and orgless: a consumer who belongs to no organisation reaches all of it.
|
|
4
|
+
*
|
|
5
|
+
* GET /api/person/addresses the caller's own, default first then newest
|
|
6
|
+
* POST /api/person/addresses add one (the first is always the default)
|
|
7
|
+
* PATCH /api/person/addresses/{id} change some parts; `is_default: true` moves the default here
|
|
8
|
+
* DELETE /api/person/addresses/{id} delete (hard); deleting the default promotes the newest left
|
|
9
|
+
*
|
|
10
|
+
* Only `address_line1` and `address_city` are required, unless the place is a map point (`latitude`,
|
|
11
|
+
* `longitude`): a saved place may be only a pin, and then both may be null. Unsetting the last default is refused
|
|
12
|
+
* (422 `default_required`): choose another default instead. Another person's address and a missing
|
|
13
|
+
* one are the same 422 `address_not_found`. A shop reads an address only through the person's
|
|
14
|
+
* consent for one delivery, never through this namespace.
|
|
15
|
+
*/
|
|
16
|
+
import type { Http } from './http.js';
|
|
17
|
+
export interface PersonAddress {
|
|
18
|
+
id: string;
|
|
19
|
+
label: string | null;
|
|
20
|
+
is_default: boolean;
|
|
21
|
+
address_line1: string | null;
|
|
22
|
+
address_line2: string | null;
|
|
23
|
+
address_city: string | null;
|
|
24
|
+
address_region: string | null;
|
|
25
|
+
address_postcode: string | null;
|
|
26
|
+
address_country: string | null;
|
|
27
|
+
latitude: number | string | null;
|
|
28
|
+
longitude: number | string | null;
|
|
29
|
+
verified_at: string | null;
|
|
30
|
+
/** A convention: `home`, `work`, `other`; free text. */
|
|
31
|
+
icon?: string | null;
|
|
32
|
+
note?: string | null;
|
|
33
|
+
/** The person's own order (0 until they reorder). */
|
|
34
|
+
position?: number;
|
|
35
|
+
/** Purposes this place is the default for (`delivery`, `sharing`, …); one place per purpose. */
|
|
36
|
+
default_for?: string[];
|
|
37
|
+
created_at?: string | null;
|
|
38
|
+
}
|
|
39
|
+
export interface PersonAddressWrite {
|
|
40
|
+
icon?: string | null;
|
|
41
|
+
note?: string | null;
|
|
42
|
+
default_for?: string[];
|
|
43
|
+
label?: string | null;
|
|
44
|
+
is_default?: boolean;
|
|
45
|
+
address_line1?: string;
|
|
46
|
+
address_line2?: string | null;
|
|
47
|
+
address_city?: string;
|
|
48
|
+
address_region?: string | null;
|
|
49
|
+
address_postcode?: string | null;
|
|
50
|
+
address_country?: string | null;
|
|
51
|
+
latitude?: number | null;
|
|
52
|
+
longitude?: number | null;
|
|
53
|
+
}
|
|
54
|
+
/** Adding needs the street and the town, OR a map point (a saved place may be only a pin). */
|
|
55
|
+
export type PersonAddressCreate = PersonAddressWrite & ({
|
|
56
|
+
address_line1: string;
|
|
57
|
+
address_city: string;
|
|
58
|
+
} | {
|
|
59
|
+
latitude: number;
|
|
60
|
+
longitude: number;
|
|
61
|
+
});
|
|
62
|
+
export declare function createPersonAddressesNamespace(http: Http): {
|
|
63
|
+
/** GET — the caller's own addresses, default first then newest. */
|
|
64
|
+
list: (options?: {
|
|
65
|
+
signal?: AbortSignal;
|
|
66
|
+
}) => Promise<{
|
|
67
|
+
data: PersonAddress[];
|
|
68
|
+
}>;
|
|
69
|
+
/** POST — add one; the first address is the default whatever `is_default` says. 201. */
|
|
70
|
+
create: (address: PersonAddressCreate) => Promise<{
|
|
71
|
+
data: PersonAddress;
|
|
72
|
+
}>;
|
|
73
|
+
/** PATCH — only the keys sent change; `is_default: true` makes it the default. */
|
|
74
|
+
update: (addressId: string, changes: PersonAddressWrite) => Promise<{
|
|
75
|
+
data: PersonAddress;
|
|
76
|
+
}>;
|
|
77
|
+
/** PATCH `{is_default: true}` — the shorthand for "make this the default". */
|
|
78
|
+
makeDefault: (addressId: string) => Promise<{
|
|
79
|
+
data: PersonAddress;
|
|
80
|
+
}>;
|
|
81
|
+
/** DELETE — 204. Deleting the default promotes the newest remaining address. */
|
|
82
|
+
remove: (addressId: string) => Promise<void>;
|
|
83
|
+
/** PUT `{address_ids}` — the person's own order; unlisted places keep theirs after these. */
|
|
84
|
+
reorder: (addressIds: string[]) => Promise<{
|
|
85
|
+
data: PersonAddress[];
|
|
86
|
+
}>;
|
|
87
|
+
};
|
|
88
|
+
export type PersonAddressesNamespace = ReturnType<typeof createPersonAddressesNamespace>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const BASE = '/api/person/addresses';
|
|
2
|
+
export function createPersonAddressesNamespace(http) {
|
|
3
|
+
const segment = encodeURIComponent;
|
|
4
|
+
return {
|
|
5
|
+
|
|
6
|
+
list: (options) => http.get(BASE, options?.signal ? { signal: options.signal } : {}),
|
|
7
|
+
|
|
8
|
+
create: (address) => http.post(BASE, address),
|
|
9
|
+
|
|
10
|
+
update: (addressId, changes) => http.patch(`${BASE}/${segment(addressId)}`, changes),
|
|
11
|
+
|
|
12
|
+
makeDefault: (addressId) => http.patch(`${BASE}/${segment(addressId)}`, { is_default: true }),
|
|
13
|
+
|
|
14
|
+
remove: (addressId) => http.delete(`${BASE}/${segment(addressId)}`),
|
|
15
|
+
|
|
16
|
+
reorder: (addressIds) => http.put(`${BASE}/order`, { address_ids: addressIds }),
|
|
17
|
+
};
|
|
18
|
+
}
|