mirror of
https://github.com/bitwarden/browser
synced 2026-02-16 08:34:39 +00:00
wip
This commit is contained in:
@@ -19,6 +19,7 @@ export class ManageTaxInformationComponent implements OnInit, OnDestroy {
|
||||
postalCode: ["", Validators.required],
|
||||
includeTaxId: false,
|
||||
taxId: "",
|
||||
taxIdType: "",
|
||||
line1: "",
|
||||
line2: "",
|
||||
city: "",
|
||||
@@ -74,6 +75,7 @@ export class ManageTaxInformationComponent implements OnInit, OnDestroy {
|
||||
country: values.country,
|
||||
postalCode: values.postalCode,
|
||||
taxId: values.taxId,
|
||||
taxIdType: values.taxIdType,
|
||||
line1: values.line1,
|
||||
line2: values.line2,
|
||||
city: values.city,
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import { CountryListItem } from "@bitwarden/common/billing/models/domain";
|
||||
import { TaxIdTypesResponse } from "@bitwarden/common/billing/models/response/tax-id-types.response";
|
||||
import { PreviewIndividualInvoiceRequest } from "@bitwarden/common/billing/models/request/preview-individual-invoice.request";
|
||||
import { PreviewInvoiceResponse } from "@bitwarden/common/billing/models/response/preview-invoice.response";
|
||||
|
||||
export abstract class TaxServiceAbstraction {
|
||||
getTaxIdTypes: () => Promise<TaxIdTypesResponse>;
|
||||
|
||||
getCountries: () => CountryListItem[];
|
||||
|
||||
/**
|
||||
* Whether the country supports tax.
|
||||
*/
|
||||
getSupportedCountries: () => string[];
|
||||
|
||||
previewIndividualInvoice: (
|
||||
request: PreviewIndividualInvoiceRequest,
|
||||
) => Promise<PreviewInvoiceResponse>;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ export class TaxInformation {
|
||||
country: string;
|
||||
postalCode: string;
|
||||
taxId: string;
|
||||
taxIdType: string;
|
||||
line1: string;
|
||||
line2: string;
|
||||
city: string;
|
||||
@@ -14,6 +15,7 @@ export class TaxInformation {
|
||||
country: null,
|
||||
postalCode: null,
|
||||
taxId: null,
|
||||
taxIdType: null,
|
||||
line1: null,
|
||||
line2: null,
|
||||
city: null,
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
export class PreviewIndividualInvoiceRequest {
|
||||
passwordManager: PasswordManager;
|
||||
taxInformation: TaxInformation;
|
||||
}
|
||||
|
||||
class PasswordManager {
|
||||
additionalStorage: number;
|
||||
}
|
||||
|
||||
class TaxInformation {
|
||||
postalCode: string;
|
||||
country: string;
|
||||
taxId: string;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { BaseResponse } from "@bitwarden/common/models/response/base.response";
|
||||
|
||||
export class PreviewInvoiceResponse extends BaseResponse {
|
||||
effectiveTaxRate: number;
|
||||
taxableBaseAmount: number;
|
||||
taxAmount: number;
|
||||
totalAmount: number;
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
this.effectiveTaxRate = this.getResponseProperty("EffectiveTaxRate");
|
||||
this.taxableBaseAmount = this.getResponseProperty("TaxableBaseAmount");
|
||||
this.taxAmount = this.getResponseProperty("TaxAmount");
|
||||
this.totalAmount = this.getResponseProperty("TotalAmount");
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,12 @@
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { TaxServiceAbstraction } from "@bitwarden/common/billing/abstractions/tax.service.abstraction";
|
||||
import { CountryListItem } from "@bitwarden/common/billing/models/domain";
|
||||
import { TaxIdTypesResponse } from "@bitwarden/common/billing/models/response/tax-id-types.response";
|
||||
import { PreviewIndividualInvoiceRequest } from "@bitwarden/common/billing/models/request/preview-individual-invoice.request";
|
||||
import { PreviewInvoiceResponse } from "@bitwarden/common/billing/models/response/preview-invoice.response";
|
||||
|
||||
export class TaxService implements TaxServiceAbstraction {
|
||||
constructor(private apiService: ApiService) {}
|
||||
|
||||
async getTaxIdTypes(): Promise<TaxIdTypesResponse> {
|
||||
const response = await this.apiService.send("GET", "/tax/id-types", null, true, true);
|
||||
return new TaxIdTypesResponse(response);
|
||||
}
|
||||
|
||||
getCountries(): CountryListItem[] {
|
||||
return [
|
||||
{ name: "-- Select --", value: "", disabled: false },
|
||||
@@ -344,4 +340,17 @@ export class TaxService implements TaxServiceAbstraction {
|
||||
"VN",
|
||||
];
|
||||
}
|
||||
|
||||
async previewIndividualInvoice(
|
||||
request: PreviewIndividualInvoiceRequest,
|
||||
): Promise<PreviewInvoiceResponse> {
|
||||
const response = await this.apiService.send(
|
||||
"POST",
|
||||
"/accounts/billing/preview-invoice",
|
||||
request,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
return new PreviewInvoiceResponse(response);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user