Skip to content

Commit 119c52f

Browse files
authored
Merge pull request #7 from ConsumerDataStandardsAustralia/feature/mandatory-string-energy-account-balances
Energy account balance - mandatory string
2 parents 7d530b9 + ae75527 commit 119c52f

File tree

9 files changed

+10
-45
lines changed

9 files changed

+10
-45
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cds-au/testdata",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "Tools for the creation of manufactured test data for the Australian Consumer Data Right regime",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/commands/factory.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export const handler = (argv: Arguments<Options>): void => {
5959
if (factory.canCreateEnergyConcessions()) output +=' create a set of energy concessions\n';
6060
if (factory.canCreateEnergyAccount()) output +=' create an energy account\n';
6161
if (factory.canCreateEnergyAccounts()) output +=' create a set of energy accounts\n';
62-
if (factory.canCreateEnergyBalance()) output +=' create an energy account balance\n';
6362
if (factory.canCreateEnergyInvoice()) output +=' create an energy invoice\n';
6463
if (factory.canCreateEnergyInvoices()) output +=' create a set of energy invoices\n';
6564
if (factory.canCreateEnergyTransaction()) output +=' create an energy transaction\n';

src/factories/energy/createEnergyAccountData.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ Key values randomly allocated:
101101
energyAccount.plans.push(plan);
102102
}
103103
let result: EnergyAccountWrapper = {
104-
account: energyAccount
104+
account: energyAccount,
105+
balance: Helper.generateRandomDecimalInRange(-500, 5000)
105106
};
106107
return result;
107108
}

src/factories/energy/createEnergyTransactions.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EnergyBillingDemandTransaction, EnergyBillingOnceOffTransaction, EnergyBillingOtherTransaction, EnergyBillingPaymentTransaction, EnergyBillingTransaction, EnergyBillingUsageTransaction, EnergyPlan, EnergyPlanDetailV2} from "consumer-data-standards/energy";
2-
import { EnergyAccountBalance, EnergyAccountWrapper, EnergyServicePointWrapper } from "../../logic/schema/cdr-test-data-schema";
2+
import { EnergyAccountWrapper, EnergyServicePointWrapper } from "../../logic/schema/cdr-test-data-schema";
33
import { TransactionUType } from "../../random-generators";
44
import { Factory, FactoryOptions, Helper } from "../../logic/factoryService";
55
import { RandomEnergy } from '../../random-generators';
@@ -39,15 +39,6 @@ Key values randomly allocated:
3939
return st;
4040
}
4141

42-
public canCreateEnergyBalance(): boolean { return true};
43-
44-
public generateEnergyBalance(account: EnergyAccountWrapper): EnergyAccountBalance | undefined {
45-
let accBalance: EnergyAccountBalance = {
46-
balance: Helper.generateRandomDecimalInRange(-500, 5000, 2)
47-
}
48-
return account.balance = accBalance;
49-
}
50-
5142
public canCreateEnergyTransaction(): boolean { return true; };
5243
public generateEnergyTransaction(account: EnergyAccountWrapper, servicePoints: EnergyServicePointWrapper[]): EnergyBillingTransaction | undefined
5344
{

src/factories/invalid-factories/createInvalidEnergyAccountData.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export class CreateInvalidEnergyAccountData extends Factory {
2929
invoiceAmount: Helper.generateRandomDecimalInRange(10, 500)
3030
}
3131
let wrapper: EnergyAccountWrapper = {
32-
account : energyAccount
32+
account : energyAccount,
33+
balance : Helper.generateRandomDecimalInRange(-500, 5000)
3334
};
3435

3536
return wrapper;

src/factories/static-factories/simpleFull.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,8 @@ This factory supports the follow option fields:
10841084
]
10851085
}
10861086
]
1087-
}
1087+
},
1088+
balance: Helper.generateRandomDecimalInRange(-500, 5000)
10881089
}
10891090
}
10901091

@@ -1100,14 +1101,6 @@ This factory supports the follow option fields:
11001101
return ret;
11011102
}
11021103

1103-
// public canCreateEnergyBalance(): boolean { return true; };
1104-
// public generateEnergyBalance(account: EnergyAccountWrapper): EnergyBalanceResponse | undefined {
1105-
// return {
1106-
// accountId: account.account.accountId,
1107-
// balance: "10.00"
1108-
// }
1109-
// }
1110-
11111104
public canCreateEnergyPaymentSchedules(): boolean { return true; };
11121105
public generateEnergyPaymentSchedules(account: EnergyAccountWrapper): any[] | undefined {
11131106
let count = Helper.isPositiveInteger(this.options.options?.count) ? (this.options.options?.count as number) : 1;

src/logic/factoryService/factory.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import { OptionsGeneral } from '../options';
3-
import { AdminOutage, AdminStatus, BankAccountWrapper, Client, ConsumerDataRightTestDataJSONSchema, CustomerWrapper, EnergyAccountBalance, EnergyAccountWrapper, EnergyServicePointWrapper, Holders, HolderWrapper } from '../schema/cdr-test-data-schema';
3+
import { AdminOutage, AdminStatus, BankAccountWrapper, Client, ConsumerDataRightTestDataJSONSchema, CustomerWrapper, EnergyAccountWrapper, EnergyServicePointWrapper, Holders, HolderWrapper } from '../schema/cdr-test-data-schema';
44

55
export interface FactoryOptions {
66
general?: OptionsGeneral,
@@ -115,9 +115,6 @@ export abstract class Factory {
115115
public canCreateEnergyAccounts(): boolean { return false; };
116116
public generateEnergyAccounts(customer: CustomerWrapper): EnergyAccountWrapper[] | undefined { return }
117117

118-
public canCreateEnergyBalance(): boolean { return false; };
119-
public generateEnergyBalance(account: EnergyAccountWrapper): EnergyAccountBalance | undefined { return }
120-
121118
public canCreateEnergyPaymentSchedules(): boolean { return false; };
122119
public generateEnergyPaymentSchedules(account: EnergyAccountWrapper): any[] | undefined { return }
123120

src/logic/factoryService/generateData.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -889,20 +889,6 @@ function generateDetailedEnergyAccounts(options: Options, accountOptions: any, c
889889
if (account && account.account) {
890890
result.push(account);
891891

892-
// Create the detail inside the created account
893-
if (accountOptions.balanceFactory) {
894-
Helper.log(`Executing balance factories for energy account`, 1);
895-
account.balance = generateSingleItem(options, accountOptions.balanceFactory,
896-
(factory) => {
897-
return factory.canCreateEnergyBalance();
898-
},
899-
(factory) => {
900-
return factory.generateEnergyBalance(account);
901-
})
902-
} else {
903-
Helper.log(`No energy account balance factories configured`, 1)
904-
}
905-
906892
if (accountOptions.invoicesFactory) {
907893
Helper.log(`Executing invoices factories for energy account`, 1);
908894
account.invoices = generateArrayOfItems(options, accountOptions.invoicesFactory,

src/logic/schema/cdr-test-data-schema.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export interface EnergyServicePointWrapper {
5353
*/
5454
export interface EnergyAccountWrapper {
5555
account: EnergyAccountDetailV3;
56-
balance?: EnergyAccountBalance;
56+
balance: string;
5757
/**
5858
* An array of agreed payment schedules
5959
*/
@@ -217,6 +217,3 @@ export interface Customer {
217217
/**
218218
* An energy account balance structure aligned to the current version of the data standards
219219
*/
220-
export interface EnergyAccountBalance {
221-
[k: string]: unknown;
222-
}

0 commit comments

Comments
 (0)