From 00ef10dc1d47142dbc5f0f3066ecad393a3c1859 Mon Sep 17 00:00:00 2001 From: DmitriyMX Date: Tue, 24 Jul 2018 12:32:12 +0300 Subject: [PATCH] Honorarium -> HonorariumPercent & HonorariumRUB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Разделение по двум разным форумлам --- .../ru/dmitriymx/corrector1s/Corrector1S.java | 78 +++++++++++++++---- .../java/ru/dmitriymx/corrector1s/Main.java | 15 +++- 2 files changed, 73 insertions(+), 20 deletions(-) diff --git a/src/main/java/ru/dmitriymx/corrector1s/Corrector1S.java b/src/main/java/ru/dmitriymx/corrector1s/Corrector1S.java index a4b29e6..ffa2433 100644 --- a/src/main/java/ru/dmitriymx/corrector1s/Corrector1S.java +++ b/src/main/java/ru/dmitriymx/corrector1s/Corrector1S.java @@ -39,7 +39,9 @@ public class Corrector1S { @Setter private File targetFile; @Setter - private double honorarium; + private Double honorariumPercent = null; + @Setter + private Double honorariumRub = null; @Setter private double fss; @@ -50,6 +52,14 @@ public class Corrector1S { private int cellNumSum = 0; /** номер колонки с больничными */ private int cellBol = 0; + /** номер колонки "Дневные" */ + private int cellDay = 0; + /** номер колонки "Выходные" */ + private int cellWeekend = 0; + /** номер колонки "Сверхурочные 1.5 ставки" */ + private int cellOver15 = 0; + /** номер колонки "Сверхурочные 2 ставки" */ + private int cellOver2 = 0; /** последняя колонка в исходном документе */ private int lastColumn = 0; private CellStyle cellStyle1, cellStyle2; @@ -70,7 +80,8 @@ public class Corrector1S { } public void check() throws Exception { - if (honorarium == 0.0d) throw new AssertionError("Honorarium not be 0.0%!"); + if (honorariumPercent != null && honorariumPercent == 0.0d) throw new AssertionError("Honorarium not be 0.0%!"); + if (honorariumRub != null && honorariumRub == 0.0d) throw new AssertionError("Honorarium not be 0.0 rub!"); if (fss == 0.0d) throw new AssertionError("FSS not be 0.0%!"); if (sourceFile == null) throw new AssertionError("Source file not be null!"); @@ -125,7 +136,14 @@ public class Corrector1S { record.addition = 0; } } else { - record.dataList.add(cell.getNumericCellValue()); + double value; + if (cell.getCellTypeEnum().equals(CellType.STRING)) { + String preDouble = cell.getStringCellValue().replace(',','.'); + value = Double.parseDouble(preDouble); + } else { + value = cell.getNumericCellValue(); + } + record.dataList.add(value); } } @@ -191,11 +209,17 @@ public class Corrector1S { setCellRecord(record, column++); this.cellBol = column-1; } - if ((record = mapRecords.remove("Дневные")) != null) setCellRecord(record, column++); + if ((record = mapRecords.remove("Дневные")) != null) { + setCellRecord(record, column++); + this.cellDay = column-1; + } if ((record = mapRecords.remove("Ночные")) != null) setCellRecord(record, column++); if ((record = mapRecords.remove("Ночные_123")) != null) setCellRecord(record, column++); if ((record = mapRecords.remove("питание_124")) != null) setCellRecord(record, column++); - if ((record = mapRecords.remove("Выходные")) != null) setCellRecord(record, column++); + if ((record = mapRecords.remove("Выходные")) != null) { + setCellRecord(record, column++); + this.cellWeekend = column-1; + } if ((record = mapRecords.remove("выходные_135")) != null) setCellRecord(record, column++); if ((record = mapRecords.remove("пересчет за прошлый месяц_141")) != null) setCellRecord(record, column++); if ((record = mapRecords.remove("вредность_145")) != null) setCellRecord(record, column++); @@ -204,9 +228,15 @@ public class Corrector1S { if ((record = mapRecords.remove("Оплата по среднему (донорство, посещение врача)_174")) != null) setCellRecord(record, column++); if ((record = mapRecords.remove("Компенсация проезда при использовании личного транспорта_176")) != null) setCellRecord(record, column++); if ((record = mapRecords.remove("сверхурочные_133")) != null) setCellRecord(record, column++); - if ((record = mapRecords.remove("Сверхурочные 1.5 ставки")) != null) setCellRecord(record, column++); + if ((record = mapRecords.remove("Сверхурочные 1.5 ставки")) != null) { + setCellRecord(record, column++); + this.cellOver15 = column-1; + } if ((record = mapRecords.remove("сверхурочные 1,5_180")) != null) setCellRecord(record, column++); - if ((record = mapRecords.remove("Сверхурочные 2 ставки")) != null) setCellRecord(record, column++); + if ((record = mapRecords.remove("Сверхурочные 2 ставки")) != null) { + setCellRecord(record, column++); + this.cellOver2 = column-1; + } if ((record = mapRecords.remove("сверхурочные 2_181")) != null) setCellRecord(record, column++); if ((record = mapRecords.remove("Компенсация за неиспользованный отпуск (с декабря 2017)_184")) != null) setCellRecord(record, column++); if ((record = mapRecords.remove("Месячная премия 2018_186")) != null) setCellRecord(record, column++); @@ -316,15 +346,31 @@ public class Corrector1S { ); // HONORARIUM - insertCell( - "Гонорар", - String.format("%.2f%%", this.honorarium), - String.format("%s{L}*%.2f%%", - CellReference.convertNumToColString(column-1), - this.honorarium), - buildSumFormula(column, 8, this.maxLines), - column++ - ); + if (honorariumPercent != null) { + insertCell( + "Гонорар", + String.format("%.2f%%", this.honorariumPercent), + String.format("%s{L}*%.2f%%", + CellReference.convertNumToColString(column-1), + this.honorariumPercent), + buildSumFormula(column, 8, this.maxLines), + column++ + ); + } else if (honorariumRub != null) { + insertCell( + "Гонорар", + String.format("%.2f руб/час", this.honorariumRub), + // =(K9+L9+U9+W9)*38,41 + String.format("(%s{L}+%s{L}+%s{L}+%s{L})*%.2f", + CellReference.convertNumToColString(this.cellDay), + CellReference.convertNumToColString(this.cellWeekend), + CellReference.convertNumToColString(this.cellOver15), + CellReference.convertNumToColString(this.cellOver2), + this.honorariumRub), + buildSumFormula(column, 8, this.maxLines), + column++ + ); + } // SUM ALL insertCell( diff --git a/src/main/java/ru/dmitriymx/corrector1s/Main.java b/src/main/java/ru/dmitriymx/corrector1s/Main.java index 2200156..daa7042 100644 --- a/src/main/java/ru/dmitriymx/corrector1s/Main.java +++ b/src/main/java/ru/dmitriymx/corrector1s/Main.java @@ -8,6 +8,7 @@ import ru.dmitriymx.corrector1s.gui.MainApp; import java.io.File; import java.nio.file.Files; import java.util.Arrays; +import java.util.Collections; import java.util.List; @Slf4j @@ -24,10 +25,12 @@ public class Main { optionParser.acceptsAll(Arrays.asList("t", "target"), "Target Excel file (default: target = source)") .withRequiredArg() .ofType(File.class); - optionParser.acceptsAll(Arrays.asList("h", "honorarium"), "Honorarium (in percentages)") + optionParser.acceptsAll(Collections.singletonList("honorariumPercent"), "Honorarium (in percentages)") .withRequiredArg() - .ofType(Double.class) - .defaultsTo(9.0d); + .ofType(Double.class); + optionParser.acceptsAll(Collections.singletonList("honorariumRub"), "Honorarium (in rub)") + .withRequiredArg() + .ofType(Double.class); optionParser.acceptsAll(Arrays.asList("f", "fss"), "FSS (in percentages)") .withRequiredArg() .ofType(Double.class) @@ -82,7 +85,11 @@ public class Main { Corrector1S corrector1S = new Corrector1S(); corrector1S.setSourceFile(sourceFile); corrector1S.setTargetFile(targetFile); - corrector1S.setHonorarium((Double) optionSet.valueOf("honorarium")); + if (optionSet.has("honorariumPercent")) { + corrector1S.setHonorariumPercent((Double) optionSet.valueOf("honorariumPercent")); + } else if (optionSet.has("honorariumRub")) { + corrector1S.setHonorariumRub((Double) optionSet.valueOf("honorariumRub")); + } corrector1S.setFss((Double) optionSet.valueOf("fss")); corrector1S.check();