From 90e2b37412f447ac35847710e4feebf45acf7909 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Sun, 25 Apr 2021 08:59:57 +0300 Subject: [PATCH] Fix Helen basic pay calculation --- README.md | 2 +- .../com/devsoap/parsers/helen/Parser.java | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9160e14..0bb4011 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Usage: ``./gradlew :helen-invoice:run --args="/path/to/pdf :dayKwh (); + var basicPay = 0.0; while(scanner.hasNextLine()) { var line = scanner.nextLine(); if(PERUSMAKSU_PATTERN.asPredicate().test(line)) { var matcher = PERUSMAKSU_PATTERN.matcher(line); while (matcher.find()) { - var month = LocalDate.from( FI_DATE.parse(matcher.group(1))) - .getMonth().getDisplayName(TextStyle.FULL, new Locale("FI","fi")); - month = month.substring(0,1).toUpperCase() + month.substring(1, month.length()-2); - var basicPay = Double.parseDouble(matcher.group(3).replace(",", ".")); - - periods.computeIfAbsent(month, s -> new Period()); - periods.computeIfPresent(month, (s,p) -> { - p.basicPay =basicPay; - return p; - }); + basicPay = Double.parseDouble(matcher.group(3).replace(",", ".")); } } else if(ENERGIA_PATTERN.asPredicate().test(line)) { var matcher = ENERGIA_PATTERN.matcher(line); @@ -108,6 +111,12 @@ public class Parser { } } } + + var totalBasicPay = basicPay; + periods.forEach((month, period) -> { + period.basicPay = totalBasicPay / periods.size(); + }); + return periods; } catch (IOException e) { throw new RuntimeException(e);