pricing - fallback when no pricing definition
MODIFY
src/integration/pricing/ConsumptionPricer.ts
src/integration/pricing/ConsumptionPricer.ts
@@ -20,7 +20,7 @@ export default class ConsumptionPricer {
this.checkPricingDefinitionRestrictions(pricingDefinition)
);
// It does not make sense to apply several tariffs to a single consumption
- this.actualPricingDefinitions = [ actualPricingDefinitions?.[0] ];
+ this.actualPricingDefinitions = [ actualPricingDefinitions[0] ];
}
public priceConsumption(): PricedConsumptionData {

MODIFY
src/integration/pricing/simple-pricing/BuiltInPricingIntegration.ts
src/integration/pricing/simple-pricing/BuiltInPricingIntegration.ts
@@ -93,17 +93,15 @@ export default class BuiltInPricingIntegration extends PricingIntegration<Simple
private async resolvePricingContext(tenant: Tenant, transaction: Transaction, chargingStation: ChargingStation): Promise<ResolvedPricingModel> {
const resolvedPricingModel: ResolvedPricingModel = await PricingEngine.resolvePricingContext(tenant, transaction, chargingStation);
- if (!resolvedPricingModel.pricingDefinitions?.length) {
- resolvedPricingModel.pricingDefinitions = [ this.getDefaultPricingDefinition() ];
- }
+ // Fallback when no pricing definition matches
+ resolvedPricingModel.pricingDefinitions.push(this.getDefaultPricingDefinition());
return resolvedPricingModel;
}
private getDefaultPricingDefinition(): ResolvedPricingDefinition {
- // Defaults to the simple pricing settings
const simplePricingDefinition: ResolvedPricingDefinition = {
name: 'No Tariff',
- description: 'Default tariff when no pricing definition is found',
+ description: 'Tariff used when no other pricing definition matches',
dimensions: {
energy: {
active: true,

pricing - fallback when no pricing definition