bp - minor renaming
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
}
}
},
- "amount": {
+ "totalAmount": {
"type": "number"
},
- "transferredAmount": {
+ "transferAmount": {
"type": "number"
},
"platformFeeData": {

MODIFY
src/integration/billing/BillingIntegration.ts
src/integration/billing/BillingIntegration.ts
@@ -765,7 +765,7 @@ export default abstract class BillingIntegration {
let transfer: BillingTransfer = transfers.result[0];
if (!transfer) {
transfer = {
- accountID, status: BillingTransferStatus.DRAFT, sessions: [], amount: 0, transferredAmount: 0,
+ accountID, status: BillingTransferStatus.DRAFT, sessions: [], totalAmount: 0, transferAmount: 0,
platformFeeData: null, transferExternalID: null,
};
}
@@ -792,7 +792,7 @@ export default abstract class BillingIntegration {
transferAmountAsDecimal = transferAmountAsDecimal.plus(session.amountAsDecimal);
});
// Round the final result only!
- transfer.amount = Utils.roundTo(transferAmountAsDecimal, 2);
+ transfer.totalAmount = Utils.roundTo(transferAmountAsDecimal, 2);
// Finally - create or update the transfer
await BillingStorage.saveTransfer(this.tenant, transfer);
} catch (error) {

MODIFY
src/storage/mongodb/BillingStorage.ts
src/storage/mongodb/BillingStorage.ts
@@ -342,8 +342,8 @@ export default class BillingStorage {
const transferMDB: any = {
_id: transfer.id ? DatabaseUtils.convertToObjectID(transfer.id) : new ObjectId(),
status: transfer.status,
- amount: transfer.amount,
- transferredAmount: transfer.transferredAmount,
+ totalAmount: transfer.totalAmount,
+ transferAmount: transfer.transferAmount,
accountID: DatabaseUtils.convertToObjectID(transfer.accountID),
transferExternalID: transfer.transferExternalID,
sessions: transfer.sessions.map((session) => ({

MODIFY
src/types/Billing.ts
src/types/Billing.ts
@@ -182,6 +182,7 @@ export interface BillingSessionAccountData extends BillingAccountData {
export enum BillingTransferStatus {
DRAFT = 'draft',
PENDING = 'pending',
+ FINALIZED = 'finalized',
TRANSFERRED = 'transferred'
}
@@ -196,8 +197,8 @@ export interface BillingTransfer extends CreatedUpdatedProps, BillingTransferAut
id?: string;
status: BillingTransferStatus;
sessions: BillingTransferSession[];
- amount: number; // Depends on the fee strategy and thus on the final number of sessions
- transferredAmount: number // Amount transferred after applying platform fees
+ totalAmount: number; // Depends on the fee strategy and thus on the final number of sessions
+ transferAmount: number // Amount transferred after applying platform fees
accountID: string;
platformFeeData: BillingPlatformFeeData;
transferExternalID?: string; // Transfer sent to the CPO

MODIFY
test/api/BillingPlatformTest.ts
test/api/BillingPlatformTest.ts
@@ -48,10 +48,6 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
describe('Where admin user', () => {
// eslint-disable-next-line @typescript-eslint/require-await
- beforeAll(async () => {
- billingTestHelper.initUserContextAsAdmin();
- });
-
// eslint-disable-next-line @typescript-eslint/require-await
beforeAll(async () => {
billingTestHelper.initUserContextAsAdmin();
@@ -60,6 +56,16 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
});
it('should create an invoice, and get transfers generated', async () => {
+ // -------------------------------------------------------------------------------------------------------------
+ // -------------------------------------------------------------------------------------------------------------
+ // -------------------------------------------------------------------------------------------------------------
+ // -------------------------------------------------------------------------------------------------------------
+ // -------------------------------------------------------------------------------------------------------------
+ // TO DO - GENERATE SEVERAL TRANSACTIONS to TARGET SEVERAL SUB-ACCOUNTS and this GENERATE SEVERAL TRANSFERS!!!!
+ // -------------------------------------------------------------------------------------------------------------
+ // -------------------------------------------------------------------------------------------------------------
+ // -------------------------------------------------------------------------------------------------------------
+ // -------------------------------------------------------------------------------------------------------------
await billingTestHelper.userService.billingApi.forceSynchronizeUser({ id: billingTestHelper.userContext.id });
const userWithBillingData = await billingTestHelper.billingImpl.getUser(billingTestHelper.userContext);
await billingTestHelper.assignPaymentMethod(userWithBillingData, 'tok_fr');

MODIFY
test/factories/BillingFactory.ts
test/factories/BillingFactory.ts
@@ -4,10 +4,10 @@ import { Factory } from 'rosie';
import faker from 'faker';
export const BillingTransferFactory = Factory.define<BillingTransfer>('billingtransfer')
- .attr('amount', () => faker.datatype.number())
+ .attr('totalAmount', () => faker.datatype.number())
.attr('accountID', () => faker.datatype.hexaDecimal(24).substring(2).toLowerCase())
- .attr('status', () => faker.random.arrayElement([BillingTransferStatus.DRAFT, BillingTransferStatus.PENDING, BillingTransferStatus.TRANSFERRED]))
- .attr('transferredAmount', () => faker.datatype.number())
+ .attr('status', () => faker.random.arrayElement([BillingTransferStatus.DRAFT, BillingTransferStatus.PENDING, BillingTransferStatus.FINALIZED, BillingTransferStatus.TRANSFERRED]))
+ .attr('transferAmount', () => faker.datatype.number())
.attr('transferExternalID', () => faker.datatype.uuid())
.attr('platformFeeData', () => ({
feeAmount: faker.datatype.number(),

bp - minor renaming