change numeric types
All checks were successful
Builder / Build-Project (push) Successful in 2m58s

This commit is contained in:
alex 2024-12-27 14:18:01 -05:00
parent 9f82cc3afe
commit 5067a3eb5e
6 changed files with 84 additions and 74 deletions

View File

@ -4,7 +4,7 @@
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@f0rce/ace-widget": "1.0.2", "@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-component-factory/vcf-pdf-viewer": "2.0.1",
"@vaadin/bundles": "24.5.1", "@vaadin/bundles": "24.5.1",
"@vaadin/common-frontend": "0.0.19", "@vaadin/common-frontend": "0.0.19",
@ -19,30 +19,29 @@
"@vaadin/vaadin-usage-statistics": "2.1.3", "@vaadin/vaadin-usage-statistics": "2.1.3",
"construct-style-sheets-polyfill": "3.1.0", "construct-style-sheets-polyfill": "3.1.0",
"date-fns": "2.29.3", "date-fns": "2.29.3",
"lit": "3.2.1", "lit": "3.1.4",
"print-js": "1.6.0", "print-js": "1.6.0",
"proj4": "2.12.1", "proj4": "2.12.1",
"react": "18.3.1", "react": "18.3.1",
"react-dom": "18.3.1", "react-dom": "18.3.1",
"react-router-dom": "6.26.2" "react-router-dom": "6.23.1"
}, },
"devDependencies": { "devDependencies": {
"@babel/preset-react": "7.25.7", "@babel/preset-react": "7.24.7",
"@preact/signals-react-transform": "0.4.0", "@rollup/plugin-replace": "5.0.7",
"@rollup/plugin-replace": "6.0.1", "@rollup/pluginutils": "5.1.0",
"@rollup/pluginutils": "5.1.2", "@types/react": "18.3.3",
"@types/react": "18.3.11", "@types/react-dom": "18.3.0",
"@types/react-dom": "18.3.1", "@vitejs/plugin-react": "4.3.1",
"@vitejs/plugin-react": "4.3.3", "async": "3.2.5",
"async": "3.2.6", "glob": "10.4.1",
"glob": "10.4.5",
"rollup-plugin-brotli": "3.1.0", "rollup-plugin-brotli": "3.1.0",
"rollup-plugin-visualizer": "5.12.0", "rollup-plugin-visualizer": "5.12.0",
"strip-css-comments": "5.0.0", "strip-css-comments": "5.0.0",
"transform-ast": "2.4.4", "transform-ast": "2.4.4",
"typescript": "5.6.3", "typescript": "5.4.5",
"vite": "5.4.9", "vite": "5.3.3",
"vite-plugin-checker": "0.8.0", "vite-plugin-checker": "0.6.4",
"workbox-build": "7.1.1", "workbox-build": "7.1.1",
"workbox-core": "7.1.0", "workbox-core": "7.1.0",
"workbox-precaching": "7.1.0" "workbox-precaching": "7.1.0"
@ -50,7 +49,7 @@
"vaadin": { "vaadin": {
"dependencies": { "dependencies": {
"@f0rce/ace-widget": "1.0.2", "@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-component-factory/vcf-pdf-viewer": "2.0.1",
"@vaadin/bundles": "24.5.1", "@vaadin/bundles": "24.5.1",
"@vaadin/common-frontend": "0.0.19", "@vaadin/common-frontend": "0.0.19",
@ -65,35 +64,34 @@
"@vaadin/vaadin-usage-statistics": "2.1.3", "@vaadin/vaadin-usage-statistics": "2.1.3",
"construct-style-sheets-polyfill": "3.1.0", "construct-style-sheets-polyfill": "3.1.0",
"date-fns": "2.29.3", "date-fns": "2.29.3",
"lit": "3.2.1", "lit": "3.1.4",
"print-js": "1.6.0", "print-js": "1.6.0",
"proj4": "2.12.1", "proj4": "2.12.1",
"react": "18.3.1", "react": "18.3.1",
"react-dom": "18.3.1", "react-dom": "18.3.1",
"react-router-dom": "6.26.2" "react-router-dom": "6.23.1"
}, },
"devDependencies": { "devDependencies": {
"@babel/preset-react": "7.25.7", "@babel/preset-react": "7.24.7",
"@preact/signals-react-transform": "0.4.0", "@rollup/plugin-replace": "5.0.7",
"@rollup/plugin-replace": "6.0.1", "@rollup/pluginutils": "5.1.0",
"@rollup/pluginutils": "5.1.2", "@types/react": "18.3.3",
"@types/react": "18.3.11", "@types/react-dom": "18.3.0",
"@types/react-dom": "18.3.1", "@vitejs/plugin-react": "4.3.1",
"@vitejs/plugin-react": "4.3.3", "async": "3.2.5",
"async": "3.2.6", "glob": "10.4.1",
"glob": "10.4.5",
"rollup-plugin-brotli": "3.1.0", "rollup-plugin-brotli": "3.1.0",
"rollup-plugin-visualizer": "5.12.0", "rollup-plugin-visualizer": "5.12.0",
"strip-css-comments": "5.0.0", "strip-css-comments": "5.0.0",
"transform-ast": "2.4.4", "transform-ast": "2.4.4",
"typescript": "5.6.3", "typescript": "5.4.5",
"vite": "5.4.9", "vite": "5.3.3",
"vite-plugin-checker": "0.8.0", "vite-plugin-checker": "0.6.4",
"workbox-build": "7.1.1", "workbox-build": "7.1.1",
"workbox-core": "7.1.0", "workbox-core": "7.1.0",
"workbox-precaching": "7.1.0" "workbox-precaching": "7.1.0"
}, },
"hash": "2dc40a4f634ae025081ca2239cba00b14a35fe94ab78ac0a4dd3023d882081d5" "hash": "1a0f17d48b329307b5862bc57499307d1b89f7d89260121c2b7189f76957c436"
}, },
"overrides": { "overrides": {
"@vaadin/bundles": "$@vaadin/bundles", "@vaadin/bundles": "$@vaadin/bundles",

Binary file not shown.

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
@ -93,11 +94,10 @@ public class Employee extends BaseEntity implements UserDetails {
private LocalDate dateOfExit; private LocalDate dateOfExit;
private String seniority; private String seniority;
@Pattern(regexp = "^[0-9]+(\\.[0-9]{1,2})?$", message = "El salario debe ser un número con hasta dos decimales") private BigDecimal salaryTotal = BigDecimal.ZERO;
private String salarytotal; private BigDecimal salaryBasic = BigDecimal.ZERO;
private String salaryBasic; private BigDecimal professionalBonus = BigDecimal.ZERO;
private String bonoProfesional; private BigDecimal tenureBonus = BigDecimal.ZERO;
private String antiguedad;
@Pattern(regexp = "^[a-zA-Z ]+$", message = "El nombre del banco solo debe contener letras") @Pattern(regexp = "^[a-zA-Z ]+$", message = "El nombre del banco solo debe contener letras")
private String bankName; private String bankName;
@Pattern(regexp = "^[0-9]+$", message = "El número de cuenta debe contener solo números") @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) @Enumerated(EnumType.STRING)
private ContractType contractType; private ContractType contractType;
@Size(max = 255, message = "El detalle del contrato no debe exceder 255 caracteres")
private String otherContractDetail;
public enum ContractType { public enum ContractType {
CONTRATO_LABORAL, CONTRATO_LABORAL,
CONTRATO_CIVIL_O_SERVICIOS, CONTRATO_CIVIL_O_SERVICIOS,
@ -189,7 +192,4 @@ public class Employee extends BaseEntity implements UserDetails {
CONTRATO_MIXTO, CONTRATO_MIXTO,
OTROS OTROS
} }
@Size(max = 255, message = "El detalle del contrato no debe exceder 255 caracteres")
private String otherContractDetail;
} }

View File

@ -232,9 +232,9 @@ public class ReportService {
employee.getDateOfEntry().toString(), employee.getDateOfExit() != null ? employee.getDateOfExit() employee.getDateOfEntry().toString(), employee.getDateOfExit() != null ? employee.getDateOfExit()
.toString() : "", .toString() : "",
employee.getContractType().toString(), employee.getCustomContractType(), employee.getContractType().toString(), employee.getCustomContractType(),
employee.getSeniority(), employee.getSalarytotal(), employee.getSalaryBasic(), employee.getSeniority(), employee.getSalaryTotal().toString(), employee.getSalaryBasic().toString(),
employee.getAntiguedad(), employee.getBonoProfesional(), employee.getBankName(), employee.getTenureBonus().toString(), employee.getProfessionalBonus().toString(),
employee.getAccountNumber(), employee.getGpss(), employee.getSss(), employee.getBankName(), employee.getAccountNumber(), employee.getGpss(), employee.getSss(),
employee.getBeneficiarie1(), employee.getBeneficiarie2() employee.getBeneficiarie1(), employee.getBeneficiarie2()
}; };
for (int i = 0; i < employeeData.length; i++) { for (int i = 0; i < employeeData.length; i++) {

View File

@ -21,6 +21,7 @@ import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.FlexComponent; import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout; 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.EmailField;
import com.vaadin.flow.component.textfield.TextField; import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.component.upload.Upload; import com.vaadin.flow.component.upload.Upload;
@ -37,6 +38,7 @@ import org.vaadin.firitin.form.BeanValidationForm;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.Base64; import java.util.Base64;
@ -106,12 +108,12 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
private final VDatePicker dateOfExit = new VDatePicker("Fecha de Retiro"); private final VDatePicker dateOfExit = new VDatePicker("Fecha de Retiro");
private final ComboBox<Employee.ContractType> contractType = createContractTypeComboBox(); private final ComboBox<Employee.ContractType> contractType = createContractTypeComboBox();
private final TextField customContractType = createCustomContractTypeField(); private final TextField customContractType = createCustomContractTypeField();
private final TextField seniority = createTextField("Antiguedad", 30, false); private final TextField seniority = createTextField("Antiguedad", 30, false);
private final TextField salaryTotal = createTextField("Salario Total", 10, false); private final BigDecimalField salaryTotal = createBigDecimalField("Salario Total", false);
private final TextField salaryBasic = createTextField("Salario Basico", 10, false); private final BigDecimalField salaryBasic = createBigDecimalField("Salario Basico", false);
private final TextField antiguedad = createTextField("Bono de Antiguedad", 10, false); private final BigDecimalField tenureBonus = createBigDecimalField("Bono de Antiguedad", false);
private final TextField bonoProfesional = createTextField("Bono Profesional", 30, false); private final BigDecimalField professionalBonus = createBigDecimalField("Bono Profesional", false);
private final TextField bankName = createTextField("Banco", 30, false); private final TextField bankName = createTextField("Banco", 30, false);
private final TextField accountNumber = createTextField("Nro. de Cuenta", 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 gpss = createTextField("Código Único de Asegurado (GPSS)", 30, false);
private final TextField sss = createTextField("Matricula de Asegurado (SSS)", 30, false); private final TextField sss = createTextField("Matricula de Asegurado (SSS)", 30, false);
@ -288,16 +290,16 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
private void calculateSalaryTotal() { private void calculateSalaryTotal() {
if (contractType.getValue() == Employee.ContractType.CONTRATO_LABORAL) { if (contractType.getValue() == Employee.ContractType.CONTRATO_LABORAL) {
salaryBasic.setVisible(true); salaryBasic.setVisible(true);
bonoProfesional.setVisible(true); professionalBonus.setVisible(true);
antiguedad.setVisible(true); tenureBonus.setVisible(true);
salaryTotal.setVisible(true); salaryTotal.setVisible(true);
salaryBasic.addValueChangeListener(event -> updateTotalSalary()); salaryBasic.addValueChangeListener(event -> updateTotalSalary());
bonoProfesional.addValueChangeListener(event -> updateTotalSalary()); professionalBonus.addValueChangeListener(event -> updateTotalSalary());
antiguedad.addValueChangeListener(event -> updateTotalSalary()); tenureBonus.addValueChangeListener(event -> updateTotalSalary());
} else { } else {
salaryBasic.setVisible(false); salaryBasic.setVisible(false);
bonoProfesional.setVisible(false); professionalBonus.setVisible(false);
antiguedad.setVisible(false); tenureBonus.setVisible(false);
salaryTotal.setVisible(true); salaryTotal.setVisible(true);
} }
salaryTotal.getValue(); salaryTotal.getValue();
@ -305,13 +307,13 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
private void updateTotalSalary() { private void updateTotalSalary() {
try { try {
double basic = parseDoubleValue(salaryBasic.getValue()); final BigDecimal basic = salaryBasic.getValue();
double bonus = parseDoubleValue(bonoProfesional.getValue()); final BigDecimal bonus = professionalBonus.getValue();
double seniorityBonus = parseDoubleValue(antiguedad.getValue()); final BigDecimal seniorityBonus = tenureBonus.getValue();
double totalSalary = basic + bonus + seniorityBonus; final BigDecimal totalSalary = basic.add(bonus).add(seniorityBonus);
salaryTotal.setValue(String.valueOf(totalSalary)); salaryTotal.setValue(totalSalary);
} catch (Exception e) { } catch (Exception e) {
salaryTotal.setValue("0.0"); salaryTotal.setValue(BigDecimal.valueOf(0.0));
} }
} }
@ -430,6 +432,13 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
return textField; 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) { private EmailField createEmailField(final String label) {
EmailField emailField = new EmailField(label); EmailField emailField = new EmailField(label);
emailField.setWidthFull(); emailField.setWidthFull();
@ -490,9 +499,9 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
employee.setStatus(status.getValue()); employee.setStatus(status.getValue());
employee.setAge(age.getValue()); employee.setAge(age.getValue());
employee.setSalaryBasic(salaryBasic.getValue()); employee.setSalaryBasic(salaryBasic.getValue());
employee.setBonoProfesional(bonoProfesional.getValue()); employee.setProfessionalBonus(professionalBonus.getValue());
employee.setAntiguedad(antiguedad.getValue()); employee.setTenureBonus(tenureBonus.getValue());
employee.setSalarytotal((salaryTotal.getValue())); employee.setSalaryTotal((salaryTotal.getValue()));
employee.setContractType(contractType.getValue()); employee.setContractType(contractType.getValue());
if (contractType.getValue() == Employee.ContractType.OTROS) { if (contractType.getValue() == Employee.ContractType.OTROS) {
employee.setCustomContractType(customContractType.getValue()); employee.setCustomContractType(customContractType.getValue());
@ -524,7 +533,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
setFieldsEditable(); setFieldsEditable();
upload.setVisible(true); upload.setVisible(true);
profileImagePreview.setVisible(true); profileImagePreview.setVisible(true);
salaryTotal.setValue(String.valueOf(0.0)); salaryTotal.setValue(BigDecimal.valueOf(0.0));
} else { } else {
UUID employeeId = UUID.fromString(s); UUID employeeId = UUID.fromString(s);
var employee = employeeService.getEmployee(employeeId); var employee = employeeService.getEmployee(employeeId);
@ -537,14 +546,14 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
upload.setVisible(true); upload.setVisible(true);
displayProfileImage(employee); displayProfileImage(employee);
profileImagePreview.setVisible(true); profileImagePreview.setVisible(true);
salaryTotal.setValue(employee.getSalarytotal()); salaryTotal.setValue(employee.getSalaryTotal());
} else if ("view".equals(action) && !s.isEmpty()) { } else if ("view".equals(action) && !s.isEmpty()) {
setFieldsReadOnly(); setFieldsReadOnly();
saveButton.setVisible(false); saveButton.setVisible(false);
editButton.setVisible(true); editButton.setVisible(true);
setFieldsReadOnly(); setFieldsReadOnly();
displayProfileImage(employee); displayProfileImage(employee);
salaryTotal.setValue(employee.getSalarytotal()); salaryTotal.setValue(employee.getSalaryTotal());
} }
} }
} }
@ -614,8 +623,8 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
seniority.setReadOnly(true); seniority.setReadOnly(true);
salaryTotal.setReadOnly(true); salaryTotal.setReadOnly(true);
salaryBasic.setReadOnly(true); salaryBasic.setReadOnly(true);
bonoProfesional.setReadOnly(true); professionalBonus.setReadOnly(true);
antiguedad.setReadOnly(true); tenureBonus.setReadOnly(true);
bankName.setReadOnly(true); bankName.setReadOnly(true);
accountNumber.setReadOnly(true); accountNumber.setReadOnly(true);
gpss.setReadOnly(true); gpss.setReadOnly(true);
@ -676,8 +685,8 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
seniority.setReadOnly(false); seniority.setReadOnly(false);
salaryTotal.setReadOnly(false); salaryTotal.setReadOnly(false);
salaryBasic.setReadOnly(false); salaryBasic.setReadOnly(false);
bonoProfesional.setReadOnly(false); professionalBonus.setReadOnly(false);
antiguedad.setReadOnly(false); tenureBonus.setReadOnly(false);
bankName.setReadOnly(false); bankName.setReadOnly(false);
accountNumber.setReadOnly(false); accountNumber.setReadOnly(false);
gpss.setReadOnly(false); gpss.setReadOnly(false);
@ -709,7 +718,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
infoAdm, infoAdm,
cod, position, team, leadManager, cod, position, team, leadManager,
infoCont, dateOfEntry, dateOfExit, seniority, contractType, customContractType, infoCont, dateOfEntry, dateOfExit, seniority, contractType, customContractType,
salaryBasic, bonoProfesional, antiguedad, salaryTotal, salaryBasic, professionalBonus, tenureBonus, salaryTotal,
datBanc, bankName, accountNumber, datBanc, bankName, accountNumber,
datGest, gpss, sss, beneficiarie1, beneficiarie2, datGest, gpss, sss, beneficiarie1, beneficiarie2,
saveButton, editButton, reportButton, excelReportButton, dialog saveButton, editButton, reportButton, excelReportButton, dialog

View File

@ -112,10 +112,13 @@ public class EmployeesListView extends BaseView {
.toString() : ""); .toString() : "");
row.createCell(24).setCellValue(employee.getContractType() != null ? employee.getContractType() row.createCell(24).setCellValue(employee.getContractType() != null ? employee.getContractType()
.toString() : ""); .toString() : "");
row.createCell(25).setCellValue(employee.getCustomContractType() != null ? employee row.createCell(25).setCellValue(employee.getCustomContractType() != null
.getCustomContractType() : ""); ? employee.getCustomContractType()
: "");
row.createCell(26).setCellValue(employee.getSeniority() != null ? employee.getSeniority() : ""); 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); workbook.write(out);
return new ByteArrayInputStream(out.toByteArray()); return new ByteArrayInputStream(out.toByteArray());