From 974e0701e6e4a67f8b627370212d8049cdd84494 Mon Sep 17 00:00:00 2001 From: Jonas Hendrickx Date: Thu, 28 Nov 2024 10:29:38 +0100 Subject: [PATCH] Revert "remove" This reverts commit f0413bd90d46d075803f01955c70be6c963a81be. --- ...organization-payment-method.component.html | 15 +++++++++ .../organization-payment-method.component.ts | 32 ++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/apps/web/src/app/billing/organizations/payment-method/organization-payment-method.component.html b/apps/web/src/app/billing/organizations/payment-method/organization-payment-method.component.html index 57844805f55..7a6e8558bae 100644 --- a/apps/web/src/app/billing/organizations/payment-method/organization-payment-method.component.html +++ b/apps/web/src/app/billing/organizations/payment-method/organization-payment-method.component.html @@ -63,5 +63,20 @@

{{ "paymentMethod" | i18n }}

{{ "paymentChargedWithUnpaidSubscription" | i18n }}

+ + +

{{ "taxInformation" | i18n }}

+

{{ "taxInformationDesc" | i18n }}

+ + +
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 d11fff22d72..e2178e7c02c 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,5 +1,5 @@ import { Location } from "@angular/common"; -import { Component, OnDestroy } from "@angular/core"; +import { Component, OnDestroy, ViewChild } from "@angular/core"; import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; import { ActivatedRoute, Router } from "@angular/router"; import { from, lastValueFrom, switchMap } from "rxjs"; @@ -9,6 +9,7 @@ import { OrganizationService } from "@bitwarden/common/admin-console/abstraction import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; import { BillingApiServiceAbstraction } from "@bitwarden/common/billing/abstractions"; import { PaymentMethodType } from "@bitwarden/common/billing/enums"; +import { ExpandedTaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/expanded-tax-info-update.request"; import { VerifyBankAccountRequest } from "@bitwarden/common/billing/models/request/verify-bank-account.request"; import { OrganizationSubscriptionResponse } from "@bitwarden/common/billing/models/response/organization-subscription.response"; import { PaymentSourceResponse } from "@bitwarden/common/billing/models/response/payment-source.response"; @@ -19,6 +20,7 @@ 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, @@ -32,6 +34,8 @@ import { templateUrl: "./organization-payment-method.component.html", }) export class OrganizationPaymentMethodComponent implements OnDestroy { + @ViewChild(TaxInfoComponent) taxInfoComponent: TaxInfoComponent; + organizationId: string; isUnpaid = false; accountCredit: number; @@ -177,6 +181,32 @@ export class OrganizationPaymentMethodComponent implements OnDestroy { } }; + protected updateTaxInformation = async (): Promise => { + this.taxInfoComponent.taxFormGroup.updateValueAndValidity(); + this.taxInfoComponent.taxFormGroup.markAllAsTouched(); + + if (this.taxInfoComponent.taxFormGroup.invalid) { + return; + } + + const request = new ExpandedTaxInfoUpdateRequest(); + request.country = this.taxInfoComponent.country; + request.postalCode = this.taxInfoComponent.postalCode; + request.taxId = this.taxInfoComponent.taxId; + request.line1 = this.taxInfoComponent.line1; + request.line2 = this.taxInfoComponent.line2; + request.city = this.taxInfoComponent.city; + request.state = this.taxInfoComponent.state; + + await this.billingApiService.updateOrganizationTaxInformation(this.organizationId, request); + + this.toastService.showToast({ + variant: "success", + title: null, + message: this.i18nService.t("taxInfoUpdated"), + }); + }; + protected verifyBankAccount = async (request: VerifyBankAccountRequest): Promise => { await this.billingApiService.verifyOrganizationBankAccount(this.organizationId, request); this.toastService.showToast({