Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pm 11525 estimated tax shown to customers potentially incorrect #11502

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class PremiumV2Component {

protected get estimatedTax(): number {
return this.taxInfoComponent?.taxRate != null
? (this.taxInfoComponent.taxRate / 100) * this.subtotal
? this.taxInfoComponent.taxRate * this.subtotal
: 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class PremiumComponent implements OnInit {

get taxCharges(): number {
return this.taxInfoComponent != null && this.taxInfoComponent.taxRate != null
? (this.taxInfoComponent.taxRate / 100) * this.subtotal
? this.taxInfoComponent.taxRate * this.subtotal
: 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ export class ChangePlanDialogComponent implements OnInit, OnDestroy {

get taxCharges() {
return this.taxComponent != null && this.taxComponent.taxRate != null
? (this.taxComponent.taxRate / 100) * this.passwordManagerSubtotal
? this.taxComponent.taxRate * this.passwordManagerSubtotal
: 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,7 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {

get taxCharges() {
return this.taxComponent != null && this.taxComponent.taxRate != null
? (this.taxComponent.taxRate / 100) *
(this.passwordManagerSubtotal + this.secretsManagerSubtotal)
? this.taxComponent.taxRate * (this.passwordManagerSubtotal + this.secretsManagerSubtotal)
: 0;
}

Expand Down
440 changes: 55 additions & 385 deletions apps/web/src/app/billing/shared/tax-info.component.ts

Large diffs are not rendered by default.

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions libs/angular/src/services/jslib-services.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,13 @@
import { AccountBillingApiServiceAbstraction } from "@bitwarden/common/billing/abstractions/account/account-billing-api.service.abstraction";
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
import { OrganizationBillingApiServiceAbstraction } from "@bitwarden/common/billing/abstractions/organizations/organization-billing-api.service.abstraction";
import { TaxServiceAbstraction } from "@bitwarden/common/billing/abstractions/tax.service.abstraction";

Check warning on line 133 in libs/angular/src/services/jslib-services.module.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/services/jslib-services.module.ts#L133

Added line #L133 was not covered by tests
import { AccountBillingApiService } from "@bitwarden/common/billing/services/account/account-billing-api.service";
import { DefaultBillingAccountProfileStateService } from "@bitwarden/common/billing/services/account/billing-account-profile-state.service";
import { BillingApiService } from "@bitwarden/common/billing/services/billing-api.service";
import { OrganizationBillingApiService } from "@bitwarden/common/billing/services/organization/organization-billing-api.service";
import { OrganizationBillingService } from "@bitwarden/common/billing/services/organization-billing.service";
import { TaxService } from "@bitwarden/common/billing/services/tax.service";

Check warning on line 139 in libs/angular/src/services/jslib-services.module.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/services/jslib-services.module.ts#L139

Added line #L139 was not covered by tests
import { AppIdService as AppIdServiceAbstraction } from "@bitwarden/common/platform/abstractions/app-id.service";
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
import { BulkEncryptService } from "@bitwarden/common/platform/abstractions/bulk-encrypt.service";
Expand Down Expand Up @@ -1245,6 +1247,11 @@
useClass: DefaultBillingAccountProfileStateService,
deps: [StateProvider],
}),
safeProvider({
provide: TaxServiceAbstraction,
useClass: TaxService,
deps: [],
}),
safeProvider({
provide: OrganizationManagementPreferencesService,
useClass: DefaultOrganizationManagementPreferencesService,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ProviderOrganizationOrganizationDetailsResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-organization.response";
import { PaymentMethodType } from "@bitwarden/common/billing/enums";
import { CalculateTaxRequest } from "@bitwarden/common/billing/models/request/calculate-tax.request";
import { ExpandedTaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/expanded-tax-info-update.request";
import { UpdatePaymentMethodRequest } from "@bitwarden/common/billing/models/request/update-payment-method.request";
import { VerifyBankAccountRequest } from "@bitwarden/common/billing/models/request/verify-bank-account.request";
import { CalculateTaxResponse } from "@bitwarden/common/billing/models/response/calculate-tax.response";
import { InvoicesResponse } from "@bitwarden/common/billing/models/response/invoices.response";
import { PaymentMethodResponse } from "@bitwarden/common/billing/models/response/payment-method.response";

Expand All @@ -15,6 +17,8 @@ import { UpdateClientOrganizationRequest } from "../models/request/update-client
import { ProviderSubscriptionResponse } from "../models/response/provider-subscription-response";

export abstract class BillingApiServiceAbstraction {
calculateTax: (request: CalculateTaxRequest) => Promise<CalculateTaxResponse>;

cancelOrganizationSubscription: (
organizationId: string,
request: SubscriptionCancellationRequest,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { TaxableCountry } from "@bitwarden/common/billing/models/domain/taxable-country";

export abstract class TaxServiceAbstraction {

Check warning on line 3 in libs/common/src/billing/abstractions/tax.service.abstraction.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/billing/abstractions/tax.service.abstraction.ts#L3

Added line #L3 was not covered by tests
getSelectableCountries: () => TaxableCountry[];
isSupportedCountry: (country: string) => boolean;
}
5 changes: 5 additions & 0 deletions libs/common/src/billing/models/domain/taxable-country.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class TaxableCountry {

Check warning on line 1 in libs/common/src/billing/models/domain/taxable-country.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/billing/models/domain/taxable-country.ts#L1

Added line #L1 was not covered by tests
name: string;
value: string;
disabled: boolean;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class CalculateTaxRequest {

Check warning on line 1 in libs/common/src/billing/models/request/calculate-tax.request.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/billing/models/request/calculate-tax.request.ts#L1

Added line #L1 was not covered by tests
amount: number;
country: string;
postalCode: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class CalculateTaxResponse {

Check warning on line 1 in libs/common/src/billing/models/response/calculate-tax.response.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/billing/models/response/calculate-tax.response.ts#L1

Added line #L1 was not covered by tests
salesTaxRate: number;
salesTaxAmount: number;
taxableAmount: number;
totalAmount: number;
}
6 changes: 6 additions & 0 deletions libs/common/src/billing/services/billing-api.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ProviderOrganizationOrganizationDetailsResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-organization.response";
import { CalculateTaxRequest } from "@bitwarden/common/billing/models/request/calculate-tax.request";
import { UpdatePaymentMethodRequest } from "@bitwarden/common/billing/models/request/update-payment-method.request";
import { VerifyBankAccountRequest } from "@bitwarden/common/billing/models/request/verify-bank-account.request";
import { CalculateTaxResponse } from "@bitwarden/common/billing/models/response/calculate-tax.response";
import { InvoicesResponse } from "@bitwarden/common/billing/models/response/invoices.response";
import { PaymentMethodResponse } from "@bitwarden/common/billing/models/response/payment-method.response";
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
Expand All @@ -26,6 +28,10 @@
private toastService: ToastService,
) {}

calculateTax(request: CalculateTaxRequest): Promise<CalculateTaxResponse> {
return this.apiService.send("POST", "/tax/calculate", request, true, true);

Check warning on line 32 in libs/common/src/billing/services/billing-api.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/billing/services/billing-api.service.ts#L32

Added line #L32 was not covered by tests
}

cancelOrganizationSubscription(
organizationId: string,
request: SubscriptionCancellationRequest,
Expand Down
Loading
Loading