mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
Estimate tax for trial initiation flow when trial length is 0 (#14674)
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { CountryListItem } from "../models/domain";
|
||||
import { PreviewIndividualInvoiceRequest } from "../models/request/preview-individual-invoice.request";
|
||||
import { PreviewOrganizationInvoiceRequest } from "../models/request/preview-organization-invoice.request";
|
||||
import { PreviewTaxAmountForOrganizationTrialRequest } from "../models/request/tax";
|
||||
import { PreviewInvoiceResponse } from "../models/response/preview-invoice.response";
|
||||
import { PreviewTaxAmountResponse } from "../models/response/tax";
|
||||
|
||||
export abstract class TaxServiceAbstraction {
|
||||
abstract getCountries(): CountryListItem[];
|
||||
@@ -15,4 +17,8 @@ export abstract class TaxServiceAbstraction {
|
||||
abstract previewOrganizationInvoice(
|
||||
request: PreviewOrganizationInvoiceRequest,
|
||||
): Promise<PreviewInvoiceResponse>;
|
||||
|
||||
abstract previewTaxAmountForOrganizationTrial: (
|
||||
request: PreviewTaxAmountForOrganizationTrialRequest,
|
||||
) => Promise<PreviewTaxAmountResponse>;
|
||||
}
|
||||
|
||||
1
libs/common/src/billing/models/request/tax/index.ts
Normal file
1
libs/common/src/billing/models/request/tax/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./preview-tax-amount-for-organization-trial.request";
|
||||
@@ -0,0 +1,11 @@
|
||||
import { PlanType, ProductType } from "../../../enums";
|
||||
|
||||
export type PreviewTaxAmountForOrganizationTrialRequest = {
|
||||
planType: PlanType;
|
||||
productType: ProductType;
|
||||
taxInformation: {
|
||||
country: string;
|
||||
postalCode: string;
|
||||
taxId?: string;
|
||||
};
|
||||
};
|
||||
1
libs/common/src/billing/models/response/tax/index.ts
Normal file
1
libs/common/src/billing/models/response/tax/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./preview-tax-amount.response";
|
||||
@@ -0,0 +1,11 @@
|
||||
import { BaseResponse } from "../../../../models/response/base.response";
|
||||
|
||||
export class PreviewTaxAmountResponse extends BaseResponse {
|
||||
taxAmount: number;
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
|
||||
this.taxAmount = this.getResponseProperty("TaxAmount");
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
import { PreviewTaxAmountForOrganizationTrialRequest } from "@bitwarden/common/billing/models/request/tax";
|
||||
import { PreviewTaxAmountResponse } from "@bitwarden/common/billing/models/response/tax";
|
||||
|
||||
import { ApiService } from "../../abstractions/api.service";
|
||||
import { TaxServiceAbstraction } from "../abstractions/tax.service.abstraction";
|
||||
import { CountryListItem } from "../models/domain";
|
||||
@@ -300,4 +303,16 @@ export class TaxService implements TaxServiceAbstraction {
|
||||
);
|
||||
return new PreviewInvoiceResponse(response);
|
||||
}
|
||||
|
||||
async previewTaxAmountForOrganizationTrial(
|
||||
request: PreviewTaxAmountForOrganizationTrialRequest,
|
||||
): Promise<PreviewTaxAmountResponse> {
|
||||
return await this.apiService.send(
|
||||
"POST",
|
||||
"/tax/preview-amount/organization-trial",
|
||||
request,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user