billing - show Invoice Number
MODIFY
src/integration/billing/stripe/StripeBillingIntegration.ts
src/integration/billing/stripe/StripeBillingIntegration.ts
@@ -928,6 +928,7 @@ export default class StripeBillingIntegration extends BillingIntegration {
status: BillingStatus.BILLED,
invoiceID: billingInvoice.id,
invoiceStatus: billingInvoice.status,
+ invoiceNumber: billingInvoice.number,
invoiceItem: this.shrinkInvoiceItem(invoiceItem),
};
}

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -48,7 +48,8 @@ export default class TransactionService {
'currentTotalDurationSecs', 'currentTotalInactivitySecs', 'currentInstantWatts', 'currentTotalConsumptionWh', 'currentStateOfCharge',
'currentCumulatedPrice', 'currentInactivityStatus', 'roundedPrice', 'price', 'priceUnit', 'tagID',
'stop.roundedPrice', 'stop.price', 'stop.priceUnit', 'stop.inactivityStatus', 'stop.stateOfCharge', 'stop.timestamp', 'stop.totalConsumptionWh',
- 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs', 'stop.meterStop', 'billingData.invoiceID',
+ 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs', 'stop.meterStop',
+ 'billingData.stop.invoiceNumber',
'ocpi', 'ocpiWithCdr', 'tagID', 'stop.tagID',
]));
next();
@@ -666,7 +667,9 @@ export default class TransactionService {
'id', 'chargeBoxID', 'timestamp', 'issuer', 'stateOfCharge', 'timezone', 'connectorId', 'meterStart', 'siteAreaID', 'siteID',
'currentTotalDurationSecs', 'currentTotalInactivitySecs', 'currentInstantWatts', 'currentTotalConsumptionWh', 'currentStateOfCharge', 'currentInactivityStatus',
'stop.roundedPrice', 'stop.price', 'stop.priceUnit', 'stop.inactivityStatus', 'stop.stateOfCharge', 'stop.timestamp', 'stop.totalConsumptionWh',
- 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs', 'billingData.invoiceID', 'ocpi', 'ocpiWithCdr', 'tagID', 'stop.tagID',
+ 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs',
+ 'billingData.stop.invoiceNumber',
+ 'ocpi', 'ocpiWithCdr', 'tagID', 'stop.tagID',
]);
res.json(transactions);
next();
@@ -702,7 +705,9 @@ export default class TransactionService {
const transactions = await TransactionService.getTransactions(req, action, {}, [
'id', 'chargeBoxID', 'timestamp', 'issuer', 'stateOfCharge', 'timezone', 'connectorId', 'meterStart', 'siteAreaID', 'siteID',
'stop.roundedPrice', 'stop.price', 'stop.priceUnit', 'stop.inactivityStatus', 'stop.stateOfCharge', 'stop.timestamp', 'stop.totalConsumptionWh',
- 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs', 'stop.meterStop', 'billingData.invoiceID', 'ocpi', 'ocpiWithCdr', 'tagID', 'stop.tagID',
+ 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs', 'stop.meterStop',
+ 'billingData.stop.invoiceNumber',
+ 'ocpi', 'ocpiWithCdr', 'tagID', 'stop.tagID',
]);
res.json(transactions);
next();
@@ -720,7 +725,9 @@ export default class TransactionService {
'id', 'chargeBoxID', 'timestamp', 'issuer', 'stateOfCharge', 'timezone', 'connectorId', 'meterStart', 'siteAreaID', 'siteID',
'refundData.reportId', 'refundData.refundedAt', 'refundData.status',
'stop.roundedPrice', 'stop.price', 'stop.priceUnit', 'stop.inactivityStatus', 'stop.stateOfCharge', 'stop.timestamp', 'stop.totalConsumptionWh',
- 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs', 'billingData.invoiceID', 'tagID', 'stop.tagID',
+ 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs',
+ 'billingData.stop.invoiceNumber',
+ 'tagID', 'stop.tagID',
]);
res.json(transactions);
next();
@@ -785,7 +792,9 @@ export default class TransactionService {
return TransactionService.getTransactions(req, ServerAction.TRANSACTIONS_EXPORT, { withTag: true }, [
'id', 'chargeBoxID', 'timestamp', 'issuer', 'stateOfCharge', 'timezone', 'connectorId', 'meterStart', 'siteAreaID', 'siteID',
'stop.roundedPrice', 'stop.price', 'stop.priceUnit', 'stop.inactivityStatus', 'stop.stateOfCharge', 'stop.timestamp', 'stop.totalConsumptionWh',
- 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs', 'billingData.invoiceID', 'ocpi', 'ocpiWithCdr', 'tagID', 'stop.tagID', 'tag.description'
+ 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs',
+ 'billingData.stop.invoiceNumber',
+ 'ocpi', 'ocpiWithCdr', 'tagID', 'stop.tagID', 'tag.description'
]);
}
@@ -802,7 +811,9 @@ export default class TransactionService {
'id', 'chargeBoxID', 'timestamp', 'issuer', 'stateOfCharge', 'timezone', 'connectorId', 'meterStart', 'siteAreaID', 'siteID',
'refundData.reportId', 'refundData.refundedAt', 'refundData.status',
'stop.roundedPrice', 'stop.price', 'stop.priceUnit', 'stop.inactivityStatus', 'stop.stateOfCharge', 'stop.timestamp', 'stop.totalConsumptionWh',
- 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs', 'billingData.invoiceID', 'tagID', 'stop.tagID',
+ 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs',
+ 'billingData.stop.invoiceNumber',
+ 'tagID', 'stop.tagID',
]);
}

MODIFY
src/storage/mongodb/TransactionStorage.ts
src/storage/mongodb/TransactionStorage.ts
@@ -2,6 +2,7 @@ import RefundReport, { RefundStatus } from '../../types/Refund';
import { TransactionInError, TransactionInErrorType } from '../../types/InError';
import global, { FilterParams } from './../../types/GlobalType';
+import { BillingStatus } from '../../types/Billing';
import Constants from '../../utils/Constants';
import ConsumptionStorage from './ConsumptionStorage';
import { DataResult } from '../../types/DataResult';
@@ -173,6 +174,7 @@ export default class TransactionStorage {
stop: {
status: transactionToSave.billingData.stop?.status,
invoiceID: Utils.convertToObjectID(transactionToSave.billingData.stop?.invoiceID),
+ invoiceNumber: transactionToSave.billingData.stop?.invoiceNumber,
invoiceStatus: transactionToSave.billingData.stop?.invoiceStatus,
invoiceItem: transactionToSave.billingData.stop?.invoiceItem,
},
@@ -1300,13 +1302,14 @@ export default class TransactionStorage {
{
$match: {
$and: [
- { 'billingData.isTransactionBillingActivated': { $eq: true } },
+ { 'billingData.withBillingActive': { $eq: true } },
{
$or: [
{ 'billingData': { $exists: false } },
{ 'billingData.stop': { $exists: false } },
- { 'billingData.stop.invoiceID': { $exists: false } },
- { 'billingData.stop.invoiceID': { $eq: null } }
+ { 'billingData.stop.status': { $eq: BillingStatus.FAILED } },
+ // { 'billingData.stop.invoiceID': { $exists: false } },
+ // { 'billingData.stop.invoiceID': { $eq: null } }
]
}
]

MODIFY
src/types/Billing.ts
src/types/Billing.ts
@@ -24,6 +24,7 @@ export enum BillingStatus {
export interface BillingDataTransactionStop {
status?: string;
invoiceID?: string;
+ invoiceNumber?: string;
invoiceStatus?: BillingInvoiceStatus;
invoiceItem?: BillingInvoiceItem;
}

billing - show Invoice Number