billing - STRIPE - transaction.billingData.withBillingActive
MODIFY
src/integration/billing/stripe/StripeBillingIntegration.ts
src/integration/billing/stripe/StripeBillingIntegration.ts
@@ -637,7 +637,8 @@ export default class StripeBillingIntegration extends BillingIntegration {
if (!this.settings.billing.isTransactionBillingActivated) {
return {
- isTransactionBillingActivated: false
+ // Keeps track whether the billing was activated or not on start transaction
+ withBillingActive: false
};
}
@@ -670,7 +671,7 @@ export default class StripeBillingIntegration extends BillingIntegration {
});
}
return {
- isTransactionBillingActivated: true
+ withBillingActive: true
};
}
@@ -687,7 +688,8 @@ export default class StripeBillingIntegration extends BillingIntegration {
});
}
return {
- isTransactionBillingActivated: true
+ // Just propagate the initial state
+ withBillingActive: transaction.billingData?.withBillingActive
};
}
@@ -747,10 +749,8 @@ export default class StripeBillingIntegration extends BillingIntegration {
}
public async stopTransaction(transaction: Transaction): Promise<BillingDataTransactionStop> {
- if (!transaction.billingData.isTransactionBillingActivated) {
- // --------------------------------------------------------------------
- // The billing feature has been activated after the startTransaction
- // --------------------------------------------------------------------
+ // Check whether the billing was activated on start transaction
+ if (!transaction.billingData.withBillingActive) {
return {
status: BillingStatus.UNBILLED
};

MODIFY
src/server/ocpp/utils/OCPPUtils.ts
src/server/ocpp/utils/OCPPUtils.ts
@@ -327,7 +327,7 @@ export default class OCPPUtils {
const billingDataTransactionStart: BillingDataTransactionStart = await billingImpl.startTransaction(transaction);
// Update
transaction.billingData = {
- isTransactionBillingActivated: billingDataTransactionStart.isTransactionBillingActivated,
+ withBillingActive: billingDataTransactionStart.withBillingActive,
lastUpdate: new Date()
};
} catch (error) {

MODIFY
src/storage/mongodb/TransactionStorage.ts
src/storage/mongodb/TransactionStorage.ts
@@ -168,7 +168,7 @@ export default class TransactionStorage {
}
if (transactionToSave.billingData) {
transactionMDB.billingData = {
- isTransactionBillingActivated: transactionToSave.billingData.isTransactionBillingActivated,
+ withBillingActive: transactionToSave.billingData.withBillingActive,
lastUpdate: Utils.convertToDate(transactionToSave.billingData.lastUpdate),
stop: {
status: transactionToSave.billingData.stop?.status,
@@ -1285,8 +1285,9 @@ export default class TransactionStorage {
$match: {
$or: [
{ 'billingData': { $exists: false } },
- { 'billingData.invoiceID': { $exists: false } },
- { 'billingData.invoiceID': { $eq: null } }
+ { 'billingData.stop': { $exists: false } },
+ { 'billingData.stop.invoiceID': { $exists: false } },
+ { 'billingData.stop.invoiceID': { $eq: null } }
]
}
},

MODIFY
src/types/Billing.ts
src/types/Billing.ts
@@ -3,17 +3,17 @@ import { ActionsResponse, DocumentEncoding, DocumentType } from './GlobalType';
import User from './User';
export interface BillingTransactionData {
- isTransactionBillingActivated?: boolean;
+ withBillingActive?: boolean;
lastUpdate?: Date;
stop?: BillingDataTransactionStop;
}
export interface BillingDataTransactionStart {
- isTransactionBillingActivated: boolean;
+ withBillingActive: boolean;
}
export interface BillingDataTransactionUpdate {
- isTransactionBillingActivated: boolean;
+ withBillingActive: boolean;
}
export enum BillingStatus {

billing - STRIPE - transaction.billingData.withBillingActive