Skip to content

Commit

Permalink
exclude personal plans from entering tax id
Browse files Browse the repository at this point in the history
  • Loading branch information
jonashendrickx committed Dec 23, 2024
1 parent ba0596b commit 7ffbdf4
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ export class PremiumV2Component {
formData.append("additionalStorageGb", this.addOnFormGroup.value.additionalStorage.toString());
formData.append("country", this.taxInfoComponent.country);
formData.append("postalCode", this.taxInfoComponent.postalCode);
formData.append("taxId", this.taxInfoComponent.taxId);

await this.apiService.postPremium(formData);
await this.finalizeUpgrade();
Expand Down Expand Up @@ -197,7 +196,6 @@ export class PremiumV2Component {
taxInformation: {
postalCode: this.taxInfoComponent.postalCode,
country: this.taxInfoComponent.country,
taxId: this.taxInfoComponent.taxId,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ export class PremiumComponent implements OnInit {
taxInformation: {
postalCode: this.taxInfoComponent.postalCode,
country: this.taxInfoComponent.country,
taxId: this.taxInfoComponent.taxId,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ <h2 bitTypography="h2">
></app-payment-v2>
<app-manage-tax-information
class="tw-my-4"
[showTaxIdField]="showTaxIdField"
[startWith]="taxInformation"
(taxInformationChanged)="onTaxInformationChanged($event)"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,16 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {
this.messagingService.send("organizationCreated", { organizationId });
};

protected get showTaxIdField(): boolean {
switch (this.formGroup.controls.productTier.value) {
case ProductTierType.Free:
case ProductTierType.Families:
return false;
default:
return true;
}
}

private refreshSalesTax(): void {
if (this.formGroup.controls.plan.value == PlanType.Free) {
this.estimatedTax = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { Location } from "@angular/common";
import { Component, OnDestroy, ViewChild } from "@angular/core";
import { Component, OnDestroy } from "@angular/core";
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
import { ActivatedRoute, Router } from "@angular/router";
import { from, lastValueFrom, switchMap } from "rxjs";
Expand All @@ -21,7 +21,6 @@ import { DialogService, ToastService } from "@bitwarden/components";

import { FreeTrial } from "../../../core/types/free-trial";
import { TrialFlowService } from "../../services/trial-flow.service";
import { TaxInfoComponent } from "../../shared";
import {
AddCreditDialogResult,
openAddCreditDialog,
Expand All @@ -35,8 +34,6 @@ import {
templateUrl: "./organization-payment-method.component.html",
})
export class OrganizationPaymentMethodComponent implements OnDestroy {
@ViewChild(TaxInfoComponent) taxInfoComponent: TaxInfoComponent;

organizationId: string;
isUnpaid = false;
accountCredit: number;
Expand Down Expand Up @@ -154,6 +151,7 @@ export class OrganizationPaymentMethodComponent implements OnDestroy {
data: {
initialPaymentMethod: this.paymentSource?.type,
organizationId: this.organizationId,
productTier: this.organization?.productTierType,
},
});

Expand All @@ -169,6 +167,7 @@ export class OrganizationPaymentMethodComponent implements OnDestroy {
data: {
initialPaymentMethod: this.paymentSource?.type,
organizationId: this.organizationId,
productTier: this.organization?.productTierType,
},
});
const result = await lastValueFrom(dialogRef.closed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
></app-payment-v2>
<app-manage-tax-information
*ngIf="taxInformation"
[showTaxIdField]="showTaxIdField"
[startWith]="taxInformation"
(taxInformationChanged)="taxInformationChanged($event)"
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { DIALOG_DATA, DialogConfig, DialogRef } from "@angular/cdk/dialog";
import { forwardRef, Component, Inject, ViewChild, OnInit } from "@angular/core";
import { Component, forwardRef, Inject, OnInit, ViewChild } from "@angular/core";

import { ManageTaxInformationComponent } from "@bitwarden/angular/billing/components";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
import { BillingApiServiceAbstraction } from "@bitwarden/common/billing/abstractions";
import { PaymentMethodType } from "@bitwarden/common/billing/enums";
import { PaymentMethodType, ProductTierType } from "@bitwarden/common/billing/enums";
import { TaxInformation } from "@bitwarden/common/billing/models/domain";
import { ExpandedTaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/expanded-tax-info-update.request";
import { PaymentRequest } from "@bitwarden/common/billing/models/request/payment.request";
Expand All @@ -21,6 +21,7 @@ import { PaymentV2Component } from "../payment/payment-v2.component";
export interface AdjustPaymentDialogV2Params {
initialPaymentMethod?: PaymentMethodType;
organizationId?: string;
productTier?: ProductTierType;
}

export enum AdjustPaymentDialogV2ResultType {
Expand All @@ -42,6 +43,7 @@ export class AdjustPaymentDialogV2Component implements OnInit {
protected dialogHeader: string;
protected initialPaymentMethod: PaymentMethodType;
protected organizationId?: string;
protected productTier?: ProductTierType;

protected taxInformation: TaxInformation;

Expand Down Expand Up @@ -124,6 +126,20 @@ export class AdjustPaymentDialogV2Component implements OnInit {
await this.billingApiService.updateOrganizationPaymentMethod(this.organizationId, request);
};

protected get showTaxIdField(): boolean {
if (!this.organizationId) {
return false;
}

switch (this.productTier) {
case ProductTierType.Free:
case ProductTierType.Families:
return false;
default:
return true;
}
}

private updatePremiumUserPaymentMethod = async () => {
const { type, token } = await this.paymentComponent.tokenize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<app-payment [hideBank]="!organizationId" [hideCredit]="true"></app-payment>
<app-manage-tax-information
*ngIf="taxInformation"
[showTaxIdField]="showTaxIdField"
[startWith]="taxInformation"
(taxInformationChanged)="taxInformationChanged($event)"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ export class AdjustPaymentDialogComponent implements OnInit {
}
}
}

protected get showTaxIdField(): boolean {
return !!this.organizationId;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/billing/shared/tax-info.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<input bitInput type="text" formControlName="state" autocomplete="address-level1" />
</bit-form-field>
</div>
<div class="tw-col-span-6" *ngIf="isTaxSupported">
<div class="tw-col-span-6" *ngIf="isTaxSupported && showTaxIdField">
<bit-form-field>
<bit-label>{{ "taxIdNumber" | i18n }}</bit-label>
<input bitInput type="text" formControlName="taxId" />
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/app/billing/shared/tax-info.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ export class TaxInfoComponent implements OnInit, OnDestroy {
return this.taxFormGroup.controls.state.value;
}

get showTaxIdField(): boolean {
return !!this.organizationId;
}

async ngOnInit() {
// Provider setup
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<input bitInput type="text" formControlName="state" autocomplete="address-level1" />
</bit-form-field>
</div>
<div class="tw-col-span-6">
<div class="tw-col-span-6" *ngIf="showTaxIdField">
<bit-form-field disableMargin>
<bit-label>{{ "taxIdNumber" | i18n }}</bit-label>
<input bitInput type="text" formControlName="taxId" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { CountryListItem, TaxInformation } from "@bitwarden/common/billing/model
export class ManageTaxInformationComponent implements OnInit, OnDestroy {
@Input() startWith: TaxInformation;
@Input() onSubmit?: (taxInformation: TaxInformation) => Promise<void>;
@Input() showTaxIdField: boolean = true;

/**
* Emits when the tax information has changed.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-strict-ignore
export class PreviewIndividualInvoiceRequest {
passwordManager: PasswordManager;
taxInformation: TaxInformation;
Expand All @@ -10,5 +11,4 @@ class PasswordManager {
class TaxInformation {
postalCode: string;
country: string;
taxId: string;
}

0 comments on commit 7ffbdf4

Please sign in to comment.