1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 23:33:31 +00:00

Add tax information to provider setup component when FF is on. (#8616)

This commit is contained in:
Alex Morask
2024-04-10 14:10:47 -04:00
committed by GitHub
parent 4a3cd24510
commit 4c2afb4121
10 changed files with 80 additions and 26 deletions

View File

@@ -279,10 +279,7 @@
/>
</div>
</div>
<div
class="col-6"
*ngIf="organizationId && taxInfo.country !== 'US' && countrySupportsTax(taxInfo.country)"
>
<div class="col-6" *ngIf="showTaxIdCheckbox">
<div class="form-group form-check">
<input
class="form-check-input"
@@ -295,21 +292,22 @@
</div>
</div>
</div>
<div
class="row"
*ngIf="organizationId && taxInfo.includeTaxId && countrySupportsTax(taxInfo.country)"
>
<div class="row" *ngIf="showTaxIdFields">
<div class="col-6">
<div class="form-group">
<label for="taxId">{{ "taxIdNumber" | i18n }}</label>
<input id="taxId" class="form-control" type="text" name="taxId" [(ngModel)]="taxInfo.taxId" />
<input
id="taxId"
class="form-control"
type="text"
name="taxId"
[(ngModel)]="taxInfo.taxId"
[required]="taxInfo.includeTaxId"
/>
</div>
</div>
</div>
<div
class="row"
*ngIf="organizationId && taxInfo.includeTaxId && countrySupportsTax(taxInfo.country)"
>
<div class="row" *ngIf="showTaxIdFields">
<div class="col-6">
<div class="form-group">
<label for="addressLine1">{{ "address1" | i18n }}</label>

View File

@@ -3,7 +3,7 @@ import { ActivatedRoute } from "@angular/router";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
import { OrganizationTaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/organization-tax-info-update.request";
import { ExpandedTaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/expanded-tax-info-update.request";
import { TaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/tax-info-update.request";
import { TaxInfoResponse } from "@bitwarden/common/billing/models/response/tax-info.response";
import { TaxRateResponse } from "@bitwarden/common/billing/models/response/tax-rate.response";
@@ -29,6 +29,7 @@ export class TaxInfoComponent {
loading = true;
organizationId: string;
providerId: string;
taxInfo: TaxInfoView = {
taxId: null,
line1: null,
@@ -61,6 +62,12 @@ export class TaxInfoComponent {
) {}
async ngOnInit() {
// Provider setup
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
this.route.queryParams.subscribe((params) => {
this.providerId = params.providerId;
});
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
this.route.parent.parent.params.subscribe(async (params) => {
this.organizationId = params.organizationId;
@@ -126,9 +133,25 @@ export class TaxInfoComponent {
}
}
get showTaxIdCheckbox() {
return (
(this.organizationId || this.providerId) &&
this.taxInfo.country !== "US" &&
this.countrySupportsTax(this.taxInfo.country)
);
}
get showTaxIdFields() {
return (
(this.organizationId || this.providerId) &&
this.taxInfo.includeTaxId &&
this.countrySupportsTax(this.taxInfo.country)
);
}
getTaxInfoRequest(): TaxInfoUpdateRequest {
if (this.organizationId) {
const request = new OrganizationTaxInfoUpdateRequest();
if (this.organizationId || this.providerId) {
const request = new ExpandedTaxInfoUpdateRequest();
request.country = this.taxInfo.country;
request.postalCode = this.taxInfo.postalCode;
@@ -164,7 +187,7 @@ export class TaxInfoComponent {
return this.organizationId
? this.organizationApiService.updateTaxInfo(
this.organizationId,
request as OrganizationTaxInfoUpdateRequest,
request as ExpandedTaxInfoUpdateRequest,
)
: this.apiService.putTaxInfo(request);
}