user import - handled quoted csv
statisticService - renamed numberOfTransaction"s"
MODIFY
src/server/rest/v1/service/StatisticService.ts
src/server/rest/v1/service/StatisticService.ts
+/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
import { Action, Entity } from '../../../../types/Authorization';
import { NextFunction, Request, Response } from 'express';
import StatisticFilter, { ChargingStationStats, StatsDataCategory, StatsDataScope, StatsDataType, StatsGroupBy, UserStats } from '../../../../types/Statistic';
@@ -640,9 +641,9 @@ export default class StatisticService {
});
}
// Now build the export file
- let numberOfTransaction: number;
+ let numberOfTransactions: number;
const rows = transactions.map((transaction) => {
- numberOfTransaction = Utils.truncTo(transaction.total, 2);
+ numberOfTransactions = Utils.truncTo(transaction.total, 2);
// Use raw numbers - it makes no sense to format numbers here,
// anyway only locale 'en-US' is supported here as could be seen by:
// const supportedLocales = Intl.NumberFormat.supportedLocalesOf(['fr-FR', 'en-US', 'de-DE']);
@@ -650,7 +651,7 @@ export default class StatisticService {
dataCategory === StatsDataCategory.CHARGING_STATION ? transaction.chargeBox : Utils.buildUserFullName(transaction.user, false),
year && year !== '0' ? year : '',
transaction.month > 0 ? transaction.month : '',
- dataType === StatsDataType.PRICING ? StatisticService.getPricingCell(transaction, numberOfTransaction) : numberOfTransaction.toString()
+ dataType === StatsDataType.PRICING ? StatisticService.getPricingCell(transaction, numberOfTransactions) : numberOfTransactions.toString()
].map((value) => typeof value === 'string' ? '"' + value.replace(/^"|"$/g, '') + '"' : value);
return row;
}).join(Constants.CR_LF);

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -832,7 +832,6 @@ export default class UserService {
trim: true,
delimiter: Constants.CSV_SEPARATOR,
output: 'json',
- quote: 'on',
});
void converter.subscribe(async (user: ImportedUser) => {
// Check connection
@@ -1343,10 +1342,11 @@ export default class UserService {
private static async processUser(action: ServerAction, req: Request, importedUser: ImportedUser, usersToBeImported: ImportedUser[]): Promise<boolean> {
try {
const newImportedUser: ImportedUser = {
- name: importedUser.name.toUpperCase(),
- firstName: importedUser.firstName,
- email: importedUser.email,
+ name: importedUser.name.toUpperCase().replace(/^"|"$/g, ''),
+ firstName: importedUser.firstName.replace(/^"|"$/g, ''),
+ email: importedUser.email.replace(/^"|"$/g, ''),
};
+
// Validate User data
UserValidator.getInstance().validateImportedUserCreation(newImportedUser);
// Set properties

user import - handled quoted csv
statisticService - renamed numberOfTransaction"s"