@mydoormot/app-types 1.8.2 → 1.9.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/.turbo/turbo-build.log +18 -18
- package/CHANGELOG.md +12 -0
- package/dist/index.cjs +46 -0
- package/dist/index.d.cts +174 -3
- package/dist/index.d.ts +174 -3
- package/dist/index.js +42 -0
- package/package.json +1 -1
- package/src/customer.ts +21 -0
- package/src/index.ts +1 -0
- package/src/invoice.ts +106 -0
- package/src/portal.ts +46 -0
- package/src/vehicle.ts +9 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
> @mydoormot/app-types@1.
|
|
3
|
-
> tsup src/index.ts --format esm,cjs --dts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
|
|
2
|
+
> @mydoormot/app-types@1.9.0 build /Users/chuksben/Desktop/projects/microservices/mydoormot/packages/app-types
|
|
3
|
+
> tsup src/index.ts --format esm,cjs --dts
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v7.3.0
|
|
8
|
+
[34mCLI[39m Target: es2021
|
|
9
|
+
[34mESM[39m Build start
|
|
10
|
+
[34mCJS[39m Build start
|
|
11
|
+
[34mDTS[39m Build start
|
|
12
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m15.79 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 301ms
|
|
14
|
+
[32mESM[39m [1mdist/index.js [22m[32m13.19 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 301ms
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 931ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m40.67 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m40.67 KB[39m
|
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -35,16 +35,20 @@ __export(src_exports, {
|
|
|
35
35
|
FeePaymentStatus: () => FeePaymentStatus,
|
|
36
36
|
FeeSettlement: () => FeeSettlement,
|
|
37
37
|
GlobalRoles: () => GlobalRoles,
|
|
38
|
+
InvoiceEventType: () => InvoiceEventType,
|
|
38
39
|
InvoiceGenerationType: () => InvoiceGenerationType,
|
|
39
40
|
InvoiceItemType: () => InvoiceItemType,
|
|
41
|
+
InvoicePaymentMethod: () => InvoicePaymentMethod,
|
|
40
42
|
InvoiceStatus: () => InvoiceStatus,
|
|
41
43
|
LinkDestination: () => LinkDestination,
|
|
42
44
|
MembershipStatus: () => MembershipStatus,
|
|
43
45
|
NotificationType: () => NotificationType,
|
|
44
46
|
ParcelSize: () => ParcelSize,
|
|
45
47
|
PaymentOptions: () => PaymentOptions,
|
|
48
|
+
PortalStatus: () => PortalStatus,
|
|
46
49
|
RemittanceStatus: () => RemittanceStatus,
|
|
47
50
|
RoleType: () => RoleType,
|
|
51
|
+
SweepExclusionReason: () => SweepExclusionReason,
|
|
48
52
|
VehicleLogType: () => VehicleLogType,
|
|
49
53
|
VehicleType: () => VehicleType,
|
|
50
54
|
WhatsappButtonType: () => WhatsappButtonType,
|
|
@@ -188,6 +192,37 @@ var PaymentOptions = /* @__PURE__ */ ((PaymentOptions2) => {
|
|
|
188
192
|
PaymentOptions2["BusinessInvoice"] = "business_invoice";
|
|
189
193
|
return PaymentOptions2;
|
|
190
194
|
})(PaymentOptions || {});
|
|
195
|
+
var InvoicePaymentMethod = /* @__PURE__ */ ((InvoicePaymentMethod2) => {
|
|
196
|
+
InvoicePaymentMethod2["Transfer"] = "transfer";
|
|
197
|
+
InvoicePaymentMethod2["Cash"] = "cash";
|
|
198
|
+
InvoicePaymentMethod2["Card"] = "card";
|
|
199
|
+
InvoicePaymentMethod2["Pos"] = "pos";
|
|
200
|
+
InvoicePaymentMethod2["Other"] = "other";
|
|
201
|
+
return InvoicePaymentMethod2;
|
|
202
|
+
})(InvoicePaymentMethod || {});
|
|
203
|
+
var InvoiceEventType = /* @__PURE__ */ ((InvoiceEventType2) => {
|
|
204
|
+
InvoiceEventType2["Frozen"] = "frozen";
|
|
205
|
+
InvoiceEventType2["ErrandsAdded"] = "errands_added";
|
|
206
|
+
InvoiceEventType2["ErrandRemoved"] = "errand_removed";
|
|
207
|
+
InvoiceEventType2["Recalculated"] = "recalculated";
|
|
208
|
+
InvoiceEventType2["LineAmountChanged"] = "line_amount_changed";
|
|
209
|
+
InvoiceEventType2["PaymentRecorded"] = "payment_recorded";
|
|
210
|
+
InvoiceEventType2["PaymentReversed"] = "payment_reversed";
|
|
211
|
+
InvoiceEventType2["StatusChanged"] = "status_changed";
|
|
212
|
+
InvoiceEventType2["LinkCreated"] = "link_created";
|
|
213
|
+
InvoiceEventType2["LinkRevoked"] = "link_revoked";
|
|
214
|
+
InvoiceEventType2["Viewed"] = "viewed";
|
|
215
|
+
return InvoiceEventType2;
|
|
216
|
+
})(InvoiceEventType || {});
|
|
217
|
+
var SweepExclusionReason = /* @__PURE__ */ ((SweepExclusionReason2) => {
|
|
218
|
+
SweepExclusionReason2["Cancelled"] = "cancelled";
|
|
219
|
+
SweepExclusionReason2["AlreadyInvoiced"] = "already_invoiced";
|
|
220
|
+
SweepExclusionReason2["SettledCash"] = "settled_cash";
|
|
221
|
+
SweepExclusionReason2["Prepaid"] = "prepaid";
|
|
222
|
+
SweepExclusionReason2["Owed"] = "owed";
|
|
223
|
+
SweepExclusionReason2["NotInvoiceable"] = "not_invoiceable";
|
|
224
|
+
return SweepExclusionReason2;
|
|
225
|
+
})(SweepExclusionReason || {});
|
|
191
226
|
|
|
192
227
|
// src/notification.ts
|
|
193
228
|
var NotificationType = /* @__PURE__ */ ((NotificationType2) => {
|
|
@@ -336,6 +371,13 @@ var WhatsappTemplateParamSource = /* @__PURE__ */ ((WhatsappTemplateParamSource2
|
|
|
336
371
|
return WhatsappTemplateParamSource2;
|
|
337
372
|
})(WhatsappTemplateParamSource || {});
|
|
338
373
|
|
|
374
|
+
// src/portal.ts
|
|
375
|
+
var PortalStatus = /* @__PURE__ */ ((PortalStatus2) => {
|
|
376
|
+
PortalStatus2["Draft"] = "draft";
|
|
377
|
+
PortalStatus2["Published"] = "published";
|
|
378
|
+
return PortalStatus2;
|
|
379
|
+
})(PortalStatus || {});
|
|
380
|
+
|
|
339
381
|
// src/index.ts
|
|
340
382
|
var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
|
|
341
383
|
LinkDestination2["Website"] = "web";
|
|
@@ -360,16 +402,20 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
|
|
|
360
402
|
FeePaymentStatus,
|
|
361
403
|
FeeSettlement,
|
|
362
404
|
GlobalRoles,
|
|
405
|
+
InvoiceEventType,
|
|
363
406
|
InvoiceGenerationType,
|
|
364
407
|
InvoiceItemType,
|
|
408
|
+
InvoicePaymentMethod,
|
|
365
409
|
InvoiceStatus,
|
|
366
410
|
LinkDestination,
|
|
367
411
|
MembershipStatus,
|
|
368
412
|
NotificationType,
|
|
369
413
|
ParcelSize,
|
|
370
414
|
PaymentOptions,
|
|
415
|
+
PortalStatus,
|
|
371
416
|
RemittanceStatus,
|
|
372
417
|
RoleType,
|
|
418
|
+
SweepExclusionReason,
|
|
373
419
|
VehicleLogType,
|
|
374
420
|
VehicleType,
|
|
375
421
|
WhatsappButtonType,
|
package/dist/index.d.cts
CHANGED
|
@@ -132,6 +132,29 @@ interface Customer {
|
|
|
132
132
|
customerBusinessId?: string;
|
|
133
133
|
transactionStats?: CustomerTransactionStats;
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* What a customer owes, computed server-side. `unbilled` is a SET, not a
|
|
137
|
+
* period — it has no start or end date, and `oldestUnbilledAt` is simply its
|
|
138
|
+
* earliest member.
|
|
139
|
+
*/
|
|
140
|
+
interface CustomerBilling {
|
|
141
|
+
unbilledAmount: number;
|
|
142
|
+
unbilledCount: number;
|
|
143
|
+
oldestUnbilledAt: string | null;
|
|
144
|
+
outstandingAmount: number;
|
|
145
|
+
openInvoiceCount: number;
|
|
146
|
+
/** End of the newest period already invoiced. */
|
|
147
|
+
lastInvoicedThrough: string | null;
|
|
148
|
+
/**
|
|
149
|
+
* The next invoice window, derived rather than typed: from the day after the
|
|
150
|
+
* last invoice closed, to today. Consecutive periods therefore tile with no
|
|
151
|
+
* gap and no overlap.
|
|
152
|
+
*/
|
|
153
|
+
nextPeriod: {
|
|
154
|
+
from: string | null;
|
|
155
|
+
to: string;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
135
158
|
|
|
136
159
|
declare enum InvoiceStatus {
|
|
137
160
|
Pending = "pending",
|
|
@@ -152,6 +175,82 @@ declare enum PaymentOptions {
|
|
|
152
175
|
Card = "card",
|
|
153
176
|
BusinessInvoice = "business_invoice"
|
|
154
177
|
}
|
|
178
|
+
declare enum InvoicePaymentMethod {
|
|
179
|
+
Transfer = "transfer",
|
|
180
|
+
Cash = "cash",
|
|
181
|
+
Card = "card",
|
|
182
|
+
Pos = "pos",
|
|
183
|
+
Other = "other"
|
|
184
|
+
}
|
|
185
|
+
declare enum InvoiceEventType {
|
|
186
|
+
Frozen = "frozen",
|
|
187
|
+
ErrandsAdded = "errands_added",
|
|
188
|
+
ErrandRemoved = "errand_removed",
|
|
189
|
+
Recalculated = "recalculated",
|
|
190
|
+
LineAmountChanged = "line_amount_changed",
|
|
191
|
+
PaymentRecorded = "payment_recorded",
|
|
192
|
+
PaymentReversed = "payment_reversed",
|
|
193
|
+
StatusChanged = "status_changed",
|
|
194
|
+
LinkCreated = "link_created",
|
|
195
|
+
LinkRevoked = "link_revoked",
|
|
196
|
+
Viewed = "viewed"
|
|
197
|
+
}
|
|
198
|
+
/** Why an errand in the period was not charged on the statement. */
|
|
199
|
+
declare enum SweepExclusionReason {
|
|
200
|
+
Cancelled = "cancelled",
|
|
201
|
+
AlreadyInvoiced = "already_invoiced",
|
|
202
|
+
SettledCash = "settled_cash",
|
|
203
|
+
Prepaid = "prepaid",
|
|
204
|
+
Owed = "owed",
|
|
205
|
+
NotInvoiceable = "not_invoiceable"
|
|
206
|
+
}
|
|
207
|
+
interface InvoicePayment {
|
|
208
|
+
id: string;
|
|
209
|
+
invoiceId: string;
|
|
210
|
+
businessId: string;
|
|
211
|
+
amount: number;
|
|
212
|
+
paidAt: string;
|
|
213
|
+
method?: InvoicePaymentMethod | `${InvoicePaymentMethod}`;
|
|
214
|
+
reference?: string;
|
|
215
|
+
note?: string;
|
|
216
|
+
recordedBy: string;
|
|
217
|
+
reversedAt?: string;
|
|
218
|
+
reversedBy?: string;
|
|
219
|
+
reversalReason?: string;
|
|
220
|
+
createdAt: string;
|
|
221
|
+
updatedAt: string;
|
|
222
|
+
}
|
|
223
|
+
interface InvoiceEvent {
|
|
224
|
+
id: string;
|
|
225
|
+
invoiceId: string;
|
|
226
|
+
businessId: string;
|
|
227
|
+
type: InvoiceEventType | `${InvoiceEventType}`;
|
|
228
|
+
actorUserId?: string;
|
|
229
|
+
amountBefore?: number;
|
|
230
|
+
amountAfter?: number;
|
|
231
|
+
summary?: string;
|
|
232
|
+
/** Repeated back to the customer on their own statement. */
|
|
233
|
+
customerVisible: boolean;
|
|
234
|
+
meta?: Record<string, unknown>;
|
|
235
|
+
createdAt: string;
|
|
236
|
+
}
|
|
237
|
+
interface InvoiceStatementLink {
|
|
238
|
+
id: string;
|
|
239
|
+
invoiceId: string;
|
|
240
|
+
businessId: string;
|
|
241
|
+
token: string;
|
|
242
|
+
expiresAt: string;
|
|
243
|
+
revokedAt?: string;
|
|
244
|
+
viewCount: number;
|
|
245
|
+
firstViewedAt?: string;
|
|
246
|
+
lastViewedAt?: string;
|
|
247
|
+
createdAt: string;
|
|
248
|
+
}
|
|
249
|
+
/** Whether a frozen invoice has fallen out of date, and by how much. */
|
|
250
|
+
interface InvoiceDrift {
|
|
251
|
+
errandCount: number;
|
|
252
|
+
amount: number;
|
|
253
|
+
}
|
|
155
254
|
interface Invoice {
|
|
156
255
|
id: string;
|
|
157
256
|
businessId: string;
|
|
@@ -159,9 +258,26 @@ interface Invoice {
|
|
|
159
258
|
invoiceNumber: string;
|
|
160
259
|
startDate: string;
|
|
161
260
|
endDate: string;
|
|
261
|
+
/** What the customer is asked for. Excludes zero-rated lines. */
|
|
162
262
|
totalAmount: number;
|
|
263
|
+
/**
|
|
264
|
+
* What the settled-at-the-door lines were worth. Never owed, never part of
|
|
265
|
+
* `totalAmount` — carried so the statement can show the period's full
|
|
266
|
+
* activity without charging for it twice.
|
|
267
|
+
*/
|
|
268
|
+
zeroRatedTotal: number;
|
|
163
269
|
paidAmount: number;
|
|
164
270
|
unpaidAmount: number;
|
|
271
|
+
lastRecalculatedAt?: string;
|
|
272
|
+
/**
|
|
273
|
+
* Document lifecycle, kept separate from `status`: an invoice can be
|
|
274
|
+
* part-paid and viewed, or paid and never opened.
|
|
275
|
+
*/
|
|
276
|
+
sentAt?: string;
|
|
277
|
+
firstViewedAt?: string;
|
|
278
|
+
lastViewedAt?: string;
|
|
279
|
+
viewCount?: number;
|
|
280
|
+
drift?: InvoiceDrift;
|
|
165
281
|
status: InvoiceStatus | `${InvoiceStatus}`;
|
|
166
282
|
customerId: string;
|
|
167
283
|
items: InvoiceItem[];
|
|
@@ -176,7 +292,13 @@ interface InvoiceItem {
|
|
|
176
292
|
invoiceId: string;
|
|
177
293
|
itemType: InvoiceItemType | `${InvoiceItemType}`;
|
|
178
294
|
itemId: string;
|
|
295
|
+
/** Contribution to the invoice total. Zero for a settled line. */
|
|
179
296
|
amount: number;
|
|
297
|
+
/** Shown but not charged — work the customer already paid for in cash. */
|
|
298
|
+
zeroRated?: boolean;
|
|
299
|
+
settledBy?: 'cash';
|
|
300
|
+
/** What the work was worth, on a zero-rated line only. */
|
|
301
|
+
originalAmount?: number;
|
|
180
302
|
description: string;
|
|
181
303
|
date: string;
|
|
182
304
|
createdAt: string;
|
|
@@ -397,11 +519,17 @@ type VehicleLog = {
|
|
|
397
519
|
createdAt: string;
|
|
398
520
|
updatedAt: string;
|
|
399
521
|
previousLogId?: string;
|
|
400
|
-
errandIdsSinceLastRefuel?: string[];
|
|
401
|
-
lastRecalculatedAt?: string;
|
|
402
522
|
vehicleDetails?: Vehicle;
|
|
403
523
|
};
|
|
404
524
|
type VehicleLogWithErrands = VehicleLog & {
|
|
525
|
+
/**
|
|
526
|
+
* The errands the vehicle ran during this refuel's fuel period —
|
|
527
|
+
* `(previousLog.createdAt, createdAt]`. Derived on read, so it always
|
|
528
|
+
* reflects current assignments and cancellations.
|
|
529
|
+
*/
|
|
530
|
+
errands?: Errand[];
|
|
531
|
+
/** Start of the fuel period; null for a vehicle's first log. */
|
|
532
|
+
periodStart?: string | null;
|
|
405
533
|
errandsCount?: number;
|
|
406
534
|
totalErrandsRevenue?: number;
|
|
407
535
|
/**
|
|
@@ -1284,6 +1412,49 @@ interface WhatsappSendLog {
|
|
|
1284
1412
|
sentAt: string | Date;
|
|
1285
1413
|
}
|
|
1286
1414
|
|
|
1415
|
+
declare enum PortalStatus {
|
|
1416
|
+
Draft = "draft",
|
|
1417
|
+
Published = "published"
|
|
1418
|
+
}
|
|
1419
|
+
interface BusinessPortal {
|
|
1420
|
+
id: string;
|
|
1421
|
+
businessId: string;
|
|
1422
|
+
/** Compose the URL yourself, e.g. `https://mydoormot.io/b/${handle}`. */
|
|
1423
|
+
handle: string;
|
|
1424
|
+
previousHandles: string[];
|
|
1425
|
+
status: PortalStatus;
|
|
1426
|
+
publishedAt?: string;
|
|
1427
|
+
createdAt: string;
|
|
1428
|
+
updatedAt: string;
|
|
1429
|
+
}
|
|
1430
|
+
interface PublicPortalBusiness {
|
|
1431
|
+
name?: string;
|
|
1432
|
+
description?: string;
|
|
1433
|
+
officeNumber?: string;
|
|
1434
|
+
address?: string;
|
|
1435
|
+
logoUrl?: string;
|
|
1436
|
+
logoBlurHash?: string;
|
|
1437
|
+
coverImageUrl?: string;
|
|
1438
|
+
coverImageBlurHash?: string;
|
|
1439
|
+
isOnline?: boolean;
|
|
1440
|
+
openingHours?: Record<string, unknown>;
|
|
1441
|
+
socialLinks?: Record<string, unknown>;
|
|
1442
|
+
}
|
|
1443
|
+
/** `GET /api/v2/portals/:handle` — unauthenticated. */
|
|
1444
|
+
interface PublicPortal {
|
|
1445
|
+
handle: string;
|
|
1446
|
+
/** Set when the requested handle was retired — redirect to `handle`. */
|
|
1447
|
+
redirectedFrom?: string;
|
|
1448
|
+
business: PublicPortalBusiness;
|
|
1449
|
+
}
|
|
1450
|
+
/** `GET /api/v2/portals/handles/:handle` — unauthenticated. */
|
|
1451
|
+
interface PortalHandleAvailability {
|
|
1452
|
+
/** Normalised — what you would actually be assigned. */
|
|
1453
|
+
handle: string;
|
|
1454
|
+
available: boolean;
|
|
1455
|
+
reason?: string;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1287
1458
|
interface PaginateResult<T> {
|
|
1288
1459
|
docs: T[];
|
|
1289
1460
|
totalDocs: number;
|
|
@@ -1306,4 +1477,4 @@ declare enum LinkDestination {
|
|
|
1306
1477
|
}
|
|
1307
1478
|
type NullOrUndefined = null | undefined;
|
|
1308
1479
|
|
|
1309
|
-
export { type AddonGroup, type AddonGroupItem, type AddressDetails, AddressTypes, type AggregatedErrand, AuthType, type Business, BusinessCapability, type BusinessCategory, type BusinessCourierLink, BusinessCourierLinkStatus, type BusinessMember, type BusinessModules, type BusinessPg, BusinessRole, type BusinessSettings, BusinessStatus, type BusinessWhatsappConfig, type City, type Collection, type Customer, type CustomerAddress, type CustomerTransactionStats, DEFAULT_BUSINESS_MODULES, DEFAULT_BUSINESS_SETTINGS, DeliveryStatus, type DraftErrand, DraftErrandStatus, type Enterprise, type EnterpriseCategoryDoc, type EnterpriseSubCategoryDoc, EnterpriseType, type Errand, type ErrandDeliveryTiming, type ErrandPackagingQuality, type ErrandRating, type ErrandReview, type ErrandReviewLink, type ErrandRiderBehavior, ErrandStatus, type ErrandTimeline, type ExpensePaidBy, FeePaymentStatus, FeeSettlement, type GeoPoint, GlobalRoles, type Invoice, InvoiceGenerationType, type InvoiceItem, InvoiceItemType, InvoiceStatus, type LatLng, LinkDestination, type MaintenanceItem, type MaintenancePartUsage, type MaintenanceRecord, type MaintenanceStats, type MaintenanceStatsSummary, type MaintenanceTopItem, MembershipStatus, type Notification, type NotificationData, NotificationType, type NullOrUndefined, type OpeningHours, type PaginateResult, ParcelSize, PaymentOptions, type PendingErrand, type Product, type ProductCategory, type ProductImage, type ProductOption, type ProductOptionValue, type ProductStatus, type ProductTag, type ProductVariant, type ProductVariantPrice, RemittanceStatus, type Rider, type RiderPerformanceItem, type RiderPerformanceStats, type RiderPerformanceSummary, type RiderPerformanceTimeSeries, type RiderSettlement, type RiderWithUserDetails, RoleType, type State, type TrackerPosition, type Transaction, type TransactionCategory, type TransactionItem, type TransactionType, type TransactionWithCategory, type TransactionWithJoin, type User, type UserAddress, type Vehicle, type VehicleErrandStats, type VehicleFuelStats, type VehicleLog, type VehicleLogStatsSummary, VehicleLogType, type VehicleLogWithErrands, type VehicleMaintenanceStats, type VehiclePerformanceData, type VehiclePerformanceFilters, type VehiclePerformanceItem, type VehiclePerformanceTotals, VehicleType, type VehicleWithRider, type Vendor, WhatsappButtonType, WhatsappComponentType, WhatsappEvent, WhatsappRecipient, type WhatsappSendLog, type WhatsappTemplate, type WhatsappTemplateButton, type WhatsappTemplateComponent, WhatsappTemplateMetaStatus, WhatsappTemplateParamSource, type WhatsappTemplateSource, errandTimeline };
|
|
1480
|
+
export { type AddonGroup, type AddonGroupItem, type AddressDetails, AddressTypes, type AggregatedErrand, AuthType, type Business, BusinessCapability, type BusinessCategory, type BusinessCourierLink, BusinessCourierLinkStatus, type BusinessMember, type BusinessModules, type BusinessPg, type BusinessPortal, BusinessRole, type BusinessSettings, BusinessStatus, type BusinessWhatsappConfig, type City, type Collection, type Customer, type CustomerAddress, type CustomerBilling, type CustomerTransactionStats, DEFAULT_BUSINESS_MODULES, DEFAULT_BUSINESS_SETTINGS, DeliveryStatus, type DraftErrand, DraftErrandStatus, type Enterprise, type EnterpriseCategoryDoc, type EnterpriseSubCategoryDoc, EnterpriseType, type Errand, type ErrandDeliveryTiming, type ErrandPackagingQuality, type ErrandRating, type ErrandReview, type ErrandReviewLink, type ErrandRiderBehavior, ErrandStatus, type ErrandTimeline, type ExpensePaidBy, FeePaymentStatus, FeeSettlement, type GeoPoint, GlobalRoles, type Invoice, type InvoiceDrift, type InvoiceEvent, InvoiceEventType, InvoiceGenerationType, type InvoiceItem, InvoiceItemType, type InvoicePayment, InvoicePaymentMethod, type InvoiceStatementLink, InvoiceStatus, type LatLng, LinkDestination, type MaintenanceItem, type MaintenancePartUsage, type MaintenanceRecord, type MaintenanceStats, type MaintenanceStatsSummary, type MaintenanceTopItem, MembershipStatus, type Notification, type NotificationData, NotificationType, type NullOrUndefined, type OpeningHours, type PaginateResult, ParcelSize, PaymentOptions, type PendingErrand, type PortalHandleAvailability, PortalStatus, type Product, type ProductCategory, type ProductImage, type ProductOption, type ProductOptionValue, type ProductStatus, type ProductTag, type ProductVariant, type ProductVariantPrice, type PublicPortal, type PublicPortalBusiness, RemittanceStatus, type Rider, type RiderPerformanceItem, type RiderPerformanceStats, type RiderPerformanceSummary, type RiderPerformanceTimeSeries, type RiderSettlement, type RiderWithUserDetails, RoleType, type State, SweepExclusionReason, type TrackerPosition, type Transaction, type TransactionCategory, type TransactionItem, type TransactionType, type TransactionWithCategory, type TransactionWithJoin, type User, type UserAddress, type Vehicle, type VehicleErrandStats, type VehicleFuelStats, type VehicleLog, type VehicleLogStatsSummary, VehicleLogType, type VehicleLogWithErrands, type VehicleMaintenanceStats, type VehiclePerformanceData, type VehiclePerformanceFilters, type VehiclePerformanceItem, type VehiclePerformanceTotals, VehicleType, type VehicleWithRider, type Vendor, WhatsappButtonType, WhatsappComponentType, WhatsappEvent, WhatsappRecipient, type WhatsappSendLog, type WhatsappTemplate, type WhatsappTemplateButton, type WhatsappTemplateComponent, WhatsappTemplateMetaStatus, WhatsappTemplateParamSource, type WhatsappTemplateSource, errandTimeline };
|
package/dist/index.d.ts
CHANGED
|
@@ -132,6 +132,29 @@ interface Customer {
|
|
|
132
132
|
customerBusinessId?: string;
|
|
133
133
|
transactionStats?: CustomerTransactionStats;
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* What a customer owes, computed server-side. `unbilled` is a SET, not a
|
|
137
|
+
* period — it has no start or end date, and `oldestUnbilledAt` is simply its
|
|
138
|
+
* earliest member.
|
|
139
|
+
*/
|
|
140
|
+
interface CustomerBilling {
|
|
141
|
+
unbilledAmount: number;
|
|
142
|
+
unbilledCount: number;
|
|
143
|
+
oldestUnbilledAt: string | null;
|
|
144
|
+
outstandingAmount: number;
|
|
145
|
+
openInvoiceCount: number;
|
|
146
|
+
/** End of the newest period already invoiced. */
|
|
147
|
+
lastInvoicedThrough: string | null;
|
|
148
|
+
/**
|
|
149
|
+
* The next invoice window, derived rather than typed: from the day after the
|
|
150
|
+
* last invoice closed, to today. Consecutive periods therefore tile with no
|
|
151
|
+
* gap and no overlap.
|
|
152
|
+
*/
|
|
153
|
+
nextPeriod: {
|
|
154
|
+
from: string | null;
|
|
155
|
+
to: string;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
135
158
|
|
|
136
159
|
declare enum InvoiceStatus {
|
|
137
160
|
Pending = "pending",
|
|
@@ -152,6 +175,82 @@ declare enum PaymentOptions {
|
|
|
152
175
|
Card = "card",
|
|
153
176
|
BusinessInvoice = "business_invoice"
|
|
154
177
|
}
|
|
178
|
+
declare enum InvoicePaymentMethod {
|
|
179
|
+
Transfer = "transfer",
|
|
180
|
+
Cash = "cash",
|
|
181
|
+
Card = "card",
|
|
182
|
+
Pos = "pos",
|
|
183
|
+
Other = "other"
|
|
184
|
+
}
|
|
185
|
+
declare enum InvoiceEventType {
|
|
186
|
+
Frozen = "frozen",
|
|
187
|
+
ErrandsAdded = "errands_added",
|
|
188
|
+
ErrandRemoved = "errand_removed",
|
|
189
|
+
Recalculated = "recalculated",
|
|
190
|
+
LineAmountChanged = "line_amount_changed",
|
|
191
|
+
PaymentRecorded = "payment_recorded",
|
|
192
|
+
PaymentReversed = "payment_reversed",
|
|
193
|
+
StatusChanged = "status_changed",
|
|
194
|
+
LinkCreated = "link_created",
|
|
195
|
+
LinkRevoked = "link_revoked",
|
|
196
|
+
Viewed = "viewed"
|
|
197
|
+
}
|
|
198
|
+
/** Why an errand in the period was not charged on the statement. */
|
|
199
|
+
declare enum SweepExclusionReason {
|
|
200
|
+
Cancelled = "cancelled",
|
|
201
|
+
AlreadyInvoiced = "already_invoiced",
|
|
202
|
+
SettledCash = "settled_cash",
|
|
203
|
+
Prepaid = "prepaid",
|
|
204
|
+
Owed = "owed",
|
|
205
|
+
NotInvoiceable = "not_invoiceable"
|
|
206
|
+
}
|
|
207
|
+
interface InvoicePayment {
|
|
208
|
+
id: string;
|
|
209
|
+
invoiceId: string;
|
|
210
|
+
businessId: string;
|
|
211
|
+
amount: number;
|
|
212
|
+
paidAt: string;
|
|
213
|
+
method?: InvoicePaymentMethod | `${InvoicePaymentMethod}`;
|
|
214
|
+
reference?: string;
|
|
215
|
+
note?: string;
|
|
216
|
+
recordedBy: string;
|
|
217
|
+
reversedAt?: string;
|
|
218
|
+
reversedBy?: string;
|
|
219
|
+
reversalReason?: string;
|
|
220
|
+
createdAt: string;
|
|
221
|
+
updatedAt: string;
|
|
222
|
+
}
|
|
223
|
+
interface InvoiceEvent {
|
|
224
|
+
id: string;
|
|
225
|
+
invoiceId: string;
|
|
226
|
+
businessId: string;
|
|
227
|
+
type: InvoiceEventType | `${InvoiceEventType}`;
|
|
228
|
+
actorUserId?: string;
|
|
229
|
+
amountBefore?: number;
|
|
230
|
+
amountAfter?: number;
|
|
231
|
+
summary?: string;
|
|
232
|
+
/** Repeated back to the customer on their own statement. */
|
|
233
|
+
customerVisible: boolean;
|
|
234
|
+
meta?: Record<string, unknown>;
|
|
235
|
+
createdAt: string;
|
|
236
|
+
}
|
|
237
|
+
interface InvoiceStatementLink {
|
|
238
|
+
id: string;
|
|
239
|
+
invoiceId: string;
|
|
240
|
+
businessId: string;
|
|
241
|
+
token: string;
|
|
242
|
+
expiresAt: string;
|
|
243
|
+
revokedAt?: string;
|
|
244
|
+
viewCount: number;
|
|
245
|
+
firstViewedAt?: string;
|
|
246
|
+
lastViewedAt?: string;
|
|
247
|
+
createdAt: string;
|
|
248
|
+
}
|
|
249
|
+
/** Whether a frozen invoice has fallen out of date, and by how much. */
|
|
250
|
+
interface InvoiceDrift {
|
|
251
|
+
errandCount: number;
|
|
252
|
+
amount: number;
|
|
253
|
+
}
|
|
155
254
|
interface Invoice {
|
|
156
255
|
id: string;
|
|
157
256
|
businessId: string;
|
|
@@ -159,9 +258,26 @@ interface Invoice {
|
|
|
159
258
|
invoiceNumber: string;
|
|
160
259
|
startDate: string;
|
|
161
260
|
endDate: string;
|
|
261
|
+
/** What the customer is asked for. Excludes zero-rated lines. */
|
|
162
262
|
totalAmount: number;
|
|
263
|
+
/**
|
|
264
|
+
* What the settled-at-the-door lines were worth. Never owed, never part of
|
|
265
|
+
* `totalAmount` — carried so the statement can show the period's full
|
|
266
|
+
* activity without charging for it twice.
|
|
267
|
+
*/
|
|
268
|
+
zeroRatedTotal: number;
|
|
163
269
|
paidAmount: number;
|
|
164
270
|
unpaidAmount: number;
|
|
271
|
+
lastRecalculatedAt?: string;
|
|
272
|
+
/**
|
|
273
|
+
* Document lifecycle, kept separate from `status`: an invoice can be
|
|
274
|
+
* part-paid and viewed, or paid and never opened.
|
|
275
|
+
*/
|
|
276
|
+
sentAt?: string;
|
|
277
|
+
firstViewedAt?: string;
|
|
278
|
+
lastViewedAt?: string;
|
|
279
|
+
viewCount?: number;
|
|
280
|
+
drift?: InvoiceDrift;
|
|
165
281
|
status: InvoiceStatus | `${InvoiceStatus}`;
|
|
166
282
|
customerId: string;
|
|
167
283
|
items: InvoiceItem[];
|
|
@@ -176,7 +292,13 @@ interface InvoiceItem {
|
|
|
176
292
|
invoiceId: string;
|
|
177
293
|
itemType: InvoiceItemType | `${InvoiceItemType}`;
|
|
178
294
|
itemId: string;
|
|
295
|
+
/** Contribution to the invoice total. Zero for a settled line. */
|
|
179
296
|
amount: number;
|
|
297
|
+
/** Shown but not charged — work the customer already paid for in cash. */
|
|
298
|
+
zeroRated?: boolean;
|
|
299
|
+
settledBy?: 'cash';
|
|
300
|
+
/** What the work was worth, on a zero-rated line only. */
|
|
301
|
+
originalAmount?: number;
|
|
180
302
|
description: string;
|
|
181
303
|
date: string;
|
|
182
304
|
createdAt: string;
|
|
@@ -397,11 +519,17 @@ type VehicleLog = {
|
|
|
397
519
|
createdAt: string;
|
|
398
520
|
updatedAt: string;
|
|
399
521
|
previousLogId?: string;
|
|
400
|
-
errandIdsSinceLastRefuel?: string[];
|
|
401
|
-
lastRecalculatedAt?: string;
|
|
402
522
|
vehicleDetails?: Vehicle;
|
|
403
523
|
};
|
|
404
524
|
type VehicleLogWithErrands = VehicleLog & {
|
|
525
|
+
/**
|
|
526
|
+
* The errands the vehicle ran during this refuel's fuel period —
|
|
527
|
+
* `(previousLog.createdAt, createdAt]`. Derived on read, so it always
|
|
528
|
+
* reflects current assignments and cancellations.
|
|
529
|
+
*/
|
|
530
|
+
errands?: Errand[];
|
|
531
|
+
/** Start of the fuel period; null for a vehicle's first log. */
|
|
532
|
+
periodStart?: string | null;
|
|
405
533
|
errandsCount?: number;
|
|
406
534
|
totalErrandsRevenue?: number;
|
|
407
535
|
/**
|
|
@@ -1284,6 +1412,49 @@ interface WhatsappSendLog {
|
|
|
1284
1412
|
sentAt: string | Date;
|
|
1285
1413
|
}
|
|
1286
1414
|
|
|
1415
|
+
declare enum PortalStatus {
|
|
1416
|
+
Draft = "draft",
|
|
1417
|
+
Published = "published"
|
|
1418
|
+
}
|
|
1419
|
+
interface BusinessPortal {
|
|
1420
|
+
id: string;
|
|
1421
|
+
businessId: string;
|
|
1422
|
+
/** Compose the URL yourself, e.g. `https://mydoormot.io/b/${handle}`. */
|
|
1423
|
+
handle: string;
|
|
1424
|
+
previousHandles: string[];
|
|
1425
|
+
status: PortalStatus;
|
|
1426
|
+
publishedAt?: string;
|
|
1427
|
+
createdAt: string;
|
|
1428
|
+
updatedAt: string;
|
|
1429
|
+
}
|
|
1430
|
+
interface PublicPortalBusiness {
|
|
1431
|
+
name?: string;
|
|
1432
|
+
description?: string;
|
|
1433
|
+
officeNumber?: string;
|
|
1434
|
+
address?: string;
|
|
1435
|
+
logoUrl?: string;
|
|
1436
|
+
logoBlurHash?: string;
|
|
1437
|
+
coverImageUrl?: string;
|
|
1438
|
+
coverImageBlurHash?: string;
|
|
1439
|
+
isOnline?: boolean;
|
|
1440
|
+
openingHours?: Record<string, unknown>;
|
|
1441
|
+
socialLinks?: Record<string, unknown>;
|
|
1442
|
+
}
|
|
1443
|
+
/** `GET /api/v2/portals/:handle` — unauthenticated. */
|
|
1444
|
+
interface PublicPortal {
|
|
1445
|
+
handle: string;
|
|
1446
|
+
/** Set when the requested handle was retired — redirect to `handle`. */
|
|
1447
|
+
redirectedFrom?: string;
|
|
1448
|
+
business: PublicPortalBusiness;
|
|
1449
|
+
}
|
|
1450
|
+
/** `GET /api/v2/portals/handles/:handle` — unauthenticated. */
|
|
1451
|
+
interface PortalHandleAvailability {
|
|
1452
|
+
/** Normalised — what you would actually be assigned. */
|
|
1453
|
+
handle: string;
|
|
1454
|
+
available: boolean;
|
|
1455
|
+
reason?: string;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1287
1458
|
interface PaginateResult<T> {
|
|
1288
1459
|
docs: T[];
|
|
1289
1460
|
totalDocs: number;
|
|
@@ -1306,4 +1477,4 @@ declare enum LinkDestination {
|
|
|
1306
1477
|
}
|
|
1307
1478
|
type NullOrUndefined = null | undefined;
|
|
1308
1479
|
|
|
1309
|
-
export { type AddonGroup, type AddonGroupItem, type AddressDetails, AddressTypes, type AggregatedErrand, AuthType, type Business, BusinessCapability, type BusinessCategory, type BusinessCourierLink, BusinessCourierLinkStatus, type BusinessMember, type BusinessModules, type BusinessPg, BusinessRole, type BusinessSettings, BusinessStatus, type BusinessWhatsappConfig, type City, type Collection, type Customer, type CustomerAddress, type CustomerTransactionStats, DEFAULT_BUSINESS_MODULES, DEFAULT_BUSINESS_SETTINGS, DeliveryStatus, type DraftErrand, DraftErrandStatus, type Enterprise, type EnterpriseCategoryDoc, type EnterpriseSubCategoryDoc, EnterpriseType, type Errand, type ErrandDeliveryTiming, type ErrandPackagingQuality, type ErrandRating, type ErrandReview, type ErrandReviewLink, type ErrandRiderBehavior, ErrandStatus, type ErrandTimeline, type ExpensePaidBy, FeePaymentStatus, FeeSettlement, type GeoPoint, GlobalRoles, type Invoice, InvoiceGenerationType, type InvoiceItem, InvoiceItemType, InvoiceStatus, type LatLng, LinkDestination, type MaintenanceItem, type MaintenancePartUsage, type MaintenanceRecord, type MaintenanceStats, type MaintenanceStatsSummary, type MaintenanceTopItem, MembershipStatus, type Notification, type NotificationData, NotificationType, type NullOrUndefined, type OpeningHours, type PaginateResult, ParcelSize, PaymentOptions, type PendingErrand, type Product, type ProductCategory, type ProductImage, type ProductOption, type ProductOptionValue, type ProductStatus, type ProductTag, type ProductVariant, type ProductVariantPrice, RemittanceStatus, type Rider, type RiderPerformanceItem, type RiderPerformanceStats, type RiderPerformanceSummary, type RiderPerformanceTimeSeries, type RiderSettlement, type RiderWithUserDetails, RoleType, type State, type TrackerPosition, type Transaction, type TransactionCategory, type TransactionItem, type TransactionType, type TransactionWithCategory, type TransactionWithJoin, type User, type UserAddress, type Vehicle, type VehicleErrandStats, type VehicleFuelStats, type VehicleLog, type VehicleLogStatsSummary, VehicleLogType, type VehicleLogWithErrands, type VehicleMaintenanceStats, type VehiclePerformanceData, type VehiclePerformanceFilters, type VehiclePerformanceItem, type VehiclePerformanceTotals, VehicleType, type VehicleWithRider, type Vendor, WhatsappButtonType, WhatsappComponentType, WhatsappEvent, WhatsappRecipient, type WhatsappSendLog, type WhatsappTemplate, type WhatsappTemplateButton, type WhatsappTemplateComponent, WhatsappTemplateMetaStatus, WhatsappTemplateParamSource, type WhatsappTemplateSource, errandTimeline };
|
|
1480
|
+
export { type AddonGroup, type AddonGroupItem, type AddressDetails, AddressTypes, type AggregatedErrand, AuthType, type Business, BusinessCapability, type BusinessCategory, type BusinessCourierLink, BusinessCourierLinkStatus, type BusinessMember, type BusinessModules, type BusinessPg, type BusinessPortal, BusinessRole, type BusinessSettings, BusinessStatus, type BusinessWhatsappConfig, type City, type Collection, type Customer, type CustomerAddress, type CustomerBilling, type CustomerTransactionStats, DEFAULT_BUSINESS_MODULES, DEFAULT_BUSINESS_SETTINGS, DeliveryStatus, type DraftErrand, DraftErrandStatus, type Enterprise, type EnterpriseCategoryDoc, type EnterpriseSubCategoryDoc, EnterpriseType, type Errand, type ErrandDeliveryTiming, type ErrandPackagingQuality, type ErrandRating, type ErrandReview, type ErrandReviewLink, type ErrandRiderBehavior, ErrandStatus, type ErrandTimeline, type ExpensePaidBy, FeePaymentStatus, FeeSettlement, type GeoPoint, GlobalRoles, type Invoice, type InvoiceDrift, type InvoiceEvent, InvoiceEventType, InvoiceGenerationType, type InvoiceItem, InvoiceItemType, type InvoicePayment, InvoicePaymentMethod, type InvoiceStatementLink, InvoiceStatus, type LatLng, LinkDestination, type MaintenanceItem, type MaintenancePartUsage, type MaintenanceRecord, type MaintenanceStats, type MaintenanceStatsSummary, type MaintenanceTopItem, MembershipStatus, type Notification, type NotificationData, NotificationType, type NullOrUndefined, type OpeningHours, type PaginateResult, ParcelSize, PaymentOptions, type PendingErrand, type PortalHandleAvailability, PortalStatus, type Product, type ProductCategory, type ProductImage, type ProductOption, type ProductOptionValue, type ProductStatus, type ProductTag, type ProductVariant, type ProductVariantPrice, type PublicPortal, type PublicPortalBusiness, RemittanceStatus, type Rider, type RiderPerformanceItem, type RiderPerformanceStats, type RiderPerformanceSummary, type RiderPerformanceTimeSeries, type RiderSettlement, type RiderWithUserDetails, RoleType, type State, SweepExclusionReason, type TrackerPosition, type Transaction, type TransactionCategory, type TransactionItem, type TransactionType, type TransactionWithCategory, type TransactionWithJoin, type User, type UserAddress, type Vehicle, type VehicleErrandStats, type VehicleFuelStats, type VehicleLog, type VehicleLogStatsSummary, VehicleLogType, type VehicleLogWithErrands, type VehicleMaintenanceStats, type VehiclePerformanceData, type VehiclePerformanceFilters, type VehiclePerformanceItem, type VehiclePerformanceTotals, VehicleType, type VehicleWithRider, type Vendor, WhatsappButtonType, WhatsappComponentType, WhatsappEvent, WhatsappRecipient, type WhatsappSendLog, type WhatsappTemplate, type WhatsappTemplateButton, type WhatsappTemplateComponent, WhatsappTemplateMetaStatus, WhatsappTemplateParamSource, type WhatsappTemplateSource, errandTimeline };
|
package/dist/index.js
CHANGED
|
@@ -129,6 +129,37 @@ var PaymentOptions = /* @__PURE__ */ ((PaymentOptions2) => {
|
|
|
129
129
|
PaymentOptions2["BusinessInvoice"] = "business_invoice";
|
|
130
130
|
return PaymentOptions2;
|
|
131
131
|
})(PaymentOptions || {});
|
|
132
|
+
var InvoicePaymentMethod = /* @__PURE__ */ ((InvoicePaymentMethod2) => {
|
|
133
|
+
InvoicePaymentMethod2["Transfer"] = "transfer";
|
|
134
|
+
InvoicePaymentMethod2["Cash"] = "cash";
|
|
135
|
+
InvoicePaymentMethod2["Card"] = "card";
|
|
136
|
+
InvoicePaymentMethod2["Pos"] = "pos";
|
|
137
|
+
InvoicePaymentMethod2["Other"] = "other";
|
|
138
|
+
return InvoicePaymentMethod2;
|
|
139
|
+
})(InvoicePaymentMethod || {});
|
|
140
|
+
var InvoiceEventType = /* @__PURE__ */ ((InvoiceEventType2) => {
|
|
141
|
+
InvoiceEventType2["Frozen"] = "frozen";
|
|
142
|
+
InvoiceEventType2["ErrandsAdded"] = "errands_added";
|
|
143
|
+
InvoiceEventType2["ErrandRemoved"] = "errand_removed";
|
|
144
|
+
InvoiceEventType2["Recalculated"] = "recalculated";
|
|
145
|
+
InvoiceEventType2["LineAmountChanged"] = "line_amount_changed";
|
|
146
|
+
InvoiceEventType2["PaymentRecorded"] = "payment_recorded";
|
|
147
|
+
InvoiceEventType2["PaymentReversed"] = "payment_reversed";
|
|
148
|
+
InvoiceEventType2["StatusChanged"] = "status_changed";
|
|
149
|
+
InvoiceEventType2["LinkCreated"] = "link_created";
|
|
150
|
+
InvoiceEventType2["LinkRevoked"] = "link_revoked";
|
|
151
|
+
InvoiceEventType2["Viewed"] = "viewed";
|
|
152
|
+
return InvoiceEventType2;
|
|
153
|
+
})(InvoiceEventType || {});
|
|
154
|
+
var SweepExclusionReason = /* @__PURE__ */ ((SweepExclusionReason2) => {
|
|
155
|
+
SweepExclusionReason2["Cancelled"] = "cancelled";
|
|
156
|
+
SweepExclusionReason2["AlreadyInvoiced"] = "already_invoiced";
|
|
157
|
+
SweepExclusionReason2["SettledCash"] = "settled_cash";
|
|
158
|
+
SweepExclusionReason2["Prepaid"] = "prepaid";
|
|
159
|
+
SweepExclusionReason2["Owed"] = "owed";
|
|
160
|
+
SweepExclusionReason2["NotInvoiceable"] = "not_invoiceable";
|
|
161
|
+
return SweepExclusionReason2;
|
|
162
|
+
})(SweepExclusionReason || {});
|
|
132
163
|
|
|
133
164
|
// src/notification.ts
|
|
134
165
|
var NotificationType = /* @__PURE__ */ ((NotificationType2) => {
|
|
@@ -277,6 +308,13 @@ var WhatsappTemplateParamSource = /* @__PURE__ */ ((WhatsappTemplateParamSource2
|
|
|
277
308
|
return WhatsappTemplateParamSource2;
|
|
278
309
|
})(WhatsappTemplateParamSource || {});
|
|
279
310
|
|
|
311
|
+
// src/portal.ts
|
|
312
|
+
var PortalStatus = /* @__PURE__ */ ((PortalStatus2) => {
|
|
313
|
+
PortalStatus2["Draft"] = "draft";
|
|
314
|
+
PortalStatus2["Published"] = "published";
|
|
315
|
+
return PortalStatus2;
|
|
316
|
+
})(PortalStatus || {});
|
|
317
|
+
|
|
280
318
|
// src/index.ts
|
|
281
319
|
var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
|
|
282
320
|
LinkDestination2["Website"] = "web";
|
|
@@ -300,16 +338,20 @@ export {
|
|
|
300
338
|
FeePaymentStatus,
|
|
301
339
|
FeeSettlement,
|
|
302
340
|
GlobalRoles,
|
|
341
|
+
InvoiceEventType,
|
|
303
342
|
InvoiceGenerationType,
|
|
304
343
|
InvoiceItemType,
|
|
344
|
+
InvoicePaymentMethod,
|
|
305
345
|
InvoiceStatus,
|
|
306
346
|
LinkDestination,
|
|
307
347
|
MembershipStatus,
|
|
308
348
|
NotificationType,
|
|
309
349
|
ParcelSize,
|
|
310
350
|
PaymentOptions,
|
|
351
|
+
PortalStatus,
|
|
311
352
|
RemittanceStatus,
|
|
312
353
|
RoleType,
|
|
354
|
+
SweepExclusionReason,
|
|
313
355
|
VehicleLogType,
|
|
314
356
|
VehicleType,
|
|
315
357
|
WhatsappButtonType,
|
package/package.json
CHANGED
package/src/customer.ts
CHANGED
|
@@ -48,3 +48,24 @@ export interface Customer {
|
|
|
48
48
|
// city?: City;
|
|
49
49
|
// state?: State;
|
|
50
50
|
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* What a customer owes, computed server-side. `unbilled` is a SET, not a
|
|
54
|
+
* period — it has no start or end date, and `oldestUnbilledAt` is simply its
|
|
55
|
+
* earliest member.
|
|
56
|
+
*/
|
|
57
|
+
export interface CustomerBilling {
|
|
58
|
+
unbilledAmount: number;
|
|
59
|
+
unbilledCount: number;
|
|
60
|
+
oldestUnbilledAt: string | null;
|
|
61
|
+
outstandingAmount: number;
|
|
62
|
+
openInvoiceCount: number;
|
|
63
|
+
/** End of the newest period already invoiced. */
|
|
64
|
+
lastInvoicedThrough: string | null;
|
|
65
|
+
/**
|
|
66
|
+
* The next invoice window, derived rather than typed: from the day after the
|
|
67
|
+
* last invoice closed, to today. Consecutive periods therefore tile with no
|
|
68
|
+
* gap and no overlap.
|
|
69
|
+
*/
|
|
70
|
+
nextPeriod: { from: string | null; to: string };
|
|
71
|
+
}
|
package/src/index.ts
CHANGED
package/src/invoice.ts
CHANGED
|
@@ -25,6 +25,89 @@ export enum PaymentOptions {
|
|
|
25
25
|
BusinessInvoice = 'business_invoice',
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
export enum InvoicePaymentMethod {
|
|
29
|
+
Transfer = 'transfer',
|
|
30
|
+
Cash = 'cash',
|
|
31
|
+
Card = 'card',
|
|
32
|
+
Pos = 'pos',
|
|
33
|
+
Other = 'other',
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export enum InvoiceEventType {
|
|
37
|
+
Frozen = 'frozen',
|
|
38
|
+
ErrandsAdded = 'errands_added',
|
|
39
|
+
ErrandRemoved = 'errand_removed',
|
|
40
|
+
Recalculated = 'recalculated',
|
|
41
|
+
LineAmountChanged = 'line_amount_changed',
|
|
42
|
+
PaymentRecorded = 'payment_recorded',
|
|
43
|
+
PaymentReversed = 'payment_reversed',
|
|
44
|
+
StatusChanged = 'status_changed',
|
|
45
|
+
LinkCreated = 'link_created',
|
|
46
|
+
LinkRevoked = 'link_revoked',
|
|
47
|
+
Viewed = 'viewed',
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Why an errand in the period was not charged on the statement. */
|
|
51
|
+
export enum SweepExclusionReason {
|
|
52
|
+
Cancelled = 'cancelled',
|
|
53
|
+
AlreadyInvoiced = 'already_invoiced',
|
|
54
|
+
SettledCash = 'settled_cash',
|
|
55
|
+
Prepaid = 'prepaid',
|
|
56
|
+
Owed = 'owed',
|
|
57
|
+
NotInvoiceable = 'not_invoiceable',
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface InvoicePayment {
|
|
61
|
+
id: string;
|
|
62
|
+
invoiceId: string;
|
|
63
|
+
businessId: string;
|
|
64
|
+
amount: number;
|
|
65
|
+
paidAt: string;
|
|
66
|
+
method?: InvoicePaymentMethod | `${InvoicePaymentMethod}`;
|
|
67
|
+
reference?: string;
|
|
68
|
+
note?: string;
|
|
69
|
+
recordedBy: string;
|
|
70
|
+
reversedAt?: string;
|
|
71
|
+
reversedBy?: string;
|
|
72
|
+
reversalReason?: string;
|
|
73
|
+
createdAt: string;
|
|
74
|
+
updatedAt: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface InvoiceEvent {
|
|
78
|
+
id: string;
|
|
79
|
+
invoiceId: string;
|
|
80
|
+
businessId: string;
|
|
81
|
+
type: InvoiceEventType | `${InvoiceEventType}`;
|
|
82
|
+
actorUserId?: string;
|
|
83
|
+
amountBefore?: number;
|
|
84
|
+
amountAfter?: number;
|
|
85
|
+
summary?: string;
|
|
86
|
+
/** Repeated back to the customer on their own statement. */
|
|
87
|
+
customerVisible: boolean;
|
|
88
|
+
meta?: Record<string, unknown>;
|
|
89
|
+
createdAt: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface InvoiceStatementLink {
|
|
93
|
+
id: string;
|
|
94
|
+
invoiceId: string;
|
|
95
|
+
businessId: string;
|
|
96
|
+
token: string;
|
|
97
|
+
expiresAt: string;
|
|
98
|
+
revokedAt?: string;
|
|
99
|
+
viewCount: number;
|
|
100
|
+
firstViewedAt?: string;
|
|
101
|
+
lastViewedAt?: string;
|
|
102
|
+
createdAt: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Whether a frozen invoice has fallen out of date, and by how much. */
|
|
106
|
+
export interface InvoiceDrift {
|
|
107
|
+
errandCount: number;
|
|
108
|
+
amount: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
28
111
|
export interface Invoice {
|
|
29
112
|
id: string;
|
|
30
113
|
businessId: string;
|
|
@@ -32,9 +115,26 @@ export interface Invoice {
|
|
|
32
115
|
invoiceNumber: string;
|
|
33
116
|
startDate: string;
|
|
34
117
|
endDate: string;
|
|
118
|
+
/** What the customer is asked for. Excludes zero-rated lines. */
|
|
35
119
|
totalAmount: number;
|
|
120
|
+
/**
|
|
121
|
+
* What the settled-at-the-door lines were worth. Never owed, never part of
|
|
122
|
+
* `totalAmount` — carried so the statement can show the period's full
|
|
123
|
+
* activity without charging for it twice.
|
|
124
|
+
*/
|
|
125
|
+
zeroRatedTotal: number;
|
|
36
126
|
paidAmount: number;
|
|
37
127
|
unpaidAmount: number;
|
|
128
|
+
lastRecalculatedAt?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Document lifecycle, kept separate from `status`: an invoice can be
|
|
131
|
+
* part-paid and viewed, or paid and never opened.
|
|
132
|
+
*/
|
|
133
|
+
sentAt?: string;
|
|
134
|
+
firstViewedAt?: string;
|
|
135
|
+
lastViewedAt?: string;
|
|
136
|
+
viewCount?: number;
|
|
137
|
+
drift?: InvoiceDrift;
|
|
38
138
|
status: InvoiceStatus | `${InvoiceStatus}`;
|
|
39
139
|
customerId: string;
|
|
40
140
|
items: InvoiceItem[];
|
|
@@ -52,7 +152,13 @@ export interface InvoiceItem {
|
|
|
52
152
|
itemType: InvoiceItemType | `${InvoiceItemType}`;
|
|
53
153
|
itemId: string;
|
|
54
154
|
// item: Errand;
|
|
155
|
+
/** Contribution to the invoice total. Zero for a settled line. */
|
|
55
156
|
amount: number;
|
|
157
|
+
/** Shown but not charged — work the customer already paid for in cash. */
|
|
158
|
+
zeroRated?: boolean;
|
|
159
|
+
settledBy?: 'cash';
|
|
160
|
+
/** What the work was worth, on a zero-rated line only. */
|
|
161
|
+
originalAmount?: number;
|
|
56
162
|
description: string;
|
|
57
163
|
date: string;
|
|
58
164
|
createdAt: string;
|
package/src/portal.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export enum PortalStatus {
|
|
2
|
+
Draft = 'draft',
|
|
3
|
+
Published = 'published',
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface BusinessPortal {
|
|
7
|
+
id: string;
|
|
8
|
+
businessId: string;
|
|
9
|
+
/** Compose the URL yourself, e.g. `https://mydoormot.io/b/${handle}`. */
|
|
10
|
+
handle: string;
|
|
11
|
+
previousHandles: string[];
|
|
12
|
+
status: PortalStatus;
|
|
13
|
+
publishedAt?: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface PublicPortalBusiness {
|
|
19
|
+
name?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
officeNumber?: string;
|
|
22
|
+
address?: string;
|
|
23
|
+
logoUrl?: string;
|
|
24
|
+
logoBlurHash?: string;
|
|
25
|
+
coverImageUrl?: string;
|
|
26
|
+
coverImageBlurHash?: string;
|
|
27
|
+
isOnline?: boolean;
|
|
28
|
+
openingHours?: Record<string, unknown>;
|
|
29
|
+
socialLinks?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** `GET /api/v2/portals/:handle` — unauthenticated. */
|
|
33
|
+
export interface PublicPortal {
|
|
34
|
+
handle: string;
|
|
35
|
+
/** Set when the requested handle was retired — redirect to `handle`. */
|
|
36
|
+
redirectedFrom?: string;
|
|
37
|
+
business: PublicPortalBusiness;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** `GET /api/v2/portals/handles/:handle` — unauthenticated. */
|
|
41
|
+
export interface PortalHandleAvailability {
|
|
42
|
+
/** Normalised — what you would actually be assigned. */
|
|
43
|
+
handle: string;
|
|
44
|
+
available: boolean;
|
|
45
|
+
reason?: string;
|
|
46
|
+
}
|
package/src/vehicle.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Errand } from './errand';
|
|
1
2
|
import { RiderWithUserDetails } from './rider';
|
|
2
3
|
|
|
3
4
|
export enum VehicleType {
|
|
@@ -73,12 +74,18 @@ export type VehicleLog = {
|
|
|
73
74
|
createdAt: string;
|
|
74
75
|
updatedAt: string;
|
|
75
76
|
previousLogId?: string;
|
|
76
|
-
errandIdsSinceLastRefuel?: string[];
|
|
77
|
-
lastRecalculatedAt?: string;
|
|
78
77
|
vehicleDetails?: Vehicle;
|
|
79
78
|
};
|
|
80
79
|
|
|
81
80
|
export type VehicleLogWithErrands = VehicleLog & {
|
|
81
|
+
/**
|
|
82
|
+
* The errands the vehicle ran during this refuel's fuel period —
|
|
83
|
+
* `(previousLog.createdAt, createdAt]`. Derived on read, so it always
|
|
84
|
+
* reflects current assignments and cancellations.
|
|
85
|
+
*/
|
|
86
|
+
errands?: Errand[];
|
|
87
|
+
/** Start of the fuel period; null for a vehicle's first log. */
|
|
88
|
+
periodStart?: string | null;
|
|
82
89
|
errandsCount?: number;
|
|
83
90
|
totalErrandsRevenue?: number;
|
|
84
91
|
/**
|