From 9c1921df9acb5b555661e1bf1198bc8d464fd1f4 Mon Sep 17 00:00:00 2001 From: Melina Gutierrez Date: Mon, 25 Nov 2024 16:32:02 -0400 Subject: [PATCH] Corregir nombre de bono por Antiguedad --- .../primefactorsolutions/model/Employee.java | 5 +++ .../views/EmployeeView.java | 35 +++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/primefactorsolutions/model/Employee.java b/src/main/java/com/primefactorsolutions/model/Employee.java index 83b9d42..d62f09b 100644 --- a/src/main/java/com/primefactorsolutions/model/Employee.java +++ b/src/main/java/com/primefactorsolutions/model/Employee.java @@ -102,6 +102,7 @@ public class Employee extends BaseEntity implements UserDetails { private String bankName; @Pattern(regexp = "^[0-9]+$", message = "El número de cuenta debe contener solo números") private String accountNumber; + private String customContractType; private String gpss; private String sss; @@ -114,6 +115,10 @@ public class Employee extends BaseEntity implements UserDetails { @Enumerated(EnumType.STRING) private Status status; + public void setCustomContractType(String customContractType) { + this.customContractType = customContractType; + } + @Override public Collection getAuthorities() { return Lists.newArrayList(); diff --git a/src/main/java/com/primefactorsolutions/views/EmployeeView.java b/src/main/java/com/primefactorsolutions/views/EmployeeView.java index 0fcc551..1e15de9 100644 --- a/src/main/java/com/primefactorsolutions/views/EmployeeView.java +++ b/src/main/java/com/primefactorsolutions/views/EmployeeView.java @@ -106,10 +106,11 @@ public class EmployeeView extends BeanValidationForm implements HasUrl private final VDatePicker dateOfEntry = new VDatePicker("Fecha de Ingreso"); 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("Descuento por Antiguedad", 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 accountNumber = createTextField("Nro. de Cuenta", 30, false); @@ -383,10 +384,30 @@ public class EmployeeView extends BeanValidationForm implements HasUrl comboBox.setItemLabelGenerator(Employee.ContractType::name); comboBox.setRequiredIndicatorVisible(true); comboBox.setWidth("300px"); - comboBox.setMinWidth("200px"); + comboBox.addValueChangeListener(event -> handleContractTypeChange(event.getValue())); return comboBox; } + private TextField createCustomContractTypeField() { + TextField textField = new TextField("Especificar Tipo de Contrato"); + textField.setPlaceholder("Ingrese el tipo de contrato..."); + textField.setVisible(false); + textField.setWidth("300px"); + return textField; + } + + private void handleContractTypeChange(Employee.ContractType selectedType) { + if (selectedType == Employee.ContractType.OTROS) { + customContractType.setVisible(true); + customContractType.setRequired(true); + } else { + customContractType.setVisible(false); + customContractType.clear(); + customContractType.setRequired(false); + } + } + + private VerticalLayout createContentLayout() { VerticalLayout contentLayout = new VerticalLayout(); contentLayout.setWidth("100%"); @@ -464,6 +485,12 @@ public class EmployeeView extends BeanValidationForm implements HasUrl employee.setBonoProfesional(bonoProfesional.getValue()); employee.setAntiguedad(antiguedad.getValue()); employee.setSalarytotal((salaryTotal.getValue())); + employee.setContractType(contractType.getValue()); + if (contractType.getValue() == Employee.ContractType.OTROS) { + employee.setCustomContractType(customContractType.getValue()); + } else { + employee.setCustomContractType(null); + } employeeService.createOrUpdate(employee); Notification.show(NOTIFICATION_SAVE_SUCCESS); getUI().ifPresent(ui -> ui.navigate(EmployeesListView.class)); @@ -575,6 +602,7 @@ public class EmployeeView extends BeanValidationForm implements HasUrl dateOfEntry.setReadOnly(true); dateOfExit.setReadOnly(true); contractType.setReadOnly(true); + customContractType.setReadOnly(true); seniority.setReadOnly(true); salaryTotal.setReadOnly(true); salaryBasic.setReadOnly(true); @@ -637,6 +665,7 @@ public class EmployeeView extends BeanValidationForm implements HasUrl dateOfEntry.setReadOnly(false); dateOfExit.setReadOnly(false); contractType.setReadOnly(false); + customContractType.setReadOnly(false); seniority.setReadOnly(false); salaryTotal.setReadOnly(false); salaryBasic.setReadOnly(false); @@ -671,7 +700,7 @@ public class EmployeeView extends BeanValidationForm implements HasUrl idioma, language1, language1Level, language2, language2Level, infoAdm, cod, position, team, leadManager, - infoCont, dateOfEntry, dateOfExit, contractType, seniority, + infoCont, dateOfEntry, dateOfExit, seniority, contractType, customContractType, salaryBasic, bonoProfesional, antiguedad, salaryTotal, datBanc, bankName, accountNumber, datGest, gpss, sss, beneficiarie1, beneficiarie2,