@driveflux/api-functions 0.0.7-next.22 → 0.0.7-next.24
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/dist/auth/tokens.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export declare const createToken: (userId: string | null, type: "email" | "phone
|
|
|
13
13
|
metadata: PrismaJson.AnyMetadata | null;
|
|
14
14
|
createdAt: Date;
|
|
15
15
|
updatedAt: Date;
|
|
16
|
-
userId: string | null;
|
|
17
16
|
value: string | null;
|
|
17
|
+
userId: string | null;
|
|
18
18
|
client: string | null;
|
|
19
19
|
identifier: string | null;
|
|
20
20
|
expiresAt: Date | null;
|
|
@@ -29,8 +29,8 @@ export declare const createEmailToken: (userId: string, email: string) => Promis
|
|
|
29
29
|
metadata: PrismaJson.AnyMetadata | null;
|
|
30
30
|
createdAt: Date;
|
|
31
31
|
updatedAt: Date;
|
|
32
|
-
userId: string | null;
|
|
33
32
|
value: string | null;
|
|
33
|
+
userId: string | null;
|
|
34
34
|
client: string | null;
|
|
35
35
|
identifier: string | null;
|
|
36
36
|
expiresAt: Date | null;
|
|
@@ -45,8 +45,8 @@ export declare const createSMSToken: (userId: string | null, phoneNumber: string
|
|
|
45
45
|
metadata: PrismaJson.AnyMetadata | null;
|
|
46
46
|
createdAt: Date;
|
|
47
47
|
updatedAt: Date;
|
|
48
|
-
userId: string | null;
|
|
49
48
|
value: string | null;
|
|
49
|
+
userId: string | null;
|
|
50
50
|
client: string | null;
|
|
51
51
|
identifier: string | null;
|
|
52
52
|
expiresAt: Date | null;
|
|
@@ -190,8 +190,8 @@ export declare const notionDatabasePropertyRollupSchema: ZodObject<{
|
|
|
190
190
|
type: z.ZodEnum<{
|
|
191
191
|
number: "number";
|
|
192
192
|
date: "date";
|
|
193
|
-
incomplete: "incomplete";
|
|
194
193
|
array: "array";
|
|
194
|
+
incomplete: "incomplete";
|
|
195
195
|
unsupported: "unsupported";
|
|
196
196
|
}>;
|
|
197
197
|
}, z.core.$strip>;
|
|
@@ -231,8 +231,8 @@ export declare const notionPagePropertyRollupSchema: ZodObject<{
|
|
|
231
231
|
type: z.ZodEnum<{
|
|
232
232
|
number: "number";
|
|
233
233
|
date: "date";
|
|
234
|
-
incomplete: "incomplete";
|
|
235
234
|
array: "array";
|
|
235
|
+
incomplete: "incomplete";
|
|
236
236
|
unsupported: "unsupported";
|
|
237
237
|
}>;
|
|
238
238
|
}, z.core.$strip>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type DisplayVehicle, type MileagePackage, type PlanType, type UltraTier, type Vehicle, type VehicleType } from '@driveflux/db';
|
|
2
2
|
export declare const fetchDisplayVehicle: (displayVehicle: DisplayVehicle | string) => Promise<{
|
|
3
3
|
object: import("@driveflux/db").DisplayVehicleObject;
|
|
4
|
+
type: VehicleType;
|
|
4
5
|
id: string;
|
|
5
6
|
createdAt: Date;
|
|
6
7
|
updatedAt: Date;
|
|
@@ -8,7 +9,6 @@ export declare const fetchDisplayVehicle: (displayVehicle: DisplayVehicle | stri
|
|
|
8
9
|
vehicleModel: string;
|
|
9
10
|
variant: string;
|
|
10
11
|
year: number;
|
|
11
|
-
type: VehicleType;
|
|
12
12
|
brandSlug: string;
|
|
13
13
|
brandId: string;
|
|
14
14
|
defaultHostId: string;
|
|
@@ -191,20 +191,20 @@ export declare const fetchDisplayVehicle: (displayVehicle: DisplayVehicle | stri
|
|
|
191
191
|
export declare const createVehicleFromDisplayVehicle: (displayVehicle: DisplayVehicle | string, selectedColor?: string) => Promise<({
|
|
192
192
|
host: {
|
|
193
193
|
object: import("@driveflux/db").HostObject;
|
|
194
|
-
|
|
194
|
+
phoneNumber: string | null;
|
|
195
|
+
type: import("@driveflux/db").HostType | null;
|
|
195
196
|
id: string;
|
|
196
197
|
metadata: PrismaJson.AnyMetadata | null;
|
|
198
|
+
name: string;
|
|
197
199
|
createdAt: Date;
|
|
198
200
|
updatedAt: Date;
|
|
199
|
-
registrationNumber: string | null;
|
|
200
|
-
type: import("@driveflux/db").HostType | null;
|
|
201
|
-
active: boolean;
|
|
202
201
|
email: string | null;
|
|
203
|
-
phoneNumber: string | null;
|
|
204
202
|
race: import("@driveflux/db").Race | null;
|
|
205
203
|
emergencyContactName: string | null;
|
|
206
204
|
emergencyPhoneNumber: string | null;
|
|
205
|
+
active: boolean;
|
|
207
206
|
commencementDate: Date | null;
|
|
207
|
+
registrationNumber: string | null;
|
|
208
208
|
stripeAccountId: string | null;
|
|
209
209
|
isStripeConnected: boolean;
|
|
210
210
|
serviceCenterIds: string[];
|
|
@@ -262,11 +262,15 @@ export declare const createVehicleFromDisplayVehicle: (displayVehicle: DisplayVe
|
|
|
262
262
|
};
|
|
263
263
|
} & {
|
|
264
264
|
object: import("@driveflux/db").VehicleObject;
|
|
265
|
+
type: VehicleType;
|
|
265
266
|
id: string;
|
|
266
|
-
status: import("@driveflux/db").VehicleStatus;
|
|
267
267
|
metadata: PrismaJson.AnyMetadata | null;
|
|
268
268
|
createdAt: Date;
|
|
269
269
|
updatedAt: Date;
|
|
270
|
+
status: import("@driveflux/db").VehicleStatus;
|
|
271
|
+
temporary: boolean;
|
|
272
|
+
registrationNumber: string | null;
|
|
273
|
+
hostId: string;
|
|
270
274
|
make: string;
|
|
271
275
|
vehicleModel: string;
|
|
272
276
|
variant: string;
|
|
@@ -276,7 +280,6 @@ export declare const createVehicleFromDisplayVehicle: (displayVehicle: DisplayVe
|
|
|
276
280
|
compositeSearchScore: number;
|
|
277
281
|
registrationDate: Date | null;
|
|
278
282
|
mileage: number | null;
|
|
279
|
-
registrationNumber: string | null;
|
|
280
283
|
vin: string | null;
|
|
281
284
|
engineNumber: string | null;
|
|
282
285
|
availability: import("@driveflux/db").VehicleAvailablity | null;
|
|
@@ -291,8 +294,6 @@ export declare const createVehicleFromDisplayVehicle: (displayVehicle: DisplayVe
|
|
|
291
294
|
delistedAt: Date | null;
|
|
292
295
|
imagesNotActual: boolean;
|
|
293
296
|
imagesNotActualMessage: string | null;
|
|
294
|
-
hostId: string;
|
|
295
|
-
type: VehicleType;
|
|
296
297
|
allowedServiceCenterIds: string[];
|
|
297
298
|
displayVehicleId: string | null;
|
|
298
299
|
isHostConfirmed: boolean | null;
|
|
@@ -305,7 +306,6 @@ export declare const createVehicleFromDisplayVehicle: (displayVehicle: DisplayVe
|
|
|
305
306
|
featureOnLandingPage: boolean;
|
|
306
307
|
lastMileageRecordedAt: Date | null;
|
|
307
308
|
locationAvailability: string[];
|
|
308
|
-
temporary: boolean;
|
|
309
309
|
hotDeal: boolean | null;
|
|
310
310
|
activeSubscriptionId: string | null;
|
|
311
311
|
addresses: {
|
|
@@ -689,11 +689,15 @@ export declare const createVehicleFromDisplayVehicle: (displayVehicle: DisplayVe
|
|
|
689
689
|
}) | undefined>;
|
|
690
690
|
export declare const transfromVehicleDisplayToVehicle: (displayVehicle: DisplayVehicle | string, selectedColor: string) => Promise<({
|
|
691
691
|
object: import("@driveflux/db").VehicleObject;
|
|
692
|
+
type: VehicleType;
|
|
692
693
|
id: string;
|
|
693
|
-
status: import("@driveflux/db").VehicleStatus;
|
|
694
694
|
metadata: PrismaJson.AnyMetadata | null;
|
|
695
695
|
createdAt: Date;
|
|
696
696
|
updatedAt: Date;
|
|
697
|
+
status: import("@driveflux/db").VehicleStatus;
|
|
698
|
+
temporary: boolean;
|
|
699
|
+
registrationNumber: string | null;
|
|
700
|
+
hostId: string;
|
|
697
701
|
make: string;
|
|
698
702
|
vehicleModel: string;
|
|
699
703
|
variant: string;
|
|
@@ -703,7 +707,6 @@ export declare const transfromVehicleDisplayToVehicle: (displayVehicle: DisplayV
|
|
|
703
707
|
compositeSearchScore: number;
|
|
704
708
|
registrationDate: Date | null;
|
|
705
709
|
mileage: number | null;
|
|
706
|
-
registrationNumber: string | null;
|
|
707
710
|
vin: string | null;
|
|
708
711
|
engineNumber: string | null;
|
|
709
712
|
availability: import("@driveflux/db").VehicleAvailablity | null;
|
|
@@ -718,8 +721,6 @@ export declare const transfromVehicleDisplayToVehicle: (displayVehicle: DisplayV
|
|
|
718
721
|
delistedAt: Date | null;
|
|
719
722
|
imagesNotActual: boolean;
|
|
720
723
|
imagesNotActualMessage: string | null;
|
|
721
|
-
hostId: string;
|
|
722
|
-
type: VehicleType;
|
|
723
724
|
allowedServiceCenterIds: string[];
|
|
724
725
|
displayVehicleId: string | null;
|
|
725
726
|
isHostConfirmed: boolean | null;
|
|
@@ -732,7 +733,6 @@ export declare const transfromVehicleDisplayToVehicle: (displayVehicle: DisplayV
|
|
|
732
733
|
featureOnLandingPage: boolean;
|
|
733
734
|
lastMileageRecordedAt: Date | null;
|
|
734
735
|
locationAvailability: string[];
|
|
735
|
-
temporary: boolean;
|
|
736
736
|
hotDeal: boolean | null;
|
|
737
737
|
activeSubscriptionId: string | null;
|
|
738
738
|
addresses: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { config } from '@driveflux/config/backend';
|
|
2
2
|
import { loadCoupon, PROBLEM_APPLICABLE_NOT_FOUND } from '@driveflux/coupon';
|
|
3
|
-
import { prisma
|
|
3
|
+
import { prisma } from '@driveflux/db';
|
|
4
4
|
import { generateId } from '@driveflux/db/id';
|
|
5
5
|
import { EMPTY_BILLING_ADDRESS } from '@driveflux/db/models/other';
|
|
6
6
|
import { PURPOSE_RESERVATION } from '@driveflux/db/models/subscription';
|
|
@@ -12,16 +12,15 @@ import { Ok } from '@driveflux/result';
|
|
|
12
12
|
import { format } from '@driveflux/time';
|
|
13
13
|
import { isAfter } from 'date-fns/isAfter';
|
|
14
14
|
import { subMinutes } from 'date-fns/subMinutes';
|
|
15
|
-
export const updateReservationInvoiceIfNeeded = async (oldReservationInvoice, newParams)
|
|
15
|
+
export const updateReservationInvoiceIfNeeded = async (oldReservationInvoice, newParams)=>{
|
|
16
16
|
const couponIsDifferent = oldReservationInvoice.couponCode !== newParams.couponCode;
|
|
17
|
-
if (!couponIsDifferent &&
|
|
18
|
-
oldReservationInvoice.stripePaymentIntentId === newParams.paymentIntentId) {
|
|
17
|
+
if (!couponIsDifferent && oldReservationInvoice.stripePaymentIntentId === newParams.paymentIntentId) {
|
|
19
18
|
return new Ok(oldReservationInvoice);
|
|
20
19
|
}
|
|
21
20
|
// If the coupon or payment intent are differnt we should update the invoice
|
|
22
21
|
let update = {
|
|
23
22
|
stripePaymentIntentId: newParams.paymentIntentId,
|
|
24
|
-
couponCode: newParams.couponCode
|
|
23
|
+
couponCode: newParams.couponCode
|
|
25
24
|
};
|
|
26
25
|
// If the coupon is different, we need to apply the coupon to the invoice
|
|
27
26
|
if (couponIsDifferent) {
|
|
@@ -29,63 +28,56 @@ export const updateReservationInvoiceIfNeeded = async (oldReservationInvoice, ne
|
|
|
29
28
|
const result = await coupons.applyCouponToUnsavedInvoice(newParams.couponCode, oldReservationInvoice);
|
|
30
29
|
if (result.ok) {
|
|
31
30
|
const { discounts, ...rest } = result.val;
|
|
32
|
-
const toDisconnect = discounts
|
|
33
|
-
|
|
34
|
-
:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
: undefined;
|
|
31
|
+
const toDisconnect = discounts ? oldReservationInvoice.discountIds?.filter((id)=>!discounts.connect?.some((d)=>d.id === id)) : undefined;
|
|
32
|
+
const disconnectClauses = toDisconnect?.length ? {
|
|
33
|
+
disconnect: toDisconnect.map((id)=>({
|
|
34
|
+
id
|
|
35
|
+
}))
|
|
36
|
+
} : undefined;
|
|
40
37
|
update = {
|
|
41
38
|
...update,
|
|
42
39
|
...rest,
|
|
43
|
-
...
|
|
44
|
-
|
|
45
|
-
discounts
|
|
46
|
-
|
|
47
|
-
...(disconnectClauses || {}),
|
|
48
|
-
},
|
|
40
|
+
...discounts || disconnectClauses ? {
|
|
41
|
+
discounts: {
|
|
42
|
+
...discounts || {},
|
|
43
|
+
...disconnectClauses || {}
|
|
49
44
|
}
|
|
50
|
-
|
|
45
|
+
} : {},
|
|
51
46
|
metadata: {
|
|
52
47
|
...update.metadata,
|
|
53
|
-
couponCode: newParams.couponCode
|
|
48
|
+
couponCode: newParams.couponCode
|
|
54
49
|
},
|
|
55
50
|
providerMetadata: {
|
|
56
51
|
...update.providerMetadata,
|
|
57
|
-
couponCode: newParams.couponCode
|
|
58
|
-
}
|
|
52
|
+
couponCode: newParams.couponCode
|
|
53
|
+
}
|
|
59
54
|
};
|
|
60
55
|
}
|
|
61
56
|
if (result.err && result.val.code !== PROBLEM_APPLICABLE_NOT_FOUND) {
|
|
62
57
|
return result;
|
|
63
58
|
}
|
|
64
|
-
}
|
|
65
|
-
else if (oldReservationInvoice.discountIds.length) {
|
|
59
|
+
} else if (oldReservationInvoice.discountIds.length) {
|
|
66
60
|
// No discounts, so we disconnect all of them
|
|
67
61
|
update = {
|
|
68
62
|
discounts: {
|
|
69
|
-
disconnect: oldReservationInvoice.discountIds.map((id)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
63
|
+
disconnect: oldReservationInvoice.discountIds.map((id)=>({
|
|
64
|
+
id
|
|
65
|
+
}))
|
|
66
|
+
}
|
|
73
67
|
};
|
|
74
68
|
}
|
|
75
69
|
}
|
|
76
70
|
let updated = await wrapInResult(biller.updateInvoice(oldReservationInvoice.id, update));
|
|
77
71
|
// If the invoice was locked due to pending status and we're more than 1 minute old, we unlock it
|
|
78
72
|
if (updated.err && updated.val.code === 'invoice_pending') {
|
|
79
|
-
if ((oldReservationInvoice.lockedAt
|
|
80
|
-
isAfter(oldReservationInvoice.lockedAt, subMinutes(new Date(), 1))) ||
|
|
81
|
-
!oldReservationInvoice.lockedAt) {
|
|
73
|
+
if (oldReservationInvoice.lockedAt && isAfter(oldReservationInvoice.lockedAt, subMinutes(new Date(), 1)) || !oldReservationInvoice.lockedAt) {
|
|
82
74
|
updated = await wrapInResult(biller.updateInvoice(oldReservationInvoice.id, {
|
|
83
75
|
...update,
|
|
84
76
|
locked: false,
|
|
85
77
|
lockedAt: null,
|
|
86
78
|
lockReason: null,
|
|
87
79
|
unlockAt: null,
|
|
88
|
-
status: 'draft'
|
|
80
|
+
status: 'draft'
|
|
89
81
|
}));
|
|
90
82
|
}
|
|
91
83
|
}
|
|
@@ -94,7 +86,7 @@ export const updateReservationInvoiceIfNeeded = async (oldReservationInvoice, ne
|
|
|
94
86
|
}
|
|
95
87
|
return new Ok(updated.val);
|
|
96
88
|
};
|
|
97
|
-
export const createReservationInvoice = async ({ invoiceId, couponCode, plan, mileagePackage, referralCode, reservationId, paymentIntentId, freeReservation, freeReservationReason, analytics, vehicle, payer, subscribingUser
|
|
89
|
+
export const createReservationInvoice = async ({ invoiceId, couponCode, plan, mileagePackage, referralCode, reservationId, paymentIntentId, freeReservation, freeReservationReason, analytics, vehicle, payer, subscribingUser })=>{
|
|
98
90
|
if (freeReservation) {
|
|
99
91
|
// It's a free reservation, so we don't need to add a coupon code
|
|
100
92
|
return await wrapInResult(biller.createInvoice(getInvoiceCreateDetails({
|
|
@@ -107,21 +99,17 @@ export const createReservationInvoice = async ({ invoiceId, couponCode, plan, mi
|
|
|
107
99
|
freeReservation,
|
|
108
100
|
freeReservationReason,
|
|
109
101
|
analytics,
|
|
110
|
-
reservationId
|
|
102
|
+
reservationId
|
|
111
103
|
})));
|
|
112
104
|
}
|
|
113
105
|
let finalCouponCode = couponCode;
|
|
114
106
|
// If we don't have a reservation coupon ID, we apply the referral discount if any
|
|
115
|
-
const referral = referralCode &&
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (!finalCouponCode &&
|
|
122
|
-
referral &&
|
|
123
|
-
referral.discountToReceiverCouponId &&
|
|
124
|
-
referral.discountToReceiverCouponApplicationName === 'reservationFee') {
|
|
107
|
+
const referral = referralCode && await prisma.referral.findUnique({
|
|
108
|
+
where: {
|
|
109
|
+
id: referralCode
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
if (!finalCouponCode && referral && referral.discountToReceiverCouponId && referral.discountToReceiverCouponApplicationName === 'reservationFee') {
|
|
125
113
|
const referralCoupon = await loadCoupon(referral.discountToReceiverCouponId);
|
|
126
114
|
if (referralCoupon) {
|
|
127
115
|
finalCouponCode = referralCoupon.code;
|
|
@@ -140,15 +128,15 @@ export const createReservationInvoice = async ({ invoiceId, couponCode, plan, mi
|
|
|
140
128
|
freeReservation,
|
|
141
129
|
freeReservationReason,
|
|
142
130
|
analytics,
|
|
143
|
-
reservationId
|
|
131
|
+
reservationId
|
|
144
132
|
}),
|
|
145
133
|
lines: [
|
|
146
134
|
{
|
|
147
135
|
amount: reservationAmount,
|
|
148
136
|
description: `Reservation fee for ${vehicleName(vehicle)}`,
|
|
149
|
-
chargingFor: 'reservationFee'
|
|
150
|
-
}
|
|
151
|
-
]
|
|
137
|
+
chargingFor: 'reservationFee'
|
|
138
|
+
}
|
|
139
|
+
]
|
|
152
140
|
};
|
|
153
141
|
if (finalCouponCode) {
|
|
154
142
|
const withCoupon = await coupons.applyCouponToUnsavedInvoice(finalCouponCode, invoiceCreateDetails, 'reservationFee', {
|
|
@@ -158,10 +146,9 @@ export const createReservationInvoice = async ({ invoiceId, couponCode, plan, mi
|
|
|
158
146
|
vehicleMake: vehicle.make,
|
|
159
147
|
userId: subscribingUser.id,
|
|
160
148
|
businessId: payer.object === 'business' ? payer.id : undefined,
|
|
161
|
-
vehicleType: vehicle.type
|
|
149
|
+
vehicleType: vehicle.type
|
|
162
150
|
});
|
|
163
|
-
if (withCoupon.err &&
|
|
164
|
-
withCoupon.val.code !== PROBLEM_APPLICABLE_NOT_FOUND) {
|
|
151
|
+
if (withCoupon.err && withCoupon.val.code !== PROBLEM_APPLICABLE_NOT_FOUND) {
|
|
165
152
|
return withCoupon;
|
|
166
153
|
}
|
|
167
154
|
if (withCoupon.ok) {
|
|
@@ -169,18 +156,18 @@ export const createReservationInvoice = async ({ invoiceId, couponCode, plan, mi
|
|
|
169
156
|
...withCoupon.val,
|
|
170
157
|
metadata: {
|
|
171
158
|
...withCoupon.val.metadata,
|
|
172
|
-
couponCode: finalCouponCode
|
|
159
|
+
couponCode: finalCouponCode
|
|
173
160
|
},
|
|
174
161
|
providerMetadata: {
|
|
175
162
|
...withCoupon.val.providerMetadata,
|
|
176
|
-
couponCode: finalCouponCode
|
|
177
|
-
}
|
|
163
|
+
couponCode: finalCouponCode
|
|
164
|
+
}
|
|
178
165
|
};
|
|
179
166
|
}
|
|
180
167
|
}
|
|
181
168
|
return await wrapInResult(biller.createInvoice(invoiceCreateDetails));
|
|
182
169
|
};
|
|
183
|
-
const getInvoiceCreateDetails = ({ invoiceId, payer, date, reservationDiscountId, vehicle, plan, mileagePackage, couponCode, paymentIntentId, freeReservation, freeReservationReason, analytics, reservationId
|
|
170
|
+
const getInvoiceCreateDetails = ({ invoiceId, payer, date, reservationDiscountId, vehicle, plan, mileagePackage, couponCode, paymentIntentId, freeReservation, freeReservationReason, analytics, reservationId })=>{
|
|
184
171
|
return {
|
|
185
172
|
id: invoiceId || generateId('Invoice'),
|
|
186
173
|
taxPercentage: 0,
|
|
@@ -196,15 +183,13 @@ const getInvoiceCreateDetails = ({ invoiceId, payer, date, reservationDiscountId
|
|
|
196
183
|
description: 'Reservation fee for a FLUX subscription',
|
|
197
184
|
footer: `Invoice for a FLUX subscription reservation. Due by ${format(date ?? new Date())}`,
|
|
198
185
|
invoiceUrl: `${config.appUrl}/invoice-preview/${invoiceId}`,
|
|
199
|
-
...
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
},
|
|
205
|
-
},
|
|
186
|
+
...reservationDiscountId ? {
|
|
187
|
+
discounts: {
|
|
188
|
+
connect: {
|
|
189
|
+
id: reservationDiscountId
|
|
190
|
+
}
|
|
206
191
|
}
|
|
207
|
-
|
|
192
|
+
} : {},
|
|
208
193
|
lines: [],
|
|
209
194
|
subscriptionDetails: {
|
|
210
195
|
vehicleId: vehicle.id,
|
|
@@ -213,7 +198,7 @@ const getInvoiceCreateDetails = ({ invoiceId, payer, date, reservationDiscountId
|
|
|
213
198
|
variant: vehicle.variant,
|
|
214
199
|
year: vehicle.year,
|
|
215
200
|
plan: plan,
|
|
216
|
-
mileagePackage: mileagePackage
|
|
201
|
+
mileagePackage: mileagePackage
|
|
217
202
|
},
|
|
218
203
|
stripePaymentIntentId: paymentIntentId,
|
|
219
204
|
providerMetadata: {
|
|
@@ -221,14 +206,18 @@ const getInvoiceCreateDetails = ({ invoiceId, payer, date, reservationDiscountId
|
|
|
221
206
|
mileagePackage,
|
|
222
207
|
vehicleId: vehicle.id,
|
|
223
208
|
vehicleName: vehicleName(vehicle),
|
|
224
|
-
...
|
|
225
|
-
|
|
209
|
+
...reservationId ? {
|
|
210
|
+
reservationId
|
|
211
|
+
} : {},
|
|
212
|
+
...couponCode ? {
|
|
213
|
+
couponCode
|
|
214
|
+
} : {}
|
|
226
215
|
},
|
|
227
216
|
autoRetry: {
|
|
228
217
|
enabled: false,
|
|
229
218
|
interval: 0,
|
|
230
219
|
maxAttempts: 0,
|
|
231
|
-
attempts: 0
|
|
220
|
+
attempts: 0
|
|
232
221
|
},
|
|
233
222
|
metadata: {
|
|
234
223
|
purpose: PURPOSE_RESERVATION,
|
|
@@ -237,11 +226,10 @@ const getInvoiceCreateDetails = ({ invoiceId, payer, date, reservationDiscountId
|
|
|
237
226
|
plan,
|
|
238
227
|
mileagePackage,
|
|
239
228
|
couponCode,
|
|
240
|
-
...
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
analytics
|
|
244
|
-
}
|
|
229
|
+
...freeReservation && freeReservationReason ? {
|
|
230
|
+
freeReservationReason
|
|
231
|
+
} : {},
|
|
232
|
+
analytics
|
|
233
|
+
}
|
|
245
234
|
};
|
|
246
235
|
};
|
|
247
|
-
//# sourceMappingURL=invoice.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driveflux/api-functions",
|
|
3
|
-
"version": "0.0.7-next.
|
|
3
|
+
"version": "0.0.7-next.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./notion": {
|
|
@@ -73,22 +73,22 @@
|
|
|
73
73
|
],
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@casl/ability": "^6.7.3",
|
|
76
|
-
"@driveflux/auth": "3.0.0-next.
|
|
77
|
-
"@driveflux/billing": "7.0.0-develop.
|
|
76
|
+
"@driveflux/auth": "3.0.0-next.12",
|
|
77
|
+
"@driveflux/billing": "7.0.0-develop.42",
|
|
78
78
|
"@driveflux/config": "2.1.0-next.2",
|
|
79
|
-
"@driveflux/coupon": "8.0.0-develop.
|
|
80
|
-
"@driveflux/db": "3.0.0-develop.
|
|
81
|
-
"@driveflux/email": "6.0.0-develop.
|
|
82
|
-
"@driveflux/email-templates": "0.0.2-develop.
|
|
83
|
-
"@driveflux/engine": "0.1.2-develop.
|
|
79
|
+
"@driveflux/coupon": "8.0.0-develop.55",
|
|
80
|
+
"@driveflux/db": "3.0.0-develop.68",
|
|
81
|
+
"@driveflux/email": "6.0.0-develop.49",
|
|
82
|
+
"@driveflux/email-templates": "0.0.2-develop.53",
|
|
83
|
+
"@driveflux/engine": "0.1.2-develop.88",
|
|
84
84
|
"@driveflux/fetch": "7.0.4-next.0",
|
|
85
85
|
"@driveflux/format-money": "6.0.3-next.0",
|
|
86
86
|
"@driveflux/problem": "5.0.4-next.0",
|
|
87
87
|
"@driveflux/reporter": "6.0.4-next.3",
|
|
88
88
|
"@driveflux/result": "5.0.4-next.0",
|
|
89
|
-
"@driveflux/scheduler": "7.0.0-develop.
|
|
89
|
+
"@driveflux/scheduler": "7.0.0-develop.54",
|
|
90
90
|
"@driveflux/singleton": "2.0.3-next.0",
|
|
91
|
-
"@driveflux/subscription": "8.0.0-develop.
|
|
91
|
+
"@driveflux/subscription": "8.0.0-develop.36",
|
|
92
92
|
"@driveflux/time": "5.0.3-next.0",
|
|
93
93
|
"@driveflux/utils": "5.0.3-next.0",
|
|
94
94
|
"@notionhq/client": "^4.0.2",
|