@mydoormot/app-types 1.9.0 → 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.
@@ -1,18 +1,18 @@
1
-
2
- > @mydoormot/app-types@1.8.2 build /Users/chuksben/Desktop/projects/microservices/mydoormot/packages/app-types
3
- > tsup src/index.ts --format esm,cjs --dts
4
-
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v7.3.0
8
- CLI Target: es2021
9
- ESM Build start
10
- CJS Build start
11
- CJS dist/index.cjs 14.07 KB
12
- CJS ⚡️ Build success in 57ms
13
- ESM dist/index.js 11.62 KB
14
- ESM ⚡️ Build success in 57ms
15
- DTS Build start
16
- DTS ⚡️ Build success in 752ms
17
- DTS dist/index.d.ts 36.60 KB
18
- DTS dist/index.d.cts 36.60 KB
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
+ CLI Building entry: src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v7.3.0
8
+ CLI Target: es2021
9
+ ESM Build start
10
+ CJS Build start
11
+ DTS Build start
12
+ CJS dist/index.cjs 15.79 KB
13
+ CJS ⚡️ Build success in 301ms
14
+ ESM dist/index.js 13.19 KB
15
+ ESM ⚡️ Build success in 301ms
16
+ DTS ⚡️ Build success in 931ms
17
+ DTS dist/index.d.ts 40.67 KB
18
+ DTS dist/index.d.cts 40.67 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @mydoormot/app-types
2
2
 
3
+ ## 1.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Added customer billing
8
+
3
9
  ## 1.9.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -35,8 +35,10 @@ __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,
@@ -46,6 +48,7 @@ __export(src_exports, {
46
48
  PortalStatus: () => PortalStatus,
47
49
  RemittanceStatus: () => RemittanceStatus,
48
50
  RoleType: () => RoleType,
51
+ SweepExclusionReason: () => SweepExclusionReason,
49
52
  VehicleLogType: () => VehicleLogType,
50
53
  VehicleType: () => VehicleType,
51
54
  WhatsappButtonType: () => WhatsappButtonType,
@@ -189,6 +192,37 @@ var PaymentOptions = /* @__PURE__ */ ((PaymentOptions2) => {
189
192
  PaymentOptions2["BusinessInvoice"] = "business_invoice";
190
193
  return PaymentOptions2;
191
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 || {});
192
226
 
193
227
  // src/notification.ts
194
228
  var NotificationType = /* @__PURE__ */ ((NotificationType2) => {
@@ -368,8 +402,10 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
368
402
  FeePaymentStatus,
369
403
  FeeSettlement,
370
404
  GlobalRoles,
405
+ InvoiceEventType,
371
406
  InvoiceGenerationType,
372
407
  InvoiceItemType,
408
+ InvoicePaymentMethod,
373
409
  InvoiceStatus,
374
410
  LinkDestination,
375
411
  MembershipStatus,
@@ -379,6 +415,7 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
379
415
  PortalStatus,
380
416
  RemittanceStatus,
381
417
  RoleType,
418
+ SweepExclusionReason,
382
419
  VehicleLogType,
383
420
  VehicleType,
384
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
  /**
@@ -1312,14 +1440,14 @@ interface PublicPortalBusiness {
1312
1440
  openingHours?: Record<string, unknown>;
1313
1441
  socialLinks?: Record<string, unknown>;
1314
1442
  }
1315
- /** `GET /api/v2/public/b/:handle` */
1443
+ /** `GET /api/v2/portals/:handle` — unauthenticated. */
1316
1444
  interface PublicPortal {
1317
1445
  handle: string;
1318
1446
  /** Set when the requested handle was retired — redirect to `handle`. */
1319
1447
  redirectedFrom?: string;
1320
1448
  business: PublicPortalBusiness;
1321
1449
  }
1322
- /** `GET /api/v2/public/portal-handle-availability` */
1450
+ /** `GET /api/v2/portals/handles/:handle` — unauthenticated. */
1323
1451
  interface PortalHandleAvailability {
1324
1452
  /** Normalised — what you would actually be assigned. */
1325
1453
  handle: string;
@@ -1349,4 +1477,4 @@ declare enum LinkDestination {
1349
1477
  }
1350
1478
  type NullOrUndefined = null | undefined;
1351
1479
 
1352
- 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 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 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, 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
  /**
@@ -1312,14 +1440,14 @@ interface PublicPortalBusiness {
1312
1440
  openingHours?: Record<string, unknown>;
1313
1441
  socialLinks?: Record<string, unknown>;
1314
1442
  }
1315
- /** `GET /api/v2/public/b/:handle` */
1443
+ /** `GET /api/v2/portals/:handle` — unauthenticated. */
1316
1444
  interface PublicPortal {
1317
1445
  handle: string;
1318
1446
  /** Set when the requested handle was retired — redirect to `handle`. */
1319
1447
  redirectedFrom?: string;
1320
1448
  business: PublicPortalBusiness;
1321
1449
  }
1322
- /** `GET /api/v2/public/portal-handle-availability` */
1450
+ /** `GET /api/v2/portals/handles/:handle` — unauthenticated. */
1323
1451
  interface PortalHandleAvailability {
1324
1452
  /** Normalised — what you would actually be assigned. */
1325
1453
  handle: string;
@@ -1349,4 +1477,4 @@ declare enum LinkDestination {
1349
1477
  }
1350
1478
  type NullOrUndefined = null | undefined;
1351
1479
 
1352
- 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 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 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, 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) => {
@@ -307,8 +338,10 @@ export {
307
338
  FeePaymentStatus,
308
339
  FeeSettlement,
309
340
  GlobalRoles,
341
+ InvoiceEventType,
310
342
  InvoiceGenerationType,
311
343
  InvoiceItemType,
344
+ InvoicePaymentMethod,
312
345
  InvoiceStatus,
313
346
  LinkDestination,
314
347
  MembershipStatus,
@@ -318,6 +351,7 @@ export {
318
351
  PortalStatus,
319
352
  RemittanceStatus,
320
353
  RoleType,
354
+ SweepExclusionReason,
321
355
  VehicleLogType,
322
356
  VehicleType,
323
357
  WhatsappButtonType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mydoormot/app-types",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
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/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 CHANGED
@@ -29,7 +29,7 @@ export interface PublicPortalBusiness {
29
29
  socialLinks?: Record<string, unknown>;
30
30
  }
31
31
 
32
- /** `GET /api/v2/public/b/:handle` */
32
+ /** `GET /api/v2/portals/:handle` — unauthenticated. */
33
33
  export interface PublicPortal {
34
34
  handle: string;
35
35
  /** Set when the requested handle was retired — redirect to `handle`. */
@@ -37,7 +37,7 @@ export interface PublicPortal {
37
37
  business: PublicPortalBusiness;
38
38
  }
39
39
 
40
- /** `GET /api/v2/public/portal-handle-availability` */
40
+ /** `GET /api/v2/portals/handles/:handle` — unauthenticated. */
41
41
  export interface PortalHandleAvailability {
42
42
  /** Normalised — what you would actually be assigned. */
43
43
  handle: string;
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
  /**