@mydoormot/app-types 1.7.42 → 1.8.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.7.42 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
- ESM dist/index.js 11.08 KB
12
- ESM ⚡️ Build success in 59ms
13
- CJS dist/index.cjs 13.45 KB
14
- CJS ⚡️ Build success in 58ms
15
- DTS Build start
16
- DTS ⚡️ Build success in 618ms
17
- DTS dist/index.d.ts 34.32 KB
18
- DTS dist/index.d.cts 34.32 KB
1
+
2
+ > @mydoormot/app-types@1.8.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
+ ESM dist/index.js 11.40 KB
13
+ ESM ⚡️ Build success in 313ms
14
+ CJS dist/index.cjs 13.82 KB
15
+ CJS ⚡️ Build success in 313ms
16
+ DTS ⚡️ Build success in 791ms
17
+ DTS dist/index.d.ts 35.07 KB
18
+ DTS dist/index.d.cts 35.07 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @mydoormot/app-types
2
2
 
3
+ ## 1.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Added customer addresses
8
+
9
+ ## 1.8.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Added delivery types
14
+
3
15
  ## 1.7.42
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -32,6 +32,8 @@ __export(src_exports, {
32
32
  DraftErrandStatus: () => DraftErrandStatus,
33
33
  EnterpriseType: () => EnterpriseType,
34
34
  ErrandStatus: () => ErrandStatus,
35
+ FeePaymentStatus: () => FeePaymentStatus,
36
+ FeeSettlement: () => FeeSettlement,
35
37
  GlobalRoles: () => GlobalRoles,
36
38
  InvoiceGenerationType: () => InvoiceGenerationType,
37
39
  InvoiceItemType: () => InvoiceItemType,
@@ -43,7 +45,6 @@ __export(src_exports, {
43
45
  PaymentOptions: () => PaymentOptions,
44
46
  RemittanceStatus: () => RemittanceStatus,
45
47
  RoleType: () => RoleType,
46
- SettlementType: () => SettlementType,
47
48
  VehicleLogType: () => VehicleLogType,
48
49
  VehicleType: () => VehicleType,
49
50
  WhatsappButtonType: () => WhatsappButtonType,
@@ -123,6 +124,19 @@ var errandTimeline = [
123
124
  description: "Your package has been delivered and the errand closed, please leave a review and a rating for the rider"
124
125
  }
125
126
  ];
127
+ var FeePaymentStatus = /* @__PURE__ */ ((FeePaymentStatus2) => {
128
+ FeePaymentStatus2["Unpaid"] = "unpaid";
129
+ FeePaymentStatus2["Partial"] = "partial";
130
+ FeePaymentStatus2["Paid"] = "paid";
131
+ return FeePaymentStatus2;
132
+ })(FeePaymentStatus || {});
133
+ var FeeSettlement = /* @__PURE__ */ ((FeeSettlement2) => {
134
+ FeeSettlement2["CashOnDelivery"] = "cash_on_delivery";
135
+ FeeSettlement2["Prepaid"] = "prepaid";
136
+ FeeSettlement2["Invoice"] = "invoice";
137
+ FeeSettlement2["Owed"] = "owed";
138
+ return FeeSettlement2;
139
+ })(FeeSettlement || {});
126
140
  var AddressTypes = /* @__PURE__ */ ((AddressTypes2) => {
127
141
  AddressTypes2["DeliveryAddress"] = "deliveryAddress";
128
142
  AddressTypes2["PickupAddress"] = "pickupAddress";
@@ -202,11 +216,6 @@ var RemittanceStatus = /* @__PURE__ */ ((RemittanceStatus2) => {
202
216
  RemittanceStatus2["Cancelled"] = "cancelled";
203
217
  return RemittanceStatus2;
204
218
  })(RemittanceStatus || {});
205
- var SettlementType = /* @__PURE__ */ ((SettlementType2) => {
206
- SettlementType2["DeliveryFee"] = "delivery_fee";
207
- SettlementType2["Additional"] = "additional";
208
- return SettlementType2;
209
- })(SettlementType || {});
210
219
 
211
220
  // src/enterprise.ts
212
221
  var EnterpriseType = /* @__PURE__ */ ((EnterpriseType2) => {
@@ -348,6 +357,8 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
348
357
  DraftErrandStatus,
349
358
  EnterpriseType,
350
359
  ErrandStatus,
360
+ FeePaymentStatus,
361
+ FeeSettlement,
351
362
  GlobalRoles,
352
363
  InvoiceGenerationType,
353
364
  InvoiceItemType,
@@ -359,7 +370,6 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
359
370
  PaymentOptions,
360
371
  RemittanceStatus,
361
372
  RoleType,
362
- SettlementType,
363
373
  VehicleLogType,
364
374
  VehicleType,
365
375
  WhatsappButtonType,
package/dist/index.d.cts CHANGED
@@ -93,21 +93,6 @@ type UserAddress = {
93
93
  direction?: string;
94
94
  };
95
95
 
96
- interface Coupon {
97
- id: string;
98
- phoneNumber: string;
99
- couponType: 'errand';
100
- isUsed: boolean;
101
- expiresAt: Date;
102
- couponCode: string;
103
- updatedAt: Date;
104
- createdAt: Date;
105
- hasExpired: boolean;
106
- couponValue: number;
107
- ref?: string;
108
- fullName?: string;
109
- }
110
-
111
96
  interface CustomerTransactionStats {
112
97
  totalSaleCount: number;
113
98
  totalSaleAmount: number;
@@ -116,14 +101,32 @@ interface CustomerTransactionStats {
116
101
  lastTransactionDate: string | null;
117
102
  updatedAt: string;
118
103
  }
104
+ interface CustomerAddress {
105
+ id: string;
106
+ label: string;
107
+ address: string;
108
+ landmark?: string;
109
+ cityId?: string;
110
+ location?: {
111
+ type: 'Point';
112
+ coordinates: number[];
113
+ };
114
+ isDefault: boolean;
115
+ createdAt: string;
116
+ updatedAt: string;
117
+ }
119
118
  interface Customer {
120
119
  id: string;
121
120
  businessId: string;
122
121
  phoneNumber: string;
123
122
  fullName: string;
124
123
  cityId: string;
124
+ /** @deprecated Mirrored from the default entry in `addresses`. */
125
125
  address: string;
126
+ /** @deprecated Mirrored from the default entry in `addresses`. */
126
127
  landmark?: string;
128
+ /** Absent on customers created before the address-book backfill. */
129
+ addresses?: CustomerAddress[];
127
130
  createdAt: string;
128
131
  updatedAt: string;
129
132
  customerBusinessId?: string;
@@ -477,10 +480,10 @@ interface RiderSettlement {
477
480
  draftErrandId?: string;
478
481
  riderId: string;
479
482
  businessId: string;
480
- deliveryFee: number;
481
- additionalAmount: number;
482
483
  totalCollectionAmount: number;
483
- remittedAmount: number;
484
+ deliveryFee?: number;
485
+ additionalAmount?: number;
486
+ remittedAmount?: number;
484
487
  remittanceStatus: RemittanceStatus | `${RemittanceStatus}`;
485
488
  remittedAt?: Date;
486
489
  remittedBy?: string;
@@ -511,10 +514,6 @@ interface RiderPerformanceStats {
511
514
  riders: RiderPerformanceItem[];
512
515
  timeSeries?: RiderPerformanceTimeSeries[];
513
516
  }
514
- declare enum SettlementType {
515
- DeliveryFee = "delivery_fee",
516
- Additional = "additional"
517
- }
518
517
 
519
518
  declare enum ErrandStatus {
520
519
  Pending = "pending",
@@ -582,6 +581,18 @@ interface PendingErrand {
582
581
  id: string;
583
582
  ownerMobileNumber?: string;
584
583
  }
584
+ declare enum FeePaymentStatus {
585
+ Unpaid = "unpaid",
586
+ Partial = "partial",
587
+ Paid = "paid"
588
+ }
589
+ declare enum FeeSettlement {
590
+ CashOnDelivery = "cash_on_delivery",
591
+ Prepaid = "prepaid",
592
+ Invoice = "invoice",
593
+ Owed = "owed"
594
+ }
595
+ type ExpensePaidBy = 'rider' | 'company' | 'customer';
585
596
  interface Errand {
586
597
  id: string;
587
598
  nameOfItem: string;
@@ -600,13 +611,10 @@ interface Errand {
600
611
  updatedAt: Date;
601
612
  createdAt: Date;
602
613
  errandRating?: string | ErrandRating;
603
- payOnDeliveryAmount?: string;
604
614
  additionalData?: string;
605
615
  deliveryDate?: Date;
606
616
  cityId?: City;
607
- couponPrice?: number;
608
617
  price: number;
609
- coupon?: string | Coupon;
610
618
  ownerMobileNumber?: string;
611
619
  errandTimeline?: string | ErrandTimeline;
612
620
  queuePosition?: number;
@@ -635,7 +643,6 @@ interface Errand {
635
643
  isDelayed?: boolean;
636
644
  delayedAt?: Date;
637
645
  wasDeliveredBy?: 'rider' | 'admin' | 'system' | 'business';
638
- paymentMethod?: 'cash_on_delivery' | 'prepaid_online' | 'prepaid_transfer' | 'business_invoice';
639
646
  additionalFees?: Array<{
640
647
  description: string;
641
648
  amount: number;
@@ -644,6 +651,12 @@ interface Errand {
644
651
  }>;
645
652
  riderDetails?: Rider;
646
653
  vehicleDetails?: Vehicle;
654
+ amountPaid?: number;
655
+ collections?: number;
656
+ feeSettlement?: `${FeeSettlement}`;
657
+ expenseAmount?: number;
658
+ expensePaidBy?: ExpensePaidBy;
659
+ feePaymentStatus?: `${FeePaymentStatus}`;
647
660
  }
648
661
  interface AggregatedErrand extends Errand {
649
662
  parcelSize: `${ParcelSize}`;
@@ -763,7 +776,6 @@ interface DraftErrand {
763
776
  deliveryDetails?: AddressDetails;
764
777
  additionalData?: string;
765
778
  parcelSize?: `${ParcelSize}`;
766
- payOnDeliveryAmount?: number;
767
779
  status: DraftErrandStatus;
768
780
  convertedErrandId?: string;
769
781
  settlementId?: string;
@@ -1104,6 +1116,13 @@ interface MaintenanceItem {
1104
1116
  unit?: string;
1105
1117
  defaultUnitPrice?: number;
1106
1118
  isActive: boolean;
1119
+ /**
1120
+ * `maintenanceDate` of the most recent record that used this item.
1121
+ * Undefined until first use, and always undefined on global items
1122
+ * (`businessId: null`) — a shared item's "last used by anyone" is not a
1123
+ * fact any single business can act on.
1124
+ */
1125
+ lastUsedAt?: string;
1107
1126
  createdAt: string;
1108
1127
  updatedAt: string;
1109
1128
  }
@@ -1281,4 +1300,4 @@ declare enum LinkDestination {
1281
1300
  }
1282
1301
  type NullOrUndefined = null | undefined;
1283
1302
 
1284
- 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 Coupon, type Customer, 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 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, SettlementType, 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 };
1303
+ 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 };
package/dist/index.d.ts CHANGED
@@ -93,21 +93,6 @@ type UserAddress = {
93
93
  direction?: string;
94
94
  };
95
95
 
96
- interface Coupon {
97
- id: string;
98
- phoneNumber: string;
99
- couponType: 'errand';
100
- isUsed: boolean;
101
- expiresAt: Date;
102
- couponCode: string;
103
- updatedAt: Date;
104
- createdAt: Date;
105
- hasExpired: boolean;
106
- couponValue: number;
107
- ref?: string;
108
- fullName?: string;
109
- }
110
-
111
96
  interface CustomerTransactionStats {
112
97
  totalSaleCount: number;
113
98
  totalSaleAmount: number;
@@ -116,14 +101,32 @@ interface CustomerTransactionStats {
116
101
  lastTransactionDate: string | null;
117
102
  updatedAt: string;
118
103
  }
104
+ interface CustomerAddress {
105
+ id: string;
106
+ label: string;
107
+ address: string;
108
+ landmark?: string;
109
+ cityId?: string;
110
+ location?: {
111
+ type: 'Point';
112
+ coordinates: number[];
113
+ };
114
+ isDefault: boolean;
115
+ createdAt: string;
116
+ updatedAt: string;
117
+ }
119
118
  interface Customer {
120
119
  id: string;
121
120
  businessId: string;
122
121
  phoneNumber: string;
123
122
  fullName: string;
124
123
  cityId: string;
124
+ /** @deprecated Mirrored from the default entry in `addresses`. */
125
125
  address: string;
126
+ /** @deprecated Mirrored from the default entry in `addresses`. */
126
127
  landmark?: string;
128
+ /** Absent on customers created before the address-book backfill. */
129
+ addresses?: CustomerAddress[];
127
130
  createdAt: string;
128
131
  updatedAt: string;
129
132
  customerBusinessId?: string;
@@ -477,10 +480,10 @@ interface RiderSettlement {
477
480
  draftErrandId?: string;
478
481
  riderId: string;
479
482
  businessId: string;
480
- deliveryFee: number;
481
- additionalAmount: number;
482
483
  totalCollectionAmount: number;
483
- remittedAmount: number;
484
+ deliveryFee?: number;
485
+ additionalAmount?: number;
486
+ remittedAmount?: number;
484
487
  remittanceStatus: RemittanceStatus | `${RemittanceStatus}`;
485
488
  remittedAt?: Date;
486
489
  remittedBy?: string;
@@ -511,10 +514,6 @@ interface RiderPerformanceStats {
511
514
  riders: RiderPerformanceItem[];
512
515
  timeSeries?: RiderPerformanceTimeSeries[];
513
516
  }
514
- declare enum SettlementType {
515
- DeliveryFee = "delivery_fee",
516
- Additional = "additional"
517
- }
518
517
 
519
518
  declare enum ErrandStatus {
520
519
  Pending = "pending",
@@ -582,6 +581,18 @@ interface PendingErrand {
582
581
  id: string;
583
582
  ownerMobileNumber?: string;
584
583
  }
584
+ declare enum FeePaymentStatus {
585
+ Unpaid = "unpaid",
586
+ Partial = "partial",
587
+ Paid = "paid"
588
+ }
589
+ declare enum FeeSettlement {
590
+ CashOnDelivery = "cash_on_delivery",
591
+ Prepaid = "prepaid",
592
+ Invoice = "invoice",
593
+ Owed = "owed"
594
+ }
595
+ type ExpensePaidBy = 'rider' | 'company' | 'customer';
585
596
  interface Errand {
586
597
  id: string;
587
598
  nameOfItem: string;
@@ -600,13 +611,10 @@ interface Errand {
600
611
  updatedAt: Date;
601
612
  createdAt: Date;
602
613
  errandRating?: string | ErrandRating;
603
- payOnDeliveryAmount?: string;
604
614
  additionalData?: string;
605
615
  deliveryDate?: Date;
606
616
  cityId?: City;
607
- couponPrice?: number;
608
617
  price: number;
609
- coupon?: string | Coupon;
610
618
  ownerMobileNumber?: string;
611
619
  errandTimeline?: string | ErrandTimeline;
612
620
  queuePosition?: number;
@@ -635,7 +643,6 @@ interface Errand {
635
643
  isDelayed?: boolean;
636
644
  delayedAt?: Date;
637
645
  wasDeliveredBy?: 'rider' | 'admin' | 'system' | 'business';
638
- paymentMethod?: 'cash_on_delivery' | 'prepaid_online' | 'prepaid_transfer' | 'business_invoice';
639
646
  additionalFees?: Array<{
640
647
  description: string;
641
648
  amount: number;
@@ -644,6 +651,12 @@ interface Errand {
644
651
  }>;
645
652
  riderDetails?: Rider;
646
653
  vehicleDetails?: Vehicle;
654
+ amountPaid?: number;
655
+ collections?: number;
656
+ feeSettlement?: `${FeeSettlement}`;
657
+ expenseAmount?: number;
658
+ expensePaidBy?: ExpensePaidBy;
659
+ feePaymentStatus?: `${FeePaymentStatus}`;
647
660
  }
648
661
  interface AggregatedErrand extends Errand {
649
662
  parcelSize: `${ParcelSize}`;
@@ -763,7 +776,6 @@ interface DraftErrand {
763
776
  deliveryDetails?: AddressDetails;
764
777
  additionalData?: string;
765
778
  parcelSize?: `${ParcelSize}`;
766
- payOnDeliveryAmount?: number;
767
779
  status: DraftErrandStatus;
768
780
  convertedErrandId?: string;
769
781
  settlementId?: string;
@@ -1104,6 +1116,13 @@ interface MaintenanceItem {
1104
1116
  unit?: string;
1105
1117
  defaultUnitPrice?: number;
1106
1118
  isActive: boolean;
1119
+ /**
1120
+ * `maintenanceDate` of the most recent record that used this item.
1121
+ * Undefined until first use, and always undefined on global items
1122
+ * (`businessId: null`) — a shared item's "last used by anyone" is not a
1123
+ * fact any single business can act on.
1124
+ */
1125
+ lastUsedAt?: string;
1107
1126
  createdAt: string;
1108
1127
  updatedAt: string;
1109
1128
  }
@@ -1281,4 +1300,4 @@ declare enum LinkDestination {
1281
1300
  }
1282
1301
  type NullOrUndefined = null | undefined;
1283
1302
 
1284
- 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 Coupon, type Customer, 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 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, SettlementType, 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 };
1303
+ 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 };
package/dist/index.js CHANGED
@@ -65,6 +65,19 @@ var errandTimeline = [
65
65
  description: "Your package has been delivered and the errand closed, please leave a review and a rating for the rider"
66
66
  }
67
67
  ];
68
+ var FeePaymentStatus = /* @__PURE__ */ ((FeePaymentStatus2) => {
69
+ FeePaymentStatus2["Unpaid"] = "unpaid";
70
+ FeePaymentStatus2["Partial"] = "partial";
71
+ FeePaymentStatus2["Paid"] = "paid";
72
+ return FeePaymentStatus2;
73
+ })(FeePaymentStatus || {});
74
+ var FeeSettlement = /* @__PURE__ */ ((FeeSettlement2) => {
75
+ FeeSettlement2["CashOnDelivery"] = "cash_on_delivery";
76
+ FeeSettlement2["Prepaid"] = "prepaid";
77
+ FeeSettlement2["Invoice"] = "invoice";
78
+ FeeSettlement2["Owed"] = "owed";
79
+ return FeeSettlement2;
80
+ })(FeeSettlement || {});
68
81
  var AddressTypes = /* @__PURE__ */ ((AddressTypes2) => {
69
82
  AddressTypes2["DeliveryAddress"] = "deliveryAddress";
70
83
  AddressTypes2["PickupAddress"] = "pickupAddress";
@@ -144,11 +157,6 @@ var RemittanceStatus = /* @__PURE__ */ ((RemittanceStatus2) => {
144
157
  RemittanceStatus2["Cancelled"] = "cancelled";
145
158
  return RemittanceStatus2;
146
159
  })(RemittanceStatus || {});
147
- var SettlementType = /* @__PURE__ */ ((SettlementType2) => {
148
- SettlementType2["DeliveryFee"] = "delivery_fee";
149
- SettlementType2["Additional"] = "additional";
150
- return SettlementType2;
151
- })(SettlementType || {});
152
160
 
153
161
  // src/enterprise.ts
154
162
  var EnterpriseType = /* @__PURE__ */ ((EnterpriseType2) => {
@@ -289,6 +297,8 @@ export {
289
297
  DraftErrandStatus,
290
298
  EnterpriseType,
291
299
  ErrandStatus,
300
+ FeePaymentStatus,
301
+ FeeSettlement,
292
302
  GlobalRoles,
293
303
  InvoiceGenerationType,
294
304
  InvoiceItemType,
@@ -300,7 +310,6 @@ export {
300
310
  PaymentOptions,
301
311
  RemittanceStatus,
302
312
  RoleType,
303
- SettlementType,
304
313
  VehicleLogType,
305
314
  VehicleType,
306
315
  WhatsappButtonType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mydoormot/app-types",
3
- "version": "1.7.42",
3
+ "version": "1.8.1",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
package/src/customer.ts CHANGED
@@ -9,14 +9,33 @@ export interface CustomerTransactionStats {
9
9
  updatedAt: string;
10
10
  }
11
11
 
12
+ export interface CustomerAddress {
13
+ id: string;
14
+ label: string;
15
+ address: string;
16
+ landmark?: string;
17
+ cityId?: string;
18
+ location?: {
19
+ type: 'Point';
20
+ coordinates: number[];
21
+ };
22
+ isDefault: boolean;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ }
26
+
12
27
  export interface Customer {
13
28
  id: string;
14
29
  businessId: string;
15
30
  phoneNumber: string;
16
31
  fullName: string;
17
32
  cityId: string;
33
+ /** @deprecated Mirrored from the default entry in `addresses`. */
18
34
  address: string;
35
+ /** @deprecated Mirrored from the default entry in `addresses`. */
19
36
  landmark?: string;
37
+ /** Absent on customers created before the address-book backfill. */
38
+ addresses?: CustomerAddress[];
20
39
  createdAt: string;
21
40
  updatedAt: string;
22
41
 
package/src/errand.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Business } from '.';
2
- import { Coupon } from './coupon';
3
2
  import { Invoice, InvoiceStatus } from './invoice';
4
3
  import { City } from './location';
5
4
  import { Rider } from './rider';
@@ -112,6 +111,34 @@ export interface PendingErrand {
112
111
  ownerMobileNumber?: string;
113
112
  }
114
113
 
114
+ // --- money model redesign (see docs/errand-money-model-redesign.md) ---
115
+ // Customer-facing form of "customer owes us": derived from `price - amountPaid`,
116
+ // never hand-set. Distinct from the legacy 5-value `paymentStatus` (InvoiceStatus).
117
+ export enum FeePaymentStatus {
118
+ Unpaid = 'unpaid',
119
+ Partial = 'partial',
120
+ Paid = 'paid',
121
+ }
122
+
123
+ // How our fee gets settled — the single business fact behind three behaviours:
124
+ // what `amountPaid` starts at, whether the errand is invoiced, and whether the
125
+ // rider is carrying our fee. Replaces the `payOnDelivery` boolean, which could
126
+ // not tell `prepaid` / `invoice` / `owed` apart. See docs §2.9.
127
+ export enum FeeSettlement {
128
+ // Rider collects the fee at the door. Paid on arrival; rider owes it to us.
129
+ CashOnDelivery = 'cash_on_delivery',
130
+ // Already paid before dispatch. Paid; nobody is carrying it.
131
+ Prepaid = 'prepaid',
132
+ // Goes on the customer's statement. Unpaid until the invoice is paid.
133
+ Invoice = 'invoice',
134
+ // Owed by the customer with no settlement arranged yet. Unpaid, NOT invoiced.
135
+ Owed = 'owed',
136
+ }
137
+
138
+ // Who fronted an errand expense. `customer` covers "paid on call" and
139
+ // "handed to the rider directly" — only `company`-fronted expenses are billed.
140
+ export type ExpensePaidBy = 'rider' | 'company' | 'customer';
141
+
115
142
  export interface Errand {
116
143
  // NOTE: Deprecated fields
117
144
  // rider: string | Rider;
@@ -143,13 +170,10 @@ export interface Errand {
143
170
  updatedAt: Date;
144
171
  createdAt: Date;
145
172
  errandRating?: string | ErrandRating;
146
- payOnDeliveryAmount?: string;
147
173
  additionalData?: string;
148
174
  deliveryDate?: Date;
149
175
  cityId?: City;
150
- couponPrice?: number;
151
176
  price: number;
152
- coupon?: string | Coupon;
153
177
  ownerMobileNumber?: string;
154
178
  errandTimeline?: string | ErrandTimeline;
155
179
  queuePosition?: number;
@@ -173,11 +197,6 @@ export interface Errand {
173
197
  isDelayed?: boolean;
174
198
  delayedAt?: Date;
175
199
  wasDeliveredBy?: 'rider' | 'admin' | 'system' | 'business';
176
- paymentMethod?:
177
- | 'cash_on_delivery'
178
- | 'prepaid_online'
179
- | 'prepaid_transfer'
180
- | 'business_invoice';
181
200
  additionalFees?: Array<{
182
201
  description: string;
183
202
  amount: number;
@@ -188,6 +207,22 @@ export interface Errand {
188
207
  // new fields
189
208
  riderDetails?: Rider;
190
209
  vehicleDetails?: Vehicle;
210
+
211
+ // --- money model redesign (Phase 1: additive; see docs/errand-money-model-redesign.md) ---
212
+ // How much of `price` has been paid, by any route. Drives `feePaymentStatus`.
213
+ amountPaid?: number;
214
+ // Goods money the rider collects for the customer — NEVER our fee.
215
+ // This IS "we owe the customer".
216
+ collections?: number;
217
+ // How our fee is settled (§2.9). Drives `amountPaid` at creation, invoice
218
+ // eligibility, and whether the rider carries our fee. Orthogonal to
219
+ // `collections`, which is always goods money for the customer.
220
+ feeSettlement?: `${FeeSettlement}`;
221
+ // Out-of-pocket cost during the errand (e.g. waybill).
222
+ expenseAmount?: number;
223
+ expensePaidBy?: ExpensePaidBy;
224
+ // Derived from `price - amountPaid` (never hand-set). Stored so Mongo can filter on it.
225
+ feePaymentStatus?: `${FeePaymentStatus}`;
191
226
  }
192
227
 
193
228
  export interface AggregatedErrand extends Errand {
@@ -322,7 +357,6 @@ export interface DraftErrand {
322
357
  deliveryDetails?: AddressDetails;
323
358
  additionalData?: string;
324
359
  parcelSize?: `${ParcelSize}`;
325
- payOnDeliveryAmount?: number;
326
360
 
327
361
  // Lifecycle
328
362
  status: DraftErrandStatus;
package/src/index.ts CHANGED
@@ -30,7 +30,6 @@ export * from './notification';
30
30
  export * from './rider';
31
31
  export * from './vehicle';
32
32
  export * from './enterprise';
33
- export * from './coupon';
34
33
  export * from './business';
35
34
  export * from './commerce';
36
35
  export * from './customer';
@@ -10,6 +10,13 @@ export interface MaintenanceItem {
10
10
  unit?: string; // "piece", "liter", etc.
11
11
  defaultUnitPrice?: number;
12
12
  isActive: boolean;
13
+ /**
14
+ * `maintenanceDate` of the most recent record that used this item.
15
+ * Undefined until first use, and always undefined on global items
16
+ * (`businessId: null`) — a shared item's "last used by anyone" is not a
17
+ * fact any single business can act on.
18
+ */
19
+ lastUsedAt?: string;
13
20
  createdAt: string;
14
21
  updatedAt: string;
15
22
  }
package/src/rider.ts CHANGED
@@ -55,11 +55,15 @@ export interface RiderSettlement {
55
55
  riderId: string;
56
56
  businessId: string;
57
57
 
58
- // Money breakdown
59
- deliveryFee: number;
60
- additionalAmount: number;
58
+ // The cash the rider collected and owes us. Remittance is all-or-nothing
59
+ // (see `remittanceStatus`) — no partial remittance, no fee/additional split.
61
60
  totalCollectionAmount: number;
62
- remittedAmount: number;
61
+
62
+ // DEPRECATED (read-only, transitional; see docs §7.5). Historical records
63
+ // store money here; kept for the balance fallback until the Phase 5 drop.
64
+ deliveryFee?: number;
65
+ additionalAmount?: number;
66
+ remittedAmount?: number;
63
67
 
64
68
  // Status
65
69
  remittanceStatus: RemittanceStatus | `${RemittanceStatus}`;
@@ -101,7 +105,3 @@ export interface RiderPerformanceStats {
101
105
  timeSeries?: RiderPerformanceTimeSeries[];
102
106
  }
103
107
 
104
- export enum SettlementType {
105
- DeliveryFee = 'delivery_fee',
106
- Additional = 'additional',
107
- }
package/src/coupon.ts DELETED
@@ -1,14 +0,0 @@
1
- export interface Coupon {
2
- id: string;
3
- phoneNumber: string;
4
- couponType: 'errand';
5
- isUsed: boolean;
6
- expiresAt: Date;
7
- couponCode: string;
8
- updatedAt: Date;
9
- createdAt: Date;
10
- hasExpired: boolean;
11
- couponValue: number;
12
- ref?: string;
13
- fullName?: string;
14
- }