feat: QA + tax ID

This commit is contained in:
Arman committed 2023-10-27 11:59:23 +02:00
1 parent fe216a172d
commit c7bd163675
19 files changed
+169 -67

No files matched your search

+6 -6
View File
@@ -265,15 +265,15 @@ export enum Submit {
BillingAddressCreate = 'submit_billing_address_create',
BillingAddressUpdate = 'submit_billing_address_update',
BillingAddressDelete = 'submit_billing_address_delete',
OrganizationPaymentSet = 'submit_organization_payment_set',
OrganizationPaymentRemove = 'submit_organization_payment_remove',
OrganizationBackupPaymentSet = 'submit_organization_backup_payment_set',
OrganizationPaymentUpdate = 'submit_organization_payment_update',
OrganizationPaymentDelete = 'submit_organization_payment_delete',
OrganizationBackupPaymentUpdate = 'submit_organization_backup_payment_update',
OrganizationBackupPaymentRemove = 'submit_organization_backup_payment_remove',
OrganizationBillingAddressSet = 'submit_organization_billing_address_set',
OrganizationBillingAddressRemove = 'submit_organization_billing_address_remove',
OrganizationBackupPaymentDelete = 'submit_organization_backup_payment_delete',
OrganizationBillingAddressUpdate = 'submit_organization_billing_address_update',
OrganizationBillingAddressDelete = 'submit_organization_billing_address_delete',
OrganizationUpgrade = 'submit_organization_upgrade',
OrganizationDowngrade = 'submit_organization_downgrade',
OrganizationBillingTaxIdUpdate = 'submit_organization_billing_tax_id_update',
SupportTicket = 'submit_support_ticket',
InstallationCreate = 'submit_installation_create',
InstallationDelete = 'submit_installation_delete',
+6 -1
View File
@@ -1,4 +1,6 @@
<script lang="ts">
import { tooltip } from '$lib/actions/tooltip';
export let name: string;
export let group: string;
export let value: string | number | boolean;
@@ -9,6 +11,8 @@
export let borderRadius: 'xsmall' | 'small' | 'medium' | 'large' = 'small';
export let backgroundColor: string = null;
export let backgroundColorHover: string = null;
export let tooltipText: string = null;
export let showTooltip = false;
enum Radius {
xsmall = '--border-radius-xsmall',
@@ -26,7 +30,8 @@
style:--card-padding={`${padding}rem`}
style:--card-border-radius={`var(${Radius[borderRadius]})`}
style:--p-card-bg-color-default={backgroundColor}
style:--p-card-bg-color-hover={backgroundColorHover}>
style:--p-card-bg-color-hover={backgroundColorHover}
use:tooltip={{ content: tooltipText, disabled: !tooltipText || !showTooltip }}>
<div class="u-flex u-gap-8">
<input
class="is-small u-margin-block-start-2"
+17
View File
@@ -554,6 +554,23 @@ export class Billing {
);
}
async updateTaxId(organizationId: string, taxId: string): Promise<Organization> {
const path = `/organizations/${organizationId}/tax-id`;
const params = {
organizationId,
taxId
};
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call(
'PATCH',
uri,
{
'content-type': 'application/json'
},
params
);
}
//ACCOUNT
async listPaymentMethods(queries: [] = []): Promise<PaymentList> {
+3 -6
View File
@@ -81,19 +81,16 @@ export type TierData = {
export const tierFree: TierData = {
price: 0,
name: 'Starter',
description: 'For personal, passion projects.',
collaboratorPrice: undefined
description: 'For personal, passion projects.'
};
export const tierPro: TierData = {
price: 15,
name: 'Pro',
description: 'For pro developers and production projects that need the ability to scale.',
collaboratorPrice: 15
description: 'For pro developers and production projects that need the ability to scale.'
};
export const tierScale: TierData = {
price: 685,
name: 'Scale',
description: 'For scaling teams that need dedicated support.',
collaboratorPrice: 0
description: 'For scaling teams that need dedicated support.'
};
+1
View File
@@ -16,6 +16,7 @@ export type Organization = Models.Team<Record<string, unknown>> & {
billingTrialDays?: number;
billingAddress?: string;
amount: number;
taxId?: string;
};
export type BillingLimits = {
@@ -50,7 +50,7 @@
let org: Organization = null;
if (organization) {
org = await sdk.forConsole.billing.setBillingAddress(organization, response.$id);
trackEvent(Submit.OrganizationBillingAddressSet);
trackEvent(Submit.OrganizationBillingAddressUpdate);
}
await invalidate(Dependencies.ADDRESS);
show = false;
@@ -34,7 +34,8 @@
<Heading tag="h2" size="6">Billing Address</Heading>
<p class="text">
View or update your billing address. This address will appear on your invoice.
View or update your billing address. This address will be included in your invoices from
Appwrite.
</p>
<svelte:fragment slot="aside">
{#if $addressList.total && countryList?.total}
@@ -8,6 +8,7 @@
import PaymentMethods from './paymentMethods.svelte';
import AvailableCredit from './availableCredit.svelte';
import PaymentHistory from './paymentHistory.svelte';
import TaxId from './taxId.svelte';
import { Alert, Heading } from '$lib/components';
import { failedInvoice, paymentMethods } from '$lib/stores/billing';
import type { PaymentMethodData } from '$lib/sdk/billing';
@@ -45,6 +46,7 @@
<PaymentHistory />
<PaymentMethods />
<BillingAddress />
<TaxId />
<BudgetCap />
{#if $organization?.billingPlan !== 'tier-0' && !!$organization?.billingBudget}
<BudgetAlert />
@@ -23,13 +23,13 @@
type: 'success',
message: `A new billing address has been added to ${$organization.name}`
});
trackEvent(Submit.OrganizationBillingAddressSet);
trackEvent(Submit.OrganizationBillingAddressUpdate);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.OrganizationBillingAddressSet);
trackError(error, Submit.OrganizationBillingAddressUpdate);
}
}
@@ -42,7 +42,8 @@
<Heading tag="h2" size="6">Billing address</Heading>
<p class="text">
View or update your billing address. This address will appear on your invoice.
View or update your billing address. This address will be included in your invoices from
Appwrite.
</p>
<svelte:fragment slot="aside">
{#if $organization?.billingAddress && billingAddress}
@@ -23,11 +23,11 @@
type: 'success',
message: `The payment method has been removed from ${$organization.name}`
});
trackEvent(Submit.OrganizationPaymentRemove);
trackEvent(Submit.OrganizationPaymentDelete);
invalidate(Dependencies.ORGANIZATION);
} catch (e) {
error = e.message;
trackError(e, Submit.OrganizationPaymentRemove);
trackError(e, Submit.OrganizationPaymentDelete);
}
}
async function removeBackuptMethod() {
@@ -40,11 +40,11 @@
type: 'success',
message: `The payment method has been removed from ${$organization.name}`
});
trackEvent(Submit.OrganizationBackupPaymentRemove);
trackEvent(Submit.OrganizationBackupPaymentDelete);
invalidate(Dependencies.ORGANIZATION);
} catch (e) {
error = e.message;
trackError(e, Submit.OrganizationBackupPaymentRemove);
trackError(e, Submit.OrganizationBackupPaymentDelete);
}
}
</script>
@@ -43,14 +43,14 @@
type: 'success',
message: `A new payment method has been added to ${$organization.name}`
});
trackEvent(Submit.OrganizationPaymentSet);
trackEvent(Submit.OrganizationPaymentUpdate);
invalidate(Dependencies.ORGANIZATION);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.OrganizationPaymentSet);
trackError(error, Submit.OrganizationPaymentUpdate);
}
}
@@ -70,7 +70,7 @@
type: 'error',
message: error.message
});
trackError(error, Submit.OrganizationPaymentSet);
trackError(error, Submit.OrganizationPaymentUpdate);
}
}
@@ -46,14 +46,14 @@
});
invalidate(Dependencies.ORGANIZATION);
trackEvent(
isBackup ? Submit.OrganizationBackupPaymentRemove : Submit.OrganizationPaymentRemove
isBackup ? Submit.OrganizationBackupPaymentDelete : Submit.OrganizationPaymentDelete
);
show = false;
} catch (e) {
error = e.message;
trackError(
e,
isBackup ? Submit.OrganizationBackupPaymentRemove : Submit.OrganizationPaymentRemove
isBackup ? Submit.OrganizationBackupPaymentDelete : Submit.OrganizationPaymentDelete
);
}
}
@@ -0,0 +1,55 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, Form, FormList, InputText } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
let taxId: string;
onMount(() => {
taxId = $organization?.taxId;
});
async function updateTaxId() {
try {
await sdk.forConsole.billing.setBillingAddress($organization.$id, taxId || undefined);
await invalidate(Dependencies.ADDRESS);
addNotification({
type: 'success',
message: `${$organization.name} tax ID has been successfully updated`
});
trackEvent(Submit.OrganizationBillingTaxIdUpdate);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.OrganizationBillingTaxIdUpdate);
}
}
</script>
<Form onSubmit={updateTaxId}>
<CardGrid>
<Heading tag="h2" size="6">Tax ID</Heading>
Add a tax identification number to your organization.
<svelte:fragment slot="aside">
<FormList>
<InputText
label="Tax ID"
placeholder="Enter tax ID"
id="taxId"
bind:value={taxId} />
</FormList>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={$organization?.taxId === taxId} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
@@ -65,20 +65,26 @@
<ul
class="u-flex u-flex-vertical u-gap-16 u-margin-block-start-16"
style="--p-grid-item-size:16em; --p-grid-item-size-small-screens:16rem; --grid-gap: 1rem;">
{#if !anyOrgFree}
<li>
<LabelCard name="plan" bind:group={$createOrganization.billingPlan} value="tier-0">
<svelte:fragment slot="custom">
<div class="u-flex u-flex-vertical u-gap-4 u-width-full-line">
<h4 class="body-text-2 u-bold">
{tierFree.name} - ${tierFree.price}/month
</h4>
<p class="u-color-text-gray u-small">{tierFree.description}</p>
</div>
</svelte:fragment>
</LabelCard>
</li>
{/if}
<li>
<LabelCard
name="plan"
bind:group={$createOrganization.billingPlan}
value="tier-0"
disabled={!!anyOrgFree}
tooltipText="You are limited to 1 Free organization per account."
showTooltip={!!anyOrgFree}>
<svelte:fragment slot="custom" let:disabled>
<div
class="u-flex u-flex-vertical u-gap-4 u-width-full-line"
class:u-opacity-50={disabled}>
<h4 class="body-text-2 u-bold">
{tierFree.name} - ${tierFree.price}/month
</h4>
<p class="u-color-text-gray u-small">{tierFree.description}</p>
</div>
</svelte:fragment>
</LabelCard>
</li>
<li>
<LabelCard name="plan" bind:group={$createOrganization.billingPlan} value="tier-1">
@@ -12,6 +12,10 @@
import { initializeStripe, isStripeInitialized, submitStripeCard } from '$lib/stores/stripe';
import { sdk } from '$lib/stores/sdk';
import { CreditCardBrandImage } from '$lib/components';
import { toLocaleDate } from '$lib/helpers/date';
const today = new Date();
const billingPayDate = new Date(today.getTime() + 44 * 24 * 60 * 60 * 1000);
let methods: PaymentList;
let name: string;
@@ -47,9 +51,14 @@
<WizardStep beforeSubmit={handleSubmit}>
<svelte:fragment slot="title">Payment details</svelte:fragment>
<svelte:fragment slot="subtitle">Add a payment method to your organization.</svelte:fragment>
<svelte:fragment slot="subtitle">
Add a payment method to your organization. You will not be charged until your trial ends on <b
>{toLocaleDate(billingPayDate.toString())}</b
>.
</svelte:fragment>
<FormList>
<p class="text"><b>Payment method</b></p>
<FormList class="u-margin-block-start-8">
<div class:boxes-wrapper={methods?.total}>
{#if methods?.total}
{#each filteredMethods as method}
@@ -11,8 +11,11 @@
TableRow
} from '$lib/elements/table';
import { WizardStep } from '$lib/layout';
import { plansInfo } from '$lib/stores/billing';
import { createOrganization } from './store';
const plan = $plansInfo.plans.find((p) => p.$id === $createOrganization.billingPlan);
let email: string;
function addCollaborator() {
@@ -38,11 +41,12 @@
<Alert type="info">
{#if $createOrganization.billingPlan === 'tier-2'}
You can add unlimited organization members on the Scale plan at no cost. Each member
You can add unlimited organization members on the {plan.name} plan at no cost. Each member
added will receive an email invite to your organization on completion.
{:else if $createOrganization.billingPlan === 'tier-1'}
You can add unlimited organization members on the Pro plan for $15 each. Each member
added will receive an email invite to your organization on completion.
You can add unlimited organization members on the {plan.name} plan for
<b>${plan.memberAddon.price} each per month</b>. Each member added will receive an email
invite to your organization on completion.
{/if}
</Alert>
@@ -3,14 +3,14 @@
import { Pill } from '$lib/elements';
import { toLocaleDate } from '$lib/helpers/date';
import { WizardStep } from '$lib/layout';
import { tierToPlan } from '$lib/stores/billing';
import { plansInfo } from '$lib/stores/billing';
import { sdk } from '$lib/stores/sdk';
import { createOrganization } from './store';
const plan = tierToPlan($createOrganization.billingPlan);
const plan = $plansInfo.plans.find((p) => p.$id === $createOrganization.billingPlan);
const collaboratorPrice = plan?.memberAddon?.price ?? 0;
const collaboratorsNumber = $createOrganization?.collaborators?.length ?? 0;
const totalExpences = plan.price + plan.collaboratorPrice * collaboratorsNumber;
const totalExpences = plan.price + collaboratorPrice * collaboratorsNumber;
const today = new Date();
const billingPayDate = new Date(today.getTime() + 44 * 24 * 60 * 60 * 1000);
@@ -44,7 +44,7 @@
{#if $createOrganization.billingPlan !== 'tier-0'}
<div class="u-margin-block-start-32">
<p class="body-text-1 u-bold">Organization members</p>
<p class="text">{collaboratorsNumber} invited</p>
<p class="text">{collaboratorsNumber} members invited</p>
</div>
<div class="u-margin-block-start-32">
<p class="body-text-1 u-bold">Payment</p>
@@ -69,8 +69,8 @@
<p class="text">${plan.price}</p>
</span>
<span class="u-flex u-main-space-between">
<p class="text">Invited members</p>
<p class="text">${plan.collaboratorPrice * collaboratorsNumber}</p>
<p class="text">Additional members ({collaboratorsNumber})</p>
<p class="text">${collaboratorPrice * collaboratorsNumber}</p>
</span>
{/if}
<div class="u-sep-block-start" />
@@ -80,8 +80,8 @@
</span>
<p class="text u-margin-block-start-16">
This amount and any extra usage fees will be charged on a recurring 30 day billing cycle
after your trial period ends on <b>{toLocaleDate(billingPayDate.toString())}</b>.
This amount and any additional usage fees will be charged on a recurring 30 day billing
cycle after your trial period ends on <b>{toLocaleDate(billingPayDate.toString())}</b>.
</p>
</div>
</WizardStep>
@@ -11,8 +11,11 @@
TableRow
} from '$lib/elements/table';
import { WizardStep } from '$lib/layout';
import { plansInfo } from '$lib/stores/billing';
import { changeOrganizationTier } from './store';
const plan = $plansInfo.plans.find((p) => p.$id === $changeOrganizationTier.billingPlan);
let email: string;
function addCollaborator() {
@@ -38,11 +41,12 @@
<Alert type="info">
{#if $changeOrganizationTier.billingPlan === 'tier-2'}
You can add unlimited organization members on the Scale plan at no cost. Each member
You can add unlimited organization members on the {plan.name} plan at no cost. Each member
added will receive an email invite to your organization on completion.
{:else if $changeOrganizationTier.billingPlan === 'tier-1'}
You can add unlimited organization members on the Pro plan for $15 each. Each member
added will receive an email invite to your organization on completion.
You can add unlimited organization members on the {plan.name} plan for
<b>${plan.memberAddon.price} each per month</b>. Each member added will receive an email
invite to your organization on completion.
{/if}
</Alert>
@@ -4,19 +4,19 @@
import { InputTextarea } from '$lib/elements/forms';
import { toLocaleDate } from '$lib/helpers/date';
import { WizardStep } from '$lib/layout';
import { tierToPlan } from '$lib/stores/billing';
import { plansInfo } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import { changeOrganizationFinalAction, changeOrganizationTier, isUpgrade } from './store';
let comment: string = null;
const plan = tierToPlan($changeOrganizationTier.billingPlan);
const plan = $plansInfo.plans.find((p) => p.$id === $changeOrganizationTier.billingPlan);
const collaboratorPrice = plan?.memberAddon?.price ?? 0;
const collaboratorsNumber = $changeOrganizationTier?.collaborators?.length ?? 0;
const totalExpences = plan.price + plan.collaboratorPrice * collaboratorsNumber;
const totalExpences = plan.price + collaboratorPrice * collaboratorsNumber;
const today = new Date();
const billingPayDate = new Date(today.getTime() + 44 * 24 * 60 * 60 * 1000);
let comment: string = null;
async function fetchCard() {
try {
const card = await sdk.forConsole.billing.getPaymentMethod(
@@ -93,8 +93,8 @@
<p class="text">${plan.price}</p>
</span>
<span class="u-flex u-main-space-between">
<p class="text">Invited members</p>
<p class="text">${plan.collaboratorPrice * collaboratorsNumber}</p>
<p class="text">Additional members ({collaboratorsNumber})</p>
<p class="text">${collaboratorPrice * collaboratorsNumber}</p>
</span>
{/if}
<div class="u-sep-block-start" />
@@ -104,8 +104,8 @@
</span>
<p class="text u-margin-block-start-16">
This amount and any extra usage fees will be charged on a recurring 30 day billing
cycle after your trial period ends on <b
This amount and any additional usage fees will be charged on a recurring 30 day
billing cycle after your trial period ends on <b
>{toLocaleDate(billingPayDate.toString())}</b
>.
</p>