From 7ffbdf4dd16b7b8953701b6f1d3e0843b5220795 Mon Sep 17 00:00:00 2001 From: Jonas Hendrickx Date: Mon, 23 Dec 2024 15:29:00 +0100 Subject: [PATCH] exclude personal plans from entering tax id --- .../premium/premium-v2.component.ts | 2 -- .../individual/premium/premium.component.ts | 1 - .../organization-plans.component.html | 1 + .../organization-plans.component.ts | 10 ++++++++++ .../organization-payment-method.component.ts | 7 +++---- .../adjust-payment-dialog-v2.component.html | 1 + .../adjust-payment-dialog-v2.component.ts | 20 +++++++++++++++++-- .../adjust-payment-dialog.component.html | 1 + .../adjust-payment-dialog.component.ts | 4 ++++ .../billing/shared/tax-info.component.html | 2 +- .../app/billing/shared/tax-info.component.ts | 4 ++++ .../manage-tax-information.component.html | 2 +- .../manage-tax-information.component.ts | 1 + .../preview-individual-invoice.request.ts | 2 +- 14 files changed, 46 insertions(+), 12 deletions(-) diff --git a/apps/web/src/app/billing/individual/premium/premium-v2.component.ts b/apps/web/src/app/billing/individual/premium/premium-v2.component.ts index 107b6f773a3..2abab57b7e0 100644 --- a/apps/web/src/app/billing/individual/premium/premium-v2.component.ts +++ b/apps/web/src/app/billing/individual/premium/premium-v2.component.ts @@ -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(); @@ -197,7 +196,6 @@ export class PremiumV2Component { taxInformation: { postalCode: this.taxInfoComponent.postalCode, country: this.taxInfoComponent.country, - taxId: this.taxInfoComponent.taxId, }, }; diff --git a/apps/web/src/app/billing/individual/premium/premium.component.ts b/apps/web/src/app/billing/individual/premium/premium.component.ts index cfed884123c..76ca25c8cc6 100644 --- a/apps/web/src/app/billing/individual/premium/premium.component.ts +++ b/apps/web/src/app/billing/individual/premium/premium.component.ts @@ -186,7 +186,6 @@ export class PremiumComponent implements OnInit { taxInformation: { postalCode: this.taxInfoComponent.postalCode, country: this.taxInfoComponent.country, - taxId: this.taxInfoComponent.taxId, }, }; diff --git a/apps/web/src/app/billing/organizations/organization-plans.component.html b/apps/web/src/app/billing/organizations/organization-plans.component.html index 3bb25cf1524..d37f95e3aa2 100644 --- a/apps/web/src/app/billing/organizations/organization-plans.component.html +++ b/apps/web/src/app/billing/organizations/organization-plans.component.html @@ -442,6 +442,7 @@

> diff --git a/apps/web/src/app/billing/organizations/organization-plans.component.ts b/apps/web/src/app/billing/organizations/organization-plans.component.ts index 2925d9d794a..4592f8de894 100644 --- a/apps/web/src/app/billing/organizations/organization-plans.component.ts +++ b/apps/web/src/app/billing/organizations/organization-plans.component.ts @@ -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; diff --git a/apps/web/src/app/billing/organizations/payment-method/organization-payment-method.component.ts b/apps/web/src/app/billing/organizations/payment-method/organization-payment-method.component.ts index 8a11f8c5dd6..270ba54f70d 100644 --- a/apps/web/src/app/billing/organizations/payment-method/organization-payment-method.component.ts +++ b/apps/web/src/app/billing/organizations/payment-method/organization-payment-method.component.ts @@ -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"; @@ -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, @@ -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; @@ -154,6 +151,7 @@ export class OrganizationPaymentMethodComponent implements OnDestroy { data: { initialPaymentMethod: this.paymentSource?.type, organizationId: this.organizationId, + productTier: this.organization?.productTierType, }, }); @@ -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); diff --git a/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog-v2.component.html b/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog-v2.component.html index 1767fb485d0..bb06f87ca03 100644 --- a/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog-v2.component.html +++ b/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog-v2.component.html @@ -7,6 +7,7 @@ > diff --git a/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog-v2.component.ts b/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog-v2.component.ts index a5e241014a1..4660ab703f8 100644 --- a/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog-v2.component.ts +++ b/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog-v2.component.ts @@ -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"; @@ -21,6 +21,7 @@ import { PaymentV2Component } from "../payment/payment-v2.component"; export interface AdjustPaymentDialogV2Params { initialPaymentMethod?: PaymentMethodType; organizationId?: string; + productTier?: ProductTierType; } export enum AdjustPaymentDialogV2ResultType { @@ -42,6 +43,7 @@ export class AdjustPaymentDialogV2Component implements OnInit { protected dialogHeader: string; protected initialPaymentMethod: PaymentMethodType; protected organizationId?: string; + protected productTier?: ProductTierType; protected taxInformation: TaxInformation; @@ -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(); diff --git a/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog.component.html b/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog.component.html index 9979fbd6907..de607314354 100644 --- a/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog.component.html +++ b/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog.component.html @@ -7,6 +7,7 @@ diff --git a/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog.component.ts b/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog.component.ts index 9186594c668..bbae5099afa 100644 --- a/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog.component.ts +++ b/apps/web/src/app/billing/shared/adjust-payment-dialog/adjust-payment-dialog.component.ts @@ -123,6 +123,10 @@ export class AdjustPaymentDialogComponent implements OnInit { } } } + + protected get showTaxIdField(): boolean { + return !!this.organizationId; + } } /** diff --git a/apps/web/src/app/billing/shared/tax-info.component.html b/apps/web/src/app/billing/shared/tax-info.component.html index 3955c0db816..4a42c0c1109 100644 --- a/apps/web/src/app/billing/shared/tax-info.component.html +++ b/apps/web/src/app/billing/shared/tax-info.component.html @@ -43,7 +43,7 @@ -
+
{{ "taxIdNumber" | i18n }} diff --git a/apps/web/src/app/billing/shared/tax-info.component.ts b/apps/web/src/app/billing/shared/tax-info.component.ts index c45cbd991c0..214364e4cf2 100644 --- a/apps/web/src/app/billing/shared/tax-info.component.ts +++ b/apps/web/src/app/billing/shared/tax-info.component.ts @@ -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 diff --git a/libs/angular/src/billing/components/manage-tax-information/manage-tax-information.component.html b/libs/angular/src/billing/components/manage-tax-information/manage-tax-information.component.html index fbd8af4f8b9..3f635656fb7 100644 --- a/libs/angular/src/billing/components/manage-tax-information/manage-tax-information.component.html +++ b/libs/angular/src/billing/components/manage-tax-information/manage-tax-information.component.html @@ -44,7 +44,7 @@
-
+
{{ "taxIdNumber" | i18n }} diff --git a/libs/angular/src/billing/components/manage-tax-information/manage-tax-information.component.ts b/libs/angular/src/billing/components/manage-tax-information/manage-tax-information.component.ts index 67091875b1a..13a6d2d0cc3 100644 --- a/libs/angular/src/billing/components/manage-tax-information/manage-tax-information.component.ts +++ b/libs/angular/src/billing/components/manage-tax-information/manage-tax-information.component.ts @@ -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; + @Input() showTaxIdField: boolean = true; /** * Emits when the tax information has changed. diff --git a/libs/common/src/billing/models/request/preview-individual-invoice.request.ts b/libs/common/src/billing/models/request/preview-individual-invoice.request.ts index 67b7b2f3ee6..2584591ac96 100644 --- a/libs/common/src/billing/models/request/preview-individual-invoice.request.ts +++ b/libs/common/src/billing/models/request/preview-individual-invoice.request.ts @@ -1,3 +1,4 @@ +// @ts-strict-ignore export class PreviewIndividualInvoiceRequest { passwordManager: PasswordManager; taxInformation: TaxInformation; @@ -10,5 +11,4 @@ class PasswordManager { class TaxInformation { postalCode: string; country: string; - taxId: string; }