@mydoormot/app-types 1.9.4 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +33 -2
- package/dist/index.d.cts +102 -9
- package/dist/index.d.ts +102 -9
- package/dist/index.js +29 -2
- package/package.json +1 -1
- package/src/business.ts +28 -1
- package/src/invoice.ts +0 -9
- package/src/rider.ts +108 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @mydoormot/app-types@
|
|
2
|
+
> @mydoormot/app-types@2.0.0 build /Users/chuksben/Desktop/projects/microservices/mydoormot/packages/app-types
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mCLI[39m Target: es2021
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
12
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
-
[32mCJS[39m [1mdist/index.cjs [22m[
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m [1mdist/index.js [22m[32m14.62 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 63ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m17.59 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 64ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 685ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m49.44 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m49.44 KB[39m
|
package/CHANGELOG.md
CHANGED
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,
|
|
@@ -218,7 +222,6 @@ var InvoiceEventType = /* @__PURE__ */ ((InvoiceEventType2) => {
|
|
|
218
222
|
InvoiceEventType2["PaymentRecorded"] = "payment_recorded";
|
|
219
223
|
InvoiceEventType2["PaymentReversed"] = "payment_reversed";
|
|
220
224
|
InvoiceEventType2["StatusChanged"] = "status_changed";
|
|
221
|
-
InvoiceEventType2["Shared"] = "shared";
|
|
222
225
|
InvoiceEventType2["Viewed"] = "viewed";
|
|
223
226
|
return InvoiceEventType2;
|
|
224
227
|
})(InvoiceEventType || {});
|
|
@@ -262,6 +265,25 @@ var RemittanceStatus = /* @__PURE__ */ ((RemittanceStatus2) => {
|
|
|
262
265
|
RemittanceStatus2["Cancelled"] = "cancelled";
|
|
263
266
|
return RemittanceStatus2;
|
|
264
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 || {});
|
|
265
287
|
|
|
266
288
|
// src/enterprise.ts
|
|
267
289
|
var EnterpriseType = /* @__PURE__ */ ((EnterpriseType2) => {
|
|
@@ -298,6 +320,10 @@ var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
|
|
|
298
320
|
var DEFAULT_BUSINESS_FUEL_SETTINGS = {
|
|
299
321
|
revenuePercent: null
|
|
300
322
|
};
|
|
323
|
+
var DEFAULT_BUSINESS_RIDER_PAY_SETTINGS = {
|
|
324
|
+
defaultPercentage: null,
|
|
325
|
+
periodType: null
|
|
326
|
+
};
|
|
301
327
|
var DEFAULT_BUSINESS_MODULES = {
|
|
302
328
|
draftErrands: true,
|
|
303
329
|
team: true,
|
|
@@ -330,7 +356,8 @@ var DEFAULT_BUSINESS_SETTINGS = {
|
|
|
330
356
|
website: null
|
|
331
357
|
},
|
|
332
358
|
modules: DEFAULT_BUSINESS_MODULES,
|
|
333
|
-
fuel: DEFAULT_BUSINESS_FUEL_SETTINGS
|
|
359
|
+
fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
|
|
360
|
+
riderPay: DEFAULT_BUSINESS_RIDER_PAY_SETTINGS
|
|
334
361
|
};
|
|
335
362
|
var BusinessCourierLinkStatus = /* @__PURE__ */ ((BusinessCourierLinkStatus2) => {
|
|
336
363
|
BusinessCourierLinkStatus2["ACTIVE"] = "active";
|
|
@@ -410,6 +437,7 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
|
|
|
410
437
|
BusinessStatus,
|
|
411
438
|
DEFAULT_BUSINESS_FUEL_SETTINGS,
|
|
412
439
|
DEFAULT_BUSINESS_MODULES,
|
|
440
|
+
DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
|
|
413
441
|
DEFAULT_BUSINESS_SETTINGS,
|
|
414
442
|
DeliveryStatus,
|
|
415
443
|
DraftErrandStatus,
|
|
@@ -430,8 +458,11 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
|
|
|
430
458
|
NotificationType,
|
|
431
459
|
ParcelSize,
|
|
432
460
|
PaymentOptions,
|
|
461
|
+
PayoutPeriodType,
|
|
462
|
+
PayoutRateSource,
|
|
433
463
|
PortalStatus,
|
|
434
464
|
RemittanceStatus,
|
|
465
|
+
RiderPayoutStatus,
|
|
435
466
|
RoleType,
|
|
436
467
|
SweepExclusionReason,
|
|
437
468
|
VehicleLogType,
|
package/dist/index.d.cts
CHANGED
|
@@ -197,7 +197,6 @@ declare enum InvoiceEventType {
|
|
|
197
197
|
PaymentRecorded = "payment_recorded",
|
|
198
198
|
PaymentReversed = "payment_reversed",
|
|
199
199
|
StatusChanged = "status_changed",
|
|
200
|
-
Shared = "shared",
|
|
201
200
|
Viewed = "viewed"
|
|
202
201
|
}
|
|
203
202
|
/** Why an errand in the period was not charged on the statement. */
|
|
@@ -237,12 +236,6 @@ interface InvoiceEvent {
|
|
|
237
236
|
meta?: Record<string, unknown>;
|
|
238
237
|
createdAt: string;
|
|
239
238
|
}
|
|
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;
|
|
245
|
-
}
|
|
246
239
|
/** Whether a frozen invoice has fallen out of date, and by how much. */
|
|
247
240
|
interface InvoiceDrift {
|
|
248
241
|
errandCount: number;
|
|
@@ -276,7 +269,6 @@ interface Invoice {
|
|
|
276
269
|
* Document lifecycle, kept separate from `status`: an invoice can be
|
|
277
270
|
* part-paid and viewed, or paid and never opened.
|
|
278
271
|
*/
|
|
279
|
-
sentAt?: string;
|
|
280
272
|
firstViewedAt?: string;
|
|
281
273
|
lastViewedAt?: string;
|
|
282
274
|
viewCount?: number;
|
|
@@ -417,6 +409,20 @@ interface BusinessModules {
|
|
|
417
409
|
interface BusinessFuelSettings {
|
|
418
410
|
revenuePercent: number | null;
|
|
419
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
|
+
}
|
|
420
426
|
interface BusinessSettings {
|
|
421
427
|
whatsapp_notification_enabled: boolean;
|
|
422
428
|
whatsapp: BusinessWhatsappConfig;
|
|
@@ -444,8 +450,10 @@ interface BusinessSettings {
|
|
|
444
450
|
};
|
|
445
451
|
modules: BusinessModules;
|
|
446
452
|
fuel?: BusinessFuelSettings;
|
|
453
|
+
riderPay?: BusinessRiderPaySettings;
|
|
447
454
|
}
|
|
448
455
|
declare const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings;
|
|
456
|
+
declare const DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: BusinessRiderPaySettings;
|
|
449
457
|
declare const DEFAULT_BUSINESS_MODULES: BusinessModules;
|
|
450
458
|
declare const DEFAULT_BUSINESS_SETTINGS: BusinessSettings;
|
|
451
459
|
interface BusinessMember {
|
|
@@ -765,6 +773,91 @@ interface RiderPerformanceStats {
|
|
|
765
773
|
riders: RiderPerformanceItem[];
|
|
766
774
|
timeSeries?: RiderPerformanceTimeSeries[];
|
|
767
775
|
}
|
|
776
|
+
declare enum PayoutPeriodType {
|
|
777
|
+
Weekly = "weekly",
|
|
778
|
+
Fortnightly = "fortnightly",
|
|
779
|
+
Monthly = "monthly",
|
|
780
|
+
Custom = "custom"
|
|
781
|
+
}
|
|
782
|
+
declare enum RiderPayoutStatus {
|
|
783
|
+
Pending = "pending",
|
|
784
|
+
Approved = "approved",
|
|
785
|
+
Paid = "paid",
|
|
786
|
+
Cancelled = "cancelled"
|
|
787
|
+
}
|
|
788
|
+
/** Which knob supplied the percentage a payout was computed at. */
|
|
789
|
+
declare enum PayoutRateSource {
|
|
790
|
+
Rider = "rider",
|
|
791
|
+
Business = "business"
|
|
792
|
+
}
|
|
793
|
+
/** One bonus (positive `amount`) or deduction (negative) on a payout. */
|
|
794
|
+
interface RiderPayoutAdjustment {
|
|
795
|
+
id: string;
|
|
796
|
+
label: string;
|
|
797
|
+
amount: number;
|
|
798
|
+
createdAt: Date;
|
|
799
|
+
}
|
|
800
|
+
interface RiderPayout {
|
|
801
|
+
id: string;
|
|
802
|
+
riderId: string;
|
|
803
|
+
businessId: string;
|
|
804
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}`;
|
|
805
|
+
periodStart: Date;
|
|
806
|
+
periodEnd: Date;
|
|
807
|
+
/** Errands counted toward `grossEarnings`. */
|
|
808
|
+
errandCount: number;
|
|
809
|
+
/** Sum of `Errand.price` over the counted errands. */
|
|
810
|
+
grossEarnings: number;
|
|
811
|
+
/** The rate this payout was computed at — snapshotted, never re-read. */
|
|
812
|
+
payoutPercentage: number;
|
|
813
|
+
payoutRateSource: PayoutRateSource | `${PayoutRateSource}`;
|
|
814
|
+
/** `grossEarnings` at `payoutPercentage`. */
|
|
815
|
+
payoutAmount: number;
|
|
816
|
+
/** Hand-entered bonus and deduction lines. */
|
|
817
|
+
adjustments: RiderPayoutAdjustment[];
|
|
818
|
+
/** Sum of `adjustments`. Derived, never set directly. */
|
|
819
|
+
adjustmentAmount: number;
|
|
820
|
+
/** What the rider is actually paid: `payoutAmount + adjustmentAmount`. */
|
|
821
|
+
netAmount: number;
|
|
822
|
+
status: RiderPayoutStatus | `${RiderPayoutStatus}`;
|
|
823
|
+
approvedAt?: Date;
|
|
824
|
+
approvedBy?: string;
|
|
825
|
+
paidAt?: Date;
|
|
826
|
+
paymentReference?: string;
|
|
827
|
+
notes?: string;
|
|
828
|
+
createdAt: Date;
|
|
829
|
+
updatedAt: Date;
|
|
830
|
+
version: number;
|
|
831
|
+
}
|
|
832
|
+
/** One rider's computed pay for a period, before anything is persisted. */
|
|
833
|
+
interface RiderPayoutPreviewItem {
|
|
834
|
+
riderId: string;
|
|
835
|
+
riderName: string;
|
|
836
|
+
errandCount: number;
|
|
837
|
+
grossEarnings: number;
|
|
838
|
+
/** Null when neither the rider nor the business has a rate configured. */
|
|
839
|
+
payoutPercentage: number | null;
|
|
840
|
+
payoutRateSource: PayoutRateSource | `${PayoutRateSource}` | null;
|
|
841
|
+
payoutAmount: number;
|
|
842
|
+
/** Set when a payout for this rider and the same period already exists. */
|
|
843
|
+
existingPayoutId?: string;
|
|
844
|
+
existingPayoutStatus?: RiderPayoutStatus | `${RiderPayoutStatus}`;
|
|
845
|
+
}
|
|
846
|
+
interface RiderPayoutPreview {
|
|
847
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}`;
|
|
848
|
+
periodStart: Date;
|
|
849
|
+
periodEnd: Date;
|
|
850
|
+
periodLabel: string;
|
|
851
|
+
summary: {
|
|
852
|
+
riderCount: number;
|
|
853
|
+
totalErrands: number;
|
|
854
|
+
totalGrossEarnings: number;
|
|
855
|
+
totalPayoutAmount: number;
|
|
856
|
+
/** Riders skipped because no percentage is configured for them. */
|
|
857
|
+
unratedRiderCount: number;
|
|
858
|
+
};
|
|
859
|
+
riders: RiderPayoutPreviewItem[];
|
|
860
|
+
}
|
|
768
861
|
|
|
769
862
|
declare enum ErrandStatus {
|
|
770
863
|
Pending = "pending",
|
|
@@ -1606,4 +1699,4 @@ declare enum LinkDestination {
|
|
|
1606
1699
|
}
|
|
1607
1700
|
type NullOrUndefined = null | undefined;
|
|
1608
1701
|
|
|
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
|
|
1702
|
+
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
|
@@ -197,7 +197,6 @@ declare enum InvoiceEventType {
|
|
|
197
197
|
PaymentRecorded = "payment_recorded",
|
|
198
198
|
PaymentReversed = "payment_reversed",
|
|
199
199
|
StatusChanged = "status_changed",
|
|
200
|
-
Shared = "shared",
|
|
201
200
|
Viewed = "viewed"
|
|
202
201
|
}
|
|
203
202
|
/** Why an errand in the period was not charged on the statement. */
|
|
@@ -237,12 +236,6 @@ interface InvoiceEvent {
|
|
|
237
236
|
meta?: Record<string, unknown>;
|
|
238
237
|
createdAt: string;
|
|
239
238
|
}
|
|
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;
|
|
245
|
-
}
|
|
246
239
|
/** Whether a frozen invoice has fallen out of date, and by how much. */
|
|
247
240
|
interface InvoiceDrift {
|
|
248
241
|
errandCount: number;
|
|
@@ -276,7 +269,6 @@ interface Invoice {
|
|
|
276
269
|
* Document lifecycle, kept separate from `status`: an invoice can be
|
|
277
270
|
* part-paid and viewed, or paid and never opened.
|
|
278
271
|
*/
|
|
279
|
-
sentAt?: string;
|
|
280
272
|
firstViewedAt?: string;
|
|
281
273
|
lastViewedAt?: string;
|
|
282
274
|
viewCount?: number;
|
|
@@ -417,6 +409,20 @@ interface BusinessModules {
|
|
|
417
409
|
interface BusinessFuelSettings {
|
|
418
410
|
revenuePercent: number | null;
|
|
419
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
|
+
}
|
|
420
426
|
interface BusinessSettings {
|
|
421
427
|
whatsapp_notification_enabled: boolean;
|
|
422
428
|
whatsapp: BusinessWhatsappConfig;
|
|
@@ -444,8 +450,10 @@ interface BusinessSettings {
|
|
|
444
450
|
};
|
|
445
451
|
modules: BusinessModules;
|
|
446
452
|
fuel?: BusinessFuelSettings;
|
|
453
|
+
riderPay?: BusinessRiderPaySettings;
|
|
447
454
|
}
|
|
448
455
|
declare const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings;
|
|
456
|
+
declare const DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: BusinessRiderPaySettings;
|
|
449
457
|
declare const DEFAULT_BUSINESS_MODULES: BusinessModules;
|
|
450
458
|
declare const DEFAULT_BUSINESS_SETTINGS: BusinessSettings;
|
|
451
459
|
interface BusinessMember {
|
|
@@ -765,6 +773,91 @@ interface RiderPerformanceStats {
|
|
|
765
773
|
riders: RiderPerformanceItem[];
|
|
766
774
|
timeSeries?: RiderPerformanceTimeSeries[];
|
|
767
775
|
}
|
|
776
|
+
declare enum PayoutPeriodType {
|
|
777
|
+
Weekly = "weekly",
|
|
778
|
+
Fortnightly = "fortnightly",
|
|
779
|
+
Monthly = "monthly",
|
|
780
|
+
Custom = "custom"
|
|
781
|
+
}
|
|
782
|
+
declare enum RiderPayoutStatus {
|
|
783
|
+
Pending = "pending",
|
|
784
|
+
Approved = "approved",
|
|
785
|
+
Paid = "paid",
|
|
786
|
+
Cancelled = "cancelled"
|
|
787
|
+
}
|
|
788
|
+
/** Which knob supplied the percentage a payout was computed at. */
|
|
789
|
+
declare enum PayoutRateSource {
|
|
790
|
+
Rider = "rider",
|
|
791
|
+
Business = "business"
|
|
792
|
+
}
|
|
793
|
+
/** One bonus (positive `amount`) or deduction (negative) on a payout. */
|
|
794
|
+
interface RiderPayoutAdjustment {
|
|
795
|
+
id: string;
|
|
796
|
+
label: string;
|
|
797
|
+
amount: number;
|
|
798
|
+
createdAt: Date;
|
|
799
|
+
}
|
|
800
|
+
interface RiderPayout {
|
|
801
|
+
id: string;
|
|
802
|
+
riderId: string;
|
|
803
|
+
businessId: string;
|
|
804
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}`;
|
|
805
|
+
periodStart: Date;
|
|
806
|
+
periodEnd: Date;
|
|
807
|
+
/** Errands counted toward `grossEarnings`. */
|
|
808
|
+
errandCount: number;
|
|
809
|
+
/** Sum of `Errand.price` over the counted errands. */
|
|
810
|
+
grossEarnings: number;
|
|
811
|
+
/** The rate this payout was computed at — snapshotted, never re-read. */
|
|
812
|
+
payoutPercentage: number;
|
|
813
|
+
payoutRateSource: PayoutRateSource | `${PayoutRateSource}`;
|
|
814
|
+
/** `grossEarnings` at `payoutPercentage`. */
|
|
815
|
+
payoutAmount: number;
|
|
816
|
+
/** Hand-entered bonus and deduction lines. */
|
|
817
|
+
adjustments: RiderPayoutAdjustment[];
|
|
818
|
+
/** Sum of `adjustments`. Derived, never set directly. */
|
|
819
|
+
adjustmentAmount: number;
|
|
820
|
+
/** What the rider is actually paid: `payoutAmount + adjustmentAmount`. */
|
|
821
|
+
netAmount: number;
|
|
822
|
+
status: RiderPayoutStatus | `${RiderPayoutStatus}`;
|
|
823
|
+
approvedAt?: Date;
|
|
824
|
+
approvedBy?: string;
|
|
825
|
+
paidAt?: Date;
|
|
826
|
+
paymentReference?: string;
|
|
827
|
+
notes?: string;
|
|
828
|
+
createdAt: Date;
|
|
829
|
+
updatedAt: Date;
|
|
830
|
+
version: number;
|
|
831
|
+
}
|
|
832
|
+
/** One rider's computed pay for a period, before anything is persisted. */
|
|
833
|
+
interface RiderPayoutPreviewItem {
|
|
834
|
+
riderId: string;
|
|
835
|
+
riderName: string;
|
|
836
|
+
errandCount: number;
|
|
837
|
+
grossEarnings: number;
|
|
838
|
+
/** Null when neither the rider nor the business has a rate configured. */
|
|
839
|
+
payoutPercentage: number | null;
|
|
840
|
+
payoutRateSource: PayoutRateSource | `${PayoutRateSource}` | null;
|
|
841
|
+
payoutAmount: number;
|
|
842
|
+
/** Set when a payout for this rider and the same period already exists. */
|
|
843
|
+
existingPayoutId?: string;
|
|
844
|
+
existingPayoutStatus?: RiderPayoutStatus | `${RiderPayoutStatus}`;
|
|
845
|
+
}
|
|
846
|
+
interface RiderPayoutPreview {
|
|
847
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}`;
|
|
848
|
+
periodStart: Date;
|
|
849
|
+
periodEnd: Date;
|
|
850
|
+
periodLabel: string;
|
|
851
|
+
summary: {
|
|
852
|
+
riderCount: number;
|
|
853
|
+
totalErrands: number;
|
|
854
|
+
totalGrossEarnings: number;
|
|
855
|
+
totalPayoutAmount: number;
|
|
856
|
+
/** Riders skipped because no percentage is configured for them. */
|
|
857
|
+
unratedRiderCount: number;
|
|
858
|
+
};
|
|
859
|
+
riders: RiderPayoutPreviewItem[];
|
|
860
|
+
}
|
|
768
861
|
|
|
769
862
|
declare enum ErrandStatus {
|
|
770
863
|
Pending = "pending",
|
|
@@ -1606,4 +1699,4 @@ declare enum LinkDestination {
|
|
|
1606
1699
|
}
|
|
1607
1700
|
type NullOrUndefined = null | undefined;
|
|
1608
1701
|
|
|
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
|
|
1702
|
+
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
|
@@ -152,7 +152,6 @@ var InvoiceEventType = /* @__PURE__ */ ((InvoiceEventType2) => {
|
|
|
152
152
|
InvoiceEventType2["PaymentRecorded"] = "payment_recorded";
|
|
153
153
|
InvoiceEventType2["PaymentReversed"] = "payment_reversed";
|
|
154
154
|
InvoiceEventType2["StatusChanged"] = "status_changed";
|
|
155
|
-
InvoiceEventType2["Shared"] = "shared";
|
|
156
155
|
InvoiceEventType2["Viewed"] = "viewed";
|
|
157
156
|
return InvoiceEventType2;
|
|
158
157
|
})(InvoiceEventType || {});
|
|
@@ -196,6 +195,25 @@ var RemittanceStatus = /* @__PURE__ */ ((RemittanceStatus2) => {
|
|
|
196
195
|
RemittanceStatus2["Cancelled"] = "cancelled";
|
|
197
196
|
return RemittanceStatus2;
|
|
198
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 || {});
|
|
199
217
|
|
|
200
218
|
// src/enterprise.ts
|
|
201
219
|
var EnterpriseType = /* @__PURE__ */ ((EnterpriseType2) => {
|
|
@@ -232,6 +250,10 @@ var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
|
|
|
232
250
|
var DEFAULT_BUSINESS_FUEL_SETTINGS = {
|
|
233
251
|
revenuePercent: null
|
|
234
252
|
};
|
|
253
|
+
var DEFAULT_BUSINESS_RIDER_PAY_SETTINGS = {
|
|
254
|
+
defaultPercentage: null,
|
|
255
|
+
periodType: null
|
|
256
|
+
};
|
|
235
257
|
var DEFAULT_BUSINESS_MODULES = {
|
|
236
258
|
draftErrands: true,
|
|
237
259
|
team: true,
|
|
@@ -264,7 +286,8 @@ var DEFAULT_BUSINESS_SETTINGS = {
|
|
|
264
286
|
website: null
|
|
265
287
|
},
|
|
266
288
|
modules: DEFAULT_BUSINESS_MODULES,
|
|
267
|
-
fuel: DEFAULT_BUSINESS_FUEL_SETTINGS
|
|
289
|
+
fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
|
|
290
|
+
riderPay: DEFAULT_BUSINESS_RIDER_PAY_SETTINGS
|
|
268
291
|
};
|
|
269
292
|
var BusinessCourierLinkStatus = /* @__PURE__ */ ((BusinessCourierLinkStatus2) => {
|
|
270
293
|
BusinessCourierLinkStatus2["ACTIVE"] = "active";
|
|
@@ -343,6 +366,7 @@ export {
|
|
|
343
366
|
BusinessStatus,
|
|
344
367
|
DEFAULT_BUSINESS_FUEL_SETTINGS,
|
|
345
368
|
DEFAULT_BUSINESS_MODULES,
|
|
369
|
+
DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
|
|
346
370
|
DEFAULT_BUSINESS_SETTINGS,
|
|
347
371
|
DeliveryStatus,
|
|
348
372
|
DraftErrandStatus,
|
|
@@ -363,8 +387,11 @@ export {
|
|
|
363
387
|
NotificationType,
|
|
364
388
|
ParcelSize,
|
|
365
389
|
PaymentOptions,
|
|
390
|
+
PayoutPeriodType,
|
|
391
|
+
PayoutRateSource,
|
|
366
392
|
PortalStatus,
|
|
367
393
|
RemittanceStatus,
|
|
394
|
+
RiderPayoutStatus,
|
|
368
395
|
RoleType,
|
|
369
396
|
SweepExclusionReason,
|
|
370
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/invoice.ts
CHANGED
|
@@ -42,7 +42,6 @@ export enum InvoiceEventType {
|
|
|
42
42
|
PaymentRecorded = 'payment_recorded',
|
|
43
43
|
PaymentReversed = 'payment_reversed',
|
|
44
44
|
StatusChanged = 'status_changed',
|
|
45
|
-
Shared = 'shared',
|
|
46
45
|
Viewed = 'viewed',
|
|
47
46
|
}
|
|
48
47
|
|
|
@@ -86,13 +85,6 @@ export interface InvoiceEvent {
|
|
|
86
85
|
createdAt: string;
|
|
87
86
|
}
|
|
88
87
|
|
|
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;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
88
|
/** Whether a frozen invoice has fallen out of date, and by how much. */
|
|
97
89
|
export interface InvoiceDrift {
|
|
98
90
|
errandCount: number;
|
|
@@ -127,7 +119,6 @@ export interface Invoice {
|
|
|
127
119
|
* Document lifecycle, kept separate from `status`: an invoice can be
|
|
128
120
|
* part-paid and viewed, or paid and never opened.
|
|
129
121
|
*/
|
|
130
|
-
sentAt?: string;
|
|
131
122
|
firstViewedAt?: string;
|
|
132
123
|
lastViewedAt?: string;
|
|
133
124
|
viewCount?: number;
|
package/src/rider.ts
CHANGED
|
@@ -105,3 +105,111 @@ export interface RiderPerformanceStats {
|
|
|
105
105
|
timeSeries?: RiderPerformanceTimeSeries[];
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
|
|
109
|
+
// Rider Payout Types
|
|
110
|
+
//
|
|
111
|
+
// Rider pay is a percentage of the errand fees a rider earned over a pay
|
|
112
|
+
// period. The percentage comes from the rider (`Rider.payoutPercentage`) and
|
|
113
|
+
// falls back to the business default (`settings.riderPay.defaultPercentage`).
|
|
114
|
+
//
|
|
115
|
+
// Deliberately separate from `RiderSettlement`: a settlement tracks cash the
|
|
116
|
+
// rider owes US, a payout tracks money WE owe the rider. Netting the two would
|
|
117
|
+
// hide either side the moment they disagree.
|
|
118
|
+
export enum PayoutPeriodType {
|
|
119
|
+
Weekly = 'weekly',
|
|
120
|
+
Fortnightly = 'fortnightly',
|
|
121
|
+
Monthly = 'monthly',
|
|
122
|
+
Custom = 'custom',
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export enum RiderPayoutStatus {
|
|
126
|
+
Pending = 'pending',
|
|
127
|
+
Approved = 'approved',
|
|
128
|
+
Paid = 'paid',
|
|
129
|
+
Cancelled = 'cancelled',
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Which knob supplied the percentage a payout was computed at. */
|
|
133
|
+
export enum PayoutRateSource {
|
|
134
|
+
Rider = 'rider',
|
|
135
|
+
Business = 'business',
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** One bonus (positive `amount`) or deduction (negative) on a payout. */
|
|
139
|
+
export interface RiderPayoutAdjustment {
|
|
140
|
+
id: string;
|
|
141
|
+
label: string;
|
|
142
|
+
amount: number;
|
|
143
|
+
createdAt: Date;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface RiderPayout {
|
|
147
|
+
id: string;
|
|
148
|
+
riderId: string;
|
|
149
|
+
businessId: string;
|
|
150
|
+
|
|
151
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}`;
|
|
152
|
+
periodStart: Date;
|
|
153
|
+
periodEnd: Date;
|
|
154
|
+
|
|
155
|
+
/** Errands counted toward `grossEarnings`. */
|
|
156
|
+
errandCount: number;
|
|
157
|
+
/** Sum of `Errand.price` over the counted errands. */
|
|
158
|
+
grossEarnings: number;
|
|
159
|
+
|
|
160
|
+
/** The rate this payout was computed at — snapshotted, never re-read. */
|
|
161
|
+
payoutPercentage: number;
|
|
162
|
+
payoutRateSource: PayoutRateSource | `${PayoutRateSource}`;
|
|
163
|
+
/** `grossEarnings` at `payoutPercentage`. */
|
|
164
|
+
payoutAmount: number;
|
|
165
|
+
|
|
166
|
+
/** Hand-entered bonus and deduction lines. */
|
|
167
|
+
adjustments: RiderPayoutAdjustment[];
|
|
168
|
+
/** Sum of `adjustments`. Derived, never set directly. */
|
|
169
|
+
adjustmentAmount: number;
|
|
170
|
+
/** What the rider is actually paid: `payoutAmount + adjustmentAmount`. */
|
|
171
|
+
netAmount: number;
|
|
172
|
+
|
|
173
|
+
status: RiderPayoutStatus | `${RiderPayoutStatus}`;
|
|
174
|
+
approvedAt?: Date;
|
|
175
|
+
approvedBy?: string;
|
|
176
|
+
paidAt?: Date;
|
|
177
|
+
paymentReference?: string;
|
|
178
|
+
|
|
179
|
+
notes?: string;
|
|
180
|
+
|
|
181
|
+
createdAt: Date;
|
|
182
|
+
updatedAt: Date;
|
|
183
|
+
version: number;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** One rider's computed pay for a period, before anything is persisted. */
|
|
187
|
+
export interface RiderPayoutPreviewItem {
|
|
188
|
+
riderId: string;
|
|
189
|
+
riderName: string;
|
|
190
|
+
errandCount: number;
|
|
191
|
+
grossEarnings: number;
|
|
192
|
+
/** Null when neither the rider nor the business has a rate configured. */
|
|
193
|
+
payoutPercentage: number | null;
|
|
194
|
+
payoutRateSource: PayoutRateSource | `${PayoutRateSource}` | null;
|
|
195
|
+
payoutAmount: number;
|
|
196
|
+
/** Set when a payout for this rider and the same period already exists. */
|
|
197
|
+
existingPayoutId?: string;
|
|
198
|
+
existingPayoutStatus?: RiderPayoutStatus | `${RiderPayoutStatus}`;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface RiderPayoutPreview {
|
|
202
|
+
periodType: PayoutPeriodType | `${PayoutPeriodType}`;
|
|
203
|
+
periodStart: Date;
|
|
204
|
+
periodEnd: Date;
|
|
205
|
+
periodLabel: string;
|
|
206
|
+
summary: {
|
|
207
|
+
riderCount: number;
|
|
208
|
+
totalErrands: number;
|
|
209
|
+
totalGrossEarnings: number;
|
|
210
|
+
totalPayoutAmount: number;
|
|
211
|
+
/** Riders skipped because no percentage is configured for them. */
|
|
212
|
+
unratedRiderCount: number;
|
|
213
|
+
};
|
|
214
|
+
riders: RiderPayoutPreviewItem[];
|
|
215
|
+
}
|