@antelopejs/dms-saas 0.7.4 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/auth/owner-only-permissions-resolver.js +3 -2
- package/dist/auth/owner-only-permissions-resolver.js.map +1 -1
- package/dist/auth/plan-permissions-resolver.js +6 -3
- package/dist/auth/plan-permissions-resolver.js.map +1 -1
- package/dist/billing-state/directory.d.ts +2 -0
- package/dist/billing-state/directory.js +48 -3
- package/dist/billing-state/directory.js.map +1 -1
- package/dist/billing-state/past-due-banner.js +2 -0
- package/dist/billing-state/past-due-banner.js.map +1 -1
- package/dist/billing-state/recovery.js +4 -0
- package/dist/billing-state/recovery.js.map +1 -1
- package/dist/billing-state/trial-ending-banner.js +1 -0
- package/dist/billing-state/trial-ending-banner.js.map +1 -1
- package/dist/config/runtime.d.ts +2 -2
- package/dist/config/runtime.js +12 -4
- package/dist/config/runtime.js.map +1 -1
- package/dist/crons/recompute-billing-state.js +1 -4
- package/dist/crons/recompute-billing-state.js.map +1 -1
- package/dist/data-api/platformOwner/plans.d.ts +2 -0
- package/dist/data-api/platformOwner/plans.js +16 -0
- package/dist/data-api/platformOwner/plans.js.map +1 -1
- package/dist/frontend-module.d.ts +3 -0
- package/dist/frontend-module.js +29 -0
- package/dist/frontend-module.js.map +1 -0
- package/dist/hooks/register.js +8 -1
- package/dist/hooks/register.js.map +1 -1
- package/dist/hooks/tenant-provisioning.js +2 -2
- package/dist/hooks/tenant-provisioning.js.map +1 -1
- package/dist/implementations/dms-saas/billing.d.ts +2 -1
- package/dist/implementations/dms-saas/billing.js +15 -0
- package/dist/implementations/dms-saas/billing.js.map +1 -1
- package/dist/implementations/dms-saas/invoice-line-items.d.ts +2 -2
- package/dist/implementations/dms-saas/invoice-line-items.js +6 -6
- package/dist/implementations/dms-saas/invoice-line-items.js.map +1 -1
- package/dist/index.js +2 -19
- package/dist/index.js.map +1 -1
- package/dist/invoice-line-items/billing-window.d.ts +6 -2
- package/dist/invoice-line-items/billing-window.js.map +1 -1
- package/dist/invoice-line-items/recovery/admission.js +2 -5
- package/dist/invoice-line-items/recovery/admission.js.map +1 -1
- package/dist/invoice-line-items/recovery/process.d.ts +1 -0
- package/dist/invoice-line-items/recovery/process.js +119 -47
- package/dist/invoice-line-items/recovery/process.js.map +1 -1
- package/dist/invoice-line-items/recovery/task.model.js +1 -1
- package/dist/invoice-line-items/recovery/task.model.js.map +1 -1
- package/dist/invoice-line-items/recovery/task.table.d.ts +2 -2
- package/dist/invoice-line-items/recovery/task.table.js +3 -4
- package/dist/invoice-line-items/recovery/task.table.js.map +1 -1
- package/dist/metrics/revenue.d.ts +15 -3
- package/dist/metrics/revenue.js +58 -12
- package/dist/metrics/revenue.js.map +1 -1
- package/dist/operator-actions/previews.d.ts +1 -1
- package/dist/operator-actions/previews.js +13 -6
- package/dist/operator-actions/previews.js.map +1 -1
- package/dist/operator-billing/billing-settings-store.d.ts +2 -0
- package/dist/operator-billing/billing-settings-store.js +8 -2
- package/dist/operator-billing/billing-settings-store.js.map +1 -1
- package/dist/pages/platform/dashboard.d.ts +1 -1
- package/dist/pages/platform/dashboard.js +13 -10
- package/dist/pages/platform/dashboard.js.map +1 -1
- package/dist/pages/platform/plans/edit.js +4 -0
- package/dist/pages/platform/plans/edit.js.map +1 -1
- package/dist/pages/platform/plans/index.js +4 -0
- package/dist/pages/platform/plans/index.js.map +1 -1
- package/dist/pages/platform/plans/migrations.d.ts +1 -0
- package/dist/pages/platform/plans/migrations.js +3 -0
- package/dist/pages/platform/plans/migrations.js.map +1 -1
- package/dist/pages/platform/segments/edit.js +1 -0
- package/dist/pages/platform/segments/edit.js.map +1 -1
- package/dist/pages/platform/settings.js +11 -3
- package/dist/pages/platform/settings.js.map +1 -1
- package/dist/pages/platform/workspaces/index.js +1 -4
- package/dist/pages/platform/workspaces/index.js.map +1 -1
- package/dist/pages/tenant/billing.js +1 -2
- package/dist/pages/tenant/billing.js.map +1 -1
- package/dist/plans/catalogue-summary.d.ts +1 -0
- package/dist/plans/catalogue-summary.js +10 -4
- package/dist/plans/catalogue-summary.js.map +1 -1
- package/dist/plans/catalogue-usage.js +4 -2
- package/dist/plans/catalogue-usage.js.map +1 -1
- package/dist/plans/plan-audience.d.ts +1 -0
- package/dist/plans/plan-audience.js +4 -0
- package/dist/plans/plan-audience.js.map +1 -1
- package/dist/plans/plan-write.d.ts +9 -3
- package/dist/plans/plan-write.js +27 -1
- package/dist/plans/plan-write.js.map +1 -1
- package/dist/plans/seat-hooks.js +25 -16
- package/dist/plans/seat-hooks.js.map +1 -1
- package/dist/plans/stripe-sync.js +11 -3
- package/dist/plans/stripe-sync.js.map +1 -1
- package/dist/routes/platformOwner/credit-notes-issue.js +18 -12
- package/dist/routes/platformOwner/credit-notes-issue.js.map +1 -1
- package/dist/routes/platformOwner/dashboard.d.ts +4 -8
- package/dist/routes/platformOwner/dashboard.js +9 -28
- package/dist/routes/platformOwner/dashboard.js.map +1 -1
- package/dist/routes/platformOwner/plan-dialogs.js +2 -1
- package/dist/routes/platformOwner/plan-dialogs.js.map +1 -1
- package/dist/routes/platformOwner/plans.d.ts +9 -29
- package/dist/routes/platformOwner/plans.js +58 -18
- package/dist/routes/platformOwner/plans.js.map +1 -1
- package/dist/routes/platformOwner/workspace-detail.js +4 -2
- package/dist/routes/platformOwner/workspace-detail.js.map +1 -1
- package/dist/routes/platformOwner/workspace-operator-actions.js +6 -1
- package/dist/routes/platformOwner/workspace-operator-actions.js.map +1 -1
- package/dist/routes/platformOwner/workspaces-admin.d.ts +1 -1
- package/dist/routes/platformOwner/workspaces-admin.js +15 -7
- package/dist/routes/platformOwner/workspaces-admin.js.map +1 -1
- package/dist/routes/public/public-plan-catalog.js +3 -2
- package/dist/routes/public/public-plan-catalog.js.map +1 -1
- package/dist/routes/public/register.js +6 -5
- package/dist/routes/public/register.js.map +1 -1
- package/dist/routes/tenant/billing-portal.js +1 -1
- package/dist/routes/tenant/billing-portal.js.map +1 -1
- package/dist/routes/tenant/tenant-plan-checkout.js +4 -4
- package/dist/routes/tenant/tenant-plan-checkout.js.map +1 -1
- package/dist/routes/tenant/tenant-plan-resubscription.js +2 -1
- package/dist/routes/tenant/tenant-plan-resubscription.js.map +1 -1
- package/dist/routes/tenant/tenant-plan.d.ts +0 -1
- package/dist/routes/tenant/tenant-plan.js +20 -20
- package/dist/routes/tenant/tenant-plan.js.map +1 -1
- package/dist/routes/tenant/workspaces.d.ts +1 -1
- package/dist/routes/tenant/workspaces.js +13 -8
- package/dist/routes/tenant/workspaces.js.map +1 -1
- package/dist/stripe/availability.d.ts +5 -0
- package/dist/stripe/availability.js +43 -0
- package/dist/stripe/availability.js.map +1 -0
- package/dist/stripe/customer-billing.js +2 -0
- package/dist/stripe/customer-billing.js.map +1 -1
- package/dist/stripe/customer-locale.d.ts +3 -0
- package/dist/stripe/customer-locale.js +11 -0
- package/dist/stripe/customer-locale.js.map +1 -1
- package/dist/stripe/index.d.ts +1 -0
- package/dist/stripe/index.js +1 -0
- package/dist/stripe/index.js.map +1 -1
- package/dist/stripe/payload-shapes.d.ts +6 -0
- package/dist/stripe/payload-shapes.js +13 -0
- package/dist/stripe/payload-shapes.js.map +1 -1
- package/dist/stripe/subscription-cancellation.js +2 -0
- package/dist/stripe/subscription-cancellation.js.map +1 -1
- package/dist/stripe/sync-plan.js +8 -7
- package/dist/stripe/sync-plan.js.map +1 -1
- package/dist/stripe/webhook-checkout.js +1 -1
- package/dist/stripe/webhook-checkout.js.map +1 -1
- package/dist/stripe/webhook-handlers.js +5 -3
- package/dist/stripe/webhook-handlers.js.map +1 -1
- package/dist/utils/segment-matching.d.ts +4 -3
- package/dist/utils/segment-matching.js +29 -13
- package/dist/utils/segment-matching.js.map +1 -1
- package/dist/workspaces/default-plan.d.ts +1 -1
- package/dist/workspaces/default-plan.js +11 -7
- package/dist/workspaces/default-plan.js.map +1 -1
- package/dist/workspaces/provisioning.d.ts +0 -1
- package/dist/workspaces/provisioning.js +3 -6
- package/dist/workspaces/provisioning.js.map +1 -1
- package/dist/workspaces/self-serve-creation.d.ts +2 -2
- package/dist/workspaces/self-serve-creation.js +12 -6
- package/dist/workspaces/self-serve-creation.js.map +1 -1
- package/frontend-vue/app/build/period-range.ts +57 -0
- package/frontend-vue/app/build/plan-catalog.ts +2 -0
- package/frontend-vue/app/build/public/RegistrationPlanCard.vue +1 -2
- package/frontend-vue/app/components/BillingIdentityFields.vue +64 -76
- package/frontend-vue/app/components/PlanCard.vue +14 -2
- package/frontend-vue/app/components/PlanCardPublic.vue +1 -2
- package/frontend-vue/app/components/PlanEditorPreview.vue +26 -12
- package/frontend-vue/app/components/PlanUpgradeModal.vue +45 -3
- package/frontend-vue/app/components/TenantBillingForm.vue +2 -0
- package/frontend-vue/app/components/TenantPlanCard.vue +1 -2
- package/frontend-vue/app/components/WorkspaceCreateModal.vue +1 -2
- package/frontend-vue/app/composables/useBillingAddress.ts +108 -0
- package/frontend-vue/app/composables/useBillingCountries.ts +3 -69
- package/frontend-vue/app/composables/useBillingIdentity.ts +7 -5
- package/frontend-vue/app/composables/usePlanChangeReview.ts +21 -0
- package/frontend-vue/app/plugins/billing-data-types.ts +6 -13
- package/frontend-vue/i18n/locales/saas-en-GB.json +4 -0
- package/frontend-vue/i18n/locales/saas-fr-FR.json +4 -0
- package/frontend-vue/i18n/locales/saas-operator-catalog-en-GB.json +9 -2
- package/frontend-vue/i18n/locales/saas-operator-catalog-fr-FR.json +9 -2
- package/frontend-vue/i18n/locales/saas-operator-workspaces-en-GB.json +7 -2
- package/frontend-vue/i18n/locales/saas-operator-workspaces-fr-FR.json +7 -2
- package/frontend-vue/i18n/locales/saas-tenant-billing-en-GB.json +5 -7
- package/frontend-vue/i18n/locales/saas-tenant-billing-fr-FR.json +5 -7
- package/frontend-vue/package.json +1 -1
- package/package.json +11 -10
- package/skills/dms-saas/SKILL.md +22 -2
- package/frontend-vue/app/composables/usePlanDescription.ts +0 -12
|
@@ -26,7 +26,6 @@ const props = withDefaults(defineProps<PlanCardPublicProps>(), {
|
|
|
26
26
|
|
|
27
27
|
const { t } = useI18n()
|
|
28
28
|
const { priceLabel, seatExampleLabel, termsLabel } = usePublicPlanFormat()
|
|
29
|
-
const planDescription = usePlanDescription()
|
|
30
29
|
const { formatFeatureValue } = usePlanFeatureFormat()
|
|
31
30
|
const { processI18n } = useTranslation()
|
|
32
31
|
|
|
@@ -86,7 +85,7 @@ const accentStyle = computed(() =>
|
|
|
86
85
|
<header class="pr-16">
|
|
87
86
|
<h2 class="text-highlighted text-base font-semibold">{{ plan.name }}</h2>
|
|
88
87
|
<p v-if="plan.description" class="text-muted mt-1 text-[13px]">
|
|
89
|
-
{{
|
|
88
|
+
{{ plan.description }}
|
|
90
89
|
</p>
|
|
91
90
|
</header>
|
|
92
91
|
|
|
@@ -16,17 +16,20 @@ interface PlanAccess {
|
|
|
16
16
|
extraFeatures: Record<string, unknown>
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/** A plan text as the editor holds it: one value per locale. */
|
|
20
|
+
type PlanText = Record<string, string>
|
|
21
|
+
|
|
19
22
|
/** The plan fields the preview reads, saved or as typed. */
|
|
20
23
|
interface PlanDraft {
|
|
21
|
-
name?:
|
|
22
|
-
description?:
|
|
24
|
+
name?: PlanText | null
|
|
25
|
+
description?: PlanText | null
|
|
23
26
|
price?: number
|
|
24
27
|
currency?: string
|
|
25
28
|
interval?: 'month' | 'year'
|
|
26
29
|
billingMode?: 'flat' | 'seat'
|
|
27
30
|
trialDays?: number
|
|
28
31
|
maxMembers?: number
|
|
29
|
-
borderLabel?:
|
|
32
|
+
borderLabel?: PlanText | null
|
|
30
33
|
borderColor?: string | null
|
|
31
34
|
inheritance?: PlanAccess | null
|
|
32
35
|
}
|
|
@@ -51,7 +54,7 @@ const SYNC_TONES: Record<SyncState, 'success' | 'warning' | 'neutral'> = {
|
|
|
51
54
|
synced: 'success',
|
|
52
55
|
out_of_sync: 'warning',
|
|
53
56
|
off_stripe: 'neutral',
|
|
54
|
-
not_configured: '
|
|
57
|
+
not_configured: 'warning',
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
const props = defineProps<{
|
|
@@ -66,8 +69,10 @@ const EMPTY_CATALOG: PlanCatalog = {
|
|
|
66
69
|
newPlanPermissions: [],
|
|
67
70
|
}
|
|
68
71
|
|
|
72
|
+
// Locale the server reads a plan text in when the reader's has none.
|
|
73
|
+
const PLAN_FALLBACK_LOCALE = 'en'
|
|
74
|
+
|
|
69
75
|
const { t, locale } = useI18n()
|
|
70
|
-
const planDescription = usePlanDescription()
|
|
71
76
|
const { formatFeatureValue } = usePlanFeatureFormat()
|
|
72
77
|
|
|
73
78
|
const planId = computed(() => props.routeParams?.id)
|
|
@@ -99,6 +104,15 @@ const isLoading = computed(
|
|
|
99
104
|
(!planCatalog.data.value || reads.some((read) => read.pending.value)),
|
|
100
105
|
)
|
|
101
106
|
const draft = computed<PlanDraft>(() => live.value ?? saved.value ?? {})
|
|
107
|
+
|
|
108
|
+
/** A plan text as the cards show it: the reader's locale, else the fallback one. */
|
|
109
|
+
function textOf(value: PlanText | null | undefined): string {
|
|
110
|
+
return value?.[locale.value] || value?.[PLAN_FALLBACK_LOCALE] || ''
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const name = computed(() => textOf(draft.value.name))
|
|
114
|
+
const description = computed(() => textOf(draft.value.description))
|
|
115
|
+
const badge = computed(() => textOf(draft.value.borderLabel))
|
|
102
116
|
const currency = computed(() => draft.value.currency ?? 'EUR')
|
|
103
117
|
const price = computed(() => Number(draft.value.price ?? 0))
|
|
104
118
|
const interval = computed(() => draft.value.interval ?? 'month')
|
|
@@ -132,7 +146,7 @@ const terms = computed(() => {
|
|
|
132
146
|
const cta = computed(() =>
|
|
133
147
|
trialDays.value > 0
|
|
134
148
|
? t('saas.catalog.editor.preview.start_trial')
|
|
135
|
-
: t('saas.catalog.editor.preview.choose', { name:
|
|
149
|
+
: t('saas.catalog.editor.preview.choose', { name: name.value }),
|
|
136
150
|
)
|
|
137
151
|
|
|
138
152
|
const resolvedFeatures = computed(() => {
|
|
@@ -232,13 +246,13 @@ async function load(): Promise<void> {
|
|
|
232
246
|
v-else
|
|
233
247
|
class="border-default relative flex flex-col gap-3 rounded-xl border p-4"
|
|
234
248
|
:style="
|
|
235
|
-
|
|
249
|
+
badge
|
|
236
250
|
? { borderColor: draft.borderColor || undefined }
|
|
237
251
|
: undefined
|
|
238
252
|
"
|
|
239
253
|
>
|
|
240
254
|
<UBadge
|
|
241
|
-
v-if="
|
|
255
|
+
v-if="badge"
|
|
242
256
|
class="absolute -top-2.5 left-4"
|
|
243
257
|
size="sm"
|
|
244
258
|
icon="i-ph-star"
|
|
@@ -248,14 +262,14 @@ async function load(): Promise<void> {
|
|
|
248
262
|
: undefined
|
|
249
263
|
"
|
|
250
264
|
>
|
|
251
|
-
{{
|
|
265
|
+
{{ badge }}
|
|
252
266
|
</UBadge>
|
|
253
267
|
<div>
|
|
254
268
|
<p class="text-highlighted text-lg font-semibold">
|
|
255
|
-
{{
|
|
269
|
+
{{ name || $t('saas.catalog.editor.preview.unnamed') }}
|
|
256
270
|
</p>
|
|
257
|
-
<p v-if="
|
|
258
|
-
{{
|
|
271
|
+
<p v-if="description" class="text-muted line-clamp-2 text-sm">
|
|
272
|
+
{{ description }}
|
|
259
273
|
</p>
|
|
260
274
|
</div>
|
|
261
275
|
<div>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { computed, ref, watch } from 'vue'
|
|
3
3
|
import { SENTENCE_DAY_FORMAT } from '../build/day-formats'
|
|
4
4
|
import { checkoutHeadingCase } from '../build/plan-change-heading'
|
|
5
|
+
import { canContinueToCheckout } from '../composables/usePlanChangeReview'
|
|
5
6
|
|
|
6
7
|
const props = defineProps<{
|
|
7
8
|
plan: OfferedPlanView | null
|
|
@@ -38,6 +39,9 @@ const loadFailed = ref(false)
|
|
|
38
39
|
const isSubmitting = ref(false)
|
|
39
40
|
const preview = ref<PlanChangePreview | null>(null)
|
|
40
41
|
const isPricing = ref(false)
|
|
42
|
+
// A refused preview (a plan Stripe does not bill yet, Stripe unreachable)
|
|
43
|
+
// would be refused again at checkout: say why, and offer no payment.
|
|
44
|
+
const previewFailure = ref<string | null>(null)
|
|
41
45
|
let pricingTimer: ReturnType<typeof setTimeout> | null = null
|
|
42
46
|
|
|
43
47
|
const currency = computed(() => preview.value?.currency ?? props.plan?.currency)
|
|
@@ -72,6 +76,14 @@ const headingParams = computed(() => ({
|
|
|
72
76
|
date: firstChargeOn.value ?? '',
|
|
73
77
|
}))
|
|
74
78
|
|
|
79
|
+
const canContinue = computed(() =>
|
|
80
|
+
canContinueToCheckout({
|
|
81
|
+
isLoading: isLoading.value,
|
|
82
|
+
hasLoadFailed: loadFailed.value,
|
|
83
|
+
previewFailure: previewFailure.value,
|
|
84
|
+
}),
|
|
85
|
+
)
|
|
86
|
+
|
|
75
87
|
const dueToday = computed(() => {
|
|
76
88
|
if (isTrial.value) return formatMinorUnits(0, currency.value)
|
|
77
89
|
return charge.value
|
|
@@ -98,8 +110,13 @@ async function price(): Promise<void> {
|
|
|
98
110
|
isPricing.value = true
|
|
99
111
|
try {
|
|
100
112
|
preview.value = await previewChange(plan._id, draft.value.country || null)
|
|
101
|
-
|
|
113
|
+
previewFailure.value = null
|
|
114
|
+
} catch (error) {
|
|
102
115
|
preview.value = null
|
|
116
|
+
previewFailure.value = resolveApiError(
|
|
117
|
+
error,
|
|
118
|
+
`${KEY_PREFIX}.preview_failed`,
|
|
119
|
+
)
|
|
103
120
|
} finally {
|
|
104
121
|
isPricing.value = false
|
|
105
122
|
}
|
|
@@ -118,6 +135,7 @@ watch(
|
|
|
118
135
|
async (isOpen) => {
|
|
119
136
|
if (!isOpen) return
|
|
120
137
|
preview.value = null
|
|
138
|
+
previewFailure.value = null
|
|
121
139
|
await loadIdentity()
|
|
122
140
|
void price()
|
|
123
141
|
},
|
|
@@ -261,12 +279,36 @@ async function confirm(): Promise<void> {
|
|
|
261
279
|
})
|
|
262
280
|
}}
|
|
263
281
|
</p>
|
|
264
|
-
<p
|
|
282
|
+
<p
|
|
283
|
+
v-else-if="!charge && !isPricing && !previewFailure"
|
|
284
|
+
class="text-muted"
|
|
285
|
+
>
|
|
265
286
|
{{ $t(`${KEY_PREFIX}.tax_on_stripe`) }}
|
|
266
287
|
</p>
|
|
267
288
|
</div>
|
|
268
289
|
</DmsCard>
|
|
269
290
|
|
|
291
|
+
<UAlert
|
|
292
|
+
v-if="previewFailure"
|
|
293
|
+
color="error"
|
|
294
|
+
variant="subtle"
|
|
295
|
+
icon="i-ph-warning-circle"
|
|
296
|
+
:title="previewFailure"
|
|
297
|
+
>
|
|
298
|
+
<template #actions>
|
|
299
|
+
<UButton
|
|
300
|
+
color="error"
|
|
301
|
+
variant="soft"
|
|
302
|
+
size="xs"
|
|
303
|
+
icon="i-ph-arrow-clockwise"
|
|
304
|
+
:loading="isPricing"
|
|
305
|
+
@click="price"
|
|
306
|
+
>
|
|
307
|
+
{{ $t('saas.common.retry') }}
|
|
308
|
+
</UButton>
|
|
309
|
+
</template>
|
|
310
|
+
</UAlert>
|
|
311
|
+
|
|
270
312
|
<p class="text-muted flex items-center gap-2 text-sm">
|
|
271
313
|
<UIcon name="i-ph-lock-simple" />
|
|
272
314
|
{{ $t(`${KEY_PREFIX}.card_note`) }}
|
|
@@ -285,7 +327,7 @@ async function confirm(): Promise<void> {
|
|
|
285
327
|
color="primary"
|
|
286
328
|
icon="i-ph-lock-simple"
|
|
287
329
|
:loading="isSubmitting"
|
|
288
|
-
:disabled="
|
|
330
|
+
:disabled="!canContinue"
|
|
289
331
|
>
|
|
290
332
|
{{ $t(`${KEY_PREFIX}.confirm`) }}
|
|
291
333
|
</UButton>
|
|
@@ -29,7 +29,6 @@ const billingStatus = useBillingStatus()
|
|
|
29
29
|
const nextInvoice = useNextInvoice()
|
|
30
30
|
const { formatMajorUnits, formatMinorUnits } = useMoneyFormat()
|
|
31
31
|
const { statusView } = useSaasStatus()
|
|
32
|
-
const planDescription = usePlanDescription()
|
|
33
32
|
const { formatFeatureValue } = usePlanFeatureFormat()
|
|
34
33
|
const comparison = usePlanComparison()
|
|
35
34
|
const { consumeCancelledCheckout } = usePendingCheckout()
|
|
@@ -98,7 +97,7 @@ const pill = computed(() => {
|
|
|
98
97
|
|
|
99
98
|
const summary = computed(() => {
|
|
100
99
|
if (current.value?.description)
|
|
101
|
-
return
|
|
100
|
+
return current.value.description
|
|
102
101
|
const view = data.value?.available.find(
|
|
103
102
|
(plan) => plan._id === current.value?._id,
|
|
104
103
|
)
|
|
@@ -69,7 +69,6 @@ const { resolveApiError } = useApiErrorMessage()
|
|
|
69
69
|
const { formatMajorUnits } = useMoneyFormat()
|
|
70
70
|
const planPriceLabel = usePlanPriceLabel()
|
|
71
71
|
const planIntervalLabel = usePlanIntervalLabel(`${KEYS}.interval`)
|
|
72
|
-
const planDescription = usePlanDescription()
|
|
73
72
|
const config = useDmsRuntimeConfig()
|
|
74
73
|
const { user } = useCurrentUser()
|
|
75
74
|
|
|
@@ -141,7 +140,7 @@ function planMeta(plan: CreatePlanOption): string {
|
|
|
141
140
|
rule.limit,
|
|
142
141
|
)
|
|
143
142
|
}
|
|
144
|
-
const parts = [
|
|
143
|
+
const parts = [plan.description].filter(Boolean)
|
|
145
144
|
if (plan.trialDays > 0 && plan.cardRequirement === 'payment') {
|
|
146
145
|
parts.push(t(`${KEYS}.trial`, { days: plan.trialDays }))
|
|
147
146
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value of the DMS address input (`DmsInputAddress`, the `AddressType`
|
|
3
|
+
* field): the street split into its name, number and box.
|
|
4
|
+
*/
|
|
5
|
+
export interface AddressInputValue {
|
|
6
|
+
streetName: string
|
|
7
|
+
houseNumber?: string
|
|
8
|
+
boxNumber?: string
|
|
9
|
+
addressLine2?: string
|
|
10
|
+
postalCode: string
|
|
11
|
+
city: string
|
|
12
|
+
countrySubdivision?: string
|
|
13
|
+
countryCode: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The billing address as the draft and Stripe hold it: one street line. */
|
|
17
|
+
export interface BillingAddressDraft {
|
|
18
|
+
line1: string
|
|
19
|
+
line2: string
|
|
20
|
+
postalCode: string
|
|
21
|
+
city: string
|
|
22
|
+
state: string
|
|
23
|
+
country: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The street line split into the parts the address input edits. */
|
|
27
|
+
export interface StreetParts {
|
|
28
|
+
streetName: string
|
|
29
|
+
houseNumber: string
|
|
30
|
+
boxNumber: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// "Rue de l'Ermitage 41", "Rue de l'Ermitage 41/2", "Rue X, 41 bte 2": the
|
|
34
|
+
// number is the last word starting with a digit, a box after it either
|
|
35
|
+
// slashed or named as the address input itself splits it. A line written the
|
|
36
|
+
// other way round ("10 Downing Street") stays the street name, whole.
|
|
37
|
+
const NUMBER_AT_END =
|
|
38
|
+
/^(.+?)[,\s]\s*(\d[^\s/]*)(?:\s*\/\s*(\S+)|\s+(?:bo[iî]te|bus|box|bte)\.?\s*(\S+))?$/i
|
|
39
|
+
const BOX_SEPARATOR = '/'
|
|
40
|
+
|
|
41
|
+
/** Splits a stored street line into the address input's street parts. */
|
|
42
|
+
export function splitStreetLine(line: string): StreetParts {
|
|
43
|
+
const trimmed = line.trim()
|
|
44
|
+
const match = NUMBER_AT_END.exec(trimmed)
|
|
45
|
+
if (!match) return { streetName: trimmed, houseNumber: '', boxNumber: '' }
|
|
46
|
+
return {
|
|
47
|
+
streetName: match[1]?.trim() ?? '',
|
|
48
|
+
houseNumber: match[2] ?? '',
|
|
49
|
+
boxNumber: match[3] ?? match[4] ?? '',
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Joins street parts into one line: "Rue X 41", "Rue X 41/2". */
|
|
54
|
+
export function joinStreetLine(parts: StreetParts): string {
|
|
55
|
+
const number = [parts.houseNumber.trim(), parts.boxNumber.trim()]
|
|
56
|
+
.filter(Boolean)
|
|
57
|
+
.join(BOX_SEPARATOR)
|
|
58
|
+
return [parts.streetName.trim(), number].filter(Boolean).join(' ')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function hasSameStreet(left: StreetParts, right: StreetParts): boolean {
|
|
62
|
+
return (
|
|
63
|
+
left.streetName === right.streetName &&
|
|
64
|
+
left.houseNumber === right.houseNumber &&
|
|
65
|
+
left.boxNumber === right.boxNumber
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The address input's value for a stored billing address. */
|
|
70
|
+
export function toAddressInputValue(
|
|
71
|
+
address: BillingAddressDraft,
|
|
72
|
+
): AddressInputValue {
|
|
73
|
+
return {
|
|
74
|
+
...splitStreetLine(address.line1),
|
|
75
|
+
addressLine2: address.line2,
|
|
76
|
+
postalCode: address.postalCode,
|
|
77
|
+
city: address.city,
|
|
78
|
+
countrySubdivision: address.state,
|
|
79
|
+
countryCode: address.country,
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The billing address an address input value stands for. The street line is
|
|
85
|
+
* rebuilt only when its parts changed, so editing the city of a line the
|
|
86
|
+
* split could not rebuild word for word ("Rue X, 41 bte 2") leaves it as
|
|
87
|
+
* typed, and leaves the form clean until something really changed.
|
|
88
|
+
*/
|
|
89
|
+
export function fromAddressInputValue(
|
|
90
|
+
value: AddressInputValue,
|
|
91
|
+
current: BillingAddressDraft,
|
|
92
|
+
): BillingAddressDraft {
|
|
93
|
+
const street: StreetParts = {
|
|
94
|
+
streetName: value.streetName ?? '',
|
|
95
|
+
houseNumber: value.houseNumber ?? '',
|
|
96
|
+
boxNumber: value.boxNumber ?? '',
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
line1: hasSameStreet(street, splitStreetLine(current.line1))
|
|
100
|
+
? current.line1
|
|
101
|
+
: joinStreetLine(street),
|
|
102
|
+
line2: value.addressLine2 ?? '',
|
|
103
|
+
postalCode: value.postalCode ?? '',
|
|
104
|
+
city: value.city ?? '',
|
|
105
|
+
state: value.countrySubdivision ?? '',
|
|
106
|
+
country: (value.countryCode ?? '').toUpperCase(),
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -1,74 +1,8 @@
|
|
|
1
|
-
import { computed, type ComputedRef } from "vue";
|
|
2
|
-
|
|
3
|
-
export interface BillingCountryItem {
|
|
4
|
-
value: string;
|
|
5
|
-
label: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface BillingCountries {
|
|
9
|
-
countryItems: ComputedRef<BillingCountryItem[]>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const BILLING_COUNTRY_CODES = [
|
|
13
|
-
"AT",
|
|
14
|
-
"BE",
|
|
15
|
-
"BG",
|
|
16
|
-
"HR",
|
|
17
|
-
"CY",
|
|
18
|
-
"CZ",
|
|
19
|
-
"DK",
|
|
20
|
-
"EE",
|
|
21
|
-
"FI",
|
|
22
|
-
"FR",
|
|
23
|
-
"DE",
|
|
24
|
-
"GR",
|
|
25
|
-
"HU",
|
|
26
|
-
"IE",
|
|
27
|
-
"IT",
|
|
28
|
-
"LV",
|
|
29
|
-
"LT",
|
|
30
|
-
"LU",
|
|
31
|
-
"MT",
|
|
32
|
-
"NL",
|
|
33
|
-
"PL",
|
|
34
|
-
"PT",
|
|
35
|
-
"RO",
|
|
36
|
-
"SK",
|
|
37
|
-
"SI",
|
|
38
|
-
"ES",
|
|
39
|
-
"SE",
|
|
40
|
-
"GB",
|
|
41
|
-
"CH",
|
|
42
|
-
"NO",
|
|
43
|
-
"US",
|
|
44
|
-
"CA",
|
|
45
|
-
"AU",
|
|
46
|
-
"NZ",
|
|
47
|
-
];
|
|
48
|
-
|
|
49
1
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* expects.
|
|
53
|
-
*
|
|
54
|
-
* @param locale BCP 47 locale the labels are rendered in
|
|
2
|
+
* Full country name for an ISO code, or the code itself when unknown. The
|
|
3
|
+
* billing address picks its country from the DMS address input's list; the
|
|
4
|
+
* stored value stays the ISO code Stripe expects.
|
|
55
5
|
*/
|
|
56
|
-
export function buildBillingCountryItems(locale: string): BillingCountryItem[] {
|
|
57
|
-
const names = new Intl.DisplayNames([locale], { type: "region" });
|
|
58
|
-
return BILLING_COUNTRY_CODES.map((code) => ({
|
|
59
|
-
value: code,
|
|
60
|
-
label: names.of(code) ?? code,
|
|
61
|
-
})).sort((left, right) => left.label.localeCompare(right.label, locale));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Full country name for an ISO code, or the code itself when unknown. */
|
|
65
6
|
export function formatBillingCountry(code: string, locale: string): string {
|
|
66
7
|
return new Intl.DisplayNames([locale], { type: "region" }).of(code) ?? code;
|
|
67
8
|
}
|
|
68
|
-
|
|
69
|
-
export function useBillingCountries(): BillingCountries {
|
|
70
|
-
const { locale } = useI18n();
|
|
71
|
-
return {
|
|
72
|
-
countryItems: computed(() => buildBillingCountryItems(locale.value)),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
@@ -16,15 +16,11 @@ export type BillingIdentityField =
|
|
|
16
16
|
| 'billingEmail'
|
|
17
17
|
|
|
18
18
|
/** The editable billing identity, as the form holds it. */
|
|
19
|
-
export interface BillingIdentityDraft {
|
|
19
|
+
export interface BillingIdentityDraft extends BillingAddressDraft {
|
|
20
20
|
customerType: CustomerType | null
|
|
21
21
|
companyName: string
|
|
22
22
|
vatNumber: string
|
|
23
23
|
billingEmail: string
|
|
24
|
-
country: string
|
|
25
|
-
line1: string
|
|
26
|
-
postalCode: string
|
|
27
|
-
city: string
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
interface BillingAddress {
|
|
@@ -88,8 +84,10 @@ export function emptyBillingIdentityDraft(): BillingIdentityDraft {
|
|
|
88
84
|
billingEmail: '',
|
|
89
85
|
country: '',
|
|
90
86
|
line1: '',
|
|
87
|
+
line2: '',
|
|
91
88
|
postalCode: '',
|
|
92
89
|
city: '',
|
|
90
|
+
state: '',
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
93
|
|
|
@@ -103,8 +101,10 @@ export function toBillingIdentityDraft(
|
|
|
103
101
|
billingEmail: info.billingEmail ?? '',
|
|
104
102
|
country: info.address?.country ?? '',
|
|
105
103
|
line1: info.address?.line1 ?? '',
|
|
104
|
+
line2: info.address?.line2 ?? '',
|
|
106
105
|
postalCode: info.address?.postalCode ?? '',
|
|
107
106
|
city: info.address?.city ?? '',
|
|
107
|
+
state: info.address?.state ?? '',
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -118,8 +118,10 @@ function toRequestBody(draft: BillingIdentityDraft) {
|
|
|
118
118
|
address: {
|
|
119
119
|
country: draft.country,
|
|
120
120
|
line1: draft.line1,
|
|
121
|
+
line2: draft.line2,
|
|
121
122
|
postalCode: draft.postalCode,
|
|
122
123
|
city: draft.city,
|
|
124
|
+
state: draft.state,
|
|
123
125
|
},
|
|
124
126
|
}
|
|
125
127
|
}
|
|
@@ -35,6 +35,27 @@ export interface OfferedPlans {
|
|
|
35
35
|
tooSmall: OfferedPlanView[]
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/** Where the checkout dialog stands before it may send the owner to pay. */
|
|
39
|
+
export interface CheckoutReadiness {
|
|
40
|
+
isLoading: boolean
|
|
41
|
+
hasLoadFailed: boolean
|
|
42
|
+
/** Translated reason the preview was refused, null once it priced. */
|
|
43
|
+
previewFailure: string | null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Whether the checkout dialog may offer the payment page: the identity is
|
|
48
|
+
* loaded and the plan change was not refused while previewed — the checkout
|
|
49
|
+
* itself would refuse it for the same reason.
|
|
50
|
+
*/
|
|
51
|
+
export function canContinueToCheckout(readiness: CheckoutReadiness): boolean {
|
|
52
|
+
return (
|
|
53
|
+
!readiness.isLoading &&
|
|
54
|
+
!readiness.hasLoadFailed &&
|
|
55
|
+
readiness.previewFailure === null
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
38
59
|
/** Something the workspace holds that the target plan does not allow. */
|
|
39
60
|
export interface PlanChangeIncompatibility {
|
|
40
61
|
code: string
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineComponent, h, resolveComponent } from 'vue'
|
|
2
|
+
import { formatPeriodRange } from '../build/period-range'
|
|
2
3
|
import { billingDocumentTypeKey } from '../composables/useBillingDocumentType'
|
|
3
4
|
import { parseInvoiceLines } from '../composables/useInvoiceLines'
|
|
4
5
|
import { formatMinorUnits } from '../composables/useMoneyFormat'
|
|
@@ -21,14 +22,6 @@ const PERIOD_FORMAT: Intl.DateTimeFormatOptions = {
|
|
|
21
22
|
month: 'long',
|
|
22
23
|
year: 'numeric',
|
|
23
24
|
}
|
|
24
|
-
const RANGE_FORMAT: Intl.DateTimeFormatOptions = {
|
|
25
|
-
day: 'numeric',
|
|
26
|
-
month: 'short',
|
|
27
|
-
}
|
|
28
|
-
const RANGE_FORMAT_WITH_YEAR: Intl.DateTimeFormatOptions = {
|
|
29
|
-
...RANGE_FORMAT,
|
|
30
|
-
year: 'numeric',
|
|
31
|
-
}
|
|
32
25
|
const NO_VALUE = '—'
|
|
33
26
|
|
|
34
27
|
type CellRow = Record<string, unknown> | undefined
|
|
@@ -44,7 +37,10 @@ function toDate(value: unknown): Date | null {
|
|
|
44
37
|
return Number.isNaN(date.getTime()) ? null : date
|
|
45
38
|
}
|
|
46
39
|
|
|
47
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* "Sep 29 – Oct 28", with the years once the period spans two, in the
|
|
42
|
+
* reader's time zone like every other date of the console.
|
|
43
|
+
*/
|
|
48
44
|
function formatPeriod(
|
|
49
45
|
start: unknown,
|
|
50
46
|
locale: string,
|
|
@@ -55,10 +51,7 @@ function formatPeriod(
|
|
|
55
51
|
if (!from) return NO_VALUE
|
|
56
52
|
const endField = (options as PeriodOptions | undefined)?.endField
|
|
57
53
|
const to = endField ? toDate(row?.[endField]) : null
|
|
58
|
-
|
|
59
|
-
const isSameYear = from.getFullYear() === to.getFullYear()
|
|
60
|
-
const format = isSameYear ? RANGE_FORMAT : RANGE_FORMAT_WITH_YEAR
|
|
61
|
-
return new Intl.DateTimeFormat(locale, format).formatRange(from, to)
|
|
54
|
+
return formatPeriodRange(from, to, locale, regionalDateTimeFormat)
|
|
62
55
|
}
|
|
63
56
|
|
|
64
57
|
/** An amount in minor units, in the row's own currency. */
|
|
@@ -103,6 +103,10 @@
|
|
|
103
103
|
"not_eligible": "Refund not available",
|
|
104
104
|
"already_processed": "Refund already processed"
|
|
105
105
|
},
|
|
106
|
+
"stripe": {
|
|
107
|
+
"unavailable": "Stripe, our payment provider, cannot be reached right now. Nothing was charged; try again in a few minutes.",
|
|
108
|
+
"not_configured": "Payments are not set up on this platform yet. Contact the platform operator."
|
|
109
|
+
},
|
|
106
110
|
"billing": {
|
|
107
111
|
"country_required": "Billing country is required",
|
|
108
112
|
"invalid_return_url": "Invalid return URL",
|
|
@@ -103,6 +103,10 @@
|
|
|
103
103
|
"not_eligible": "Remboursement non disponible",
|
|
104
104
|
"already_processed": "Remboursement déjà traité"
|
|
105
105
|
},
|
|
106
|
+
"stripe": {
|
|
107
|
+
"unavailable": "Stripe, notre prestataire de paiement, est injoignable pour le moment. Rien n’a été débité ; réessayez dans quelques minutes.",
|
|
108
|
+
"not_configured": "Les paiements ne sont pas encore configurés sur cette plateforme. Contactez l’opérateur de la plateforme."
|
|
109
|
+
},
|
|
106
110
|
"billing": {
|
|
107
111
|
"country_required": "Le pays de facturation est requis",
|
|
108
112
|
"invalid_return_url": "URL de retour invalide",
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
"editor_preview_description": "See the plan card as customers see it and its Stripe sync status while editing",
|
|
11
11
|
"migrations_attention": "Migrations needing attention",
|
|
12
12
|
"migrations_attention_description": "See the plan migrations waiting for an operator",
|
|
13
|
+
"migration_toolbar": "Migration live mode",
|
|
14
|
+
"migration_toolbar_description": "Pause or resume the live updates of a running migration and see when it was last read",
|
|
13
15
|
"migration_header": "Migration header",
|
|
14
16
|
"migration_header_description": "See where a plan migration stands and retry, export or close it",
|
|
15
17
|
"migration_totals": "Migration totals",
|
|
@@ -130,7 +132,7 @@
|
|
|
130
132
|
"on_sale": "Plans on sale",
|
|
131
133
|
"on_sale_detail": "{public} public · {sales} sales-led",
|
|
132
134
|
"workspaces": "Workspaces",
|
|
133
|
-
"workspaces_detail": "{paying} paying · {free} free · {trialing} in trial",
|
|
135
|
+
"workspaces_detail": "{paying} paying · {free} free · {trialing} in trial · {other} other",
|
|
134
136
|
"mrr": "Catalogue MRR",
|
|
135
137
|
"mrr_detail": "Normalised · yearly ÷ 12, seats counted",
|
|
136
138
|
"mrr_detail_other": "Normalised · plus {other}",
|
|
@@ -142,6 +144,8 @@
|
|
|
142
144
|
"public": "Public",
|
|
143
145
|
"hidden": "Hidden",
|
|
144
146
|
"not_on_sale": "Not on sale",
|
|
147
|
+
"not_on_stripe": "Not on Stripe",
|
|
148
|
+
"not_on_stripe_hint": "This plan has a price but no Stripe price yet: no workspace can subscribe to it until it syncs.",
|
|
145
149
|
"legacy": "Legacy",
|
|
146
150
|
"on_sale": "On sale",
|
|
147
151
|
"more": "More actions",
|
|
@@ -174,7 +178,10 @@
|
|
|
174
178
|
"limit_error": "A cap must be at least 1 member. For no cap, tick Unlimited.",
|
|
175
179
|
"notice": {
|
|
176
180
|
"price_changed": "A new Stripe price was created",
|
|
177
|
-
"price_changed_description": "New sign-ups pay the new price. Existing subscribers keep theirs until you migrate them."
|
|
181
|
+
"price_changed_description": "New sign-ups pay the new price. Existing subscribers keep theirs until you migrate them.",
|
|
182
|
+
"stripe_not_synced": "Plan saved, but not synced with Stripe",
|
|
183
|
+
"stripe_not_synced_not_configured": "Stripe is not configured: no workspace can subscribe to this paid plan until it is.",
|
|
184
|
+
"stripe_not_synced_out_of_sync": "Stripe did not take the change. It is retried the next time the plan is offered or when the server starts; until then the plan cannot be subscribed to at its new terms."
|
|
178
185
|
},
|
|
179
186
|
"section": {
|
|
180
187
|
"identity": "Identity",
|