Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: invoice cycle changes #1331

Merged
merged 103 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
c67fea4
update create
lohanidamodar Aug 28, 2024
708517a
authorize payment
lohanidamodar Aug 28, 2024
eec5c6f
support taxid and budget while creating
lohanidamodar Aug 29, 2024
414bc60
handle validation
lohanidamodar Aug 29, 2024
c97e372
fix check with cloud
lohanidamodar Sep 3, 2024
b568e85
improve
lohanidamodar Sep 3, 2024
4376c93
Merge remote-tracking branch 'origin/main' into poc-invoice-cycle-ref
lohanidamodar Sep 19, 2024
acff39b
Merge remote-tracking branch 'origin/main' into poc-invoice-cycle-ref
lohanidamodar Nov 11, 2024
81d4ad8
remove unused
lohanidamodar Nov 11, 2024
c7a9e26
allow scale selection
lohanidamodar Nov 11, 2024
f29ca9a
update plan upgrade
lohanidamodar Nov 14, 2024
7b12f36
reset delete message
lohanidamodar Nov 14, 2024
9d7e866
Merge remote-tracking branch 'origin/main' into poc-invoice-cycle-ref
lohanidamodar Nov 27, 2024
6c97f04
fix taxid
lohanidamodar Dec 2, 2024
c1e87a2
updated pricing.
ItzNotABug Dec 16, 2024
660bddd
Merge remote-tracking branch 'origin/main' into poc-invoice-cycle-ref
lohanidamodar Dec 18, 2024
bcbf5c7
address comments.
ItzNotABug Dec 19, 2024
b6a517a
ran: formatter.
ItzNotABug Dec 19, 2024
ed9f145
Merge branch 'appwrite:poc-invoice-cycle-ref' into poc-invoice-cycle-ref
ItzNotABug Dec 19, 2024
8673209
update models
lohanidamodar Dec 22, 2024
8fdf7c5
refactor and get current plan from aggregation
lohanidamodar Dec 22, 2024
1ee29b2
update summary
lohanidamodar Dec 22, 2024
10195f4
Merge remote-tracking branch 'origin/main' into poc-invoice-cycle-ref
lohanidamodar Dec 23, 2024
16705d3
fix rename
lohanidamodar Dec 23, 2024
14a0cac
refactor
lohanidamodar Dec 23, 2024
9f517bd
improvements on error
lohanidamodar Dec 23, 2024
723da2c
Merge remote-tracking branch 'origin/main' into poc-invoice-cycle-ref
lohanidamodar Dec 24, 2024
3c1c4ed
credit support from plan
lohanidamodar Dec 24, 2024
b696c6c
option to cancel downgrade
lohanidamodar Dec 24, 2024
fb926d9
cancel downgrade
lohanidamodar Dec 24, 2024
f09bbc2
Merge branch 'poc-invoice-cycle-ref' into poc-invoice-cycle-ref
ItzNotABug Dec 29, 2024
81e5d0d
refactor types
lohanidamodar Dec 30, 2024
34f0727
ci: empty commit
ItzNotABug Jan 9, 2025
5d84c3b
fix types
lohanidamodar Jan 12, 2025
3ed6edf
Merge pull request #1565 from ItzNotABug/poc-invoice-cycle-ref
lohanidamodar Jan 13, 2025
ff25151
Merge branch 'poc-invoice-cycle-ref' of github.com:appwrite/console i…
lohanidamodar Jan 13, 2025
31b1467
use new estimation api for update plan and create organiation
lohanidamodar Jan 14, 2025
d401ade
fixes
lohanidamodar Jan 15, 2025
293eac0
refactor plan selection
lohanidamodar Jan 15, 2025
1973a23
Merge remote-tracking branch 'origin/main' into poc-invoice-cycle-ref
lohanidamodar Jan 15, 2025
c567681
fix after sync
lohanidamodar Jan 15, 2025
8c9c413
fix coupon
lohanidamodar Jan 15, 2025
9553df7
fix history not showing
lohanidamodar Jan 15, 2025
dee3b53
fix summary
lohanidamodar Jan 15, 2025
654718d
fix errors
lohanidamodar Jan 19, 2025
67aeaed
fixes to applying coupon
lohanidamodar Jan 20, 2025
d64de90
improve estimatie total
lohanidamodar Jan 20, 2025
e696d0c
check estimation before delete flow
lohanidamodar Jan 20, 2025
2f36ff2
remove unused code
lohanidamodar Jan 20, 2025
09ba618
fix check
lohanidamodar Jan 20, 2025
0cb3512
Fix review comments and errors
lohanidamodar Jan 26, 2025
dda2fd8
update review comments
lohanidamodar Jan 26, 2025
8e994cb
remove old component
lohanidamodar Jan 26, 2025
6e6daca
removed unused change
lohanidamodar Jan 26, 2025
27c5453
more review fixes
lohanidamodar Jan 26, 2025
cc0f655
fix component
lohanidamodar Jan 26, 2025
f3a28cd
remove duplicates
lohanidamodar Jan 26, 2025
acb814b
fix function definiation
lohanidamodar Jan 26, 2025
4fbd814
Merge remote-tracking branch 'origin/main' into poc-invoice-cycle-ref
lohanidamodar Jan 26, 2025
dccfb28
fix new org error
lohanidamodar Jan 26, 2025
609cf5f
fix button state
lohanidamodar Jan 26, 2025
4fb76da
fix alert
lohanidamodar Jan 27, 2025
d9fe601
fix spacing
lohanidamodar Jan 28, 2025
429c7da
bring back credits modal
lohanidamodar Jan 28, 2025
a75af80
update designs
lohanidamodar Jan 28, 2025
c52db33
fix alert
lohanidamodar Jan 28, 2025
47d0b32
review improvements
lohanidamodar Jan 29, 2025
269bf9f
fix formatting
lohanidamodar Jan 29, 2025
079b7b5
fix refactor
lohanidamodar Jan 29, 2025
3c37336
remove unused code
lohanidamodar Jan 29, 2025
65720b2
improve delete organization
lohanidamodar Jan 29, 2025
9be7e17
bind data
lohanidamodar Jan 30, 2025
998e6ab
fix downgrade info
lohanidamodar Jan 30, 2025
d0747b8
fix information on downgrade
lohanidamodar Jan 30, 2025
e53e305
unused code
lohanidamodar Jan 30, 2025
6b69f55
Update src/routes/(console)/create-organization/+page.svelte
lohanidamodar Jan 30, 2025
8abab80
update downgrade info
lohanidamodar Feb 2, 2025
4246d48
fix issue
lohanidamodar Feb 2, 2025
f28fcd6
update cancel model
lohanidamodar Feb 2, 2025
d31b971
Merge remote-tracking branch 'origin/main' into poc-invoice-cycle-ref
lohanidamodar Feb 2, 2025
bcfd428
fix alert
lohanidamodar Feb 3, 2025
9486712
format
lohanidamodar Feb 3, 2025
91988fa
refactor downgrade alerts
lohanidamodar Feb 4, 2025
c320009
fix new dev pro banner
lohanidamodar Feb 4, 2025
ab14064
fix comment
lohanidamodar Feb 4, 2025
2dd1e9a
fix alert type
lohanidamodar Feb 5, 2025
856b994
fix free downgrade
lohanidamodar Feb 5, 2025
9ae763d
updates
lohanidamodar Feb 5, 2025
b5d7230
Merge remote-tracking branch 'origin/main' into poc-invoice-cycle-ref
lohanidamodar Feb 11, 2025
2caad83
renaming constants
lohanidamodar Feb 11, 2025
c234c0c
Fix check issues
lohanidamodar Feb 13, 2025
ef6c421
Fix analysis issues 2
lohanidamodar Feb 13, 2025
5afae81
check success
lohanidamodar Feb 13, 2025
4132c03
fix error
lohanidamodar Feb 14, 2025
723b5d3
Merge remote-tracking branch 'origin/main' into poc-invoice-cycle-ref
lohanidamodar Feb 14, 2025
c72b768
fix missing await
lohanidamodar Feb 14, 2025
602f1cb
format
lohanidamodar Feb 14, 2025
80fb6ce
update endpoint for test
lohanidamodar Feb 14, 2025
1d9a1c5
Fix info
lohanidamodar Feb 14, 2025
2880967
Use constant
lohanidamodar Feb 14, 2025
55dceee
Update src/lib/constants.ts
lohanidamodar Feb 14, 2025
178698e
fix typo
lohanidamodar Feb 14, 2025
cfe49e0
Merge remote-tracking branch 'origin/main' into poc-invoice-cycle-ref
lohanidamodar Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const config: PlaywrightTestConfig = {
webServer: {
timeout: 120000,
env: {
PUBLIC_APPWRITE_ENDPOINT: 'https://console-testing-2.appwrite.org/v1',
PUBLIC_APPWRITE_ENDPOINT: 'https://dlbillingic.appwrite.org/v1',
PUBLIC_CONSOLE_MODE: 'cloud',
PUBLIC_STRIPE_KEY:
'pk_test_51LT5nsGYD1ySxNCyd7b304wPD8Y1XKKWR6hqo6cu3GIRwgvcVNzoZv4vKt5DfYXL1gRGw4JOqE19afwkJYJq1g3K004eVfpdWn'
Expand Down
2 changes: 1 addition & 1 deletion src/lib/commandCenter/searchers/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sdk } from '$lib/stores/sdk';
import type { Searcher } from '../commands';

export const orgSearcher = (async (query: string) => {
const { teams } = await sdk.forConsole.teams.list();
const { teams } = await sdk.forConsole.billing.listOrganization();
return teams
.filter((organization) => organization.name.toLowerCase().includes(query.toLowerCase()))
.map((organization) => {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/billing/alerts/newDevUpgradePro.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { base } from '$app/paths';
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
import { BillingPlan } from '$lib/constants';
import { BillingPlan, NEW_DEV_PRO_UPGRADE_COUPON } from '$lib/constants';
import { Button } from '$lib/elements/forms';
import { organization } from '$lib/stores/organization';
import { activeHeaderAlert } from '$routes/(console)/store';
Expand All @@ -29,7 +29,7 @@
secondary
fullWidthMobile
class="u-line-height-1"
href={`${base}/apply-credit?code=appw50&org=${$organization.$id}`}
href={`${base}/apply-credit?code=${NEW_DEV_PRO_UPGRADE_COUPON}&org=${$organization.$id}`}
on:click={() => {
trackEvent('click_credits_redeem', {
from: 'button',
Expand Down
47 changes: 47 additions & 0 deletions src/lib/components/billing/discountsApplied.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<script lang="ts">
import { formatCurrency } from '$lib/helpers/numbers';
import type { Coupon } from '$lib/sdk/billing';

export let label: string;
export let value: number;
export let couponData: Partial<Coupon> = {
code: null,
status: null,
credits: null
};
export let fixedCoupon = false;
</script>

{#if value > 0}
<span class="u-flex u-main-space-between">
<div class="u-flex u-cross-center u-gap-4">
<p class="text">
<span class="icon-tag u-color-text-success" aria-hidden="true" />
<span>
{label}
</span>
</p>
{#if !fixedCoupon && label.toLowerCase() === 'credits'}
<button
type="button"
class="button is-text is-only-icon"
style="--button-size:1.5rem;"
aria-label="Close"
title="Close"
on:click={() =>
(couponData = {
code: null,
status: null,
credits: null
})}>
<span class="icon-x" aria-hidden="true" />
</button>
{/if}
</div>
{#if value >= 100}
<p class="inline-tag">Credits applied</p>
{:else}
<span class="u-color-text-success">-{formatCurrency(value)}</span>
{/if}
</span>
{/if}
146 changes: 146 additions & 0 deletions src/lib/components/billing/estimatedTotal.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<script lang="ts">
import { FormList, InputChoice, InputNumber } from '$lib/elements/forms';
import { formatCurrency } from '$lib/helpers/numbers';
import type { Coupon, Estimation } from '$lib/sdk/billing';
import { sdk } from '$lib/stores/sdk';
import { AppwriteException } from '@appwrite.io/console';
import Card from '../card.svelte';
import DiscountsApplied from './discountsApplied.svelte';
import { addNotification } from '$lib/stores/notifications';

export let organizationId: string | undefined = undefined;
export let billingPlan: string;
export let collaborators: string[];
export let fixedCoupon = false;
export let couponData: Partial<Coupon>;

export let billingBudget: number;

let budgetEnabled = false;
let estimation: Estimation;

async function getEstimate(
billingPlan: string,
collaborators: string[],
couponId: string | undefined
) {
try {
estimation = await sdk.forConsole.billing.estimationCreateOrganization(
billingPlan,
couponId === '' ? null : couponId,
collaborators ?? []
);
} catch (e) {
if (e instanceof AppwriteException) {
if (
e.type === 'billing_coupon_not_found' ||
e.type === 'billing_coupon_already_used' ||
e.type === 'billing_credit_unsupported'
) {
couponData = {
code: null,
status: null,
credits: null
};
}
}
addNotification({
type: 'error',
isHtml: false,
message: e.message
});
}
}

async function getUpdatePlanEstimate(
organizationId: string,
billingPlan: string,
collaborators: string[],
couponId: string | undefined
) {
try {
estimation = await sdk.forConsole.billing.estimationUpdatePlan(
organizationId,
billingPlan,
couponId && couponId.length > 0 ? couponId : null,
collaborators ?? []
);
} catch (e) {
if (e instanceof AppwriteException) {
if (
e.type === 'billing_coupon_not_found' ||
e.type === 'billing_coupon_already_used' ||
e.type === 'billing_credit_unsupported'
) {
couponData = {
code: null,
status: null,
credits: null
};
}
}
addNotification({
type: 'error',
isHtml: false,
message: e.message
});
}
}

$: organizationId
? getUpdatePlanEstimate(organizationId, billingPlan, collaborators, couponData?.code)
: getEstimate(billingPlan, collaborators, couponData?.code);
</script>

{#if estimation}
<Card class="u-flex u-flex-vertical u-gap-8">
<slot />
{#if estimation}
{#each estimation.items ?? [] as item}
{#if item.value > 0}
<span class="u-flex u-main-space-between">
<p class="text">{item.label}</p>
<p class="text">{formatCurrency(item.value)}</p>
</span>
{/if}
{/each}
{#each estimation.discounts ?? [] as item}
<DiscountsApplied {fixedCoupon} bind:couponData {...item} />
{/each}
<div class="u-sep-block-start" />
<span class="u-flex u-main-space-between">
<p class="text">Total due</p>
<p class="text">
{formatCurrency(estimation.grossAmount)}
</p>
</span>

<p class="text u-margin-block-start-16">
You'll pay <span class="u-bold">{formatCurrency(estimation.grossAmount)}</span> now.
{#if couponData?.code}Once your credits run out,{:else}Then{/if} you'll be charged
<span class="u-bold">{formatCurrency(estimation.amount)}</span> every 30 days.
</p>
{/if}

<FormList class="u-margin-block-start-24">
<InputChoice
type="switchbox"
id="budget"
label="Enable budget cap"
tooltip="If enabled, you will be notified when your spending reaches 75% of the set cap. Update cap alerts in your organization settings."
fullWidth
bind:value={budgetEnabled}>
{#if budgetEnabled}
<div class="u-margin-block-start-16">
<InputNumber
id="budget"
label="Budget cap (USD)"
placeholder="0"
min={0}
bind:value={billingBudget} />
</div>
{/if}
</InputChoice>
</FormList>
</Card>
{/if}
99 changes: 0 additions & 99 deletions src/lib/components/billing/estimatedTotalBox.svelte

This file was deleted.

3 changes: 2 additions & 1 deletion src/lib/components/billing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ export { default as PaymentBoxes } from './paymentBoxes.svelte';
export { default as CouponInput } from './couponInput.svelte';
export { default as SelectPaymentMethod } from './selectPaymentMethod.svelte';
export { default as UsageRates } from './usageRates.svelte';
export { default as EstimatedTotalBox } from './estimatedTotalBox.svelte';
export { default as PlanComparisonBox } from './planComparisonBox.svelte';
export { default as EmptyCardCloud } from './emptyCardCloud.svelte';
export { default as CreditsApplied } from './creditsApplied.svelte';
export { default as PlanSelection } from './planSelection.svelte';
export { default as EstimatedTotal } from './estimatedTotal.svelte';
export { default as SelectPlan } from './selectPlan.svelte';
Loading