Authorize - checkBillingPrerequisites - with action
MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -313,7 +313,7 @@ export default class OCPPService {
const { user } = await Authorizations.isAuthorizedOnChargingStation(tenant, chargingStation,
authorize.idTag, ServerAction.AUTHORIZE, Action.AUTHORIZE);
// Check Billing Prerequisites
- await OCPPUtils.checkBillingPrerequisites(tenant, chargingStation, user);
+ await OCPPUtils.checkBillingPrerequisites(tenant, ServerAction.AUTHORIZE, chargingStation, user);
// Enrich
this.enrichAuthorize(user, chargingStation, headers, authorize);
// Save

MODIFY
src/server/ocpp/utils/OCPPUtils.ts
src/server/ocpp/utils/OCPPUtils.ts
@@ -1874,7 +1874,7 @@ export default class OCPPUtils {
return false;
}
- public static async checkBillingPrerequisites(tenant: Tenant, chargingStation: ChargingStation, user: User): Promise<void> {
+ public static async checkBillingPrerequisites(tenant: Tenant, action: ServerAction, chargingStation: ChargingStation, user: User): Promise<void> {
if (!user.issuer) {
// Roaming - do not check for payment methods
return;
@@ -1882,12 +1882,12 @@ export default class OCPPUtils {
const billingImpl = await BillingFactory.getBillingImpl(tenant);
if (billingImpl) {
const errorCodes = await billingImpl.precheckStartTransactionPrerequisites(user);
- if (errorCodes?.length > 0) {
+ if (!Utils.isEmptyArray(errorCodes)) {
throw new BackendError({
+ user, action,
source: chargingStation.id,
message: 'Billing prerequisites are not met',
module: MODULE_NAME, method: 'checkBillingPrerequisites',
- user,
detailedMessages: { errorCodes }
});
}

Authorize - checkBillingPrerequisites - with action