@mydoormot/app-types 1.9.2 → 1.9.4

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,5 +1,5 @@
1
1
 
2
- > @mydoormot/app-types@1.9.1 build /Users/chuksben/Desktop/projects/microservices/mydoormot/packages/app-types
2
+ > @mydoormot/app-types@1.9.3 build /Users/chuksben/Desktop/projects/microservices/mydoormot/packages/app-types
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,11 +8,11 @@
8
8
  CLI Target: es2021
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.js 13.48 KB
12
- ESM ⚡️ Build success in 55ms
13
- CJS dist/index.cjs 16.12 KB
14
- CJS ⚡️ Build success in 55ms
11
+ ESM dist/index.js 13.63 KB
12
+ ESM ⚡️ Build success in 43ms
13
+ CJS dist/index.cjs 16.39 KB
14
+ CJS ⚡️ Build success in 43ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 635ms
17
- DTS dist/index.d.ts 41.80 KB
18
- DTS dist/index.d.cts 41.80 KB
16
+ DTS ⚡️ Build success in 622ms
17
+ DTS dist/index.d.ts 46.03 KB
18
+ DTS dist/index.d.cts 46.03 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @mydoormot/app-types
2
2
 
3
+ ## 1.9.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Modifed types
8
+
9
+ ## 1.9.3
10
+
11
+ ### Patch Changes
12
+
13
+ - Modified invoice types
14
+
3
15
  ## 1.9.2
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -26,6 +26,7 @@ __export(src_exports, {
26
26
  BusinessCourierLinkStatus: () => BusinessCourierLinkStatus,
27
27
  BusinessRole: () => BusinessRole,
28
28
  BusinessStatus: () => BusinessStatus,
29
+ DEFAULT_BUSINESS_FUEL_SETTINGS: () => DEFAULT_BUSINESS_FUEL_SETTINGS,
29
30
  DEFAULT_BUSINESS_MODULES: () => DEFAULT_BUSINESS_MODULES,
30
31
  DEFAULT_BUSINESS_SETTINGS: () => DEFAULT_BUSINESS_SETTINGS,
31
32
  DeliveryStatus: () => DeliveryStatus,
@@ -35,6 +36,7 @@ __export(src_exports, {
35
36
  ErrandStatus: () => ErrandStatus,
36
37
  FeePaymentStatus: () => FeePaymentStatus,
37
38
  FeeSettlement: () => FeeSettlement,
39
+ FuelDueStatus: () => FuelDueStatus,
38
40
  GlobalRoles: () => GlobalRoles,
39
41
  InvoiceEventType: () => InvoiceEventType,
40
42
  InvoiceGenerationType: () => InvoiceGenerationType,
@@ -216,16 +218,13 @@ var InvoiceEventType = /* @__PURE__ */ ((InvoiceEventType2) => {
216
218
  InvoiceEventType2["PaymentRecorded"] = "payment_recorded";
217
219
  InvoiceEventType2["PaymentReversed"] = "payment_reversed";
218
220
  InvoiceEventType2["StatusChanged"] = "status_changed";
219
- InvoiceEventType2["LinkCreated"] = "link_created";
220
- InvoiceEventType2["LinkRevoked"] = "link_revoked";
221
+ InvoiceEventType2["Shared"] = "shared";
221
222
  InvoiceEventType2["Viewed"] = "viewed";
222
223
  return InvoiceEventType2;
223
224
  })(InvoiceEventType || {});
224
225
  var SweepExclusionReason = /* @__PURE__ */ ((SweepExclusionReason2) => {
225
226
  SweepExclusionReason2["Cancelled"] = "cancelled";
226
227
  SweepExclusionReason2["AlreadyInvoiced"] = "already_invoiced";
227
- SweepExclusionReason2["SettledCash"] = "settled_cash";
228
- SweepExclusionReason2["Prepaid"] = "prepaid";
229
228
  SweepExclusionReason2["Owed"] = "owed";
230
229
  SweepExclusionReason2["NotInvoiceable"] = "not_invoiceable";
231
230
  return SweepExclusionReason2;
@@ -250,6 +249,11 @@ var VehicleLogType = /* @__PURE__ */ ((VehicleLogType2) => {
250
249
  VehicleLogType2["REFUEL"] = "REFUEL";
251
250
  return VehicleLogType2;
252
251
  })(VehicleLogType || {});
252
+ var FuelDueStatus = /* @__PURE__ */ ((FuelDueStatus2) => {
253
+ FuelDueStatus2["Due"] = "DUE";
254
+ FuelDueStatus2["Ok"] = "OK";
255
+ return FuelDueStatus2;
256
+ })(FuelDueStatus || {});
253
257
 
254
258
  // src/rider.ts
255
259
  var RemittanceStatus = /* @__PURE__ */ ((RemittanceStatus2) => {
@@ -291,6 +295,9 @@ var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
291
295
  MembershipStatus2["SUSPENDED"] = "SUSPENDED";
292
296
  return MembershipStatus2;
293
297
  })(MembershipStatus || {});
298
+ var DEFAULT_BUSINESS_FUEL_SETTINGS = {
299
+ revenuePercent: null
300
+ };
294
301
  var DEFAULT_BUSINESS_MODULES = {
295
302
  draftErrands: true,
296
303
  team: true,
@@ -322,7 +329,8 @@ var DEFAULT_BUSINESS_SETTINGS = {
322
329
  tiktok: null,
323
330
  website: null
324
331
  },
325
- modules: DEFAULT_BUSINESS_MODULES
332
+ modules: DEFAULT_BUSINESS_MODULES,
333
+ fuel: DEFAULT_BUSINESS_FUEL_SETTINGS
326
334
  };
327
335
  var BusinessCourierLinkStatus = /* @__PURE__ */ ((BusinessCourierLinkStatus2) => {
328
336
  BusinessCourierLinkStatus2["ACTIVE"] = "active";
@@ -400,6 +408,7 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
400
408
  BusinessCourierLinkStatus,
401
409
  BusinessRole,
402
410
  BusinessStatus,
411
+ DEFAULT_BUSINESS_FUEL_SETTINGS,
403
412
  DEFAULT_BUSINESS_MODULES,
404
413
  DEFAULT_BUSINESS_SETTINGS,
405
414
  DeliveryStatus,
@@ -409,6 +418,7 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
409
418
  ErrandStatus,
410
419
  FeePaymentStatus,
411
420
  FeeSettlement,
421
+ FuelDueStatus,
412
422
  GlobalRoles,
413
423
  InvoiceEventType,
414
424
  InvoiceGenerationType,
package/dist/index.d.cts CHANGED
@@ -197,16 +197,13 @@ declare enum InvoiceEventType {
197
197
  PaymentRecorded = "payment_recorded",
198
198
  PaymentReversed = "payment_reversed",
199
199
  StatusChanged = "status_changed",
200
- LinkCreated = "link_created",
201
- LinkRevoked = "link_revoked",
200
+ Shared = "shared",
202
201
  Viewed = "viewed"
203
202
  }
204
203
  /** Why an errand in the period was not charged on the statement. */
205
204
  declare enum SweepExclusionReason {
206
205
  Cancelled = "cancelled",
207
206
  AlreadyInvoiced = "already_invoiced",
208
- SettledCash = "settled_cash",
209
- Prepaid = "prepaid",
210
207
  Owed = "owed",
211
208
  NotInvoiceable = "not_invoiceable"
212
209
  }
@@ -240,17 +237,11 @@ interface InvoiceEvent {
240
237
  meta?: Record<string, unknown>;
241
238
  createdAt: string;
242
239
  }
243
- interface InvoiceStatementLink {
244
- id: string;
245
- invoiceId: string;
246
- businessId: string;
247
- token: string;
248
- expiresAt: string;
249
- revokedAt?: string;
250
- viewCount: number;
251
- firstViewedAt?: string;
252
- lastViewedAt?: string;
253
- createdAt: string;
240
+ /** What `POST /invoices/:invoiceId/statement-link` returns. */
241
+ interface SharedStatement {
242
+ /** The slug in the public statement URL. Stable for the invoice's lifetime. */
243
+ statementSlug: string;
244
+ sentAt?: string;
254
245
  }
255
246
  /** Whether a frozen invoice has fallen out of date, and by how much. */
256
247
  interface InvoiceDrift {
@@ -262,6 +253,12 @@ interface Invoice {
262
253
  businessId: string;
263
254
  userId: string;
264
255
  invoiceNumber: string;
256
+ /**
257
+ * Slug for the public statement URL, and the only credential guarding it.
258
+ * Written at freeze time, so every invoice is shareable immediately. Absent on
259
+ * invoices frozen before the field existed.
260
+ */
261
+ statementSlug?: string;
265
262
  startDate: string;
266
263
  endDate: string;
267
264
  /** What the customer is asked for. Excludes zero-rated lines. */
@@ -300,9 +297,17 @@ interface InvoiceItem {
300
297
  itemId: string;
301
298
  /** Contribution to the invoice total. Zero for a settled line. */
302
299
  amount: number;
303
- /** Shown but not charged — work the customer already paid for in cash. */
300
+ /**
301
+ * Shown but not charged — work whose fee the customer already settled, either
302
+ * in cash at the door or prepaid before dispatch.
303
+ */
304
304
  zeroRated?: boolean;
305
- settledBy?: 'cash';
305
+ /**
306
+ * Which already-settled route a zero-rated line took. Unset on a charged line.
307
+ * The invoice's `zeroRatedTotal` is one number for the period; sum lines by
308
+ * this field for the "paid at the door" / "paid in advance" split.
309
+ */
310
+ settledBy?: 'cash' | 'prepaid';
306
311
  /** What the work was worth, on a zero-rated line only. */
307
312
  originalAmount?: number;
308
313
  description: string;
@@ -403,6 +408,15 @@ interface BusinessModules {
403
408
  invoices: boolean;
404
409
  remittances: boolean;
405
410
  }
411
+ /**
412
+ * How a business funds fuel. `revenuePercent` is the share of errand revenue a
413
+ * vehicle sets aside for its own fuel — the single knob behind the fuel-owed
414
+ * balance. `null` (the default) means the business hasn't configured it and the
415
+ * balance is not computed at all.
416
+ */
417
+ interface BusinessFuelSettings {
418
+ revenuePercent: number | null;
419
+ }
406
420
  interface BusinessSettings {
407
421
  whatsapp_notification_enabled: boolean;
408
422
  whatsapp: BusinessWhatsappConfig;
@@ -429,7 +443,9 @@ interface BusinessSettings {
429
443
  maxErrands: number | null;
430
444
  };
431
445
  modules: BusinessModules;
446
+ fuel?: BusinessFuelSettings;
432
447
  }
448
+ declare const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings;
433
449
  declare const DEFAULT_BUSINESS_MODULES: BusinessModules;
434
450
  declare const DEFAULT_BUSINESS_SETTINGS: BusinessSettings;
435
451
  interface BusinessMember {
@@ -590,6 +606,95 @@ interface VehiclePerformanceData {
590
606
  totals: VehiclePerformanceTotals;
591
607
  filters: VehiclePerformanceFilters;
592
608
  }
609
+ declare enum FuelDueStatus {
610
+ /** Worked through the fuel it was last given. Fuel this one. */
611
+ Due = "DUE",
612
+ /** Still running on fuel already paid for. Leave it. */
613
+ Ok = "OK"
614
+ }
615
+ /** What the vehicle has done since the fuel it was last given. */
616
+ interface FuelSinceLastRefuel {
617
+ revenue: number;
618
+ errandCount: number;
619
+ fuelEarned: number;
620
+ }
621
+ interface FuelDueItem {
622
+ vehicleId: string;
623
+ vehicleNumber: string;
624
+ shortName: string | null;
625
+ vehicleType: VehicleType | `${VehicleType}`;
626
+ /**
627
+ * The fuel gauge, and the field to lead a UI with: how much of the fuel this
628
+ * vehicle was last given it has worked through. 0 is freshly filled, 100 is
629
+ * due, past 100 is overdue. Null when it has never been fuelled.
630
+ */
631
+ fuelUsedPercent: number | null;
632
+ /** `fuelEarned - fuelSpent`, in naira — how much to give, not whether to. */
633
+ fuelDue: number;
634
+ fuelEarned: number;
635
+ fuelSpent: number;
636
+ revenue: number;
637
+ errandCount: number;
638
+ refuelCount: number;
639
+ /** What this vehicle is typically fuelled with; null if never fuelled. */
640
+ averageRefuelCost: number | null;
641
+ /**
642
+ * The figure has drifted far past what this vehicle is ever fuelled with —
643
+ * the signature of a wrong `revenuePercent` compounding rather than a real
644
+ * fuel need. Prompt to check the percentage instead of showing the figure.
645
+ */
646
+ needsCalibration: boolean;
647
+ lastRefuel: {
648
+ at: string;
649
+ cost: number;
650
+ } | null;
651
+ sinceLastRefuel: FuelSinceLastRefuel | null;
652
+ dueStatus: FuelDueStatus | `${FuelDueStatus}`;
653
+ /** Counting starts here when the prediction has been reset; null otherwise. */
654
+ countingFrom: string | null;
655
+ }
656
+ interface FuelDueTotals {
657
+ totalDue: number;
658
+ totalEarned: number;
659
+ totalSpent: number;
660
+ vehiclesDue: number;
661
+ vehiclesNeedingCalibration: number;
662
+ }
663
+ interface FuelDueData {
664
+ /** False when the business has not set `settings.fuel.revenuePercent`. */
665
+ configured: boolean;
666
+ revenuePercent: number | null;
667
+ /** Only when `configured` is false: what history says the percent should be. */
668
+ suggestedPercent?: number | null;
669
+ vehicles: FuelDueItem[];
670
+ totals: FuelDueTotals;
671
+ }
672
+ type FuelSuggestionConfidence = 'low' | 'medium' | 'high';
673
+ interface FuelPercentSuggestion {
674
+ /**
675
+ * Fuel spend as a share of the revenue that earned it, to one decimal —
676
+ * the percentage this business has actually been running at. Null when
677
+ * there is too little history; `reason` says which.
678
+ */
679
+ suggestedPercent: number | null;
680
+ /**
681
+ * Read off the number of refuels behind the suggestion, not the length of
682
+ * the window. Fuel bought near a window's edge is burnt outside it, so a
683
+ * thin refuel count gives a volatile ratio however many days were read.
684
+ */
685
+ confidence: FuelSuggestionConfidence;
686
+ reason: string | null;
687
+ days: number;
688
+ basedOn: {
689
+ totalFuelCost: number;
690
+ totalRevenue: number;
691
+ refuelCount: number;
692
+ errandCount: number;
693
+ refuelledVehicles: number;
694
+ /** Refuels per vehicle — what says whether the ratio has settled. */
695
+ refuelsPerVehicle: number | null;
696
+ };
697
+ }
593
698
 
594
699
  type Rider = {
595
700
  id: string;
@@ -1501,4 +1606,4 @@ declare enum LinkDestination {
1501
1606
  }
1502
1607
  type NullOrUndefined = null | undefined;
1503
1608
 
1504
- 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, ErrandInvoiceState, 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 TransactionRiderUser, 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 };
1609
+ export { type AddonGroup, type AddonGroupItem, type AddressDetails, AddressTypes, type AggregatedErrand, AuthType, type Business, BusinessCapability, type BusinessCategory, type BusinessCourierLink, BusinessCourierLinkStatus, type BusinessFuelSettings, 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_FUEL_SETTINGS, DEFAULT_BUSINESS_MODULES, DEFAULT_BUSINESS_SETTINGS, DeliveryStatus, type DraftErrand, DraftErrandStatus, type Enterprise, type EnterpriseCategoryDoc, type EnterpriseSubCategoryDoc, EnterpriseType, type Errand, type ErrandDeliveryTiming, ErrandInvoiceState, type ErrandPackagingQuality, type ErrandRating, type ErrandReview, type ErrandReviewLink, type ErrandRiderBehavior, ErrandStatus, type ErrandTimeline, type ExpensePaidBy, FeePaymentStatus, FeeSettlement, type FuelDueData, type FuelDueItem, FuelDueStatus, type FuelDueTotals, type FuelPercentSuggestion, type FuelSinceLastRefuel, type FuelSuggestionConfidence, type GeoPoint, GlobalRoles, type Invoice, type InvoiceDrift, type InvoiceEvent, InvoiceEventType, InvoiceGenerationType, type InvoiceItem, InvoiceItemType, type InvoicePayment, InvoicePaymentMethod, 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 SharedStatement, type State, SweepExclusionReason, type TrackerPosition, type Transaction, type TransactionCategory, type TransactionItem, type TransactionRiderUser, 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
@@ -197,16 +197,13 @@ declare enum InvoiceEventType {
197
197
  PaymentRecorded = "payment_recorded",
198
198
  PaymentReversed = "payment_reversed",
199
199
  StatusChanged = "status_changed",
200
- LinkCreated = "link_created",
201
- LinkRevoked = "link_revoked",
200
+ Shared = "shared",
202
201
  Viewed = "viewed"
203
202
  }
204
203
  /** Why an errand in the period was not charged on the statement. */
205
204
  declare enum SweepExclusionReason {
206
205
  Cancelled = "cancelled",
207
206
  AlreadyInvoiced = "already_invoiced",
208
- SettledCash = "settled_cash",
209
- Prepaid = "prepaid",
210
207
  Owed = "owed",
211
208
  NotInvoiceable = "not_invoiceable"
212
209
  }
@@ -240,17 +237,11 @@ interface InvoiceEvent {
240
237
  meta?: Record<string, unknown>;
241
238
  createdAt: string;
242
239
  }
243
- interface InvoiceStatementLink {
244
- id: string;
245
- invoiceId: string;
246
- businessId: string;
247
- token: string;
248
- expiresAt: string;
249
- revokedAt?: string;
250
- viewCount: number;
251
- firstViewedAt?: string;
252
- lastViewedAt?: string;
253
- createdAt: string;
240
+ /** What `POST /invoices/:invoiceId/statement-link` returns. */
241
+ interface SharedStatement {
242
+ /** The slug in the public statement URL. Stable for the invoice's lifetime. */
243
+ statementSlug: string;
244
+ sentAt?: string;
254
245
  }
255
246
  /** Whether a frozen invoice has fallen out of date, and by how much. */
256
247
  interface InvoiceDrift {
@@ -262,6 +253,12 @@ interface Invoice {
262
253
  businessId: string;
263
254
  userId: string;
264
255
  invoiceNumber: string;
256
+ /**
257
+ * Slug for the public statement URL, and the only credential guarding it.
258
+ * Written at freeze time, so every invoice is shareable immediately. Absent on
259
+ * invoices frozen before the field existed.
260
+ */
261
+ statementSlug?: string;
265
262
  startDate: string;
266
263
  endDate: string;
267
264
  /** What the customer is asked for. Excludes zero-rated lines. */
@@ -300,9 +297,17 @@ interface InvoiceItem {
300
297
  itemId: string;
301
298
  /** Contribution to the invoice total. Zero for a settled line. */
302
299
  amount: number;
303
- /** Shown but not charged — work the customer already paid for in cash. */
300
+ /**
301
+ * Shown but not charged — work whose fee the customer already settled, either
302
+ * in cash at the door or prepaid before dispatch.
303
+ */
304
304
  zeroRated?: boolean;
305
- settledBy?: 'cash';
305
+ /**
306
+ * Which already-settled route a zero-rated line took. Unset on a charged line.
307
+ * The invoice's `zeroRatedTotal` is one number for the period; sum lines by
308
+ * this field for the "paid at the door" / "paid in advance" split.
309
+ */
310
+ settledBy?: 'cash' | 'prepaid';
306
311
  /** What the work was worth, on a zero-rated line only. */
307
312
  originalAmount?: number;
308
313
  description: string;
@@ -403,6 +408,15 @@ interface BusinessModules {
403
408
  invoices: boolean;
404
409
  remittances: boolean;
405
410
  }
411
+ /**
412
+ * How a business funds fuel. `revenuePercent` is the share of errand revenue a
413
+ * vehicle sets aside for its own fuel — the single knob behind the fuel-owed
414
+ * balance. `null` (the default) means the business hasn't configured it and the
415
+ * balance is not computed at all.
416
+ */
417
+ interface BusinessFuelSettings {
418
+ revenuePercent: number | null;
419
+ }
406
420
  interface BusinessSettings {
407
421
  whatsapp_notification_enabled: boolean;
408
422
  whatsapp: BusinessWhatsappConfig;
@@ -429,7 +443,9 @@ interface BusinessSettings {
429
443
  maxErrands: number | null;
430
444
  };
431
445
  modules: BusinessModules;
446
+ fuel?: BusinessFuelSettings;
432
447
  }
448
+ declare const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings;
433
449
  declare const DEFAULT_BUSINESS_MODULES: BusinessModules;
434
450
  declare const DEFAULT_BUSINESS_SETTINGS: BusinessSettings;
435
451
  interface BusinessMember {
@@ -590,6 +606,95 @@ interface VehiclePerformanceData {
590
606
  totals: VehiclePerformanceTotals;
591
607
  filters: VehiclePerformanceFilters;
592
608
  }
609
+ declare enum FuelDueStatus {
610
+ /** Worked through the fuel it was last given. Fuel this one. */
611
+ Due = "DUE",
612
+ /** Still running on fuel already paid for. Leave it. */
613
+ Ok = "OK"
614
+ }
615
+ /** What the vehicle has done since the fuel it was last given. */
616
+ interface FuelSinceLastRefuel {
617
+ revenue: number;
618
+ errandCount: number;
619
+ fuelEarned: number;
620
+ }
621
+ interface FuelDueItem {
622
+ vehicleId: string;
623
+ vehicleNumber: string;
624
+ shortName: string | null;
625
+ vehicleType: VehicleType | `${VehicleType}`;
626
+ /**
627
+ * The fuel gauge, and the field to lead a UI with: how much of the fuel this
628
+ * vehicle was last given it has worked through. 0 is freshly filled, 100 is
629
+ * due, past 100 is overdue. Null when it has never been fuelled.
630
+ */
631
+ fuelUsedPercent: number | null;
632
+ /** `fuelEarned - fuelSpent`, in naira — how much to give, not whether to. */
633
+ fuelDue: number;
634
+ fuelEarned: number;
635
+ fuelSpent: number;
636
+ revenue: number;
637
+ errandCount: number;
638
+ refuelCount: number;
639
+ /** What this vehicle is typically fuelled with; null if never fuelled. */
640
+ averageRefuelCost: number | null;
641
+ /**
642
+ * The figure has drifted far past what this vehicle is ever fuelled with —
643
+ * the signature of a wrong `revenuePercent` compounding rather than a real
644
+ * fuel need. Prompt to check the percentage instead of showing the figure.
645
+ */
646
+ needsCalibration: boolean;
647
+ lastRefuel: {
648
+ at: string;
649
+ cost: number;
650
+ } | null;
651
+ sinceLastRefuel: FuelSinceLastRefuel | null;
652
+ dueStatus: FuelDueStatus | `${FuelDueStatus}`;
653
+ /** Counting starts here when the prediction has been reset; null otherwise. */
654
+ countingFrom: string | null;
655
+ }
656
+ interface FuelDueTotals {
657
+ totalDue: number;
658
+ totalEarned: number;
659
+ totalSpent: number;
660
+ vehiclesDue: number;
661
+ vehiclesNeedingCalibration: number;
662
+ }
663
+ interface FuelDueData {
664
+ /** False when the business has not set `settings.fuel.revenuePercent`. */
665
+ configured: boolean;
666
+ revenuePercent: number | null;
667
+ /** Only when `configured` is false: what history says the percent should be. */
668
+ suggestedPercent?: number | null;
669
+ vehicles: FuelDueItem[];
670
+ totals: FuelDueTotals;
671
+ }
672
+ type FuelSuggestionConfidence = 'low' | 'medium' | 'high';
673
+ interface FuelPercentSuggestion {
674
+ /**
675
+ * Fuel spend as a share of the revenue that earned it, to one decimal —
676
+ * the percentage this business has actually been running at. Null when
677
+ * there is too little history; `reason` says which.
678
+ */
679
+ suggestedPercent: number | null;
680
+ /**
681
+ * Read off the number of refuels behind the suggestion, not the length of
682
+ * the window. Fuel bought near a window's edge is burnt outside it, so a
683
+ * thin refuel count gives a volatile ratio however many days were read.
684
+ */
685
+ confidence: FuelSuggestionConfidence;
686
+ reason: string | null;
687
+ days: number;
688
+ basedOn: {
689
+ totalFuelCost: number;
690
+ totalRevenue: number;
691
+ refuelCount: number;
692
+ errandCount: number;
693
+ refuelledVehicles: number;
694
+ /** Refuels per vehicle — what says whether the ratio has settled. */
695
+ refuelsPerVehicle: number | null;
696
+ };
697
+ }
593
698
 
594
699
  type Rider = {
595
700
  id: string;
@@ -1501,4 +1606,4 @@ declare enum LinkDestination {
1501
1606
  }
1502
1607
  type NullOrUndefined = null | undefined;
1503
1608
 
1504
- 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, ErrandInvoiceState, 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 TransactionRiderUser, 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 };
1609
+ export { type AddonGroup, type AddonGroupItem, type AddressDetails, AddressTypes, type AggregatedErrand, AuthType, type Business, BusinessCapability, type BusinessCategory, type BusinessCourierLink, BusinessCourierLinkStatus, type BusinessFuelSettings, 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_FUEL_SETTINGS, DEFAULT_BUSINESS_MODULES, DEFAULT_BUSINESS_SETTINGS, DeliveryStatus, type DraftErrand, DraftErrandStatus, type Enterprise, type EnterpriseCategoryDoc, type EnterpriseSubCategoryDoc, EnterpriseType, type Errand, type ErrandDeliveryTiming, ErrandInvoiceState, type ErrandPackagingQuality, type ErrandRating, type ErrandReview, type ErrandReviewLink, type ErrandRiderBehavior, ErrandStatus, type ErrandTimeline, type ExpensePaidBy, FeePaymentStatus, FeeSettlement, type FuelDueData, type FuelDueItem, FuelDueStatus, type FuelDueTotals, type FuelPercentSuggestion, type FuelSinceLastRefuel, type FuelSuggestionConfidence, type GeoPoint, GlobalRoles, type Invoice, type InvoiceDrift, type InvoiceEvent, InvoiceEventType, InvoiceGenerationType, type InvoiceItem, InvoiceItemType, type InvoicePayment, InvoicePaymentMethod, 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 SharedStatement, type State, SweepExclusionReason, type TrackerPosition, type Transaction, type TransactionCategory, type TransactionItem, type TransactionRiderUser, 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
@@ -152,16 +152,13 @@ var InvoiceEventType = /* @__PURE__ */ ((InvoiceEventType2) => {
152
152
  InvoiceEventType2["PaymentRecorded"] = "payment_recorded";
153
153
  InvoiceEventType2["PaymentReversed"] = "payment_reversed";
154
154
  InvoiceEventType2["StatusChanged"] = "status_changed";
155
- InvoiceEventType2["LinkCreated"] = "link_created";
156
- InvoiceEventType2["LinkRevoked"] = "link_revoked";
155
+ InvoiceEventType2["Shared"] = "shared";
157
156
  InvoiceEventType2["Viewed"] = "viewed";
158
157
  return InvoiceEventType2;
159
158
  })(InvoiceEventType || {});
160
159
  var SweepExclusionReason = /* @__PURE__ */ ((SweepExclusionReason2) => {
161
160
  SweepExclusionReason2["Cancelled"] = "cancelled";
162
161
  SweepExclusionReason2["AlreadyInvoiced"] = "already_invoiced";
163
- SweepExclusionReason2["SettledCash"] = "settled_cash";
164
- SweepExclusionReason2["Prepaid"] = "prepaid";
165
162
  SweepExclusionReason2["Owed"] = "owed";
166
163
  SweepExclusionReason2["NotInvoiceable"] = "not_invoiceable";
167
164
  return SweepExclusionReason2;
@@ -186,6 +183,11 @@ var VehicleLogType = /* @__PURE__ */ ((VehicleLogType2) => {
186
183
  VehicleLogType2["REFUEL"] = "REFUEL";
187
184
  return VehicleLogType2;
188
185
  })(VehicleLogType || {});
186
+ var FuelDueStatus = /* @__PURE__ */ ((FuelDueStatus2) => {
187
+ FuelDueStatus2["Due"] = "DUE";
188
+ FuelDueStatus2["Ok"] = "OK";
189
+ return FuelDueStatus2;
190
+ })(FuelDueStatus || {});
189
191
 
190
192
  // src/rider.ts
191
193
  var RemittanceStatus = /* @__PURE__ */ ((RemittanceStatus2) => {
@@ -227,6 +229,9 @@ var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
227
229
  MembershipStatus2["SUSPENDED"] = "SUSPENDED";
228
230
  return MembershipStatus2;
229
231
  })(MembershipStatus || {});
232
+ var DEFAULT_BUSINESS_FUEL_SETTINGS = {
233
+ revenuePercent: null
234
+ };
230
235
  var DEFAULT_BUSINESS_MODULES = {
231
236
  draftErrands: true,
232
237
  team: true,
@@ -258,7 +263,8 @@ var DEFAULT_BUSINESS_SETTINGS = {
258
263
  tiktok: null,
259
264
  website: null
260
265
  },
261
- modules: DEFAULT_BUSINESS_MODULES
266
+ modules: DEFAULT_BUSINESS_MODULES,
267
+ fuel: DEFAULT_BUSINESS_FUEL_SETTINGS
262
268
  };
263
269
  var BusinessCourierLinkStatus = /* @__PURE__ */ ((BusinessCourierLinkStatus2) => {
264
270
  BusinessCourierLinkStatus2["ACTIVE"] = "active";
@@ -335,6 +341,7 @@ export {
335
341
  BusinessCourierLinkStatus,
336
342
  BusinessRole,
337
343
  BusinessStatus,
344
+ DEFAULT_BUSINESS_FUEL_SETTINGS,
338
345
  DEFAULT_BUSINESS_MODULES,
339
346
  DEFAULT_BUSINESS_SETTINGS,
340
347
  DeliveryStatus,
@@ -344,6 +351,7 @@ export {
344
351
  ErrandStatus,
345
352
  FeePaymentStatus,
346
353
  FeeSettlement,
354
+ FuelDueStatus,
347
355
  GlobalRoles,
348
356
  InvoiceEventType,
349
357
  InvoiceGenerationType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mydoormot/app-types",
3
- "version": "1.9.2",
3
+ "version": "1.9.4",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
package/src/business.ts CHANGED
@@ -113,6 +113,16 @@ export interface BusinessModules {
113
113
  remittances: boolean;
114
114
  }
115
115
 
116
+ /**
117
+ * How a business funds fuel. `revenuePercent` is the share of errand revenue a
118
+ * vehicle sets aside for its own fuel — the single knob behind the fuel-owed
119
+ * balance. `null` (the default) means the business hasn't configured it and the
120
+ * balance is not computed at all.
121
+ */
122
+ export interface BusinessFuelSettings {
123
+ revenuePercent: number | null;
124
+ }
125
+
116
126
  export interface BusinessSettings {
117
127
  whatsapp_notification_enabled: boolean;
118
128
  whatsapp: BusinessWhatsappConfig;
@@ -139,8 +149,13 @@ export interface BusinessSettings {
139
149
  maxErrands: number | null;
140
150
  };
141
151
  modules: BusinessModules;
152
+ fuel?: BusinessFuelSettings;
142
153
  }
143
154
 
155
+ export const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings = {
156
+ revenuePercent: null,
157
+ };
158
+
144
159
  export const DEFAULT_BUSINESS_MODULES: BusinessModules = {
145
160
  draftErrands: true,
146
161
  team: true,
@@ -174,6 +189,7 @@ export const DEFAULT_BUSINESS_SETTINGS: BusinessSettings = {
174
189
  website: null,
175
190
  },
176
191
  modules: DEFAULT_BUSINESS_MODULES,
192
+ fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
177
193
  };
178
194
 
179
195
  export interface BusinessMember {
package/src/invoice.ts CHANGED
@@ -42,8 +42,7 @@ export enum InvoiceEventType {
42
42
  PaymentRecorded = 'payment_recorded',
43
43
  PaymentReversed = 'payment_reversed',
44
44
  StatusChanged = 'status_changed',
45
- LinkCreated = 'link_created',
46
- LinkRevoked = 'link_revoked',
45
+ Shared = 'shared',
47
46
  Viewed = 'viewed',
48
47
  }
49
48
 
@@ -51,8 +50,6 @@ export enum InvoiceEventType {
51
50
  export enum SweepExclusionReason {
52
51
  Cancelled = 'cancelled',
53
52
  AlreadyInvoiced = 'already_invoiced',
54
- SettledCash = 'settled_cash',
55
- Prepaid = 'prepaid',
56
53
  Owed = 'owed',
57
54
  NotInvoiceable = 'not_invoiceable',
58
55
  }
@@ -89,17 +86,11 @@ export interface InvoiceEvent {
89
86
  createdAt: string;
90
87
  }
91
88
 
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;
89
+ /** What `POST /invoices/:invoiceId/statement-link` returns. */
90
+ export interface SharedStatement {
91
+ /** The slug in the public statement URL. Stable for the invoice's lifetime. */
92
+ statementSlug: string;
93
+ sentAt?: string;
103
94
  }
104
95
 
105
96
  /** Whether a frozen invoice has fallen out of date, and by how much. */
@@ -113,6 +104,12 @@ export interface Invoice {
113
104
  businessId: string;
114
105
  userId: string;
115
106
  invoiceNumber: string;
107
+ /**
108
+ * Slug for the public statement URL, and the only credential guarding it.
109
+ * Written at freeze time, so every invoice is shareable immediately. Absent on
110
+ * invoices frozen before the field existed.
111
+ */
112
+ statementSlug?: string;
116
113
  startDate: string;
117
114
  endDate: string;
118
115
  /** What the customer is asked for. Excludes zero-rated lines. */
@@ -154,9 +151,17 @@ export interface InvoiceItem {
154
151
  // item: Errand;
155
152
  /** Contribution to the invoice total. Zero for a settled line. */
156
153
  amount: number;
157
- /** Shown but not charged — work the customer already paid for in cash. */
154
+ /**
155
+ * Shown but not charged — work whose fee the customer already settled, either
156
+ * in cash at the door or prepaid before dispatch.
157
+ */
158
158
  zeroRated?: boolean;
159
- settledBy?: 'cash';
159
+ /**
160
+ * Which already-settled route a zero-rated line took. Unset on a charged line.
161
+ * The invoice's `zeroRatedTotal` is one number for the period; sum lines by
162
+ * this field for the "paid at the door" / "paid in advance" split.
163
+ */
164
+ settledBy?: 'cash' | 'prepaid';
160
165
  /** What the work was worth, on a zero-rated line only. */
161
166
  originalAmount?: number;
162
167
  description: string;
package/src/vehicle.ts CHANGED
@@ -142,3 +142,104 @@ export interface VehiclePerformanceData {
142
142
  totals: VehiclePerformanceTotals;
143
143
  filters: VehiclePerformanceFilters;
144
144
  }
145
+
146
+ // Fuel Due Types
147
+ //
148
+ // These answer "which vehicles are due for fuel" without anyone counting
149
+ // errands by hand. Errands generate fuel money at the business's
150
+ // `settings.fuel.revenuePercent`; logged refuels spend it. The difference is
151
+ // `fuelDue`, and `fuelUsedPercent` reads it back as a fuel gauge — 0 freshly
152
+ // filled, 100 due, beyond that overdue.
153
+
154
+ export enum FuelDueStatus {
155
+ /** Worked through the fuel it was last given. Fuel this one. */
156
+ Due = 'DUE',
157
+ /** Still running on fuel already paid for. Leave it. */
158
+ Ok = 'OK',
159
+ }
160
+
161
+ /** What the vehicle has done since the fuel it was last given. */
162
+ export interface FuelSinceLastRefuel {
163
+ revenue: number;
164
+ errandCount: number;
165
+ fuelEarned: number;
166
+ }
167
+
168
+ export interface FuelDueItem {
169
+ vehicleId: string;
170
+ vehicleNumber: string;
171
+ shortName: string | null;
172
+ vehicleType: VehicleType | `${VehicleType}`;
173
+ /**
174
+ * The fuel gauge, and the field to lead a UI with: how much of the fuel this
175
+ * vehicle was last given it has worked through. 0 is freshly filled, 100 is
176
+ * due, past 100 is overdue. Null when it has never been fuelled.
177
+ */
178
+ fuelUsedPercent: number | null;
179
+ /** `fuelEarned - fuelSpent`, in naira — how much to give, not whether to. */
180
+ fuelDue: number;
181
+ fuelEarned: number;
182
+ fuelSpent: number;
183
+ revenue: number;
184
+ errandCount: number;
185
+ refuelCount: number;
186
+ /** What this vehicle is typically fuelled with; null if never fuelled. */
187
+ averageRefuelCost: number | null;
188
+ /**
189
+ * The figure has drifted far past what this vehicle is ever fuelled with —
190
+ * the signature of a wrong `revenuePercent` compounding rather than a real
191
+ * fuel need. Prompt to check the percentage instead of showing the figure.
192
+ */
193
+ needsCalibration: boolean;
194
+ lastRefuel: { at: string; cost: number } | null;
195
+ sinceLastRefuel: FuelSinceLastRefuel | null;
196
+ dueStatus: FuelDueStatus | `${FuelDueStatus}`;
197
+ /** Counting starts here when the prediction has been reset; null otherwise. */
198
+ countingFrom: string | null;
199
+ }
200
+
201
+ export interface FuelDueTotals {
202
+ totalDue: number;
203
+ totalEarned: number;
204
+ totalSpent: number;
205
+ vehiclesDue: number;
206
+ vehiclesNeedingCalibration: number;
207
+ }
208
+
209
+ export interface FuelDueData {
210
+ /** False when the business has not set `settings.fuel.revenuePercent`. */
211
+ configured: boolean;
212
+ revenuePercent: number | null;
213
+ /** Only when `configured` is false: what history says the percent should be. */
214
+ suggestedPercent?: number | null;
215
+ vehicles: FuelDueItem[];
216
+ totals: FuelDueTotals;
217
+ }
218
+
219
+ export type FuelSuggestionConfidence = 'low' | 'medium' | 'high';
220
+
221
+ export interface FuelPercentSuggestion {
222
+ /**
223
+ * Fuel spend as a share of the revenue that earned it, to one decimal —
224
+ * the percentage this business has actually been running at. Null when
225
+ * there is too little history; `reason` says which.
226
+ */
227
+ suggestedPercent: number | null;
228
+ /**
229
+ * Read off the number of refuels behind the suggestion, not the length of
230
+ * the window. Fuel bought near a window's edge is burnt outside it, so a
231
+ * thin refuel count gives a volatile ratio however many days were read.
232
+ */
233
+ confidence: FuelSuggestionConfidence;
234
+ reason: string | null;
235
+ days: number;
236
+ basedOn: {
237
+ totalFuelCost: number;
238
+ totalRevenue: number;
239
+ refuelCount: number;
240
+ errandCount: number;
241
+ refuelledVehicles: number;
242
+ /** Refuels per vehicle — what says whether the ratio has settled. */
243
+ refuelsPerVehicle: number | null;
244
+ };
245
+ }