@mydoormot/app-types 1.10.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +18 -18
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +33 -1
- package/dist/index.d.cts +103 -1
- package/dist/index.d.ts +103 -1
- package/dist/index.js +29 -1
- package/package.json +1 -1
- package/src/business.ts +28 -1
- package/src/rider.ts +114 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
> @mydoormot/app-types@
|
|
3
|
-
> tsup src/index.ts --format esm,cjs --dts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
|
|
2
|
+
> @mydoormot/app-types@2.0.1 build /Users/chuksben/Desktop/projects/microservices/mydoormot/packages/app-types
|
|
3
|
+
> tsup src/index.ts --format esm,cjs --dts
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v7.3.0
|
|
8
|
+
[34mCLI[39m Target: es2021
|
|
9
|
+
[34mESM[39m Build start
|
|
10
|
+
[34mCJS[39m Build start
|
|
11
|
+
[32mESM[39m [1mdist/index.js [22m[32m14.62 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 57ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m17.59 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 58ms
|
|
15
|
+
[34mDTS[39m Build start
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 681ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m49.48 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m49.48 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mydoormot/app-types
|
|
2
2
|
|
|
3
|
+
## 2.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added payout percentage
|
|
8
|
+
|
|
9
|
+
## 2.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Mod
|
|
14
|
+
|
|
15
|
+
## 2.0.0
|
|
16
|
+
|
|
17
|
+
### Major Changes
|
|
18
|
+
|
|
19
|
+
- Added rider payout
|
|
20
|
+
|
|
3
21
|
## 1.10.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,7 @@ __export(src_exports, {
|
|
|
28
28
|
BusinessStatus: () => BusinessStatus,
|
|
29
29
|
DEFAULT_BUSINESS_FUEL_SETTINGS: () => DEFAULT_BUSINESS_FUEL_SETTINGS,
|
|
30
30
|
DEFAULT_BUSINESS_MODULES: () => DEFAULT_BUSINESS_MODULES,
|
|
31
|
+
DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: () => DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
|
|
31
32
|
DEFAULT_BUSINESS_SETTINGS: () => DEFAULT_BUSINESS_SETTINGS,
|
|
32
33
|
DeliveryStatus: () => DeliveryStatus,
|
|
33
34
|
DraftErrandStatus: () => DraftErrandStatus,
|
|
@@ -48,8 +49,11 @@ __export(src_exports, {
|
|
|
48
49
|
NotificationType: () => NotificationType,
|
|
49
50
|
ParcelSize: () => ParcelSize,
|
|
50
51
|
PaymentOptions: () => PaymentOptions,
|
|
52
|
+
PayoutPeriodType: () => PayoutPeriodType,
|
|
53
|
+
PayoutRateSource: () => PayoutRateSource,
|
|
51
54
|
PortalStatus: () => PortalStatus,
|
|
52
55
|
RemittanceStatus: () => RemittanceStatus,
|
|
56
|
+
RiderPayoutStatus: () => RiderPayoutStatus,
|
|
53
57
|
RoleType: () => RoleType,
|
|
54
58
|
SweepExclusionReason: () => SweepExclusionReason,
|
|
55
59
|
VehicleLogType: () => VehicleLogType,
|
|
@@ -261,6 +265,25 @@ var RemittanceStatus = /* @__PURE__ */ ((RemittanceStatus2) => {
|
|
|
261
265
|
RemittanceStatus2["Cancelled"] = "cancelled";
|
|
262
266
|
return RemittanceStatus2;
|
|
263
267
|
})(RemittanceStatus || {});
|
|
268
|
+
var PayoutPeriodType = /* @__PURE__ */ ((PayoutPeriodType2) => {
|
|
269
|
+
PayoutPeriodType2["Weekly"] = "weekly";
|
|
270
|
+
PayoutPeriodType2["Fortnightly"] = "fortnightly";
|
|
271
|
+
PayoutPeriodType2["Monthly"] = "monthly";
|
|
272
|
+
PayoutPeriodType2["Custom"] = "custom";
|
|
273
|
+
return PayoutPeriodType2;
|
|
274
|
+
})(PayoutPeriodType || {});
|
|
275
|
+
var RiderPayoutStatus = /* @__PURE__ */ ((RiderPayoutStatus2) => {
|
|
276
|
+
RiderPayoutStatus2["Pending"] = "pending";
|
|
277
|
+
RiderPayoutStatus2["Approved"] = "approved";
|
|
278
|
+
RiderPayoutStatus2["Paid"] = "paid";
|
|
279
|
+
RiderPayoutStatus2["Cancelled"] = "cancelled";
|
|
280
|
+
return RiderPayoutStatus2;
|
|
281
|
+
})(RiderPayoutStatus || {});
|
|
282
|
+
var PayoutRateSource = /* @__PURE__ */ ((PayoutRateSource2) => {
|
|
283
|
+
PayoutRateSource2["Rider"] = "rider";
|
|
284
|
+
PayoutRateSource2["Business"] = "business";
|
|
285
|
+
return PayoutRateSource2;
|
|
286
|
+
})(PayoutRateSource || {});
|
|
264
287
|
|
|
265
288
|
// src/enterprise.ts
|
|
266
289
|
var EnterpriseType = /* @__PURE__ */ ((EnterpriseType2) => {
|
|
@@ -297,6 +320,10 @@ var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
|
|
|
297
320
|
var DEFAULT_BUSINESS_FUEL_SETTINGS = {
|
|
298
321
|
revenuePercent: null
|
|
299
322
|
};
|
|
323
|
+
var DEFAULT_BUSINESS_RIDER_PAY_SETTINGS = {
|
|
324
|
+
defaultPercentage: null,
|
|
325
|
+
periodType: null
|
|
326
|
+
};
|
|
300
327
|
var DEFAULT_BUSINESS_MODULES = {
|
|
301
328
|
draftErrands: true,
|
|
302
329
|
team: true,
|
|
@@ -329,7 +356,8 @@ var DEFAULT_BUSINESS_SETTINGS = {
|
|
|
329
356
|
website: null
|
|
330
357
|
},
|
|
331
358
|
modules: DEFAULT_BUSINESS_MODULES,
|
|
332
|
-
fuel: DEFAULT_BUSINESS_FUEL_SETTINGS
|
|
359
|
+
fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
|
|
360
|
+
riderPay: DEFAULT_BUSINESS_RIDER_PAY_SETTINGS
|
|
333
361
|
};
|
|
334
362
|
var BusinessCourierLinkStatus = /* @__PURE__ */ ((BusinessCourierLinkStatus2) => {
|
|
335
363
|
BusinessCourierLinkStatus2["ACTIVE"] = "active";
|
|
@@ -409,6 +437,7 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
|
|
|
409
437
|
BusinessStatus,
|
|
410
438
|
DEFAULT_BUSINESS_FUEL_SETTINGS,
|
|
411
439
|
DEFAULT_BUSINESS_MODULES,
|
|
440
|
+
DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
|
|
412
441
|
DEFAULT_BUSINESS_SETTINGS,
|
|
413
442
|
DeliveryStatus,
|
|
414
443
|
DraftErrandStatus,
|
|
@@ -429,8 +458,11 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
|
|
|
429
458
|
NotificationType,
|
|
430
459
|
ParcelSize,
|
|
431
460
|
PaymentOptions,
|
|
461
|
+
PayoutPeriodType,
|
|
462
|
+
PayoutRateSource,
|
|
432
463
|
PortalStatus,
|
|
433
464
|
RemittanceStatus,
|
|
465
|
+
RiderPayoutStatus,
|
|
434
466
|
RoleType,
|
|
435
467
|
SweepExclusionReason,
|
|
436
468
|
VehicleLogType,
|
package/dist/index.d.cts
CHANGED
|
@@ -409,6 +409,20 @@ interface BusinessModules {
|
|
|
409
409
|
interface BusinessFuelSettings {
|
|
410
410
|
revenuePercent: number | null;
|
|
411
411
|
}
|
|
412
|
+
/**
|
|
413
|
+
* How a business pays its riders. `defaultPercentage` is the share of the
|
|
414
|
+
* errand fees a rider earned that the rider takes home, used for every rider
|
|
415
|
+
* without their own `payoutPercentage`. `null` (the default) means the business
|
|
416
|
+
* hasn't configured it — those riders simply can't have a payout generated
|
|
417
|
+
* until someone sets a rate, rather than being silently paid zero.
|
|
418
|
+
*
|
|
419
|
+
* `periodType` is only the default cadence the payout screens open on; a payout
|
|
420
|
+
* can always be generated for any period.
|
|
421
|
+
*/
|
|
422
|
+
interface BusinessRiderPaySettings {
|
|
423
|
+
defaultPercentage: number | null;
|
|
424
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}` | null;
|
|
425
|
+
}
|
|
412
426
|
interface BusinessSettings {
|
|
413
427
|
whatsapp_notification_enabled: boolean;
|
|
414
428
|
whatsapp: BusinessWhatsappConfig;
|
|
@@ -436,8 +450,10 @@ interface BusinessSettings {
|
|
|
436
450
|
};
|
|
437
451
|
modules: BusinessModules;
|
|
438
452
|
fuel?: BusinessFuelSettings;
|
|
453
|
+
riderPay?: BusinessRiderPaySettings;
|
|
439
454
|
}
|
|
440
455
|
declare const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings;
|
|
456
|
+
declare const DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: BusinessRiderPaySettings;
|
|
441
457
|
declare const DEFAULT_BUSINESS_MODULES: BusinessModules;
|
|
442
458
|
declare const DEFAULT_BUSINESS_SETTINGS: BusinessSettings;
|
|
443
459
|
interface BusinessMember {
|
|
@@ -703,6 +719,7 @@ type Rider = {
|
|
|
703
719
|
rating: number;
|
|
704
720
|
version: number;
|
|
705
721
|
hasBeenRated: boolean;
|
|
722
|
+
payoutPercentage?: number | null;
|
|
706
723
|
state?: string | State;
|
|
707
724
|
currentErrand?: Errand;
|
|
708
725
|
lastDeliveredErrand?: Errand;
|
|
@@ -757,6 +774,91 @@ interface RiderPerformanceStats {
|
|
|
757
774
|
riders: RiderPerformanceItem[];
|
|
758
775
|
timeSeries?: RiderPerformanceTimeSeries[];
|
|
759
776
|
}
|
|
777
|
+
declare enum PayoutPeriodType {
|
|
778
|
+
Weekly = "weekly",
|
|
779
|
+
Fortnightly = "fortnightly",
|
|
780
|
+
Monthly = "monthly",
|
|
781
|
+
Custom = "custom"
|
|
782
|
+
}
|
|
783
|
+
declare enum RiderPayoutStatus {
|
|
784
|
+
Pending = "pending",
|
|
785
|
+
Approved = "approved",
|
|
786
|
+
Paid = "paid",
|
|
787
|
+
Cancelled = "cancelled"
|
|
788
|
+
}
|
|
789
|
+
/** Which knob supplied the percentage a payout was computed at. */
|
|
790
|
+
declare enum PayoutRateSource {
|
|
791
|
+
Rider = "rider",
|
|
792
|
+
Business = "business"
|
|
793
|
+
}
|
|
794
|
+
/** One bonus (positive `amount`) or deduction (negative) on a payout. */
|
|
795
|
+
interface RiderPayoutAdjustment {
|
|
796
|
+
id: string;
|
|
797
|
+
label: string;
|
|
798
|
+
amount: number;
|
|
799
|
+
createdAt: Date;
|
|
800
|
+
}
|
|
801
|
+
interface RiderPayout {
|
|
802
|
+
id: string;
|
|
803
|
+
riderId: string;
|
|
804
|
+
businessId: string;
|
|
805
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}`;
|
|
806
|
+
periodStart: Date;
|
|
807
|
+
periodEnd: Date;
|
|
808
|
+
/** Errands counted toward `grossEarnings`. */
|
|
809
|
+
errandCount: number;
|
|
810
|
+
/** Sum of `Errand.price` over the counted errands. */
|
|
811
|
+
grossEarnings: number;
|
|
812
|
+
/** The rate this payout was computed at — snapshotted, never re-read. */
|
|
813
|
+
payoutPercentage: number;
|
|
814
|
+
payoutRateSource: PayoutRateSource | `${PayoutRateSource}`;
|
|
815
|
+
/** `grossEarnings` at `payoutPercentage`. */
|
|
816
|
+
payoutAmount: number;
|
|
817
|
+
/** Hand-entered bonus and deduction lines. */
|
|
818
|
+
adjustments: RiderPayoutAdjustment[];
|
|
819
|
+
/** Sum of `adjustments`. Derived, never set directly. */
|
|
820
|
+
adjustmentAmount: number;
|
|
821
|
+
/** What the rider is actually paid: `payoutAmount + adjustmentAmount`. */
|
|
822
|
+
netAmount: number;
|
|
823
|
+
status: RiderPayoutStatus | `${RiderPayoutStatus}`;
|
|
824
|
+
approvedAt?: Date;
|
|
825
|
+
approvedBy?: string;
|
|
826
|
+
paidAt?: Date;
|
|
827
|
+
paymentReference?: string;
|
|
828
|
+
notes?: string;
|
|
829
|
+
createdAt: Date;
|
|
830
|
+
updatedAt: Date;
|
|
831
|
+
version: number;
|
|
832
|
+
}
|
|
833
|
+
/** One rider's computed pay for a period, before anything is persisted. */
|
|
834
|
+
interface RiderPayoutPreviewItem {
|
|
835
|
+
riderId: string;
|
|
836
|
+
riderName: string;
|
|
837
|
+
errandCount: number;
|
|
838
|
+
grossEarnings: number;
|
|
839
|
+
/** Null when neither the rider nor the business has a rate configured. */
|
|
840
|
+
payoutPercentage: number | null;
|
|
841
|
+
payoutRateSource: PayoutRateSource | `${PayoutRateSource}` | null;
|
|
842
|
+
payoutAmount: number;
|
|
843
|
+
/** Set when a payout for this rider and the same period already exists. */
|
|
844
|
+
existingPayoutId?: string;
|
|
845
|
+
existingPayoutStatus?: RiderPayoutStatus | `${RiderPayoutStatus}`;
|
|
846
|
+
}
|
|
847
|
+
interface RiderPayoutPreview {
|
|
848
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}`;
|
|
849
|
+
periodStart: Date;
|
|
850
|
+
periodEnd: Date;
|
|
851
|
+
periodLabel: string;
|
|
852
|
+
summary: {
|
|
853
|
+
riderCount: number;
|
|
854
|
+
totalErrands: number;
|
|
855
|
+
totalGrossEarnings: number;
|
|
856
|
+
totalPayoutAmount: number;
|
|
857
|
+
/** Riders skipped because no percentage is configured for them. */
|
|
858
|
+
unratedRiderCount: number;
|
|
859
|
+
};
|
|
860
|
+
riders: RiderPayoutPreviewItem[];
|
|
861
|
+
}
|
|
760
862
|
|
|
761
863
|
declare enum ErrandStatus {
|
|
762
864
|
Pending = "pending",
|
|
@@ -1598,4 +1700,4 @@ declare enum LinkDestination {
|
|
|
1598
1700
|
}
|
|
1599
1701
|
type NullOrUndefined = null | undefined;
|
|
1600
1702
|
|
|
1601
|
-
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 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 };
|
|
1703
|
+
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, type BusinessRiderPaySettings, 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_RIDER_PAY_SETTINGS, 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, PayoutPeriodType, PayoutRateSource, 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 RiderPayout, type RiderPayoutAdjustment, type RiderPayoutPreview, type RiderPayoutPreviewItem, RiderPayoutStatus, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -409,6 +409,20 @@ interface BusinessModules {
|
|
|
409
409
|
interface BusinessFuelSettings {
|
|
410
410
|
revenuePercent: number | null;
|
|
411
411
|
}
|
|
412
|
+
/**
|
|
413
|
+
* How a business pays its riders. `defaultPercentage` is the share of the
|
|
414
|
+
* errand fees a rider earned that the rider takes home, used for every rider
|
|
415
|
+
* without their own `payoutPercentage`. `null` (the default) means the business
|
|
416
|
+
* hasn't configured it — those riders simply can't have a payout generated
|
|
417
|
+
* until someone sets a rate, rather than being silently paid zero.
|
|
418
|
+
*
|
|
419
|
+
* `periodType` is only the default cadence the payout screens open on; a payout
|
|
420
|
+
* can always be generated for any period.
|
|
421
|
+
*/
|
|
422
|
+
interface BusinessRiderPaySettings {
|
|
423
|
+
defaultPercentage: number | null;
|
|
424
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}` | null;
|
|
425
|
+
}
|
|
412
426
|
interface BusinessSettings {
|
|
413
427
|
whatsapp_notification_enabled: boolean;
|
|
414
428
|
whatsapp: BusinessWhatsappConfig;
|
|
@@ -436,8 +450,10 @@ interface BusinessSettings {
|
|
|
436
450
|
};
|
|
437
451
|
modules: BusinessModules;
|
|
438
452
|
fuel?: BusinessFuelSettings;
|
|
453
|
+
riderPay?: BusinessRiderPaySettings;
|
|
439
454
|
}
|
|
440
455
|
declare const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings;
|
|
456
|
+
declare const DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: BusinessRiderPaySettings;
|
|
441
457
|
declare const DEFAULT_BUSINESS_MODULES: BusinessModules;
|
|
442
458
|
declare const DEFAULT_BUSINESS_SETTINGS: BusinessSettings;
|
|
443
459
|
interface BusinessMember {
|
|
@@ -703,6 +719,7 @@ type Rider = {
|
|
|
703
719
|
rating: number;
|
|
704
720
|
version: number;
|
|
705
721
|
hasBeenRated: boolean;
|
|
722
|
+
payoutPercentage?: number | null;
|
|
706
723
|
state?: string | State;
|
|
707
724
|
currentErrand?: Errand;
|
|
708
725
|
lastDeliveredErrand?: Errand;
|
|
@@ -757,6 +774,91 @@ interface RiderPerformanceStats {
|
|
|
757
774
|
riders: RiderPerformanceItem[];
|
|
758
775
|
timeSeries?: RiderPerformanceTimeSeries[];
|
|
759
776
|
}
|
|
777
|
+
declare enum PayoutPeriodType {
|
|
778
|
+
Weekly = "weekly",
|
|
779
|
+
Fortnightly = "fortnightly",
|
|
780
|
+
Monthly = "monthly",
|
|
781
|
+
Custom = "custom"
|
|
782
|
+
}
|
|
783
|
+
declare enum RiderPayoutStatus {
|
|
784
|
+
Pending = "pending",
|
|
785
|
+
Approved = "approved",
|
|
786
|
+
Paid = "paid",
|
|
787
|
+
Cancelled = "cancelled"
|
|
788
|
+
}
|
|
789
|
+
/** Which knob supplied the percentage a payout was computed at. */
|
|
790
|
+
declare enum PayoutRateSource {
|
|
791
|
+
Rider = "rider",
|
|
792
|
+
Business = "business"
|
|
793
|
+
}
|
|
794
|
+
/** One bonus (positive `amount`) or deduction (negative) on a payout. */
|
|
795
|
+
interface RiderPayoutAdjustment {
|
|
796
|
+
id: string;
|
|
797
|
+
label: string;
|
|
798
|
+
amount: number;
|
|
799
|
+
createdAt: Date;
|
|
800
|
+
}
|
|
801
|
+
interface RiderPayout {
|
|
802
|
+
id: string;
|
|
803
|
+
riderId: string;
|
|
804
|
+
businessId: string;
|
|
805
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}`;
|
|
806
|
+
periodStart: Date;
|
|
807
|
+
periodEnd: Date;
|
|
808
|
+
/** Errands counted toward `grossEarnings`. */
|
|
809
|
+
errandCount: number;
|
|
810
|
+
/** Sum of `Errand.price` over the counted errands. */
|
|
811
|
+
grossEarnings: number;
|
|
812
|
+
/** The rate this payout was computed at — snapshotted, never re-read. */
|
|
813
|
+
payoutPercentage: number;
|
|
814
|
+
payoutRateSource: PayoutRateSource | `${PayoutRateSource}`;
|
|
815
|
+
/** `grossEarnings` at `payoutPercentage`. */
|
|
816
|
+
payoutAmount: number;
|
|
817
|
+
/** Hand-entered bonus and deduction lines. */
|
|
818
|
+
adjustments: RiderPayoutAdjustment[];
|
|
819
|
+
/** Sum of `adjustments`. Derived, never set directly. */
|
|
820
|
+
adjustmentAmount: number;
|
|
821
|
+
/** What the rider is actually paid: `payoutAmount + adjustmentAmount`. */
|
|
822
|
+
netAmount: number;
|
|
823
|
+
status: RiderPayoutStatus | `${RiderPayoutStatus}`;
|
|
824
|
+
approvedAt?: Date;
|
|
825
|
+
approvedBy?: string;
|
|
826
|
+
paidAt?: Date;
|
|
827
|
+
paymentReference?: string;
|
|
828
|
+
notes?: string;
|
|
829
|
+
createdAt: Date;
|
|
830
|
+
updatedAt: Date;
|
|
831
|
+
version: number;
|
|
832
|
+
}
|
|
833
|
+
/** One rider's computed pay for a period, before anything is persisted. */
|
|
834
|
+
interface RiderPayoutPreviewItem {
|
|
835
|
+
riderId: string;
|
|
836
|
+
riderName: string;
|
|
837
|
+
errandCount: number;
|
|
838
|
+
grossEarnings: number;
|
|
839
|
+
/** Null when neither the rider nor the business has a rate configured. */
|
|
840
|
+
payoutPercentage: number | null;
|
|
841
|
+
payoutRateSource: PayoutRateSource | `${PayoutRateSource}` | null;
|
|
842
|
+
payoutAmount: number;
|
|
843
|
+
/** Set when a payout for this rider and the same period already exists. */
|
|
844
|
+
existingPayoutId?: string;
|
|
845
|
+
existingPayoutStatus?: RiderPayoutStatus | `${RiderPayoutStatus}`;
|
|
846
|
+
}
|
|
847
|
+
interface RiderPayoutPreview {
|
|
848
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}`;
|
|
849
|
+
periodStart: Date;
|
|
850
|
+
periodEnd: Date;
|
|
851
|
+
periodLabel: string;
|
|
852
|
+
summary: {
|
|
853
|
+
riderCount: number;
|
|
854
|
+
totalErrands: number;
|
|
855
|
+
totalGrossEarnings: number;
|
|
856
|
+
totalPayoutAmount: number;
|
|
857
|
+
/** Riders skipped because no percentage is configured for them. */
|
|
858
|
+
unratedRiderCount: number;
|
|
859
|
+
};
|
|
860
|
+
riders: RiderPayoutPreviewItem[];
|
|
861
|
+
}
|
|
760
862
|
|
|
761
863
|
declare enum ErrandStatus {
|
|
762
864
|
Pending = "pending",
|
|
@@ -1598,4 +1700,4 @@ declare enum LinkDestination {
|
|
|
1598
1700
|
}
|
|
1599
1701
|
type NullOrUndefined = null | undefined;
|
|
1600
1702
|
|
|
1601
|
-
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 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 };
|
|
1703
|
+
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, type BusinessRiderPaySettings, 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_RIDER_PAY_SETTINGS, 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, PayoutPeriodType, PayoutRateSource, 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 RiderPayout, type RiderPayoutAdjustment, type RiderPayoutPreview, type RiderPayoutPreviewItem, RiderPayoutStatus, 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 };
|
package/dist/index.js
CHANGED
|
@@ -195,6 +195,25 @@ var RemittanceStatus = /* @__PURE__ */ ((RemittanceStatus2) => {
|
|
|
195
195
|
RemittanceStatus2["Cancelled"] = "cancelled";
|
|
196
196
|
return RemittanceStatus2;
|
|
197
197
|
})(RemittanceStatus || {});
|
|
198
|
+
var PayoutPeriodType = /* @__PURE__ */ ((PayoutPeriodType2) => {
|
|
199
|
+
PayoutPeriodType2["Weekly"] = "weekly";
|
|
200
|
+
PayoutPeriodType2["Fortnightly"] = "fortnightly";
|
|
201
|
+
PayoutPeriodType2["Monthly"] = "monthly";
|
|
202
|
+
PayoutPeriodType2["Custom"] = "custom";
|
|
203
|
+
return PayoutPeriodType2;
|
|
204
|
+
})(PayoutPeriodType || {});
|
|
205
|
+
var RiderPayoutStatus = /* @__PURE__ */ ((RiderPayoutStatus2) => {
|
|
206
|
+
RiderPayoutStatus2["Pending"] = "pending";
|
|
207
|
+
RiderPayoutStatus2["Approved"] = "approved";
|
|
208
|
+
RiderPayoutStatus2["Paid"] = "paid";
|
|
209
|
+
RiderPayoutStatus2["Cancelled"] = "cancelled";
|
|
210
|
+
return RiderPayoutStatus2;
|
|
211
|
+
})(RiderPayoutStatus || {});
|
|
212
|
+
var PayoutRateSource = /* @__PURE__ */ ((PayoutRateSource2) => {
|
|
213
|
+
PayoutRateSource2["Rider"] = "rider";
|
|
214
|
+
PayoutRateSource2["Business"] = "business";
|
|
215
|
+
return PayoutRateSource2;
|
|
216
|
+
})(PayoutRateSource || {});
|
|
198
217
|
|
|
199
218
|
// src/enterprise.ts
|
|
200
219
|
var EnterpriseType = /* @__PURE__ */ ((EnterpriseType2) => {
|
|
@@ -231,6 +250,10 @@ var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
|
|
|
231
250
|
var DEFAULT_BUSINESS_FUEL_SETTINGS = {
|
|
232
251
|
revenuePercent: null
|
|
233
252
|
};
|
|
253
|
+
var DEFAULT_BUSINESS_RIDER_PAY_SETTINGS = {
|
|
254
|
+
defaultPercentage: null,
|
|
255
|
+
periodType: null
|
|
256
|
+
};
|
|
234
257
|
var DEFAULT_BUSINESS_MODULES = {
|
|
235
258
|
draftErrands: true,
|
|
236
259
|
team: true,
|
|
@@ -263,7 +286,8 @@ var DEFAULT_BUSINESS_SETTINGS = {
|
|
|
263
286
|
website: null
|
|
264
287
|
},
|
|
265
288
|
modules: DEFAULT_BUSINESS_MODULES,
|
|
266
|
-
fuel: DEFAULT_BUSINESS_FUEL_SETTINGS
|
|
289
|
+
fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
|
|
290
|
+
riderPay: DEFAULT_BUSINESS_RIDER_PAY_SETTINGS
|
|
267
291
|
};
|
|
268
292
|
var BusinessCourierLinkStatus = /* @__PURE__ */ ((BusinessCourierLinkStatus2) => {
|
|
269
293
|
BusinessCourierLinkStatus2["ACTIVE"] = "active";
|
|
@@ -342,6 +366,7 @@ export {
|
|
|
342
366
|
BusinessStatus,
|
|
343
367
|
DEFAULT_BUSINESS_FUEL_SETTINGS,
|
|
344
368
|
DEFAULT_BUSINESS_MODULES,
|
|
369
|
+
DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
|
|
345
370
|
DEFAULT_BUSINESS_SETTINGS,
|
|
346
371
|
DeliveryStatus,
|
|
347
372
|
DraftErrandStatus,
|
|
@@ -362,8 +387,11 @@ export {
|
|
|
362
387
|
NotificationType,
|
|
363
388
|
ParcelSize,
|
|
364
389
|
PaymentOptions,
|
|
390
|
+
PayoutPeriodType,
|
|
391
|
+
PayoutRateSource,
|
|
365
392
|
PortalStatus,
|
|
366
393
|
RemittanceStatus,
|
|
394
|
+
RiderPayoutStatus,
|
|
367
395
|
RoleType,
|
|
368
396
|
SweepExclusionReason,
|
|
369
397
|
VehicleLogType,
|
package/package.json
CHANGED
package/src/business.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BusinessWhatsappConfig,
|
|
3
|
+
NullOrUndefined,
|
|
4
|
+
PayoutPeriodType,
|
|
5
|
+
User,
|
|
6
|
+
} from '.';
|
|
2
7
|
|
|
3
8
|
export enum BusinessCapability {
|
|
4
9
|
SELF_FULFILLMENT = 'self_fulfillment',
|
|
@@ -123,6 +128,21 @@ export interface BusinessFuelSettings {
|
|
|
123
128
|
revenuePercent: number | null;
|
|
124
129
|
}
|
|
125
130
|
|
|
131
|
+
/**
|
|
132
|
+
* How a business pays its riders. `defaultPercentage` is the share of the
|
|
133
|
+
* errand fees a rider earned that the rider takes home, used for every rider
|
|
134
|
+
* without their own `payoutPercentage`. `null` (the default) means the business
|
|
135
|
+
* hasn't configured it — those riders simply can't have a payout generated
|
|
136
|
+
* until someone sets a rate, rather than being silently paid zero.
|
|
137
|
+
*
|
|
138
|
+
* `periodType` is only the default cadence the payout screens open on; a payout
|
|
139
|
+
* can always be generated for any period.
|
|
140
|
+
*/
|
|
141
|
+
export interface BusinessRiderPaySettings {
|
|
142
|
+
defaultPercentage: number | null;
|
|
143
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}` | null;
|
|
144
|
+
}
|
|
145
|
+
|
|
126
146
|
export interface BusinessSettings {
|
|
127
147
|
whatsapp_notification_enabled: boolean;
|
|
128
148
|
whatsapp: BusinessWhatsappConfig;
|
|
@@ -150,12 +170,18 @@ export interface BusinessSettings {
|
|
|
150
170
|
};
|
|
151
171
|
modules: BusinessModules;
|
|
152
172
|
fuel?: BusinessFuelSettings;
|
|
173
|
+
riderPay?: BusinessRiderPaySettings;
|
|
153
174
|
}
|
|
154
175
|
|
|
155
176
|
export const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings = {
|
|
156
177
|
revenuePercent: null,
|
|
157
178
|
};
|
|
158
179
|
|
|
180
|
+
export const DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: BusinessRiderPaySettings = {
|
|
181
|
+
defaultPercentage: null,
|
|
182
|
+
periodType: null,
|
|
183
|
+
};
|
|
184
|
+
|
|
159
185
|
export const DEFAULT_BUSINESS_MODULES: BusinessModules = {
|
|
160
186
|
draftErrands: true,
|
|
161
187
|
team: true,
|
|
@@ -190,6 +216,7 @@ export const DEFAULT_BUSINESS_SETTINGS: BusinessSettings = {
|
|
|
190
216
|
},
|
|
191
217
|
modules: DEFAULT_BUSINESS_MODULES,
|
|
192
218
|
fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
|
|
219
|
+
riderPay: DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
|
|
193
220
|
};
|
|
194
221
|
|
|
195
222
|
export interface BusinessMember {
|
package/src/rider.ts
CHANGED
|
@@ -6,7 +6,12 @@ import { User } from './user';
|
|
|
6
6
|
import type { Vehicle } from './vehicle';
|
|
7
7
|
|
|
8
8
|
// Re-export vehicle types for backwards compatibility
|
|
9
|
-
export type {
|
|
9
|
+
export type {
|
|
10
|
+
Vehicle,
|
|
11
|
+
VehicleWithRider,
|
|
12
|
+
VehicleLog,
|
|
13
|
+
VehicleLogWithErrands,
|
|
14
|
+
} from './vehicle';
|
|
10
15
|
export { VehicleType, VehicleLogType } from './vehicle';
|
|
11
16
|
|
|
12
17
|
export type Rider = {
|
|
@@ -27,6 +32,7 @@ export type Rider = {
|
|
|
27
32
|
rating: number;
|
|
28
33
|
version: number;
|
|
29
34
|
hasBeenRated: boolean;
|
|
35
|
+
payoutPercentage?: number | null;
|
|
30
36
|
// enterprise: string | Enterprise;
|
|
31
37
|
// isTracking: boolean;
|
|
32
38
|
|
|
@@ -105,3 +111,110 @@ export interface RiderPerformanceStats {
|
|
|
105
111
|
timeSeries?: RiderPerformanceTimeSeries[];
|
|
106
112
|
}
|
|
107
113
|
|
|
114
|
+
// Rider Payout Types
|
|
115
|
+
//
|
|
116
|
+
// Rider pay is a percentage of the errand fees a rider earned over a pay
|
|
117
|
+
// period. The percentage comes from the rider (`Rider.payoutPercentage`) and
|
|
118
|
+
// falls back to the business default (`settings.riderPay.defaultPercentage`).
|
|
119
|
+
//
|
|
120
|
+
// Deliberately separate from `RiderSettlement`: a settlement tracks cash the
|
|
121
|
+
// rider owes US, a payout tracks money WE owe the rider. Netting the two would
|
|
122
|
+
// hide either side the moment they disagree.
|
|
123
|
+
export enum PayoutPeriodType {
|
|
124
|
+
Weekly = 'weekly',
|
|
125
|
+
Fortnightly = 'fortnightly',
|
|
126
|
+
Monthly = 'monthly',
|
|
127
|
+
Custom = 'custom',
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export enum RiderPayoutStatus {
|
|
131
|
+
Pending = 'pending',
|
|
132
|
+
Approved = 'approved',
|
|
133
|
+
Paid = 'paid',
|
|
134
|
+
Cancelled = 'cancelled',
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Which knob supplied the percentage a payout was computed at. */
|
|
138
|
+
export enum PayoutRateSource {
|
|
139
|
+
Rider = 'rider',
|
|
140
|
+
Business = 'business',
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** One bonus (positive `amount`) or deduction (negative) on a payout. */
|
|
144
|
+
export interface RiderPayoutAdjustment {
|
|
145
|
+
id: string;
|
|
146
|
+
label: string;
|
|
147
|
+
amount: number;
|
|
148
|
+
createdAt: Date;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface RiderPayout {
|
|
152
|
+
id: string;
|
|
153
|
+
riderId: string;
|
|
154
|
+
businessId: string;
|
|
155
|
+
|
|
156
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}`;
|
|
157
|
+
periodStart: Date;
|
|
158
|
+
periodEnd: Date;
|
|
159
|
+
|
|
160
|
+
/** Errands counted toward `grossEarnings`. */
|
|
161
|
+
errandCount: number;
|
|
162
|
+
/** Sum of `Errand.price` over the counted errands. */
|
|
163
|
+
grossEarnings: number;
|
|
164
|
+
|
|
165
|
+
/** The rate this payout was computed at — snapshotted, never re-read. */
|
|
166
|
+
payoutPercentage: number;
|
|
167
|
+
payoutRateSource: PayoutRateSource | `${PayoutRateSource}`;
|
|
168
|
+
/** `grossEarnings` at `payoutPercentage`. */
|
|
169
|
+
payoutAmount: number;
|
|
170
|
+
|
|
171
|
+
/** Hand-entered bonus and deduction lines. */
|
|
172
|
+
adjustments: RiderPayoutAdjustment[];
|
|
173
|
+
/** Sum of `adjustments`. Derived, never set directly. */
|
|
174
|
+
adjustmentAmount: number;
|
|
175
|
+
/** What the rider is actually paid: `payoutAmount + adjustmentAmount`. */
|
|
176
|
+
netAmount: number;
|
|
177
|
+
|
|
178
|
+
status: RiderPayoutStatus | `${RiderPayoutStatus}`;
|
|
179
|
+
approvedAt?: Date;
|
|
180
|
+
approvedBy?: string;
|
|
181
|
+
paidAt?: Date;
|
|
182
|
+
paymentReference?: string;
|
|
183
|
+
|
|
184
|
+
notes?: string;
|
|
185
|
+
|
|
186
|
+
createdAt: Date;
|
|
187
|
+
updatedAt: Date;
|
|
188
|
+
version: number;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** One rider's computed pay for a period, before anything is persisted. */
|
|
192
|
+
export interface RiderPayoutPreviewItem {
|
|
193
|
+
riderId: string;
|
|
194
|
+
riderName: string;
|
|
195
|
+
errandCount: number;
|
|
196
|
+
grossEarnings: number;
|
|
197
|
+
/** Null when neither the rider nor the business has a rate configured. */
|
|
198
|
+
payoutPercentage: number | null;
|
|
199
|
+
payoutRateSource: PayoutRateSource | `${PayoutRateSource}` | null;
|
|
200
|
+
payoutAmount: number;
|
|
201
|
+
/** Set when a payout for this rider and the same period already exists. */
|
|
202
|
+
existingPayoutId?: string;
|
|
203
|
+
existingPayoutStatus?: RiderPayoutStatus | `${RiderPayoutStatus}`;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface RiderPayoutPreview {
|
|
207
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}`;
|
|
208
|
+
periodStart: Date;
|
|
209
|
+
periodEnd: Date;
|
|
210
|
+
periodLabel: string;
|
|
211
|
+
summary: {
|
|
212
|
+
riderCount: number;
|
|
213
|
+
totalErrands: number;
|
|
214
|
+
totalGrossEarnings: number;
|
|
215
|
+
totalPayoutAmount: number;
|
|
216
|
+
/** Riders skipped because no percentage is configured for them. */
|
|
217
|
+
unratedRiderCount: number;
|
|
218
|
+
};
|
|
219
|
+
riders: RiderPayoutPreviewItem[];
|
|
220
|
+
}
|