@antelopejs/dms-saas 0.7.2 → 0.7.3
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/routes/tenant/tenant-upcoming-invoice.d.ts +7 -0
- package/dist/routes/tenant/tenant-upcoming-invoice.js +73 -8
- package/dist/routes/tenant/tenant-upcoming-invoice.js.map +1 -1
- package/frontend-vue/app/build/PlanChangeReview.vue +12 -9
- package/frontend-vue/app/build/plan-change-heading.ts +19 -0
- package/frontend-vue/i18n/locales/saas-tenant-billing-en-GB.json +4 -1
- package/frontend-vue/i18n/locales/saas-tenant-billing-fr-FR.json +4 -1
- package/package.json +1 -1
|
@@ -10,6 +10,12 @@ export interface NextInvoiceRows {
|
|
|
10
10
|
currency: string | null;
|
|
11
11
|
billingDate: string | null;
|
|
12
12
|
}
|
|
13
|
+
export interface PlanSwitch {
|
|
14
|
+
currentPlanName: string;
|
|
15
|
+
nextPlanName: string;
|
|
16
|
+
isNextPlanFree: boolean;
|
|
17
|
+
at: Date;
|
|
18
|
+
}
|
|
13
19
|
interface NextInvoiceContext {
|
|
14
20
|
paymentMethod: PaymentMethodSummary | null;
|
|
15
21
|
billingEmail: string | null;
|
|
@@ -17,6 +23,7 @@ interface NextInvoiceContext {
|
|
|
17
23
|
planNames: ReadonlyMap<string, string>;
|
|
18
24
|
}
|
|
19
25
|
export declare function toNextInvoiceRows(preview: AvailableUpcomingInvoicePreview, context: NextInvoiceContext): NextInvoiceRows;
|
|
26
|
+
export declare function withPlanSwitch(rows: NextInvoiceRows, planSwitch: PlanSwitch, context: NextInvoiceContext): NextInvoiceRows;
|
|
20
27
|
export declare function latestPaidInvoice(invoices: Invoice[]): Invoice | null;
|
|
21
28
|
export declare function planNamesByProduct(plans: Plan[]): Map<string, string>;
|
|
22
29
|
declare const SaasTenantUpcomingInvoiceController_base: import("@antelopejs/interface-api").ControllerClass<object>;
|
|
@@ -14,6 +14,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.SaasTenantUpcomingInvoiceController = void 0;
|
|
16
16
|
exports.toNextInvoiceRows = toNextInvoiceRows;
|
|
17
|
+
exports.withPlanSwitch = withPlanSwitch;
|
|
17
18
|
exports.latestPaidInvoice = latestPaidInvoice;
|
|
18
19
|
exports.planNamesByProduct = planNamesByProduct;
|
|
19
20
|
const interface_api_1 = require("@antelopejs/interface-api");
|
|
@@ -22,6 +23,7 @@ const guards_1 = require("@antelopejs/interface-dms/guards");
|
|
|
22
23
|
const request_tenant_1 = require("@antelopejs/interface-dms/request-tenant");
|
|
23
24
|
const billing_state_1 = require("../../billing-state");
|
|
24
25
|
const db_1 = require("../../db");
|
|
26
|
+
const free_plan_1 = require("../../workspaces/free-plan");
|
|
25
27
|
const billing_1 = require("../../pages/tenant/billing");
|
|
26
28
|
const composed_text_1 = require("../../i18n/composed-text");
|
|
27
29
|
const preview_1 = require("../../upcoming-invoice/preview");
|
|
@@ -33,6 +35,9 @@ const PERCENT = 100;
|
|
|
33
35
|
const MASKED_DIGITS = "••••";
|
|
34
36
|
const PAID_ON_KEY = "saas.tenant_billing.next_invoice.paid_on";
|
|
35
37
|
const SUBSCRIPTION_LINE_KEY = "saas.tenant_billing.next_invoice.subscription_line";
|
|
38
|
+
const PAID_UNTIL_KEY = "saas.tenant_billing.next_invoice.paid_until";
|
|
39
|
+
const SWITCH_ON_KEY = "saas.tenant_billing.next_invoice.switch_on";
|
|
40
|
+
const SWITCH_FREE_DETAIL_KEY = "saas.tenant_billing.next_invoice.switch_free_detail";
|
|
36
41
|
const NOTHING_TO_INVOICE = {
|
|
37
42
|
items: [],
|
|
38
43
|
totalMinorUnits: null,
|
|
@@ -142,6 +147,47 @@ function toNextInvoiceRows(preview, context) {
|
|
|
142
147
|
billingDate: preview.billingDate,
|
|
143
148
|
};
|
|
144
149
|
}
|
|
150
|
+
function switchRow(planSwitch) {
|
|
151
|
+
const plan = planSwitch.nextPlanName;
|
|
152
|
+
return {
|
|
153
|
+
label: (0, composed_text_1.composed)(SWITCH_ON_KEY, { plan }),
|
|
154
|
+
value: planSwitch.at.toISOString(),
|
|
155
|
+
type: "date",
|
|
156
|
+
tone: "warning",
|
|
157
|
+
detail: planSwitch.isNextPlanFree
|
|
158
|
+
? (0, composed_text_1.composed)(SWITCH_FREE_DETAIL_KEY, { plan })
|
|
159
|
+
: undefined,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function withPlanSwitch(rows, planSwitch, context) {
|
|
163
|
+
if (rows.items.length > 0) {
|
|
164
|
+
const contextStart = rows.items.findIndex((row) => row.label === `${KEY_PREFIX}.total`);
|
|
165
|
+
const at = contextStart < 0 ? rows.items.length : contextStart + 1;
|
|
166
|
+
return {
|
|
167
|
+
...rows,
|
|
168
|
+
items: [
|
|
169
|
+
...rows.items.slice(0, at),
|
|
170
|
+
switchRow(planSwitch),
|
|
171
|
+
...rows.items.slice(at),
|
|
172
|
+
],
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const at = planSwitch.at.toISOString();
|
|
176
|
+
return {
|
|
177
|
+
items: [
|
|
178
|
+
{
|
|
179
|
+
label: (0, composed_text_1.composed)(PAID_UNTIL_KEY, { plan: planSwitch.currentPlanName }),
|
|
180
|
+
value: at,
|
|
181
|
+
type: "date",
|
|
182
|
+
},
|
|
183
|
+
switchRow(planSwitch),
|
|
184
|
+
...contextRows(context),
|
|
185
|
+
],
|
|
186
|
+
totalMinorUnits: null,
|
|
187
|
+
currency: null,
|
|
188
|
+
billingDate: at,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
145
191
|
function latestPaidInvoice(invoices) {
|
|
146
192
|
return invoices
|
|
147
193
|
.filter((invoice) => invoice.status === PAID_STATUS && invoice.paidAt)
|
|
@@ -156,6 +202,21 @@ function planNamesByProduct(plans) {
|
|
|
156
202
|
return productId ? [[productId, plan.name]] : [];
|
|
157
203
|
}));
|
|
158
204
|
}
|
|
205
|
+
function scheduledSwitch(subscription, plans) {
|
|
206
|
+
const { planId, pendingPlanId, pendingPlanChangeAt } = subscription ?? {};
|
|
207
|
+
if (!pendingPlanId || !pendingPlanChangeAt)
|
|
208
|
+
return null;
|
|
209
|
+
const current = plans.find((plan) => plan._id === planId);
|
|
210
|
+
const next = plans.find((plan) => plan._id === pendingPlanId);
|
|
211
|
+
if (!current || !next)
|
|
212
|
+
return null;
|
|
213
|
+
return {
|
|
214
|
+
currentPlanName: current.name,
|
|
215
|
+
nextPlanName: next.name,
|
|
216
|
+
isNextPlanFree: (0, free_plan_1.isFreePlan)(next),
|
|
217
|
+
at: new Date(pendingPlanChangeAt),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
159
220
|
async function loadContext(tenantId) {
|
|
160
221
|
const [subscription, billingInfo, invoices, plans] = await Promise.all([
|
|
161
222
|
(0, interface_database_decorators_1.GetModel)(db_1.TenantSubscriptionModel, tenantId).findOne(),
|
|
@@ -167,23 +228,27 @@ async function loadContext(tenantId) {
|
|
|
167
228
|
? await (0, billing_state_1.fetchDefaultPaymentMethod)(subscription.stripeCustomerId)
|
|
168
229
|
: null;
|
|
169
230
|
return {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
231
|
+
context: {
|
|
232
|
+
paymentMethod,
|
|
233
|
+
billingEmail: billingInfo?.billingEmail ?? null,
|
|
234
|
+
lastPayment: latestPaidInvoice(invoices),
|
|
235
|
+
planNames: planNamesByProduct(plans),
|
|
236
|
+
},
|
|
237
|
+
planSwitch: scheduledSwitch(subscription, plans),
|
|
174
238
|
};
|
|
175
239
|
}
|
|
176
240
|
class SaasTenantUpcomingInvoiceController extends (0, interface_api_1.Controller)("/api/saas/tenant/upcoming-invoice") {
|
|
177
241
|
async getNextInvoice(_user, ctx) {
|
|
178
242
|
const tenantId = (0, request_tenant_1.getRequestTenantId)(ctx);
|
|
179
243
|
const preview = await (0, preview_1.getUpcomingInvoicePreview)(tenantId);
|
|
180
|
-
if (preview.status === "absent")
|
|
181
|
-
return NOTHING_TO_INVOICE;
|
|
182
244
|
if (preview.status === "unavailable") {
|
|
183
245
|
throw new interface_api_1.HTTPResult(HTTP_SERVICE_UNAVAILABLE, "saas.errors.billing.preview_unavailable");
|
|
184
246
|
}
|
|
185
|
-
const context = await loadContext(tenantId);
|
|
186
|
-
|
|
247
|
+
const { context, planSwitch } = await loadContext(tenantId);
|
|
248
|
+
const rows = preview.status === "absent"
|
|
249
|
+
? NOTHING_TO_INVOICE
|
|
250
|
+
: toNextInvoiceRows(preview, context);
|
|
251
|
+
return planSwitch ? withPlanSwitch(rows, planSwitch, context) : rows;
|
|
187
252
|
}
|
|
188
253
|
}
|
|
189
254
|
exports.SaasTenantUpcomingInvoiceController = SaasTenantUpcomingInvoiceController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenant-upcoming-invoice.js","sourceRoot":"","sources":["../../../src/routes/tenant/tenant-upcoming-invoice.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"tenant-upcoming-invoice.js","sourceRoot":"","sources":["../../../src/routes/tenant/tenant-upcoming-invoice.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA8MA,8CA0BC;AAqBD,wCAkCC;AAGD,8CAWC;AAGD,gDAOC;AApTD,6DAMmC;AACnC,6FAAqE;AAUrE,6DAA0E;AAC1E,6EAA8E;AAE9E,uDAG6B;AAC7B,iCAQkB;AAClB,0DAAwD;AACxD,wDAAyD;AACzD,4DAKkC;AAClC,4DAA2E;AAC3E,6CAAmD;AAEnD,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,MAAM,UAAU,GAAG,mCAAmC,CAAC;AACvD,MAAM,OAAO,GAAG,GAAG,CAAC;AACpB,MAAM,aAAa,GAAG,MAAM,CAAC;AAC7B,MAAM,WAAW,GAAG,0CAA0C,CAAC;AAC/D,MAAM,qBAAq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E,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC5D,MAAM,IAAI,GACR,OAAO,CAAC,MAAM,KAAK,QAAQ;YACzB,CAAC,CAAC,kBAAkB;YACpB,CAAC,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,OAAO,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvE,CAAC;CACF;AA1BD,kFA0BC;AAtBO;IADL,IAAA,mBAAG,EAAC,GAAG,CAAC;IAEN,WAAA,IAAA,+BAAsB,EAAC,qBAAW,EAAE;QACnC,sBAAsB,EAAE,IAAI;KAC7B,CAAC,CAAA;IAED,WAAA,IAAA,uBAAO,GAAE,CAAA;;;;yEAgBX"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, onMounted, ref } from 'vue'
|
|
3
3
|
import { LABEL_DAY_FORMAT, SENTENCE_DAY_FORMAT } from './day-formats'
|
|
4
|
-
import { planChangeHeadingCase } from './plan-change-heading'
|
|
4
|
+
import { planChangeHeadingCase, targetPlanEyebrow } from './plan-change-heading'
|
|
5
5
|
|
|
6
6
|
interface SummaryRow {
|
|
7
7
|
key: string
|
|
@@ -94,6 +94,15 @@ const headingCase = computed(() =>
|
|
|
94
94
|
),
|
|
95
95
|
)
|
|
96
96
|
|
|
97
|
+
const targetEyebrow = computed(() => {
|
|
98
|
+
const eyebrow = targetPlanEyebrow(preview.value, !!incompatibilities.value)
|
|
99
|
+
if (eyebrow === 'from_date')
|
|
100
|
+
return t(`${KEY_PREFIX}.from_date`, {
|
|
101
|
+
date: day(preview.value?.effectiveAt),
|
|
102
|
+
})
|
|
103
|
+
return eyebrow ? t(`${KEY_PREFIX}.${eyebrow}`) : null
|
|
104
|
+
})
|
|
105
|
+
|
|
97
106
|
const heading = computed(() => {
|
|
98
107
|
const params = {
|
|
99
108
|
plan: props.plan.name,
|
|
@@ -255,14 +264,8 @@ onMounted(() => void loadPreview())
|
|
|
255
264
|
<p class="text-muted text-sm">{{ priceOf(currentPlan) }}</p>
|
|
256
265
|
</DmsCard>
|
|
257
266
|
<DmsCard :padded="true" selected>
|
|
258
|
-
<p class="text-muted text-xs">
|
|
259
|
-
{{
|
|
260
|
-
isDowngrade
|
|
261
|
-
? $t(`${KEY_PREFIX}.from_date`, {
|
|
262
|
-
date: day(preview?.effectiveAt),
|
|
263
|
-
})
|
|
264
|
-
: $t(`${KEY_PREFIX}.from_today`)
|
|
265
|
-
}}
|
|
267
|
+
<p v-if="targetEyebrow" class="text-muted text-xs">
|
|
268
|
+
{{ targetEyebrow }}
|
|
266
269
|
</p>
|
|
267
270
|
<p class="font-semibold">{{ plan.name }}</p>
|
|
268
271
|
<p class="text-muted text-sm">{{ priceOf(plan) }}</p>
|
|
@@ -79,3 +79,22 @@ export function checkoutHeadingCase(
|
|
|
79
79
|
if (isResubscription) return 'resubscribe'
|
|
80
80
|
return isTrial ? 'trial' : 'upgrade'
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
/** When the chosen plan starts, as its card in the review says it. */
|
|
84
|
+
export type TargetPlanEyebrow = 'from_today' | 'from_date'
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The eyebrow of the chosen plan's card: from today, or from the renewal for
|
|
88
|
+
* a downgrade; none until the change is priced, and none for a change the
|
|
89
|
+
* workspace does not fit, which starts on no date at all.
|
|
90
|
+
*
|
|
91
|
+
* @param change The priced change, null while it is priced or once refused
|
|
92
|
+
* @param isRefused The workspace holds more than the chosen plan allows
|
|
93
|
+
*/
|
|
94
|
+
export function targetPlanEyebrow(
|
|
95
|
+
change: PricedChange | null,
|
|
96
|
+
isRefused: boolean,
|
|
97
|
+
): TargetPlanEyebrow | null {
|
|
98
|
+
if (isRefused || !change) return null
|
|
99
|
+
return change.kind === 'downgrade' ? 'from_date' : 'from_today'
|
|
100
|
+
}
|
|
@@ -18,7 +18,10 @@
|
|
|
18
18
|
"sent_to": "Sent to",
|
|
19
19
|
"last_payment": "Last payment",
|
|
20
20
|
"paid_on": "Paid {date}",
|
|
21
|
-
"subscription_line": "{quantity} × {plan}"
|
|
21
|
+
"subscription_line": "{quantity} × {plan}",
|
|
22
|
+
"paid_until": "{plan} paid until",
|
|
23
|
+
"switch_on": "Switch to {plan}",
|
|
24
|
+
"switch_free_detail": "No renewal: {plan} is not billed"
|
|
22
25
|
},
|
|
23
26
|
"invoices": {
|
|
24
27
|
"caption": "Invoices & credit notes",
|
|
@@ -18,7 +18,10 @@
|
|
|
18
18
|
"sent_to": "Envoyée à",
|
|
19
19
|
"last_payment": "Dernier paiement",
|
|
20
20
|
"paid_on": "Payé le {date}",
|
|
21
|
-
"subscription_line": "{quantity} × {plan}"
|
|
21
|
+
"subscription_line": "{quantity} × {plan}",
|
|
22
|
+
"paid_until": "{plan} payé jusqu'au",
|
|
23
|
+
"switch_on": "Passage à {plan}",
|
|
24
|
+
"switch_free_detail": "Pas de renouvellement : {plan} n'est pas facturé"
|
|
22
25
|
},
|
|
23
26
|
"invoices": {
|
|
24
27
|
"caption": "Factures et avoirs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/dms-saas",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "SaaS module for the AntelopeJS DMS: self-service sign-up and pricing, plans that gate features, Stripe billing, workspace settings and a back office.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|