mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 06:13:38 +00:00
Add tax information to provider setup component when FF is on. (#8616)
This commit is contained in:
@@ -279,10 +279,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="col-6" *ngIf="showTaxIdCheckbox">
|
||||||
class="col-6"
|
|
||||||
*ngIf="organizationId && taxInfo.country !== 'US' && countrySupportsTax(taxInfo.country)"
|
|
||||||
>
|
|
||||||
<div class="form-group form-check">
|
<div class="form-group form-check">
|
||||||
<input
|
<input
|
||||||
class="form-check-input"
|
class="form-check-input"
|
||||||
@@ -295,21 +292,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="row" *ngIf="showTaxIdFields">
|
||||||
class="row"
|
|
||||||
*ngIf="organizationId && taxInfo.includeTaxId && countrySupportsTax(taxInfo.country)"
|
|
||||||
>
|
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="taxId">{{ "taxIdNumber" | i18n }}</label>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="row" *ngIf="showTaxIdFields">
|
||||||
class="row"
|
|
||||||
*ngIf="organizationId && taxInfo.includeTaxId && countrySupportsTax(taxInfo.country)"
|
|
||||||
>
|
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="addressLine1">{{ "address1" | i18n }}</label>
|
<label for="addressLine1">{{ "address1" | i18n }}</label>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { ActivatedRoute } from "@angular/router";
|
|||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
|
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 { TaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/tax-info-update.request";
|
||||||
import { TaxInfoResponse } from "@bitwarden/common/billing/models/response/tax-info.response";
|
import { TaxInfoResponse } from "@bitwarden/common/billing/models/response/tax-info.response";
|
||||||
import { TaxRateResponse } from "@bitwarden/common/billing/models/response/tax-rate.response";
|
import { TaxRateResponse } from "@bitwarden/common/billing/models/response/tax-rate.response";
|
||||||
@@ -29,6 +29,7 @@ export class TaxInfoComponent {
|
|||||||
|
|
||||||
loading = true;
|
loading = true;
|
||||||
organizationId: string;
|
organizationId: string;
|
||||||
|
providerId: string;
|
||||||
taxInfo: TaxInfoView = {
|
taxInfo: TaxInfoView = {
|
||||||
taxId: null,
|
taxId: null,
|
||||||
line1: null,
|
line1: null,
|
||||||
@@ -61,6 +62,12 @@ export class TaxInfoComponent {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
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
|
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
|
||||||
this.route.parent.parent.params.subscribe(async (params) => {
|
this.route.parent.parent.params.subscribe(async (params) => {
|
||||||
this.organizationId = params.organizationId;
|
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 {
|
getTaxInfoRequest(): TaxInfoUpdateRequest {
|
||||||
if (this.organizationId) {
|
if (this.organizationId || this.providerId) {
|
||||||
const request = new OrganizationTaxInfoUpdateRequest();
|
const request = new ExpandedTaxInfoUpdateRequest();
|
||||||
request.country = this.taxInfo.country;
|
request.country = this.taxInfo.country;
|
||||||
request.postalCode = this.taxInfo.postalCode;
|
request.postalCode = this.taxInfo.postalCode;
|
||||||
|
|
||||||
@@ -164,7 +187,7 @@ export class TaxInfoComponent {
|
|||||||
return this.organizationId
|
return this.organizationId
|
||||||
? this.organizationApiService.updateTaxInfo(
|
? this.organizationApiService.updateTaxInfo(
|
||||||
this.organizationId,
|
this.organizationId,
|
||||||
request as OrganizationTaxInfoUpdateRequest,
|
request as ExpandedTaxInfoUpdateRequest,
|
||||||
)
|
)
|
||||||
: this.apiService.putTaxInfo(request);
|
: this.apiService.putTaxInfo(request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { FormsModule } from "@angular/forms";
|
|||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
import { SearchModule } from "@bitwarden/components";
|
import { SearchModule } from "@bitwarden/components";
|
||||||
import { OrganizationPlansComponent } from "@bitwarden/web-vault/app/billing";
|
import { OrganizationPlansComponent, TaxInfoComponent } from "@bitwarden/web-vault/app/billing";
|
||||||
import { PaymentMethodWarningsModule } from "@bitwarden/web-vault/app/billing/shared";
|
import { PaymentMethodWarningsModule } from "@bitwarden/web-vault/app/billing/shared";
|
||||||
import { OssModule } from "@bitwarden/web-vault/app/oss.module";
|
import { OssModule } from "@bitwarden/web-vault/app/oss.module";
|
||||||
|
|
||||||
@@ -39,6 +39,7 @@ import { SetupComponent } from "./setup/setup.component";
|
|||||||
SearchModule,
|
SearchModule,
|
||||||
ProvidersLayoutComponent,
|
ProvidersLayoutComponent,
|
||||||
PaymentMethodWarningsModule,
|
PaymentMethodWarningsModule,
|
||||||
|
TaxInfoComponent,
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
AcceptProviderComponent,
|
AcceptProviderComponent,
|
||||||
|
|||||||
@@ -25,6 +25,9 @@
|
|||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div *ngIf="enableConsolidatedBilling$ | async" class="form-group col-12">
|
||||||
|
<app-tax-info />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit, ViewChild } from "@angular/core";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
|
import { firstValueFrom } from "rxjs";
|
||||||
import { first } from "rxjs/operators";
|
import { first } from "rxjs/operators";
|
||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { ProviderSetupRequest } from "@bitwarden/common/admin-console/models/request/provider/provider-setup.request";
|
import { ProviderSetupRequest } from "@bitwarden/common/admin-console/models/request/provider/provider-setup.request";
|
||||||
|
import { ExpandedTaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/expanded-tax-info-update.request";
|
||||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
||||||
@@ -12,6 +14,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
|||||||
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||||
import { ProviderKey } from "@bitwarden/common/types/key";
|
import { ProviderKey } from "@bitwarden/common/types/key";
|
||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
|
import { TaxInfoComponent } from "@bitwarden/web-vault/app/billing";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "provider-setup",
|
selector: "provider-setup",
|
||||||
@@ -19,6 +22,8 @@ import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.serv
|
|||||||
})
|
})
|
||||||
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
|
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
|
||||||
export class SetupComponent implements OnInit {
|
export class SetupComponent implements OnInit {
|
||||||
|
@ViewChild(TaxInfoComponent) taxInfoComponent: TaxInfoComponent;
|
||||||
|
|
||||||
loading = true;
|
loading = true;
|
||||||
authed = false;
|
authed = false;
|
||||||
email: string;
|
email: string;
|
||||||
@@ -34,6 +39,11 @@ export class SetupComponent implements OnInit {
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected enableConsolidatedBilling$ = this.configService.getFeatureFlag$(
|
||||||
|
FeatureFlag.EnableConsolidatedBilling,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
@@ -102,6 +112,22 @@ export class SetupComponent implements OnInit {
|
|||||||
request.token = this.token;
|
request.token = this.token;
|
||||||
request.key = key;
|
request.key = key;
|
||||||
|
|
||||||
|
const enableConsolidatedBilling = await firstValueFrom(this.enableConsolidatedBilling$);
|
||||||
|
|
||||||
|
if (enableConsolidatedBilling) {
|
||||||
|
request.taxInfo = new ExpandedTaxInfoUpdateRequest();
|
||||||
|
const taxInfoView = this.taxInfoComponent.taxInfo;
|
||||||
|
request.taxInfo.country = taxInfoView.country;
|
||||||
|
request.taxInfo.postalCode = taxInfoView.postalCode;
|
||||||
|
if (taxInfoView.includeTaxId) {
|
||||||
|
request.taxInfo.taxId = taxInfoView.taxId;
|
||||||
|
request.taxInfo.line1 = taxInfoView.line1;
|
||||||
|
request.taxInfo.line2 = taxInfoView.line2;
|
||||||
|
request.taxInfo.city = taxInfoView.city;
|
||||||
|
request.taxInfo.state = taxInfoView.state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const provider = await this.apiService.postProviderSetup(this.providerId, request);
|
const provider = await this.apiService.postProviderSetup(this.providerId, request);
|
||||||
this.platformUtilsService.showToast("success", null, this.i18nService.t("providerSetup"));
|
this.platformUtilsService.showToast("success", null, this.i18nService.t("providerSetup"));
|
||||||
await this.syncService.fullSync(true);
|
await this.syncService.fullSync(true);
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import { OrganizationSsoRequest } from "../../../auth/models/request/organizatio
|
|||||||
import { SecretVerificationRequest } from "../../../auth/models/request/secret-verification.request";
|
import { SecretVerificationRequest } from "../../../auth/models/request/secret-verification.request";
|
||||||
import { ApiKeyResponse } from "../../../auth/models/response/api-key.response";
|
import { ApiKeyResponse } from "../../../auth/models/response/api-key.response";
|
||||||
import { OrganizationSsoResponse } from "../../../auth/models/response/organization-sso.response";
|
import { OrganizationSsoResponse } from "../../../auth/models/response/organization-sso.response";
|
||||||
|
import { ExpandedTaxInfoUpdateRequest } from "../../../billing/models/request/expanded-tax-info-update.request";
|
||||||
import { OrganizationSmSubscriptionUpdateRequest } from "../../../billing/models/request/organization-sm-subscription-update.request";
|
import { OrganizationSmSubscriptionUpdateRequest } from "../../../billing/models/request/organization-sm-subscription-update.request";
|
||||||
import { OrganizationSubscriptionUpdateRequest } from "../../../billing/models/request/organization-subscription-update.request";
|
import { OrganizationSubscriptionUpdateRequest } from "../../../billing/models/request/organization-subscription-update.request";
|
||||||
import { OrganizationTaxInfoUpdateRequest } from "../../../billing/models/request/organization-tax-info-update.request";
|
|
||||||
import { PaymentRequest } from "../../../billing/models/request/payment.request";
|
import { PaymentRequest } from "../../../billing/models/request/payment.request";
|
||||||
import { SecretsManagerSubscribeRequest } from "../../../billing/models/request/sm-subscribe.request";
|
import { SecretsManagerSubscribeRequest } from "../../../billing/models/request/sm-subscribe.request";
|
||||||
import { BillingResponse } from "../../../billing/models/response/billing.response";
|
import { BillingResponse } from "../../../billing/models/response/billing.response";
|
||||||
@@ -63,7 +63,7 @@ export class OrganizationApiServiceAbstraction {
|
|||||||
) => Promise<ListResponse<OrganizationApiKeyInformationResponse>>;
|
) => Promise<ListResponse<OrganizationApiKeyInformationResponse>>;
|
||||||
rotateApiKey: (id: string, request: OrganizationApiKeyRequest) => Promise<ApiKeyResponse>;
|
rotateApiKey: (id: string, request: OrganizationApiKeyRequest) => Promise<ApiKeyResponse>;
|
||||||
getTaxInfo: (id: string) => Promise<TaxInfoResponse>;
|
getTaxInfo: (id: string) => Promise<TaxInfoResponse>;
|
||||||
updateTaxInfo: (id: string, request: OrganizationTaxInfoUpdateRequest) => Promise<void>;
|
updateTaxInfo: (id: string, request: ExpandedTaxInfoUpdateRequest) => Promise<void>;
|
||||||
getKeys: (id: string) => Promise<OrganizationKeysResponse>;
|
getKeys: (id: string) => Promise<OrganizationKeysResponse>;
|
||||||
updateKeys: (id: string, request: OrganizationKeysRequest) => Promise<OrganizationKeysResponse>;
|
updateKeys: (id: string, request: OrganizationKeysRequest) => Promise<OrganizationKeysResponse>;
|
||||||
getSso: (id: string) => Promise<OrganizationSsoResponse>;
|
getSso: (id: string) => Promise<OrganizationSsoResponse>;
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
|
import { ExpandedTaxInfoUpdateRequest } from "../../../../billing/models/request/expanded-tax-info-update.request";
|
||||||
|
|
||||||
export class ProviderSetupRequest {
|
export class ProviderSetupRequest {
|
||||||
name: string;
|
name: string;
|
||||||
businessName: string;
|
businessName: string;
|
||||||
billingEmail: string;
|
billingEmail: string;
|
||||||
token: string;
|
token: string;
|
||||||
key: string;
|
key: string;
|
||||||
|
taxInfo: ExpandedTaxInfoUpdateRequest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import { OrganizationSsoRequest } from "../../../auth/models/request/organizatio
|
|||||||
import { SecretVerificationRequest } from "../../../auth/models/request/secret-verification.request";
|
import { SecretVerificationRequest } from "../../../auth/models/request/secret-verification.request";
|
||||||
import { ApiKeyResponse } from "../../../auth/models/response/api-key.response";
|
import { ApiKeyResponse } from "../../../auth/models/response/api-key.response";
|
||||||
import { OrganizationSsoResponse } from "../../../auth/models/response/organization-sso.response";
|
import { OrganizationSsoResponse } from "../../../auth/models/response/organization-sso.response";
|
||||||
|
import { ExpandedTaxInfoUpdateRequest } from "../../../billing/models/request/expanded-tax-info-update.request";
|
||||||
import { OrganizationSmSubscriptionUpdateRequest } from "../../../billing/models/request/organization-sm-subscription-update.request";
|
import { OrganizationSmSubscriptionUpdateRequest } from "../../../billing/models/request/organization-sm-subscription-update.request";
|
||||||
import { OrganizationSubscriptionUpdateRequest } from "../../../billing/models/request/organization-subscription-update.request";
|
import { OrganizationSubscriptionUpdateRequest } from "../../../billing/models/request/organization-subscription-update.request";
|
||||||
import { OrganizationTaxInfoUpdateRequest } from "../../../billing/models/request/organization-tax-info-update.request";
|
|
||||||
import { PaymentRequest } from "../../../billing/models/request/payment.request";
|
import { PaymentRequest } from "../../../billing/models/request/payment.request";
|
||||||
import { SecretsManagerSubscribeRequest } from "../../../billing/models/request/sm-subscribe.request";
|
import { SecretsManagerSubscribeRequest } from "../../../billing/models/request/sm-subscribe.request";
|
||||||
import { BillingResponse } from "../../../billing/models/response/billing.response";
|
import { BillingResponse } from "../../../billing/models/response/billing.response";
|
||||||
@@ -257,7 +257,7 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
|||||||
return new TaxInfoResponse(r);
|
return new TaxInfoResponse(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateTaxInfo(id: string, request: OrganizationTaxInfoUpdateRequest): Promise<void> {
|
async updateTaxInfo(id: string, request: ExpandedTaxInfoUpdateRequest): Promise<void> {
|
||||||
// Can't broadcast anything because the response doesn't have content
|
// Can't broadcast anything because the response doesn't have content
|
||||||
return this.apiService.send("PUT", "/organizations/" + id + "/tax", request, true, false);
|
return this.apiService.send("PUT", "/organizations/" + id + "/tax", request, true, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { TaxInfoUpdateRequest } from "./tax-info-update.request";
|
import { TaxInfoUpdateRequest } from "./tax-info-update.request";
|
||||||
|
|
||||||
export class OrganizationTaxInfoUpdateRequest extends TaxInfoUpdateRequest {
|
export class ExpandedTaxInfoUpdateRequest extends TaxInfoUpdateRequest {
|
||||||
taxId: string;
|
taxId: string;
|
||||||
line1: string;
|
line1: string;
|
||||||
line2: string;
|
line2: string;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { PaymentMethodType } from "../../enums";
|
import { PaymentMethodType } from "../../enums";
|
||||||
|
|
||||||
import { OrganizationTaxInfoUpdateRequest } from "./organization-tax-info-update.request";
|
import { ExpandedTaxInfoUpdateRequest } from "./expanded-tax-info-update.request";
|
||||||
|
|
||||||
export class PaymentRequest extends OrganizationTaxInfoUpdateRequest {
|
export class PaymentRequest extends ExpandedTaxInfoUpdateRequest {
|
||||||
paymentMethodType: PaymentMethodType;
|
paymentMethodType: PaymentMethodType;
|
||||||
paymentToken: string;
|
paymentToken: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user