diff --git a/package.json b/package.json index 209a580..3395e11 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "module", "dependencies": { "@f0rce/ace-widget": "1.0.2", - "@polymer/polymer": "3.5.2", + "@polymer/polymer": "3.5.1", "@vaadin-component-factory/vcf-pdf-viewer": "2.0.1", "@vaadin/bundles": "24.5.1", "@vaadin/common-frontend": "0.0.19", @@ -19,30 +19,29 @@ "@vaadin/vaadin-usage-statistics": "2.1.3", "construct-style-sheets-polyfill": "3.1.0", "date-fns": "2.29.3", - "lit": "3.2.1", + "lit": "3.1.4", "print-js": "1.6.0", "proj4": "2.12.1", "react": "18.3.1", "react-dom": "18.3.1", - "react-router-dom": "6.26.2" + "react-router-dom": "6.23.1" }, "devDependencies": { - "@babel/preset-react": "7.25.7", - "@preact/signals-react-transform": "0.4.0", - "@rollup/plugin-replace": "6.0.1", - "@rollup/pluginutils": "5.1.2", - "@types/react": "18.3.11", - "@types/react-dom": "18.3.1", - "@vitejs/plugin-react": "4.3.3", - "async": "3.2.6", - "glob": "10.4.5", + "@babel/preset-react": "7.24.7", + "@rollup/plugin-replace": "5.0.7", + "@rollup/pluginutils": "5.1.0", + "@types/react": "18.3.3", + "@types/react-dom": "18.3.0", + "@vitejs/plugin-react": "4.3.1", + "async": "3.2.5", + "glob": "10.4.1", "rollup-plugin-brotli": "3.1.0", "rollup-plugin-visualizer": "5.12.0", "strip-css-comments": "5.0.0", "transform-ast": "2.4.4", - "typescript": "5.6.3", - "vite": "5.4.9", - "vite-plugin-checker": "0.8.0", + "typescript": "5.4.5", + "vite": "5.3.3", + "vite-plugin-checker": "0.6.4", "workbox-build": "7.1.1", "workbox-core": "7.1.0", "workbox-precaching": "7.1.0" @@ -50,7 +49,7 @@ "vaadin": { "dependencies": { "@f0rce/ace-widget": "1.0.2", - "@polymer/polymer": "3.5.2", + "@polymer/polymer": "3.5.1", "@vaadin-component-factory/vcf-pdf-viewer": "2.0.1", "@vaadin/bundles": "24.5.1", "@vaadin/common-frontend": "0.0.19", @@ -65,35 +64,34 @@ "@vaadin/vaadin-usage-statistics": "2.1.3", "construct-style-sheets-polyfill": "3.1.0", "date-fns": "2.29.3", - "lit": "3.2.1", + "lit": "3.1.4", "print-js": "1.6.0", "proj4": "2.12.1", "react": "18.3.1", "react-dom": "18.3.1", - "react-router-dom": "6.26.2" + "react-router-dom": "6.23.1" }, "devDependencies": { - "@babel/preset-react": "7.25.7", - "@preact/signals-react-transform": "0.4.0", - "@rollup/plugin-replace": "6.0.1", - "@rollup/pluginutils": "5.1.2", - "@types/react": "18.3.11", - "@types/react-dom": "18.3.1", - "@vitejs/plugin-react": "4.3.3", - "async": "3.2.6", - "glob": "10.4.5", + "@babel/preset-react": "7.24.7", + "@rollup/plugin-replace": "5.0.7", + "@rollup/pluginutils": "5.1.0", + "@types/react": "18.3.3", + "@types/react-dom": "18.3.0", + "@vitejs/plugin-react": "4.3.1", + "async": "3.2.5", + "glob": "10.4.1", "rollup-plugin-brotli": "3.1.0", "rollup-plugin-visualizer": "5.12.0", "strip-css-comments": "5.0.0", "transform-ast": "2.4.4", - "typescript": "5.6.3", - "vite": "5.4.9", - "vite-plugin-checker": "0.8.0", + "typescript": "5.4.5", + "vite": "5.3.3", + "vite-plugin-checker": "0.6.4", "workbox-build": "7.1.1", "workbox-core": "7.1.0", "workbox-precaching": "7.1.0" }, - "hash": "2dc40a4f634ae025081ca2239cba00b14a35fe94ab78ac0a4dd3023d882081d5" + "hash": "1a0f17d48b329307b5862bc57499307d1b89f7d89260121c2b7189f76957c436" }, "overrides": { "@vaadin/bundles": "$@vaadin/bundles", diff --git a/src/main/bundles/prod.bundle b/src/main/bundles/prod.bundle index b8a4d20..b05a96c 100644 Binary files a/src/main/bundles/prod.bundle and b/src/main/bundles/prod.bundle differ diff --git a/src/main/java/com/primefactorsolutions/model/Employee.java b/src/main/java/com/primefactorsolutions/model/Employee.java index 02a9e14..f3e2a7a 100644 --- a/src/main/java/com/primefactorsolutions/model/Employee.java +++ b/src/main/java/com/primefactorsolutions/model/Employee.java @@ -10,6 +10,7 @@ import lombok.NoArgsConstructor; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; +import java.math.BigDecimal; import java.time.LocalDate; import java.util.Collection; @@ -93,11 +94,10 @@ public class Employee extends BaseEntity implements UserDetails { private LocalDate dateOfExit; private String seniority; - @Pattern(regexp = "^[0-9]+(\\.[0-9]{1,2})?$", message = "El salario debe ser un número con hasta dos decimales") - private String salarytotal; - private String salaryBasic; - private String bonoProfesional; - private String antiguedad; + private BigDecimal salaryTotal = BigDecimal.ZERO; + private BigDecimal salaryBasic = BigDecimal.ZERO; + private BigDecimal professionalBonus = BigDecimal.ZERO; + private BigDecimal tenureBonus = BigDecimal.ZERO; @Pattern(regexp = "^[a-zA-Z ]+$", message = "El nombre del banco solo debe contener letras") private String bankName; @Pattern(regexp = "^[0-9]+$", message = "El número de cuenta debe contener solo números") @@ -180,6 +180,9 @@ public class Employee extends BaseEntity implements UserDetails { @Enumerated(EnumType.STRING) private ContractType contractType; + @Size(max = 255, message = "El detalle del contrato no debe exceder 255 caracteres") + private String otherContractDetail; + public enum ContractType { CONTRATO_LABORAL, CONTRATO_CIVIL_O_SERVICIOS, @@ -189,7 +192,4 @@ public class Employee extends BaseEntity implements UserDetails { CONTRATO_MIXTO, OTROS } - - @Size(max = 255, message = "El detalle del contrato no debe exceder 255 caracteres") - private String otherContractDetail; } \ No newline at end of file diff --git a/src/main/java/com/primefactorsolutions/service/ReportService.java b/src/main/java/com/primefactorsolutions/service/ReportService.java index 3c27d78..90694ed 100644 --- a/src/main/java/com/primefactorsolutions/service/ReportService.java +++ b/src/main/java/com/primefactorsolutions/service/ReportService.java @@ -232,9 +232,9 @@ public class ReportService { employee.getDateOfEntry().toString(), employee.getDateOfExit() != null ? employee.getDateOfExit() .toString() : "", employee.getContractType().toString(), employee.getCustomContractType(), - employee.getSeniority(), employee.getSalarytotal(), employee.getSalaryBasic(), - employee.getAntiguedad(), employee.getBonoProfesional(), employee.getBankName(), - employee.getAccountNumber(), employee.getGpss(), employee.getSss(), + employee.getSeniority(), employee.getSalaryTotal().toString(), employee.getSalaryBasic().toString(), + employee.getTenureBonus().toString(), employee.getProfessionalBonus().toString(), + employee.getBankName(), employee.getAccountNumber(), employee.getGpss(), employee.getSss(), employee.getBeneficiarie1(), employee.getBeneficiarie2() }; for (int i = 0; i < employeeData.length; i++) { diff --git a/src/main/java/com/primefactorsolutions/views/EmployeeView.java b/src/main/java/com/primefactorsolutions/views/EmployeeView.java index 21ca7a1..2bef270 100644 --- a/src/main/java/com/primefactorsolutions/views/EmployeeView.java +++ b/src/main/java/com/primefactorsolutions/views/EmployeeView.java @@ -21,6 +21,7 @@ import com.vaadin.flow.component.notification.Notification; import com.vaadin.flow.component.orderedlayout.FlexComponent; import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.orderedlayout.VerticalLayout; +import com.vaadin.flow.component.textfield.BigDecimalField; import com.vaadin.flow.component.textfield.EmailField; import com.vaadin.flow.component.textfield.TextField; import com.vaadin.flow.component.upload.Upload; @@ -37,6 +38,7 @@ import org.vaadin.firitin.form.BeanValidationForm; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.math.BigDecimal; import java.time.LocalDate; import java.time.temporal.ChronoUnit; import java.util.Base64; @@ -106,12 +108,12 @@ public class EmployeeView extends BeanValidationForm implements HasUrl private final VDatePicker dateOfExit = new VDatePicker("Fecha de Retiro"); private final ComboBox contractType = createContractTypeComboBox(); private final TextField customContractType = createCustomContractTypeField(); - private final TextField seniority = createTextField("Antiguedad", 30, false); - private final TextField salaryTotal = createTextField("Salario Total", 10, false); - private final TextField salaryBasic = createTextField("Salario Basico", 10, false); - private final TextField antiguedad = createTextField("Bono de Antiguedad", 10, false); - private final TextField bonoProfesional = createTextField("Bono Profesional", 30, false); - private final TextField bankName = createTextField("Banco", 30, false); + private final TextField seniority = createTextField("Antiguedad", 30, false); + private final BigDecimalField salaryTotal = createBigDecimalField("Salario Total", false); + private final BigDecimalField salaryBasic = createBigDecimalField("Salario Basico", false); + private final BigDecimalField tenureBonus = createBigDecimalField("Bono de Antiguedad", false); + private final BigDecimalField professionalBonus = createBigDecimalField("Bono Profesional", false); + private final TextField bankName = createTextField("Banco", 30, false); private final TextField accountNumber = createTextField("Nro. de Cuenta", 30, false); private final TextField gpss = createTextField("Código Único de Asegurado (GPSS)", 30, false); private final TextField sss = createTextField("Matricula de Asegurado (SSS)", 30, false); @@ -288,16 +290,16 @@ public class EmployeeView extends BeanValidationForm implements HasUrl private void calculateSalaryTotal() { if (contractType.getValue() == Employee.ContractType.CONTRATO_LABORAL) { salaryBasic.setVisible(true); - bonoProfesional.setVisible(true); - antiguedad.setVisible(true); + professionalBonus.setVisible(true); + tenureBonus.setVisible(true); salaryTotal.setVisible(true); salaryBasic.addValueChangeListener(event -> updateTotalSalary()); - bonoProfesional.addValueChangeListener(event -> updateTotalSalary()); - antiguedad.addValueChangeListener(event -> updateTotalSalary()); + professionalBonus.addValueChangeListener(event -> updateTotalSalary()); + tenureBonus.addValueChangeListener(event -> updateTotalSalary()); } else { salaryBasic.setVisible(false); - bonoProfesional.setVisible(false); - antiguedad.setVisible(false); + professionalBonus.setVisible(false); + tenureBonus.setVisible(false); salaryTotal.setVisible(true); } salaryTotal.getValue(); @@ -305,13 +307,13 @@ public class EmployeeView extends BeanValidationForm implements HasUrl private void updateTotalSalary() { try { - double basic = parseDoubleValue(salaryBasic.getValue()); - double bonus = parseDoubleValue(bonoProfesional.getValue()); - double seniorityBonus = parseDoubleValue(antiguedad.getValue()); - double totalSalary = basic + bonus + seniorityBonus; - salaryTotal.setValue(String.valueOf(totalSalary)); + final BigDecimal basic = salaryBasic.getValue(); + final BigDecimal bonus = professionalBonus.getValue(); + final BigDecimal seniorityBonus = tenureBonus.getValue(); + final BigDecimal totalSalary = basic.add(bonus).add(seniorityBonus); + salaryTotal.setValue(totalSalary); } catch (Exception e) { - salaryTotal.setValue("0.0"); + salaryTotal.setValue(BigDecimal.valueOf(0.0)); } } @@ -430,6 +432,13 @@ public class EmployeeView extends BeanValidationForm implements HasUrl return textField; } + private BigDecimalField createBigDecimalField(final String label, final boolean required) { + BigDecimalField textField = new BigDecimalField(label); + textField.setWidthFull(); + textField.setRequired(required); + return textField; + } + private EmailField createEmailField(final String label) { EmailField emailField = new EmailField(label); emailField.setWidthFull(); @@ -490,9 +499,9 @@ public class EmployeeView extends BeanValidationForm implements HasUrl employee.setStatus(status.getValue()); employee.setAge(age.getValue()); employee.setSalaryBasic(salaryBasic.getValue()); - employee.setBonoProfesional(bonoProfesional.getValue()); - employee.setAntiguedad(antiguedad.getValue()); - employee.setSalarytotal((salaryTotal.getValue())); + employee.setProfessionalBonus(professionalBonus.getValue()); + employee.setTenureBonus(tenureBonus.getValue()); + employee.setSalaryTotal((salaryTotal.getValue())); employee.setContractType(contractType.getValue()); if (contractType.getValue() == Employee.ContractType.OTROS) { employee.setCustomContractType(customContractType.getValue()); @@ -524,7 +533,7 @@ public class EmployeeView extends BeanValidationForm implements HasUrl setFieldsEditable(); upload.setVisible(true); profileImagePreview.setVisible(true); - salaryTotal.setValue(String.valueOf(0.0)); + salaryTotal.setValue(BigDecimal.valueOf(0.0)); } else { UUID employeeId = UUID.fromString(s); var employee = employeeService.getEmployee(employeeId); @@ -537,14 +546,14 @@ public class EmployeeView extends BeanValidationForm implements HasUrl upload.setVisible(true); displayProfileImage(employee); profileImagePreview.setVisible(true); - salaryTotal.setValue(employee.getSalarytotal()); + salaryTotal.setValue(employee.getSalaryTotal()); } else if ("view".equals(action) && !s.isEmpty()) { setFieldsReadOnly(); saveButton.setVisible(false); editButton.setVisible(true); setFieldsReadOnly(); displayProfileImage(employee); - salaryTotal.setValue(employee.getSalarytotal()); + salaryTotal.setValue(employee.getSalaryTotal()); } } } @@ -614,8 +623,8 @@ public class EmployeeView extends BeanValidationForm implements HasUrl seniority.setReadOnly(true); salaryTotal.setReadOnly(true); salaryBasic.setReadOnly(true); - bonoProfesional.setReadOnly(true); - antiguedad.setReadOnly(true); + professionalBonus.setReadOnly(true); + tenureBonus.setReadOnly(true); bankName.setReadOnly(true); accountNumber.setReadOnly(true); gpss.setReadOnly(true); @@ -676,8 +685,8 @@ public class EmployeeView extends BeanValidationForm implements HasUrl seniority.setReadOnly(false); salaryTotal.setReadOnly(false); salaryBasic.setReadOnly(false); - bonoProfesional.setReadOnly(false); - antiguedad.setReadOnly(false); + professionalBonus.setReadOnly(false); + tenureBonus.setReadOnly(false); bankName.setReadOnly(false); accountNumber.setReadOnly(false); gpss.setReadOnly(false); @@ -709,7 +718,7 @@ public class EmployeeView extends BeanValidationForm implements HasUrl infoAdm, cod, position, team, leadManager, infoCont, dateOfEntry, dateOfExit, seniority, contractType, customContractType, - salaryBasic, bonoProfesional, antiguedad, salaryTotal, + salaryBasic, professionalBonus, tenureBonus, salaryTotal, datBanc, bankName, accountNumber, datGest, gpss, sss, beneficiarie1, beneficiarie2, saveButton, editButton, reportButton, excelReportButton, dialog diff --git a/src/main/java/com/primefactorsolutions/views/EmployeesListView.java b/src/main/java/com/primefactorsolutions/views/EmployeesListView.java index 31799b2..387de71 100644 --- a/src/main/java/com/primefactorsolutions/views/EmployeesListView.java +++ b/src/main/java/com/primefactorsolutions/views/EmployeesListView.java @@ -112,10 +112,13 @@ public class EmployeesListView extends BaseView { .toString() : ""); row.createCell(24).setCellValue(employee.getContractType() != null ? employee.getContractType() .toString() : ""); - row.createCell(25).setCellValue(employee.getCustomContractType() != null ? employee - .getCustomContractType() : ""); + row.createCell(25).setCellValue(employee.getCustomContractType() != null + ? employee.getCustomContractType() + : ""); row.createCell(26).setCellValue(employee.getSeniority() != null ? employee.getSeniority() : ""); - row.createCell(27).setCellValue(employee.getSalarytotal() != null ? employee.getSalarytotal() : ""); + row.createCell(27).setCellValue(employee.getSalaryTotal() != null + ? employee.getSalaryTotal().toString() + : ""); } workbook.write(out); return new ByteArrayInputStream(out.toByteArray());