Add ocpi data flags for export/push cdr
Use projected field for export
Add ocpi flags when empty projected field
MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -695,7 +695,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
}
},
attributes: [
- 'id', 'ocpiData'
+ 'id', 'ocpiData', 'ocpi', 'ocpiWithCdr'
]
},
{
@@ -2733,7 +2733,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
}
},
attributes: [
- 'id', 'ocpiData'
+ 'id', 'ocpiData', 'ocpi', 'ocpiWithCdr'
]
},
{

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -551,7 +551,7 @@ export default class TransactionService {
// Filter
const filteredRequest = TransactionValidatorRest.getInstance().validateTransactionCdrExportReq(req.query);
// Get Transaction
- const transaction = await UtilsService.checkAndGetTransactionAuthorization(req.tenant, req.user, filteredRequest.ID, Action.EXPORT_OCPI_CDR, action);
+ const transaction = await UtilsService.checkAndGetTransactionAuthorization(req.tenant, req.user, filteredRequest.ID, Action.EXPORT_OCPI_CDR, action, null, null, true);
if (!transaction?.ocpiData) {
throw new AppError({
...LoggingHelper.getTransactionProperties(transaction),

MODIFY
src/storage/mongodb/TransactionStorage.ts
src/storage/mongodb/TransactionStorage.ts
@@ -670,14 +670,14 @@ export default class TransactionStorage {
$limit: dbParams.limit
});
// Add OCPI data
- if (projectFields && projectFields.includes('ocpi')) {
+ if (!projectFields || projectFields && projectFields.includes('ocpi')) {
aggregation.push({
$addFields: {
'ocpi': { $gt: ['$ocpiData', null] }
}
});
}
- if (projectFields && projectFields.includes('ocpiWithCdr')) {
+ if (!projectFields || projectFields && projectFields.includes('ocpiWithCdr')) {
aggregation.push({
$addFields: {
'ocpiWithCdr': {

Add ocpi data flags for export/push cdr

- Use projected field for export
- Add ocpi flags when empty projected field