bp - tests - apply tax rate 5%
MODIFY
test/api/BillingPlatformTest.ts
test/api/BillingPlatformTest.ts
@@ -235,6 +235,8 @@ describeif(isBillingProperlyConfigured)('Billing Platform (utbillingplatform)',
beforeAll(async () => {
// Initialize the Billing module
await billingTestHelper.setBillingSystemValidCredentials(true, false /* immediateBillingAllowed OFF */);
+ // Apply 5% tax rate on platform fee
+ await billingTestHelper.setBillingPlatformTaxRate( 5 /* 5% */);
});
it('should create an invoice, and get transfers generated', async () => {
@@ -278,6 +280,8 @@ describeif(isBillingProperlyConfigured)('Billing Platform (utbillingplatform)',
beforeAll(async () => {
// Initialize the Billing module
await billingTestHelper.setBillingSystemValidCredentials(true, true /* immediateBillingAllowed ON */);
+ // Apply 5% tax rate on platform fee
+ await billingTestHelper.setBillingPlatformTaxRate( 5 /* 5% */);
});
it('should create an invoice, pay for it immediately and get a transfer generated or updated', async () => {
@@ -363,6 +367,8 @@ describeif(isBillingProperlyConfigured)('Billing Platform (utbillingplatform)',
beforeAll(async () => {
// Set the basic user as the current user context
billingTestHelper.setCurrentUserContextAsBasic();
+ // Apply 5% tax rate on platform fee
+ await billingTestHelper.setBillingPlatformTaxRate( 5 /* 5% */);
});
it('should not be able to list transfers', async () => {

MODIFY
test/api/BillingTestHelper.ts
test/api/BillingTestHelper.ts
@@ -532,6 +532,16 @@ export default class BillingTestHelper {
await this.adminUserService.settingApi.update(componentSetting);
}
+ public async setBillingPlatformTaxRate(taxRate: number) : Promise<void> {
+ assert(this.billingImpl, 'Billing implementation should not be null');
+ const stripeTaxRate = await StripeTaxHelper.fetchOrCreateTaxRate(this.billingImpl, taxRate);
+ const tenantBillingSettings = await this.adminUserService.settingApi.readByIdentifier({ 'Identifier': 'billing' });
+ expect(tenantBillingSettings.data).to.not.be.null;
+ const componentSetting: SettingDB = tenantBillingSettings.data;
+ componentSetting.content.billing.platformFeeTaxID = stripeTaxRate.id;
+ await this.adminUserService.settingApi.update(componentSetting);
+ }
+
public async checkInvoiceData(invoiceID: string, expectedStatus: BillingInvoiceStatus, expectedSessionCounter: number, expectedAmount: number): Promise<void> {
const response = await this.getCurrentUserService().billingApi.readInvoice(invoiceID);
expect(response.status).to.equal(StatusCodes.OK);
@@ -885,12 +895,9 @@ export default class BillingTestHelper {
}
public async createBillingAccount(): Promise<string> {
- // Assign a tax rate (5% exclusive) to apply to the platform fee
- const taxRate = StripeTaxHelper.fetchOrCreateTaxRate(this.billingImpl, 5 /* 5% */);
let response = await this.getCurrentUserService().billingApi.createBillingAccount({
businessOwnerID: this.getCurrentUserContext().id,
companyName: 'UT-Account-' + new Date().toISOString(),
- taxID: (await taxRate).id
});
if (response.status !== StatusCodes.OK) {
await this.dumpLastErrors();

MODIFY
test/api/StripeTestHelper.ts
test/api/StripeTestHelper.ts
@@ -218,14 +218,14 @@ export default class StripeTestHelper {
}
}
- public async assignTaxRate(rate: number) : Promise<Stripe.TaxRate> {
+ public async fetchOrCreateTaxRate(rate: number) : Promise<Stripe.TaxRate> {
return StripeTaxHelper.fetchOrCreateTaxRate(this.billingImpl, rate);
}
public async checkBusinessProcessBillToPay(paymentShouldFail: boolean, withTax?:boolean) : Promise<void> {
let taxId: string = null;
if (withTax) {
- const taxRate: Stripe.TaxRate = await this.assignTaxRate(20); // VAT 20%
+ const taxRate: Stripe.TaxRate = await this.fetchOrCreateTaxRate(20); // VAT 20%
taxId = taxRate.id;
}
// The user should have no DRAFT invoices
@@ -281,7 +281,7 @@ export default class StripeTestHelper {
// Inputs / Expected Outputs
const tax20percent = 20 /* VAT 20 % */;
// PREREQUISITE - immediateBillingAllowed MUST BE ON!
- const taxRate: Stripe.TaxRate = await this.assignTaxRate(tax20percent);
+ const taxRate: Stripe.TaxRate = await this.fetchOrCreateTaxRate(tax20percent);
const taxId = taxRate.id;
// The user should have no DRAFT invoices
await this.checkForDraftInvoices(this.dynamicUser.id, 0);

bp - tests - apply tax rate 5%