From ef3f76a0eff5ae0cd503d45807b916e5c5cc1d71 Mon Sep 17 00:00:00 2001 From: Florian Czarnecki Date: Thu, 15 Feb 2024 21:59:10 +0100 Subject: [PATCH] Fix PowerBI imports failing when Prefix doesn't start with 1010A --- .../importer/powerbi/PowerBiWorkRecordsImporter.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/importer/budgeteer-powerbi-importer/src/main/java/de/adesso/budgeteer/importer/powerbi/PowerBiWorkRecordsImporter.java b/importer/budgeteer-powerbi-importer/src/main/java/de/adesso/budgeteer/importer/powerbi/PowerBiWorkRecordsImporter.java index 3e5c45a21..ba4ce31d4 100644 --- a/importer/budgeteer-powerbi-importer/src/main/java/de/adesso/budgeteer/importer/powerbi/PowerBiWorkRecordsImporter.java +++ b/importer/budgeteer-powerbi-importer/src/main/java/de/adesso/budgeteer/importer/powerbi/PowerBiWorkRecordsImporter.java @@ -138,7 +138,7 @@ private ImportedWorkRecord mapWorkRecord( int dateColumn, int hoursColumn) { var prefixedProjectId = row.getCell(projectIdColumn).getStringCellValue(); - var projectId = prefixedProjectId.substring(prefixedProjectId.indexOf('A')); + var projectId = extractProjectId(prefixedProjectId); var projectName = row.getCell(projectNameColumn).getStringCellValue(); var employee = row.getCell(employeeNameColumn).getStringCellValue(); var date = row.getCell(dateColumn).getDateCellValue(); @@ -160,4 +160,12 @@ private List mapSkippedRecord(Row row) { private boolean isInvoiceable(String value) { return "KV".equals(value); } + + private String extractProjectId(String prefixedProjectId) { + var prefixIndex = prefixedProjectId.indexOf('A'); + if (prefixIndex == -1) { + return prefixedProjectId; + } + return prefixedProjectId.substring(prefixIndex); + } }