From 0d10bf21e2cb980f7c3a5288b7ab7a88f0348daf Mon Sep 17 00:00:00 2001 From: "Brayan.Gonzalez" Date: Mon, 28 Jul 2025 12:19:25 -0600 Subject: [PATCH] =?UTF-8?q?-=20APARTADO=20PARA=20CAPTURAR=20EL=20IDENTIFIC?= =?UTF-8?q?ADOR=20DE=20FOLIOS=20POR=20EMPLEADO=20EN=20EL=20REGISTRO=20-=20?= =?UTF-8?q?APARTADO=20PARA=20PODER=20EDITAR=20EL=20IDENTIFICADOR=20DE=20FO?= =?UTF-8?q?LIOS.=C2=A0=20-=20ACTUALIZACI=C3=93N=20DEL=20WEB=20SERVIRSE=20P?= =?UTF-8?q?ARA=20EL=20MANEJO=20DE=20LOS=20NUEVOS=20DATOS=20DE=20CAPTURA=20?= =?UTF-8?q?PARA=20LAS=20VENTAS=20"FACHADA=20DE=20LA=20CASA",=20"DESCRIPCI?= =?UTF-8?q?=C3=93N",=20"LONGITUD"=20Y=20"LATITUD=20-=20CORRECCI=C3=93N=20D?= =?UTF-8?q?E=20ERROR=20AL=20CAPTURAR=20LOS=20PAGOS=20POR=20TRANSFERENCIA?= =?UTF-8?q?=20-=20INVENTARIO=20DE=20PRODUCTOS=20SE=20AGREGAR=C3=81=20USUAR?= =?UTF-8?q?IO=20QUE=20HIZO=20EL=20MOVIMIENTO=20Y=20FECHA.=20TENDRA=20UNA?= =?UTF-8?q?=20EXPORTACION=20EN=20EXCEL.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/loan/LoanController.java | 2413 +++++++++-------- .../controller/login/LoginWSController.java | 89 +- .../controller/mobile/moxy/login/UserMxy.java | 183 +- .../LoanApprovedDetailViewRepository.java | 75 +- .../system/employee/EmployeeController.java | 5 + .../arrebol/apc/model/core/HumanResource.java | 38 + .../apc/model/core/constance/LoanCfg.java | 95 +- .../model/core/constance/LoanDetailsCfg.java | 39 +- .../java/com/arrebol/apc/model/loan/Loan.java | 82 + .../arrebol/apc/model/loan/LoanDetails.java | 572 ++-- .../com/arrebol/apc/model/loan/LoanType.java | 19 + .../apc/model/mobile/access/MobileUser.java | 169 +- .../apc/model/ws/parsed/LoanDetailJaxb.java | 13 +- .../model/ws/parsed/LoanRequestedJaxb.java | 211 +- .../apc/model/ws/parsed/NewAmountJaxb.java | 168 +- .../ws/parsed/NewTransferAccountJaxb.java | 135 +- .../apc/model/ws/parsed/PersonJaxb.java | 204 +- .../queries/loan/loan.details.queries.hbm.xml | 45 +- .../model/queries/loan/loan.queries.hbm.xml | 65 + .../apc/web/beans/admin/EmployeeListBean.java | 128 +- .../beans/system/employee/EmployeeBean.java | 21 + .../webapp/app/catalog/loanType/index.xhtml | 19 + .../app/system/employee/employeeList.xhtml | 70 +- .../webapp/app/system/employee/main.xhtml | 8 + apc-ws-rest/pom.xml | 4 +- .../java/com/arrebol/apc/ws/loan/LoanWS.java | 1484 +++++----- 26 files changed, 3518 insertions(+), 2836 deletions(-) diff --git a/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/loan/LoanController.java b/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/loan/LoanController.java index d4c3044..82b6c45 100644 --- a/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/loan/LoanController.java +++ b/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/loan/LoanController.java @@ -1,8 +1,8 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.controller.mobile.controller.loan; @@ -10,7 +10,6 @@ package com.arrebol.apc.controller.mobile.controller.loan; import com.arrebol.apc.controller.mobile.json.loan.AuthorizeTransferList; import com.arrebol.apc.controller.mobile.json.loan.AuthorizeTransferPaymentsDto; import com.arrebol.apc.controller.mobile.json.loan.DeleteLoanDetailsJaxb; -import com.arrebol.apc.model.ws.parsed.LoanRequestedJaxb; import com.arrebol.apc.controller.mobile.json.loan.LoanTypeJaxb; import com.arrebol.apc.controller.mobile.json.loan.LoanTypeListJaxb; import com.arrebol.apc.controller.mobile.json.loan.UpdateLoanToDeliveryStatusDTO; @@ -65,6 +64,7 @@ import com.arrebol.apc.model.views.constance.LoanInPendingStatusToDeliveryViewCf import com.arrebol.apc.model.views.constance.TransferInPendingStatusViewCfg; import com.arrebol.apc.model.ws.parsed.FeesToPayByLoanRequestJaxb; import com.arrebol.apc.model.ws.parsed.LoanDetailJaxb; +import com.arrebol.apc.model.ws.parsed.LoanRequestedJaxb; import com.arrebol.apc.model.ws.parsed.NewAmountJaxb; import com.arrebol.apc.model.ws.parsed.NewTransferAccountJaxb; import com.arrebol.apc.model.ws.parsed.PersonJaxb; @@ -86,1026 +86,1031 @@ import org.apache.logging.log4j.Logger; */ public class LoanController implements Serializable { - /** - * - * @param loanIdToUpdate - * @return - */ - public boolean deleteLoanDetailsFeeByLoanCurdate(String loanIdToUpdate) { - logger.debug("deleteLoanDetailsFeeByLoanCurdate"); + /** + * + * @param loanIdToUpdate + * @return + */ + public boolean deleteLoanDetailsFeeByLoanCurdate(String loanIdToUpdate) { + logger.debug("deleteLoanDetailsFeeByLoanCurdate"); - List parameters = new ArrayList<>(); + List parameters = new ArrayList<>(); - parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanIdToUpdate))); - return loanRepository.deleteLoanDetailsByLoanCurdate(LoanCfg.QUERY_DELETE_LOAN_DETAILS_FEE_CURDATE_BY_LOAN, parameters); - } + parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanIdToUpdate))); + return loanRepository.deleteLoanDetailsByLoanCurdate(LoanCfg.QUERY_DELETE_LOAN_DETAILS_FEE_CURDATE_BY_LOAN, parameters); + } - /** - * - * @param loanIdToUpdate - * @return - */ - public boolean deleteLoanFeeNotificationByLoanCurdate(String loanIdToUpdate) { - logger.debug("deleteLoanFeeNotificationByLoanCurdate"); + /** + * + * @param loanIdToUpdate + * @return + */ + public boolean deleteLoanFeeNotificationByLoanCurdate(String loanIdToUpdate) { + logger.debug("deleteLoanFeeNotificationByLoanCurdate"); - List parameters = new ArrayList<>(); + List parameters = new ArrayList<>(); - parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanIdToUpdate))); + parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanIdToUpdate))); - return loanRepository.deleteLoanDetailsByLoanCurdate(LoanCfg.QUERY_DELETE_LOAN_FEE_NOTIFICATION_CURDATE_BY_LOAN, parameters); - } + return loanRepository.deleteLoanDetailsByLoanCurdate(LoanCfg.QUERY_DELETE_LOAN_FEE_NOTIFICATION_CURDATE_BY_LOAN, parameters); + } - /** - * - * @param loan - * @return - * @throws Exception - */ - public boolean updateLoan(Loan loan) throws Exception { - logger.debug("updateLoan"); - try { - return loanRepository.updateLoan(loan); - } catch (Exception e) { - logger.error("updateLoan", e); - throw e; - } - } + /** + * + * @param loan + * @return + * @throws Exception + */ + public boolean updateLoan(Loan loan) throws Exception { + logger.debug("updateLoan"); + try { + return loanRepository.updateLoan(loan); + } catch (Exception e) { + logger.error("updateLoan", e); + throw e; + } + } - /** - * - * @param loanIdToUpdate - * @return - */ - public boolean deleteLoanDetailsByLoanCurdate(Loan loanIdToUpdate) { - logger.debug("updateLoandByUserByUserId"); + /** + * + * @param loanIdToUpdate + * @return + */ + public boolean deleteLoanDetailsByLoanCurdate(Loan loanIdToUpdate) { + logger.debug("updateLoandByUserByUserId"); - List parameters = new ArrayList<>(); + List parameters = new ArrayList<>(); - parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, loanIdToUpdate)); + parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, loanIdToUpdate)); - return loanRepository.deleteLoanDetailsByLoanCurdate(LoanCfg.QUERY_DELETE_LOAN_DETAILS_CURDATE_BY_LOAN, parameters); - } + return loanRepository.deleteLoanDetailsByLoanCurdate(LoanCfg.QUERY_DELETE_LOAN_DETAILS_CURDATE_BY_LOAN, parameters); + } - /** - * - * @param customerId - * @param userId - * @return - * @throws Exception - */ - public DeleteLoanDetailsJaxb enebleToDeleteTodayDetails(String customerId, String userId) throws Exception { - DeleteLoanDetailsJaxb result; - try { - List parameters = new ArrayList<>(); - List statuses = new ArrayList<>(); + /** + * + * @param customerId + * @param userId + * @return + * @throws Exception + */ + public DeleteLoanDetailsJaxb enebleToDeleteTodayDetails(String customerId, String userId) throws Exception { + DeleteLoanDetailsJaxb result; + try { + List parameters = new ArrayList<>(); + List statuses = new ArrayList<>(); - parameters.add(new ModelParameter(UserCfg.FIELD_ID, userId)); - UserRepository userRepository = new UserRepository(); + parameters.add(new ModelParameter(UserCfg.FIELD_ID, userId)); + UserRepository userRepository = new UserRepository(); - if (userRepository.containtsUserManagementProperty(UserCfg.QUERY_IS_USER_MANAGMENT, parameters)) { - statuses.add(LoanStatus.APPROVED); - statuses.add(LoanStatus.PENDING_RENOVATION); + if (userRepository.containtsUserManagementProperty(UserCfg.QUERY_IS_USER_MANAGMENT, parameters)) { + statuses.add(LoanStatus.APPROVED); + statuses.add(LoanStatus.PENDING_RENOVATION); - parameters.clear(); - parameters.add(new ModelParameter(LoanCfg.FIELD_CUSTOMER, new People(customerId))); - parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, statuses)); + parameters.clear(); + parameters.add(new ModelParameter(LoanCfg.FIELD_CUSTOMER, new People(customerId))); + parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, statuses)); - if (1 == loanRepository.countLoan(LoanCfg.QUERY_COUNT_LOAN_BY_CUSTOMER_IN_STATUSES, parameters)) { - String loanId = loanRepository.findLoanId(LoanCfg.QUERY_SELECT_LOAN_ID_BY_CUSTOMER_IN_STATUSES, parameters); + if (1 == loanRepository.countLoan(LoanCfg.QUERY_COUNT_LOAN_BY_CUSTOMER_IN_STATUSES, parameters)) { + String loanId = loanRepository.findLoanId(LoanCfg.QUERY_SELECT_LOAN_ID_BY_CUSTOMER_IN_STATUSES, parameters); - result = new DeleteLoanDetailsJaxb(Boolean.FALSE, Boolean.FALSE, loanId); - List types = new ArrayList<>(); + result = new DeleteLoanDetailsJaxb(Boolean.FALSE, Boolean.FALSE, loanId); + List types = new ArrayList<>(); - parameters.clear(); - parameters.add(new ModelParameter(LoanCfg.FIELD_ID, loanId)); - parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, statuses)); + parameters.clear(); + parameters.add(new ModelParameter(LoanCfg.FIELD_ID, loanId)); + parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, statuses)); - result.setApprovedOrPendingRenovation(0 < loanRepository.countLoan(LoanCfg.QUERY_COUNT_LOAN_IN_STATUSES, parameters)); + result.setApprovedOrPendingRenovation(0 < loanRepository.countLoan(LoanCfg.QUERY_COUNT_LOAN_IN_STATUSES, parameters)); - if (result.getApprovedOrPendingRenovation()) { - types.add(LoanDetailsType.PAYMENT); - types.add(LoanDetailsType.TRANSFER); + if (result.getApprovedOrPendingRenovation()) { + types.add(LoanDetailsType.PAYMENT); + types.add(LoanDetailsType.TRANSFER); - parameters.clear(); - parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID_LOAN, new Loan(loanId))); - parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_LOAN_DETAILS_TYPE, types)); + parameters.clear(); + parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID_LOAN, new Loan(loanId))); + parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_LOAN_DETAILS_TYPE, types)); - result.setTodayPayment(0 < loanDetailsRepository.countLoandDetails(LoanDetailsCfg.QUERY_COUNT_LOAN_DETAILS_IN_CURRDATE, parameters)); + result.setTodayPayment(0 < loanDetailsRepository.countLoandDetails(LoanDetailsCfg.QUERY_COUNT_LOAN_DETAILS_IN_CURRDATE, parameters)); - types.clear(); - types.add(LoanDetailsType.FEE); + types.clear(); + types.add(LoanDetailsType.FEE); - parameters.clear(); - parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID_LOAN, new Loan(loanId))); - parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_LOAN_DETAILS_TYPE, types)); + parameters.clear(); + parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID_LOAN, new Loan(loanId))); + parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_LOAN_DETAILS_TYPE, types)); - result.setTodayFee(0 < loanDetailsRepository.countLoandDetails(LoanDetailsCfg.QUERY_COUNT_LOAN_DETAILS_IN_CURRDATE, parameters)); - } - } else { - result = new DeleteLoanDetailsJaxb(Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, ""); - } + result.setTodayFee(0 < loanDetailsRepository.countLoandDetails(LoanDetailsCfg.QUERY_COUNT_LOAN_DETAILS_IN_CURRDATE, parameters)); + } } else { - result = new DeleteLoanDetailsJaxb(Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, ""); + result = new DeleteLoanDetailsJaxb(Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, ""); + } + } else { + result = new DeleteLoanDetailsJaxb(Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, ""); + } + + return result; + } catch (Exception e) { + logger.error("enebleToDeleteTodayDetails", e); + throw e; + } + } + + /** + * + * @param idLoan + * @return + * @throws Exception + */ + public List findFeesToPayByLoanId(String idLoan) throws Exception { + try { + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID_LOAN, new Loan(idLoan))); + return loanDetailsRepository.findFeesToPayByLoanId(LoanDetailsCfg.QUERY_FIND_ALL_FEES_BY_LOAN_ID, parameters); + } catch (Exception e) { + logger.error("findFeesToPayByLoanId", e); + throw e; + } + } + + /** + * + * @param feesToPayByLoanRequestJaxb + * @return + * @throws Exception + */ + public boolean updatePaidFeesStatusInLoanDetailIds(FeesToPayByLoanRequestJaxb feesToPayByLoanRequestJaxb) throws Exception { + try { + List parameters = new ArrayList<>(); + + List ids = new ArrayList<>(); + + feesToPayByLoanRequestJaxb.getFeeToPayList().forEach(fee -> { + ids.add(fee.getId()); + }); + + int cantidad = feesToPayByLoanRequestJaxb.getFeeToPayList().size(); + String texto; + String precio; + + Locale canada = new Locale("en", "CA"); + NumberFormat dollarFormat = NumberFormat.getCurrencyInstance(canada); + BigDecimal feePayment; + + if (1 == cantidad) { + precio = dollarFormat.format(50); + feePayment = new BigDecimal("50"); + + texto = " de la multa del " + feesToPayByLoanRequestJaxb.getFeeToPayList().get(0).getStrDateToPay(); + } else { + feePayment = new BigDecimal(50 * cantidad); + precio = dollarFormat.format(50 * cantidad); + String fechas = ""; + + for (int i = 0; i < feesToPayByLoanRequestJaxb.getFeeToPayList().size(); i++) { + fechas = fechas + feesToPayByLoanRequestJaxb.getFeeToPayList().get(i).getStrDateToPay(); + if (feesToPayByLoanRequestJaxb.getFeeToPayList().size() > 1) { + fechas = fechas + ","; + } } - return result; - } catch (Exception e) { - logger.error("enebleToDeleteTodayDetails", e); - throw e; - } - } - - /** - * - * @param idLoan - * @return - * @throws Exception - */ - public List findFeesToPayByLoanId(String idLoan) throws Exception { - try { - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID_LOAN, new Loan(idLoan))); - return loanDetailsRepository.findFeesToPayByLoanId(LoanDetailsCfg.QUERY_FIND_ALL_FEES_BY_LOAN_ID, parameters); - } catch (Exception e) { - logger.error("findFeesToPayByLoanId", e); - throw e; - } - } - - /** - * - * @param feesToPayByLoanRequestJaxb - * @return - * @throws Exception - */ - public boolean updatePaidFeesStatusInLoanDetailIds(FeesToPayByLoanRequestJaxb feesToPayByLoanRequestJaxb) throws Exception { - try { - List parameters = new ArrayList<>(); - - List ids = new ArrayList<>(); - - feesToPayByLoanRequestJaxb.getFeeToPayList().forEach(fee -> { - ids.add(fee.getId()); - }); - - int cantidad = feesToPayByLoanRequestJaxb.getFeeToPayList().size(); - String texto; - String precio; - - Locale canada = new Locale("en", "CA"); - NumberFormat dollarFormat = NumberFormat.getCurrencyInstance(canada); - BigDecimal feePayment; - - if (1 == cantidad) { - precio = dollarFormat.format(50); - feePayment = new BigDecimal("50"); - - texto = " de la multa del " + feesToPayByLoanRequestJaxb.getFeeToPayList().get(0).getStrDateToPay(); - } else { - feePayment = new BigDecimal(50 * cantidad); - precio = dollarFormat.format(50 * cantidad); - String fechas = ""; - - for (int i = 0; i < feesToPayByLoanRequestJaxb.getFeeToPayList().size(); i++) { - fechas = fechas + feesToPayByLoanRequestJaxb.getFeeToPayList().get(i).getStrDateToPay(); - if (feesToPayByLoanRequestJaxb.getFeeToPayList().size() > 1) { - fechas = fechas + ","; - } - } - - if (feesToPayByLoanRequestJaxb.getFeeToPayList().size() > 1) { - fechas = fechas.substring(0, fechas.length() - 1); - } - - texto = " de las multas " + fechas; + if (feesToPayByLoanRequestJaxb.getFeeToPayList().size() > 1) { + fechas = fechas.substring(0, fechas.length() - 1); } - String comments = "Se pago " + precio + texto; + texto = " de las multas " + fechas; + } - LoanDetails details = new LoanDetails( - UUID.randomUUID().toString(), - new Loan(feesToPayByLoanRequestJaxb.getIdLoan()), - new User(feesToPayByLoanRequestJaxb.getIdUser()), - PeopleType.CUSTOMER, - 0, - feePayment, - LoanDetailsType.PAYMENT, - comments, - feesToPayByLoanRequestJaxb.getIdUser(), - new Date()); + String comments = "Se pago " + precio + texto; - parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID, ids)); + LoanDetails details = new LoanDetails( + UUID.randomUUID().toString(), + new Loan(feesToPayByLoanRequestJaxb.getIdLoan()), + new User(feesToPayByLoanRequestJaxb.getIdUser()), + PeopleType.CUSTOMER, + 0, + feePayment, + LoanDetailsType.PAYMENT, + comments, + feesToPayByLoanRequestJaxb.getIdUser(), + new Date()); - return loanDetailsRepository.updatePaidFeesStatusInLoanDetailIds(LoanDetailsCfg.QUERY_UPDATE_PAID_FEES_STATUS_IN_LOAN_DETAILS_IDS, parameters, details); - } catch (Exception e) { - logger.error("updatePaidFeesStatusInLoanDetailIds", e); - throw e; - } - } + parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID, ids)); - /** - * - * @param officeId - * @return - * @throws Exception - */ - public LoanTypeListJaxb findAllLoanTypeByOffice(String officeId) throws Exception { - logger.debug("findAllLoanTypeByOffice"); - LoanTypeListJaxb loanTypeListJaxb = new LoanTypeListJaxb(); - try { - List parameters = new ArrayList<>(); + return loanDetailsRepository.updatePaidFeesStatusInLoanDetailIds(LoanDetailsCfg.QUERY_UPDATE_PAID_FEES_STATUS_IN_LOAN_DETAILS_IDS, parameters, details); + } catch (Exception e) { + logger.error("updatePaidFeesStatusInLoanDetailIds", e); + throw e; + } + } - parameters.add(new ModelParameter(LoanTypeCfg.FIELD_OFFICE, new Office(officeId))); + /** + * + * @param officeId + * @return + * @throws Exception + */ + public LoanTypeListJaxb findAllLoanTypeByOffice(String officeId) throws Exception { + logger.debug("findAllLoanTypeByOffice"); + LoanTypeListJaxb loanTypeListJaxb = new LoanTypeListJaxb(); + try { + List parameters = new ArrayList<>(); - List results = loanTypeRepository.findAllLoanTypeByOffice(LoanTypeCfg.QUERY_FIND_ALL_LOAN_TYPE_WITH_DESCRIPTION_BY_OFFICE, parameters); - List loanTypeJaxbs = new ArrayList<>(); + parameters.add(new ModelParameter(LoanTypeCfg.FIELD_OFFICE, new Office(officeId))); - results.forEach((result) -> { - loanTypeJaxbs.add(new LoanTypeJaxb(result.getId(), result.getPayment(), result.getLoanTypeName())); - }); + List results = loanTypeRepository.findAllLoanTypeByOffice(LoanTypeCfg.QUERY_FIND_ALL_LOAN_TYPE_WITH_DESCRIPTION_BY_OFFICE, parameters); + List loanTypeJaxbs = new ArrayList<>(); - loanTypeListJaxb.setLoans(loanTypeJaxbs); + results.forEach((result) -> { + loanTypeJaxbs.add(new LoanTypeJaxb(result.getId(), result.getPayment(), result.getLoanTypeName())); + }); - return loanTypeListJaxb; - } catch (Exception e) { - logger.error("findAllLoanTypeByOffice", e); - throw e; - } - } + loanTypeListJaxb.setLoans(loanTypeJaxbs); - /** - * - * @param name - * @return - * @throws Exception - */ - public List findAllAvailableCustomersByType(String name) throws Exception { - logger.debug("findAllAvailableCustomersByType"); - try { - List parameters = new ArrayList<>(); + return loanTypeListJaxb; + } catch (Exception e) { + logger.error("findAllLoanTypeByOffice", e); + throw e; + } + } - parameters.add(new ModelParameter(AvailableCustomersViewCfg.FIELD_AVAILABLE_PERSON, name)); + /** + * + * @param name + * @return + * @throws Exception + */ + public List findAllAvailableCustomersByType(String name) throws Exception { + logger.debug("findAllAvailableCustomersByType"); + try { + List parameters = new ArrayList<>(); - return searchPersonAvailableRepository.findAvailablePersonLike( - AvailableCustomersView.class, - AvailableCustomersViewCfg.QUERY_FIND_AVAILABLE_CUSTOMERS, - parameters); - } catch (Exception e) { - logger.error("findAllAvailableCustomersByType", e); - throw e; - } - } + parameters.add(new ModelParameter(AvailableCustomersViewCfg.FIELD_AVAILABLE_PERSON, name)); - /** - * - * @param name - * @return - * @throws Exception - */ - public List findAllAvailableEndorsementsByType(String name) throws Exception { - logger.debug("findAllAvailableEndorsementsByType"); - try { - List parameters = new ArrayList<>(); + return searchPersonAvailableRepository.findAvailablePersonLike( + AvailableCustomersView.class, + AvailableCustomersViewCfg.QUERY_FIND_AVAILABLE_CUSTOMERS, + parameters); + } catch (Exception e) { + logger.error("findAllAvailableCustomersByType", e); + throw e; + } + } - parameters.add(new ModelParameter(AvailableEndorsementsViewCfg.FIELD_AVAILABLE_PERSON, name)); + /** + * + * @param name + * @return + * @throws Exception + */ + public List findAllAvailableEndorsementsByType(String name) throws Exception { + logger.debug("findAllAvailableEndorsementsByType"); + try { + List parameters = new ArrayList<>(); - return searchPersonAvailableRepository.findAvailablePersonLike( - AvailableEndorsementsView.class, - AvailableEndorsementsViewCfg.QUERY_FIND_AVAILABLE_ENDORSEMENTS, - parameters); - } catch (Exception e) { - logger.error("findAllAvailableEndorsementsByType", e); - throw e; - } - } + parameters.add(new ModelParameter(AvailableEndorsementsViewCfg.FIELD_AVAILABLE_PERSON, name)); - /** - * - * @param jaxb - * @return - * @throws Exception - */ - synchronized public boolean createLoan(LoanRequestedJaxb jaxb) throws Exception { - logger.debug("createLoan"); + return searchPersonAvailableRepository.findAvailablePersonLike( + AvailableEndorsementsView.class, + AvailableEndorsementsViewCfg.QUERY_FIND_AVAILABLE_ENDORSEMENTS, + parameters); + } catch (Exception e) { + logger.error("findAllAvailableEndorsementsByType", e); + throw e; + } + } - try { + /** + * + * @param jaxb + * @return + * @throws Exception + */ + synchronized public boolean createLoan(LoanRequestedJaxb jaxb) throws Exception { + logger.debug("createLoan"); - if (!jaxb.getCustomer().isCreatePerson() - && !verifyPersonAvailability( - AvailableCustomersView.class, - jaxb.getCustomer().getId() - )) { - throw new Exception(user_unavailable); - } + try { - if (!jaxb.getEndorsement().isCreatePerson() - && !verifyPersonAvailability( - AvailableEndorsementsView.class, - jaxb.getEndorsement().getId() - )) { - throw new Exception(user_unavailable); - } + if (!jaxb.getCustomer().isCreatePerson() + && !verifyPersonAvailability( + AvailableCustomersView.class, + jaxb.getCustomer().getId() + )) { + throw new Exception(user_unavailable); + } -//DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date date = new Date();//dateFormat.parse(jaxb.getStrDate()); + if (!jaxb.getEndorsement().isCreatePerson() + && !verifyPersonAvailability( + AvailableEndorsementsView.class, + jaxb.getEndorsement().getId() + )) { + throw new Exception(user_unavailable); + } - LoanByUser loanByUser = new LoanByUser( - new LoanByUserId(null, jaxb.getUserId()), - LoanStatus.PENDING, - OwnerLoan.CURRENT_OWNER, - jaxb.getUserId()); + Date date = new Date(); - LoanType loanType = loanTypeRepository.findLoanType(jaxb.getLoanTypeId()); - RouteCtlg routeCtlg = new RouteCtlg(jaxb.getRouteId()); + LoanByUser loanByUser = new LoanByUser( + new LoanByUserId(null, jaxb.getUserId()), + LoanStatus.PENDING, + OwnerLoan.CURRENT_OWNER, + jaxb.getUserId()); - Loan loan = new Loan( - new LoanType(loanType.getId()), - null, - null, - routeCtlg, - LoanStatus.PENDING, - BigDecimal.ZERO, - loanType.getPaymentTotal(), - 0, - jaxb.getUserId(), - date, - jaxb.getCustomer().isCreatePerson() ? ActiveStatus.ENEBLED : ActiveStatus.DISABLED, - ActiveStatus.DISABLED // FROZEN funcationality + LoanType loanType = loanTypeRepository.findLoanType(jaxb.getLoanTypeId()); + RouteCtlg routeCtlg = new RouteCtlg(jaxb.getRouteId()); + + Loan loan = new Loan( + new LoanType(loanType.getId()), + null, + null, + routeCtlg, + LoanStatus.PENDING, + BigDecimal.ZERO, + loanType.getPaymentTotal(), + 0, + jaxb.getUserId(), + date, + jaxb.getCustomer().isCreatePerson() ? ActiveStatus.ENEBLED : ActiveStatus.DISABLED, + ActiveStatus.DISABLED, + jaxb.getFachadaCasa(), + jaxb.getDescripcion(), + jaxb.getLatitud(), + jaxb.getLongitud() + ); + return loanRepository.createLoan( + loan, + loanByUser, + jaxb); + } catch (Exception e) { + logger.error("createLoan", e); + throw e; + } + } + + /** + * + * @param newAmountJaxb + * @return + * @throws Exception + */ + public boolean saveNewAmount(NewAmountJaxb newAmountJaxb) throws Exception { + logger.debug("saveNewAmount"); + + LoanFeeNotification notification = null; + try { + //DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = new Date();//dateFormat.parse(newAmountJaxb.getStrDate()); + List parameters = new ArrayList<>(); + + if (newAmountJaxb.isFee()) { + parameters.add( + new ModelParameter( + LoanFeeNotificationCfg.FIELD_LOAN, + new Loan(newAmountJaxb.getLoanId()) + ) ); - return loanRepository.createLoan( - loan, - loanByUser, - jaxb); - } catch (Exception e) { - logger.error("createLoan", e); - throw e; - } - } - /** - * - * @param newAmountJaxb - * @return - * @throws Exception - */ - public boolean saveNewAmount(NewAmountJaxb newAmountJaxb) throws Exception { - logger.debug("saveNewAmount"); + Long total = loanFeeNotificationRepository.countNotificationByLoanId( + Long.class, + LoanFeeNotificationCfg.QUERY_COUNT_NOTIFICATION_BY_LOAN_ID, + parameters); - LoanFeeNotification notification = null; - try { - //DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date date = new Date();//dateFormat.parse(newAmountJaxb.getStrDate()); - List parameters = new ArrayList<>(); - - if (newAmountJaxb.isFee()) { - parameters.add( - new ModelParameter( - LoanFeeNotificationCfg.FIELD_LOAN, - new Loan(newAmountJaxb.getLoanId()) - ) - ); - - Long total = loanFeeNotificationRepository.countNotificationByLoanId( - Long.class, - LoanFeeNotificationCfg.QUERY_COUNT_NOTIFICATION_BY_LOAN_ID, - parameters); - - notification = new LoanFeeNotification( - new Loan(newAmountJaxb.getLoanId()), - new User(newAmountJaxb.getUserId()), - (total.intValue() + 1), - newAmountJaxb.getUserId(), - date - ); - } - - if (newAmountJaxb.isFee() && null == notification) { - throw new Exception("Could not create the notification for the loan " + newAmountJaxb.getLoanId()); - } - - Loan loan = loanRepository.findLoanById(newAmountJaxb.getLoanId()); - int referenceNumber = loan.getLastReferenceNumber() + 1; - - LoanDetails loanDetails = new LoanDetails( + notification = new LoanFeeNotification( new Loan(newAmountJaxb.getLoanId()), new User(newAmountJaxb.getUserId()), - newAmountJaxb.isCustomer() ? PeopleType.CUSTOMER : PeopleType.ENDORSEMENT, - newAmountJaxb.getAmount(), - referenceNumber, - newAmountJaxb.isFee() ? LoanDetailsType.FEE : LoanDetailsType.PAYMENT, + (total.intValue() + 1), newAmountJaxb.getUserId(), - date, - newAmountJaxb.getComments() + date ); + } - BigDecimal newAmountPaid, newAmountToPay; + if (newAmountJaxb.isFee() && null == notification) { + throw new Exception("Could not create the notification for the loan " + newAmountJaxb.getLoanId()); + } - if (newAmountJaxb.isFee()) { - newAmountPaid = loan.getAmountPaid(); - newAmountToPay = loan.getAmountToPay().add(newAmountJaxb.getAmount()); + Loan loan = loanRepository.findLoanById(newAmountJaxb.getLoanId()); + int referenceNumber = loan.getLastReferenceNumber() + 1; + + LoanDetails loanDetails = new LoanDetails( + new Loan(newAmountJaxb.getLoanId()), + new User(newAmountJaxb.getUserId()), + newAmountJaxb.isCustomer() ? PeopleType.CUSTOMER : PeopleType.ENDORSEMENT, + newAmountJaxb.getAmount(), + referenceNumber, + newAmountJaxb.isFee() ? LoanDetailsType.FEE : LoanDetailsType.PAYMENT, + newAmountJaxb.getUserId(), + date, + newAmountJaxb.getComments(), + newAmountJaxb.getFolio() + ); + + BigDecimal newAmountPaid, newAmountToPay; + + if (newAmountJaxb.isFee()) { + newAmountPaid = loan.getAmountPaid(); + newAmountToPay = loan.getAmountToPay().add(newAmountJaxb.getAmount()); + } else { + newAmountPaid = loan.getAmountPaid().add(newAmountJaxb.getAmount()); + newAmountToPay = loan.getAmountToPay(); + } + + parameters.clear(); + + String query = LoanCfg.QUERY_UPDATE_LOAN_BY_ID; + + if (!newAmountJaxb.isFee() && 0 == loan.getAmountToPay().compareTo(newAmountPaid)) { + parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, LoanStatus.FINISH)); + + query = LoanCfg.QUERY_UPDATE_AND_FINISH_LOAN_BY_ID; + } + + parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, newAmountPaid)); + parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_TO_PAY, newAmountToPay)); + parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, referenceNumber)); + parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, newAmountJaxb.getUserId())); + parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, date)); + parameters.add(new ModelParameter(LoanCfg.FIELD_ID, newAmountJaxb.getLoanId())); + + return addAmountRepository.saveNewAmount(notification, loanDetails, query, parameters); + } catch (Exception e) { + logger.error("saveNewAmount", e); + throw e; + } + } + + /** + * + * @param transfer + * @return + * @throws Exception + */ + public boolean saveNewTransferAmount(NewTransferAccountJaxb transfer) throws Exception { + logger.debug("saveNewTransferAmount"); + + LoanFeeNotification notification = null; + try { + Date date = new Date(); + List parameters = new ArrayList<>(); + + Loan loan = loanRepository.findLoanById(transfer.getLoanId()); + int referenceNumber = loan.getLastReferenceNumber() + 1; + + BigDecimal amountWithoutIVA = transfer.getAmount().divide(new BigDecimal(1.16), RoundingMode.FLOOR); + + amountWithoutIVA = amountWithoutIVA.setScale(2, RoundingMode.FLOOR); + + StringBuilder comments = new StringBuilder(transfer.getComments()); + + comments.append(". Monto de transferencia con IVA: $"); + comments.append(transfer.getAmount()); + comments.append(", monto de transferencia sin IVA: $"); + comments.append(amountWithoutIVA); + + LoanDetails loanDetails = new LoanDetails( + new Loan(transfer.getLoanId()), + new User(transfer.getUserId()), + PeopleType.CUSTOMER, + amountWithoutIVA, + referenceNumber, + LoanDetailsType.TRANSFER, + transfer.getUserId(), + date, + transfer.getComments(), + null == transfer.getTransferReference() || transfer.getTransferReference().trim().equals("") ? "Asesor no guardo la referencia de la transferencia. Rechar directamente o solicitar con el administrador la aclaración." : transfer.getTransferReference(), + TransferStatus.PENDING, + transfer.getFolio() + ); + + BigDecimal newAmountPaid = loan.getAmountPaid().add(amountWithoutIVA); + + parameters.clear(); + + String query = LoanCfg.QUERY_UPDATE_LOAN_BY_ID; + + if (0 == loan.getAmountToPay().compareTo(newAmountPaid)) { + parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, LoanStatus.FINISH)); + + query = LoanCfg.QUERY_UPDATE_AND_FINISH_LOAN_BY_ID; + } + + parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, newAmountPaid)); + parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_TO_PAY, loan.getAmountToPay())); + parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, referenceNumber)); + parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, transfer.getUserId())); + parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, date)); + parameters.add(new ModelParameter(LoanCfg.FIELD_ID, transfer.getLoanId())); + + return addAmountRepository.saveNewAmount(notification, loanDetails, query, parameters); + } catch (Exception e) { + logger.error("saveNewTransferAmount", e); + throw e; + } + } + + /** + * This method is for get all loan types applying some business rules, like + * number of Fees and if you are ok in 100% you can get next loan. + * + * @param officeId + * @param loanId + * @return + * @throws Exception + */ + public LoanTypeListJaxb findNewCreditLimit(String officeId, String loanId) throws Exception { + logger.debug("findNewCreditLimit"); + LoanTypeListJaxb loanTypeListJaxb = new LoanTypeListJaxb(); + try { + List parameters = new ArrayList<>(); + + parameters.add( + new ModelParameter( + LoanTypeCfg.FIELD_OFFICE, + new Office(officeId) + ) + ); + + parameters.add( + new ModelParameter( + LoanTypeCfg.PARAM_LOAN, + new Loan(loanId) + ) + ); + + parameters.add( + new ModelParameter( + LoanTypeCfg.PARAM_LOAN_ID, + loanId + ) + ); + + List results = loanTypeRepository.findIdAndPaymentLoans(LoanTypeCfg.QUERY_FIND_NEW_CREDIT_LINE_BY_LOAN_ID, parameters); + List loanTypeJaxbs = new ArrayList<>(); + + results.forEach((result) -> { + loanTypeJaxbs.add(new LoanTypeJaxb(result.getId(), result.getPayment())); + }); + + loanTypeListJaxb.setLoans(loanTypeJaxbs); + + return loanTypeListJaxb; + } catch (Exception e) { + logger.error("findNewCreditLimit", e); + throw e; + } + } + + /** + * + * @param officeId + * @return + * @throws Exception + */ + public LoanTypeListJaxb findAllLoansTypeByOffice(String officeId) throws Exception { + logger.debug("findNewCreditLimit"); + LoanTypeListJaxb loanTypeListJaxb = new LoanTypeListJaxb(); + try { + List parameters = new ArrayList<>(); + + parameters.add( + new ModelParameter( + LoanTypeCfg.FIELD_OFFICE, + new Office(officeId) + ) + ); + + List results = loanTypeRepository.findIdAndPaymentLoans( + LoanTypeCfg.QUERY_FIND_ALL_LOAN_TYPE_WITH_DESCRIPTION_BY_OFFICE, + parameters); + + List loanTypeJaxbs = new ArrayList<>(); + + results.forEach((result) -> { + loanTypeJaxbs.add(new LoanTypeJaxb(result.getId(), result.getPayment(), result.getLoanTypeName())); + }); + + loanTypeListJaxb.setLoans(loanTypeJaxbs); + + return loanTypeListJaxb; + } catch (Exception e) { + logger.error("findNewCreditLimit", e); + throw e; + } + } + + /** + * + * @param loan + * @param credit + * @param user + * @param paymentAmount + * @param endorsement + * @return + * @throws Exception + */ + public boolean renovation(String loan, + String credit, + String user, + BigDecimal paymentAmount, + PersonJaxb endorsement) throws Exception { + logger.debug("renovation"); + try { + Date date = new Date(); + + Loan currentLoan = loanRepository.findLoanById(loan); + LoanType newCredit = loanTypeRepository.findLoanType(credit); + int lastReferenceNumber = currentLoan.getLastReferenceNumber() + 1; + + LoanDetails loanDetails = new LoanDetails( + new Loan(loan), + new User(user), + PeopleType.CUSTOMER, + paymentAmount, + lastReferenceNumber, + LoanDetailsType.PAYMENT, + user, + date, + "Pago y solicitud de renovacion" + ); + + LoanByUser loanByUser = new LoanByUser( + new LoanByUserId(null, user), + LoanStatus.PENDING, + OwnerLoan.CURRENT_OWNER, + user); + + Loan renovation = new Loan( + new LoanType(newCredit.getId()), + new People(currentLoan.getCustomer().getId()), + null, + new RouteCtlg(currentLoan.getRouteCtlg().getId()), + LoanStatus.PENDING, + BigDecimal.ZERO, + newCredit.getPaymentTotal(), + 0, + user, + date, + ActiveStatus.DISABLED, + ActiveStatus.DISABLED // FROZEN funcationality + ); + + List parameters = new ArrayList<>(); + + parameters.add( + new ModelParameter( + LoanCfg.FIELD_AMOUNT_PAID, + currentLoan.getAmountPaid().add(paymentAmount) + ) + ); + + parameters.add( + new ModelParameter( + LoanCfg.FIELD_LAST_REFERENCE_NUMBER, + lastReferenceNumber + ) + ); + + parameters.add( + new ModelParameter( + LoanCfg.FIELD_LOAN_STATUS, + LoanStatus.PENDING_RENOVATION + ) + ); + + parameters.add( + new ModelParameter( + LoanCfg.FIELD_LAST_UPDATED_BY, + user + ) + ); + + parameters.add( + new ModelParameter( + LoanCfg.FIELD_LAST_UPDATED_ON, + date + ) + ); + + parameters.add( + new ModelParameter( + LoanCfg.FIELD_ID, + loan + ) + ); + + People people = null; + + if (null != endorsement) { + if (endorsement.isCreatePerson()) { + people = new People( + endorsement, false, + currentLoan.getRouteCtlg().getOffice().getId(), + user, currentLoan.getRouteCtlg().getId() + ); } else { - newAmountPaid = loan.getAmountPaid().add(newAmountJaxb.getAmount()); - newAmountToPay = loan.getAmountToPay(); + renovation.setEndorsement(new People(endorsement.getId())); } + } else { + renovation.setEndorsement(new People(currentLoan.getEndorsement().getId())); + } - parameters.clear(); + return loanRepository.renovationLoan( + loan, + renovation, + loanByUser, + LoanCfg.QUERY_UPDATE_LOAN_FROM_RENOVATION, + parameters, + loanDetails, people, + null == endorsement ? false : endorsement.isCreatePerson()); + } catch (Exception e) { + logger.error("renovation", e); + throw e; + } + } - String query = LoanCfg.QUERY_UPDATE_LOAN_BY_ID; + /** + * + * @param loan + * @param credit + * @param user + * @param paymentAmount + * @param currentOwner + * @param endorsement + * @return + * @throws Exception + */ + public boolean renovationHasPaymentToday(String loan, + String credit, + String user, + BigDecimal paymentAmount, + String currentOwner, + PersonJaxb endorsement) throws Exception { + logger.debug("renovationHasPaymentToday"); + try { + Date date = new Date(); - if (!newAmountJaxb.isFee() && 0 == loan.getAmountToPay().compareTo(newAmountPaid)) { - parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, LoanStatus.FINISH)); + Loan currentLoan = loanRepository.findLoanById(loan); + LoanType newCredit = loanTypeRepository.findLoanType(credit); - query = LoanCfg.QUERY_UPDATE_AND_FINISH_LOAN_BY_ID; + LoanByUser loanByUser = new LoanByUser( + new LoanByUserId(null, currentOwner), + LoanStatus.PENDING, + OwnerLoan.CURRENT_OWNER, + user); + + Loan renovation = new Loan( + new LoanType(newCredit.getId()), + new People(currentLoan.getCustomer().getId()), + null, + new RouteCtlg(currentLoan.getRouteCtlg().getId()), + LoanStatus.PENDING, + BigDecimal.ZERO, + newCredit.getPaymentTotal(), + 0, + user, + date, + ActiveStatus.DISABLED, + ActiveStatus.DISABLED // FROZEN funcationality + ); + + People people = null; + + if (null != endorsement) { + if (endorsement.isCreatePerson()) { + people = new People( + endorsement, false, + currentLoan.getRouteCtlg().getOffice().getId(), + user, currentLoan.getRouteCtlg().getId() + ); + } else { + renovation.setEndorsement(new People(endorsement.getId())); } + } else { + renovation.setEndorsement(new People(currentLoan.getEndorsement().getId())); + } - parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, newAmountPaid)); - parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_TO_PAY, newAmountToPay)); - parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, referenceNumber)); - parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, newAmountJaxb.getUserId())); - parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, date)); - parameters.add(new ModelParameter(LoanCfg.FIELD_ID, newAmountJaxb.getLoanId())); + return loanRepository.renovationHasPaymentToday( + loan, + renovation, + loanByUser, + people, + null == endorsement ? false : endorsement.isCreatePerson()); + } catch (Exception e) { + logger.error("renovationHasPaymentToday", e); + throw e; + } + } - return addAmountRepository.saveNewAmount(notification, loanDetails, query, parameters); - } catch (Exception e) { - logger.error("saveNewAmount", e); - throw e; - } - } + /** + * + * @param userId + * @return + * @throws Exception + */ + public List findLoansByCertifier(String userId) throws Exception { + logger.debug("findLoansByCertifier"); + try { + List parameters = new ArrayList<>(); - /** - * - * @param transfer - * @return - * @throws Exception - */ - public boolean saveNewTransferAmount(NewTransferAccountJaxb transfer) throws Exception { - logger.debug("saveNewTransferAmount"); + parameters.add(new ModelParameter(LoanToDeliveryByCertifierViewCfg.FIELD_USER_ID, userId)); - LoanFeeNotification notification = null; - try { - Date date = new Date(); - List parameters = new ArrayList<>(); + return toDeliveryByCertifierRepository.findLoansByCertifier( + LoanToDeliveryByCertifierView.class, + LoanToDeliveryByCertifierViewCfg.QUERY_FIND_LOANS_BY_CERTIFIER, + parameters); + } catch (Exception e) { + logger.error("findLoansByCertifier", e); + throw e; + } + } - Loan loan = loanRepository.findLoanById(transfer.getLoanId()); - int referenceNumber = loan.getLastReferenceNumber() + 1; - - BigDecimal amountWithoutIVA = transfer.getAmount().divide(new BigDecimal(1.16)); + /** + * + * @param id + * @param user + * @param comments + * @param action true Approved otherwise Rejected. + * @param amount + * @param discount + * @return + * @throws Exception + */ + public boolean certifierAction(String id, String user, String comments, boolean action, BigDecimal amount, BigDecimal discount) throws Exception { + logger.debug("certifierAction"); + boolean success; + try { + // revisar si es nuevo (1) o renovado (2). + // 1 = se cambia el estatus al valor de action + // 2, si action es true, hay que hacer update de 3 tablas + // A)loan renovado estutus = APPROVED + // B) Finish + // 1)old loan estatus = FINISH, + // 2)old loandbyuser estatus = FINISH + // C)loans by renovation estatus = APPROVED + // 2, si action es false, hay que hacer update de 3 tablas + // A)loan renovado estutus = REJECT, and loandbyuser estatus = REJECT + // B)old loan estatus = APPROVED + // 1)old loan estatus = APPROVED + // 2)old loandbyuser estatus = APPROVED + // C)loans by renovation estatus = REJECT + LoanByRenovation loanByRenovation = loanByRenovationRepository.findLoanRenovationByNewLoanId(id); - amountWithoutIVA = amountWithoutIVA.setScale(2, RoundingMode.FLOOR); - - StringBuilder comments = new StringBuilder(transfer.getComments()); - - comments.append(". Monto de transferencia con IVA: $"); - comments.append(transfer.getAmount()); - comments.append(", monto de transferencia sin IVA: $"); - comments.append(amountWithoutIVA); - - LoanDetails loanDetails = new LoanDetails( - new Loan(transfer.getLoanId()), - new User(transfer.getUserId()), - PeopleType.CUSTOMER, - amountWithoutIVA, - referenceNumber, - LoanDetailsType.TRANSFER, - transfer.getUserId(), - date, - transfer.getComments(), - null == transfer.getTransferReference() || transfer.getTransferReference().trim().equals("") ? "Asesor no guardo la referencia de la transferencia. Rechar directamente o solicitar con el administrador la aclaración." : transfer.getTransferReference(), - TransferStatus.PENDING - ); - - BigDecimal newAmountPaid = loan.getAmountPaid().add(amountWithoutIVA); - - parameters.clear(); - - String query = LoanCfg.QUERY_UPDATE_LOAN_BY_ID; - - if (0 == loan.getAmountToPay().compareTo(newAmountPaid)) { - parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, LoanStatus.FINISH)); - - query = LoanCfg.QUERY_UPDATE_AND_FINISH_LOAN_BY_ID; - } - - parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, newAmountPaid)); - parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_TO_PAY, loan.getAmountToPay())); - parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, referenceNumber)); - parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, transfer.getUserId())); - parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, date)); - parameters.add(new ModelParameter(LoanCfg.FIELD_ID, transfer.getLoanId())); - - return addAmountRepository.saveNewAmount(notification, loanDetails, query, parameters); - } catch (Exception e) { - logger.error("saveNewTransferAmount", e); - throw e; - } - } - - /** - * This method is for get all loan types applying some business rules, like - * number of Fees and if you are ok in 100% you can get next loan. - * - * @param officeId - * @param loanId - * @return - * @throws Exception - */ - public LoanTypeListJaxb findNewCreditLimit(String officeId, String loanId) throws Exception { - logger.debug("findNewCreditLimit"); - LoanTypeListJaxb loanTypeListJaxb = new LoanTypeListJaxb(); - try { - List parameters = new ArrayList<>(); - - parameters.add( - new ModelParameter( - LoanTypeCfg.FIELD_OFFICE, - new Office(officeId) - ) - ); - - parameters.add( - new ModelParameter( - LoanTypeCfg.PARAM_LOAN, - new Loan(loanId) - ) - ); - - parameters.add( - new ModelParameter( - LoanTypeCfg.PARAM_LOAN_ID, - loanId - ) - ); - - List results = loanTypeRepository.findIdAndPaymentLoans(LoanTypeCfg.QUERY_FIND_NEW_CREDIT_LINE_BY_LOAN_ID, parameters); - List loanTypeJaxbs = new ArrayList<>(); - - results.forEach((result) -> { - loanTypeJaxbs.add(new LoanTypeJaxb(result.getId(), result.getPayment())); - }); - - loanTypeListJaxb.setLoans(loanTypeJaxbs); - - return loanTypeListJaxb; - } catch (Exception e) { - logger.error("findNewCreditLimit", e); - throw e; - } - } - - /** - * - * @param officeId - * @return - * @throws Exception - */ - public LoanTypeListJaxb findAllLoansTypeByOffice(String officeId) throws Exception { - logger.debug("findNewCreditLimit"); - LoanTypeListJaxb loanTypeListJaxb = new LoanTypeListJaxb(); - try { - List parameters = new ArrayList<>(); - - parameters.add( - new ModelParameter( - LoanTypeCfg.FIELD_OFFICE, - new Office(officeId) - ) - ); - - List results = loanTypeRepository.findIdAndPaymentLoans( - LoanTypeCfg.QUERY_FIND_ALL_LOAN_TYPE_WITH_DESCRIPTION_BY_OFFICE, - parameters); - - List loanTypeJaxbs = new ArrayList<>(); - - results.forEach((result) -> { - loanTypeJaxbs.add(new LoanTypeJaxb(result.getId(), result.getPayment(), result.getLoanTypeName())); - }); - - loanTypeListJaxb.setLoans(loanTypeJaxbs); - - return loanTypeListJaxb; - } catch (Exception e) { - logger.error("findNewCreditLimit", e); - throw e; - } - } - - /** - * - * @param loan - * @param credit - * @param user - * @param paymentAmount - * @param endorsement - * @return - * @throws Exception - */ - public boolean renovation(String loan, - String credit, - String user, - BigDecimal paymentAmount, - PersonJaxb endorsement) throws Exception { - logger.debug("renovation"); - try { - Date date = new Date(); - - Loan currentLoan = loanRepository.findLoanById(loan); - LoanType newCredit = loanTypeRepository.findLoanType(credit); - int lastReferenceNumber = currentLoan.getLastReferenceNumber() + 1; - - LoanDetails loanDetails = new LoanDetails( - new Loan(loan), - new User(user), - PeopleType.CUSTOMER, - paymentAmount, - lastReferenceNumber, - LoanDetailsType.PAYMENT, + if (null == loanByRenovation) { + success = updateLoanByIdFromCertifiedView( + id, user, - date, - "Pago y solicitud de renovacion" - ); + action, + comments, + amount, + ComissionType.INCLUDED); + } else { + LoanDetails loanDetails = null; + BigDecimal totalAmountPaid = null; + Integer newLastReferenceNumber = null; - LoanByUser loanByUser = new LoanByUser( - new LoanByUserId(null, user), - LoanStatus.PENDING, - OwnerLoan.CURRENT_OWNER, - user); + // Means discount is bigger than 0 + if (1 == discount.compareTo(new BigDecimal(0))) { + Loan loan = loanRepository.findLoanById(loanByRenovation.getLoanOld().getId()); - Loan renovation = new Loan( - new LoanType(newCredit.getId()), - new People(currentLoan.getCustomer().getId()), - null, - new RouteCtlg(currentLoan.getRouteCtlg().getId()), - LoanStatus.PENDING, - BigDecimal.ZERO, - newCredit.getPaymentTotal(), - 0, + totalAmountPaid = loan.getAmountPaid().add(discount); + newLastReferenceNumber = loan.getLastReferenceNumber() + 1; + + loanDetails = new LoanDetails( + new Loan(loanByRenovation.getLoanOld().getId()), + new User(user), + PeopleType.CUSTOMER, + discount, + newLastReferenceNumber, + LoanDetailsType.RENOVATION_PAYMENT, + user, + new Date(), + "Retención de " + discount + " el la entrega del crédito renovado"); + } + + success = loanByRenovationRepository.updateLoanRenovationFromCerfierView( + loanByRenovation, user, - date, - ActiveStatus.DISABLED, - ActiveStatus.DISABLED // FROZEN funcationality - ); + comments, + action, + amount, + discount, + loanDetails, + totalAmountPaid, + newLastReferenceNumber, + ComissionType.INCLUDED); + } + return success; + } catch (Exception e) { + logger.error("certifierAction", e); + throw e; + } + } - List parameters = new ArrayList<>(); + /** + * + * @param id + * @param user + * @param comments + * @param action + * @param amount + * @param discount + * @param comissionType + * @return + * @throws Exception + */ + public boolean certifierAction(String id, String user, String comments, boolean action, BigDecimal amount, BigDecimal discount, ComissionType comissionType) throws Exception { + logger.debug("certifierAction"); + boolean success; + try { + // revisar si es nuevo (1) o renovado (2). + // 1 = se cambia el estatus al valor de action + // 2, si action es true, hay que hacer update de 3 tablas + // A)loan renovado estutus = APPROVED + // B) Finish + // 1)old loan estatus = FINISH, + // 2)old loandbyuser estatus = FINISH + // C)loans by renovation estatus = APPROVED + // 2, si action es false, hay que hacer update de 3 tablas + // A)loan renovado estutus = REJECT, and loandbyuser estatus = REJECT + // B)old loan estatus = APPROVED + // 1)old loan estatus = APPROVED + // 2)old loandbyuser estatus = APPROVED + // C)loans by renovation estatus = REJECT + LoanByRenovation loanByRenovation = loanByRenovationRepository.findLoanRenovationByNewLoanId(id); - parameters.add( - new ModelParameter( - LoanCfg.FIELD_AMOUNT_PAID, - currentLoan.getAmountPaid().add(paymentAmount) - ) - ); - - parameters.add( - new ModelParameter( - LoanCfg.FIELD_LAST_REFERENCE_NUMBER, - lastReferenceNumber - ) - ); - - parameters.add( - new ModelParameter( - LoanCfg.FIELD_LOAN_STATUS, - LoanStatus.PENDING_RENOVATION - ) - ); - - parameters.add( - new ModelParameter( - LoanCfg.FIELD_LAST_UPDATED_BY, - user - ) - ); - - parameters.add( - new ModelParameter( - LoanCfg.FIELD_LAST_UPDATED_ON, - date - ) - ); - - parameters.add( - new ModelParameter( - LoanCfg.FIELD_ID, - loan - ) - ); - - People people = null; - - if (null != endorsement) { - if (endorsement.isCreatePerson()) { - people = new People( - endorsement, false, - currentLoan.getRouteCtlg().getOffice().getId(), - user, currentLoan.getRouteCtlg().getId() - ); - } else { - renovation.setEndorsement(new People(endorsement.getId())); - } - } else { - renovation.setEndorsement(new People(currentLoan.getEndorsement().getId())); - } - - return loanRepository.renovationLoan( - loan, - renovation, - loanByUser, - LoanCfg.QUERY_UPDATE_LOAN_FROM_RENOVATION, - parameters, - loanDetails, people, - null == endorsement ? false : endorsement.isCreatePerson()); - } catch (Exception e) { - logger.error("renovation", e); - throw e; - } - } - - /** - * - * @param loan - * @param credit - * @param user - * @param paymentAmount - * @param currentOwner - * @param endorsement - * @return - * @throws Exception - */ - public boolean renovationHasPaymentToday(String loan, - String credit, - String user, - BigDecimal paymentAmount, - String currentOwner, - PersonJaxb endorsement) throws Exception { - logger.debug("renovationHasPaymentToday"); - try { - Date date = new Date(); - - Loan currentLoan = loanRepository.findLoanById(loan); - LoanType newCredit = loanTypeRepository.findLoanType(credit); - - LoanByUser loanByUser = new LoanByUser( - new LoanByUserId(null, currentOwner), - LoanStatus.PENDING, - OwnerLoan.CURRENT_OWNER, - user); - - Loan renovation = new Loan( - new LoanType(newCredit.getId()), - new People(currentLoan.getCustomer().getId()), - null, - new RouteCtlg(currentLoan.getRouteCtlg().getId()), - LoanStatus.PENDING, - BigDecimal.ZERO, - newCredit.getPaymentTotal(), - 0, + if (null == loanByRenovation) { + success = updateLoanByIdFromCertifiedView( + id, user, - date, - ActiveStatus.DISABLED, - ActiveStatus.DISABLED // FROZEN funcationality - ); + action, + comments, + amount, + comissionType); + } else { + LoanDetails loanDetails = null; + BigDecimal totalAmountPaid = null; + Integer newLastReferenceNumber = null; - People people = null; + // Means discount is bigger than 0 + if (1 == discount.compareTo(new BigDecimal(0))) { + Loan loan = loanRepository.findLoanById(loanByRenovation.getLoanOld().getId()); - if (null != endorsement) { - if (endorsement.isCreatePerson()) { - people = new People( - endorsement, false, - currentLoan.getRouteCtlg().getOffice().getId(), - user, currentLoan.getRouteCtlg().getId() - ); - } else { - renovation.setEndorsement(new People(endorsement.getId())); - } - } else { - renovation.setEndorsement(new People(currentLoan.getEndorsement().getId())); + totalAmountPaid = loan.getAmountPaid().add(discount); + newLastReferenceNumber = loan.getLastReferenceNumber() + 1; + + loanDetails = new LoanDetails( + new Loan(loanByRenovation.getLoanOld().getId()), + new User(user), + PeopleType.CUSTOMER, + discount, + newLastReferenceNumber, + LoanDetailsType.RENOVATION_PAYMENT, + user, + new Date(), + "Retención de " + discount + " el la entrega del crédito renovado"); } - return loanRepository.renovationHasPaymentToday( - loan, - renovation, - loanByUser, - people, - null == endorsement ? false : endorsement.isCreatePerson()); - } catch (Exception e) { - logger.error("renovationHasPaymentToday", e); - throw e; - } - } + success = loanByRenovationRepository.updateLoanRenovationFromCerfierView( + loanByRenovation, + user, + comments, + action, + amount, + discount, + loanDetails, + totalAmountPaid, + newLastReferenceNumber, + comissionType); + } + return success; + } catch (Exception e) { + logger.error("certifierAction", e); + throw e; + } + } - /** - * - * @param userId - * @return - * @throws Exception - */ - public List findLoansByCertifier(String userId) throws Exception { - logger.debug("findLoansByCertifier"); - try { - List parameters = new ArrayList<>(); + /** + * + * @param idLoan + * @return + * @throws Exception + */ + public List approvedDetailsByIdLoan(String idLoan) throws Exception { + logger.debug("approvedDetailsByIdLoan"); + try { + List parameters = new ArrayList<>(); - parameters.add(new ModelParameter(LoanToDeliveryByCertifierViewCfg.FIELD_USER_ID, userId)); + parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID_LOAN, new Loan(idLoan))); - return toDeliveryByCertifierRepository.findLoansByCertifier( - LoanToDeliveryByCertifierView.class, - LoanToDeliveryByCertifierViewCfg.QUERY_FIND_LOANS_BY_CERTIFIER, - parameters); - } catch (Exception e) { - logger.error("findLoansByCertifier", e); - throw e; - } - } + return loanApprovedDetailViewRepository.findLoanDetailsByLoan( + LoanDetailsCfg.QUERY_FIND_LOAN_DETAILS_BY_LOAN, + parameters + ); + } catch (Exception e) { + logger.error("approvedDetailsByIdLoan", e); + throw e; + } + } - /** - * - * @param id - * @param user - * @param comments - * @param action true Approved otherwise Rejected. - * @param amount - * @param discount - * @return - * @throws Exception - */ - public boolean certifierAction(String id, String user, String comments, boolean action, BigDecimal amount, BigDecimal discount) throws Exception { - logger.debug("certifierAction"); - boolean success; - try { - // revisar si es nuevo (1) o renovado (2). - // 1 = se cambia el estatus al valor de action - // 2, si action es true, hay que hacer update de 3 tablas - // A)loan renovado estutus = APPROVED - // B) Finish - // 1)old loan estatus = FINISH, - // 2)old loandbyuser estatus = FINISH - // C)loans by renovation estatus = APPROVED - // 2, si action es false, hay que hacer update de 3 tablas - // A)loan renovado estutus = REJECT, and loandbyuser estatus = REJECT - // B)old loan estatus = APPROVED - // 1)old loan estatus = APPROVED - // 2)old loandbyuser estatus = APPROVED - // C)loans by renovation estatus = REJECT - LoanByRenovation loanByRenovation = loanByRenovationRepository.findLoanRenovationByNewLoanId(id); - - if (null == loanByRenovation) { - success = updateLoanByIdFromCertifiedView( - id, - user, - action, - comments, - amount, - ComissionType.INCLUDED); - } else { - LoanDetails loanDetails = null; - BigDecimal totalAmountPaid = null; - Integer newLastReferenceNumber = null; - - // Means discount is bigger than 0 - if (1 == discount.compareTo(new BigDecimal(0))) { - Loan loan = loanRepository.findLoanById(loanByRenovation.getLoanOld().getId()); - - totalAmountPaid = loan.getAmountPaid().add(discount); - newLastReferenceNumber = loan.getLastReferenceNumber() + 1; - - loanDetails = new LoanDetails( - new Loan(loanByRenovation.getLoanOld().getId()), - new User(user), - PeopleType.CUSTOMER, - discount, - newLastReferenceNumber, - LoanDetailsType.RENOVATION_PAYMENT, - user, - new Date(), - "Retención de " + discount + " el la entrega del crédito renovado"); - } - - success = loanByRenovationRepository.updateLoanRenovationFromCerfierView( - loanByRenovation, - user, - comments, - action, - amount, - discount, - loanDetails, - totalAmountPaid, - newLastReferenceNumber, - ComissionType.INCLUDED); - } - return success; - } catch (Exception e) { - logger.error("certifierAction", e); - throw e; - } - } - - /** - * - * @param id - * @param user - * @param comments - * @param action - * @param amount - * @param discount - * @param comissionType - * @return - * @throws Exception - */ - public boolean certifierAction(String id, String user, String comments, boolean action, BigDecimal amount, BigDecimal discount, ComissionType comissionType) throws Exception { - logger.debug("certifierAction"); - boolean success; - try { - // revisar si es nuevo (1) o renovado (2). - // 1 = se cambia el estatus al valor de action - // 2, si action es true, hay que hacer update de 3 tablas - // A)loan renovado estutus = APPROVED - // B) Finish - // 1)old loan estatus = FINISH, - // 2)old loandbyuser estatus = FINISH - // C)loans by renovation estatus = APPROVED - // 2, si action es false, hay que hacer update de 3 tablas - // A)loan renovado estutus = REJECT, and loandbyuser estatus = REJECT - // B)old loan estatus = APPROVED - // 1)old loan estatus = APPROVED - // 2)old loandbyuser estatus = APPROVED - // C)loans by renovation estatus = REJECT - LoanByRenovation loanByRenovation = loanByRenovationRepository.findLoanRenovationByNewLoanId(id); - - if (null == loanByRenovation) { - success = updateLoanByIdFromCertifiedView( - id, - user, - action, - comments, - amount, - comissionType); - } else { - LoanDetails loanDetails = null; - BigDecimal totalAmountPaid = null; - Integer newLastReferenceNumber = null; - - // Means discount is bigger than 0 - if (1 == discount.compareTo(new BigDecimal(0))) { - Loan loan = loanRepository.findLoanById(loanByRenovation.getLoanOld().getId()); - - totalAmountPaid = loan.getAmountPaid().add(discount); - newLastReferenceNumber = loan.getLastReferenceNumber() + 1; - - loanDetails = new LoanDetails( - new Loan(loanByRenovation.getLoanOld().getId()), - new User(user), - PeopleType.CUSTOMER, - discount, - newLastReferenceNumber, - LoanDetailsType.RENOVATION_PAYMENT, - user, - new Date(), - "Retención de " + discount + " el la entrega del crédito renovado"); - } - - success = loanByRenovationRepository.updateLoanRenovationFromCerfierView( - loanByRenovation, - user, - comments, - action, - amount, - discount, - loanDetails, - totalAmountPaid, - newLastReferenceNumber, - comissionType); - } - return success; - } catch (Exception e) { - logger.error("certifierAction", e); - throw e; - } - } - - /** - * - * @param idLoan - * @return - * @throws Exception - */ - public List approvedDetailsByIdLoan(String idLoan) throws Exception { - logger.debug("approvedDetailsByIdLoan"); - try { - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID_LOAN, new Loan(idLoan))); - - return loanApprovedDetailViewRepository.findLoanDetailsByLoan( - LoanDetailsCfg.QUERY_FIND_LOAN_DETAILS_BY_LOAN, - parameters - ); - } catch (Exception e) { - logger.error("approvedDetailsByIdLoan", e); - throw e; - } - } - - /** + /** * * @param idLoan * @return @@ -1128,294 +1133,336 @@ public class LoanController implements Serializable { } } - /** - * Searching all loan details by id. - * - * @param loanId - * @return - * @throws Exception - */ - public List getLoanDetailsCurdatebyIdLoan(String loanId) throws Exception { - logger.debug("getLoanDetailsCurdatebyIdLoan"); - List parameters = new ArrayList<>(); + /** + * + * @param idUser + * @return + * @throws Exception + */ + public List latestFolioByUser(String idUser) throws Exception { + logger.debug("latestFolioByUser"); + try { + List parameters = new ArrayList<>(); + parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_USER, new User(idUser))); + return loanApprovedDetailViewRepository.findLoanDetailsFromTikedByLoan( + LoanDetailsCfg.QUERY_FIND_LAST_LOAN_BY_USER, + parameters + ); + } catch (Exception e) { + logger.error("approvedDetailsFromTiketByIdLoan", e); + throw e; + } + } - parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanId))); + /** + * + * @param idLoan + * @return + * @throws Exception + */ + public LoanRequestedJaxb loanById(String idLoan) throws Exception { + logger.debug("loanById"); + try { + List parameters = new ArrayList<>(); + parameters.add(new ModelParameter("id", idLoan)); + return loanApprovedDetailViewRepository.findLoanById( + LoanCfg.QUERY_FIND_LOAN_BY_ID, + parameters + ); + } catch (Exception e) { + logger.error("loanById", e); + throw e; + } + } - try { - return loanDetailsRepository.findLoanDetailsByLoanId(LoanCfg.QUERY_FIND_LOAN_DETAILS_CURDATE_BY_LOAN, parameters); - } catch (Exception ex) { - logger.error("getLoanDetailsCurdatebyIdLoan", ex); - throw ex; - } - } + /** + * Searching all loan details by id. + * + * @param loanId + * @return + * @throws Exception + */ + public List getLoanDetailsCurdatebyIdLoan(String loanId) throws Exception { + logger.debug("getLoanDetailsCurdatebyIdLoan"); + List parameters = new ArrayList<>(); - public List getLoanDetailsFeeCurdatebyIdLoan(String loanId) throws Exception { - logger.debug("getLoanDetailsFeeCurdatebyIdLoan"); - List parameters = new ArrayList<>(); + parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanId))); - parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanId))); + try { + return loanDetailsRepository.findLoanDetailsByLoanId(LoanCfg.QUERY_FIND_LOAN_DETAILS_CURDATE_BY_LOAN, parameters); + } catch (Exception ex) { + logger.error("getLoanDetailsCurdatebyIdLoan", ex); + throw ex; + } + } - try { - return loanDetailsRepository.findLoanDetailsByLoanId(LoanCfg.QUERY_FIND_LOAN_DETAILS_FEE_CURDATE_BY_LOAN, parameters); - } catch (Exception ex) { - logger.error("getLoanDetailsCurdatebyIdLoan", ex); - throw ex; - } - } + public List getLoanDetailsFeeCurdatebyIdLoan(String loanId) throws Exception { + logger.debug("getLoanDetailsFeeCurdatebyIdLoan"); + List parameters = new ArrayList<>(); - /** - * - * @param loanId - * @return - * @throws Exception - */ - public Loan getLoanById(String loanId) throws Exception { - try { - return loanRepository.findLoanById(loanId); - } catch (Exception ex) { - throw ex; - } - } + parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanId))); - /** - * - * @param idLoan - * @param idLoanType - * @return - * @throws Exception - */ - public boolean updatePaymentTotalLoanById(String idLoan, String idLoanType) throws Exception { - try { - Loan loan = loanRepository.findLoanById(idLoan); - LoanType loanType = loanTypeRepository.findLoanType(idLoanType); + try { + return loanDetailsRepository.findLoanDetailsByLoanId(LoanCfg.QUERY_FIND_LOAN_DETAILS_FEE_CURDATE_BY_LOAN, parameters); + } catch (Exception ex) { + logger.error("getLoanDetailsCurdatebyIdLoan", ex); + throw ex; + } + } - loan.setLoanType(loanType); - loan.setAmountToPay(loanType.getPaymentTotal()); + /** + * + * @param loanId + * @return + * @throws Exception + */ + public Loan getLoanById(String loanId) throws Exception { + try { + return loanRepository.findLoanById(loanId); + } catch (Exception ex) { + throw ex; + } + } - return loanRepository.updateLoan(loan); - } catch (Exception ex) { - throw ex; - } - } + /** + * + * @param idLoan + * @param idLoanType + * @return + * @throws Exception + */ + public boolean updatePaymentTotalLoanById(String idLoan, String idLoanType) throws Exception { + try { + Loan loan = loanRepository.findLoanById(idLoan); + LoanType loanType = loanTypeRepository.findLoanType(idLoanType); - /** - * - * @return @throws Exception - */ - public List findAllTransferToAuthorize() throws Exception { - try { - TransferInPendingStatusViewRepository repository = new TransferInPendingStatusViewRepository(); - List transferInPendingStatusViews = repository.findAllTransferFromHQL(TransferInPendingStatusViewCfg.QUERY_FIND_ALL_TRANSFER_IN_PENDING_STATUS, null); - List results = new ArrayList<>(); + loan.setLoanType(loanType); + loan.setAmountToPay(loanType.getPaymentTotal()); - transferInPendingStatusViews.forEach((row) -> { - results.add(new AuthorizeTransferPaymentsDto(row.getIdLoanDetail(), - row.getStrCreatedOn(), - row.getCustomerName(), - row.getEndorsementName(), - row.getUserName(), - row.getPaymentAmount(), - row.getLoanComments())); - }); + return loanRepository.updateLoan(loan); + } catch (Exception ex) { + throw ex; + } + } - return results; - } catch (Exception e) { - throw e; - } - } + /** + * + * @return @throws Exception + */ + public List findAllTransferToAuthorize() throws Exception { + try { + TransferInPendingStatusViewRepository repository = new TransferInPendingStatusViewRepository(); + List transferInPendingStatusViews = repository.findAllTransferFromHQL(TransferInPendingStatusViewCfg.QUERY_FIND_ALL_TRANSFER_IN_PENDING_STATUS, null); + List results = new ArrayList<>(); - /** - * - * @param authorizeTransferList - * @param transferStatus - * @return - * @throws Exception - */ - public boolean updateTransferList(AuthorizeTransferList authorizeTransferList, TransferStatus transferStatus) throws Exception { - try { - List parameters = new ArrayList<>(); - List ids = new ArrayList<>(); + transferInPendingStatusViews.forEach((row) -> { + results.add(new AuthorizeTransferPaymentsDto(row.getIdLoanDetail(), + row.getStrCreatedOn(), + row.getCustomerName(), + row.getEndorsementName(), + row.getUserName(), + row.getPaymentAmount(), + row.getLoanComments())); + }); - authorizeTransferList.getTransferListToUpdateStatus().forEach((row) -> { - ids.add(row.getIdLoan()); - }); + return results; + } catch (Exception e) { + throw e; + } + } - parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_TRANSFER_STATUS, transferStatus)); - parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_COMMENS, authorizeTransferList.getComments())); - parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID, ids)); + /** + * + * @param authorizeTransferList + * @param transferStatus + * @return + * @throws Exception + */ + public boolean updateTransferList(AuthorizeTransferList authorizeTransferList, TransferStatus transferStatus) throws Exception { + try { + List parameters = new ArrayList<>(); + List ids = new ArrayList<>(); - return loanDetailsRepository.updateLoanDetails(LoanDetailsCfg.UPDATE_TRANSFER_STATUS_WHERE_ID_IN, parameters); - } catch (Exception e) { - throw e; - } - } + authorizeTransferList.getTransferListToUpdateStatus().forEach((row) -> { + ids.add(row.getIdLoan()); + }); - /** - * - * @return @throws Exception - */ - public List findAllLoanInPendingStatusToDeliveryView() throws Exception { - try { - LoanInPendingStatusToDeliveryViewRepository repository = new LoanInPendingStatusToDeliveryViewRepository(); - List dataRows = repository.findAllLoanInPendingStatusToDeliveryViewFromHQL(LoanInPendingStatusToDeliveryViewCfg.QUERY_FIND_ALL_LOAN_IN_PENDING_STATUS_TO_DELIVERY_VIEW, null); - List results = new ArrayList<>(); + parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_TRANSFER_STATUS, transferStatus)); + parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_COMMENS, authorizeTransferList.getComments())); + parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID, ids)); - dataRows.forEach((row) -> { - results.add(new UpdateLoanToDeliveryStatusDTO(row.getIdLoan(), - row.getStrCreatedOn(), - row.getCustomerName(), - row.getEndorsementName(), - row.getUserName(), - row.getPayment())); - }); + return loanDetailsRepository.updateLoanDetails(LoanDetailsCfg.UPDATE_TRANSFER_STATUS_WHERE_ID_IN, parameters); + } catch (Exception e) { + throw e; + } + } - return results; - } catch (Exception e) { - logger.error("findAllLoanInPendingStatusToDeliveryView", e); - throw e; - } - } + /** + * + * @return @throws Exception + */ + public List findAllLoanInPendingStatusToDeliveryView() throws Exception { + try { + LoanInPendingStatusToDeliveryViewRepository repository = new LoanInPendingStatusToDeliveryViewRepository(); + List dataRows = repository.findAllLoanInPendingStatusToDeliveryViewFromHQL(LoanInPendingStatusToDeliveryViewCfg.QUERY_FIND_ALL_LOAN_IN_PENDING_STATUS_TO_DELIVERY_VIEW, null); + List results = new ArrayList<>(); - public boolean updateLoanPendingStatusToDelivery(UpdateLoanToDeliveryStatusList updateLoanToDeliveryStatusList, LoanStatus loanStatus) throws Exception { - try { - List loanParams = new ArrayList<>(); - List loanByUserParams = new ArrayList<>(); - List ids = new ArrayList<>(); - List loans = new ArrayList<>(); + dataRows.forEach((row) -> { + results.add(new UpdateLoanToDeliveryStatusDTO(row.getIdLoan(), + row.getStrCreatedOn(), + row.getCustomerName(), + row.getEndorsementName(), + row.getUserName(), + row.getPayment())); + }); - updateLoanToDeliveryStatusList.getLoanToDeliveryList().forEach((row) -> { - ids.add(row.getIdLoan()); - loans.add(new Loan(row.getIdLoan())); - }); + return results; + } catch (Exception e) { + logger.error("findAllLoanInPendingStatusToDeliveryView", e); + throw e; + } + } - loanParams.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, loanStatus)); - loanParams.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, new BigDecimal(0))); - loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, 0)); - loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, updateLoanToDeliveryStatusList.getIdUpdateUser())); - loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, new Date())); - loanParams.add(new ModelParameter(LoanCfg.FIELD_ID, ids)); + public boolean updateLoanPendingStatusToDelivery(UpdateLoanToDeliveryStatusList updateLoanToDeliveryStatusList, LoanStatus loanStatus) throws Exception { + try { + List loanParams = new ArrayList<>(); + List loanByUserParams = new ArrayList<>(); + List ids = new ArrayList<>(); + List loans = new ArrayList<>(); - loanByUserParams.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN_BY_USER_STATUS, loanStatus)); - loanByUserParams.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN, loans)); + updateLoanToDeliveryStatusList.getLoanToDeliveryList().forEach((row) -> { + ids.add(row.getIdLoan()); + loans.add(new Loan(row.getIdLoan())); + }); - return loanRepository.loanPendingStatusToDelivery(LoanCfg.QUERY_UPDATE_LOAN_STATUS_WHERE_ID_IN, LoanByUserCfg.QUERY_UPDATE_LOAN_BY_USER_STATUS_WHERE_LOAN_IN, loanParams, loanByUserParams); - } catch (Exception e) { - throw e; - } - } + loanParams.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, loanStatus)); + loanParams.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, new BigDecimal(0))); + loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, 0)); + loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, updateLoanToDeliveryStatusList.getIdUpdateUser())); + loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, new Date())); + loanParams.add(new ModelParameter(LoanCfg.FIELD_ID, ids)); - /** - * - * @param loanId - * @param userId - * @param action - * @param comments - * @param amount - * @param comissionType - * @return - * @throws Exception - */ - private boolean updateLoanByIdFromCertifiedView(String loanId, String userId, boolean action, String comments, BigDecimal amount, ComissionType comissionType) throws Exception { - logger.debug("updateLoanByIdFromCertifiedView"); - try { - List parameters = new ArrayList<>(); - Date date = new Date(); + loanByUserParams.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN_BY_USER_STATUS, loanStatus)); + loanByUserParams.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN, loans)); - parameters.add( - new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, action ? LoanStatus.APPROVED : LoanStatus.REJECTED) - ); + return loanRepository.loanPendingStatusToDelivery(LoanCfg.QUERY_UPDATE_LOAN_STATUS_WHERE_ID_IN, LoanByUserCfg.QUERY_UPDATE_LOAN_BY_USER_STATUS_WHERE_LOAN_IN, loanParams, loanByUserParams); + } catch (Exception e) { + throw e; + } + } - parameters.add( - new ModelParameter(LoanCfg.FIELD_COMMENTS, comments) - ); + /** + * + * @param loanId + * @param userId + * @param action + * @param comments + * @param amount + * @param comissionType + * @return + * @throws Exception + */ + private boolean updateLoanByIdFromCertifiedView(String loanId, String userId, boolean action, String comments, BigDecimal amount, ComissionType comissionType) throws Exception { + logger.debug("updateLoanByIdFromCertifiedView"); + try { + List parameters = new ArrayList<>(); + Date date = new Date(); - parameters.add( - new ModelParameter(LoanCfg.FIELD_CREATED_ON, date) - ); + parameters.add( + new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, action ? LoanStatus.APPROVED : LoanStatus.REJECTED) + ); - parameters.add( - new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, userId) - ); + parameters.add( + new ModelParameter(LoanCfg.FIELD_COMMENTS, comments) + ); - parameters.add( - new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, date) - ); + parameters.add( + new ModelParameter(LoanCfg.FIELD_CREATED_ON, date) + ); - parameters.add( - new ModelParameter(LoanCfg.FIELD_ID, loanId) - ); + parameters.add( + new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, userId) + ); - Delivery delivery = null; + parameters.add( + new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, date) + ); - if (action) { - delivery = new Delivery( - new User(userId), - new Loan(loanId), - amount, - userId, - date, - comissionType); - } + parameters.add( + new ModelParameter(LoanCfg.FIELD_ID, loanId) + ); - return loanRepository.updateLoan( - loanId, - LoanCfg.QUERY_UPDATE_LOAN_WITH_CREATED_ON_BY_ID_FROM_CERTIFIER_VIEW, - parameters, - action ? LoanStatus.APPROVED : LoanStatus.REJECTED, - delivery); - } catch (Exception e) { - logger.error("updateLoanByIdFromCertifiedView", e); - throw e; - } - } + Delivery delivery = null; - /** - * Vefify that person is available to create a new Loan. - * - * @param clazz AvailableCustomersView or AvailableEndorsementsView. - * @param idPerson Identification NUmber - * @return true if is available otherwise false. - * @throws Exception - */ - private boolean verifyPersonAvailability(Class clazz, String idPerson) throws Exception { - logger.debug("verifyPersonAvailability"); - try { - if (null == idPerson || "".equals(idPerson.trim())) { - throw new NullPointerException(clazz + " id is null"); - } + if (action) { + delivery = new Delivery( + new User(userId), + new Loan(loanId), + amount, + userId, + date, + comissionType); + } - return null != searchPersonAvailableRepository.findAvailablePersonByPersonId(clazz, idPerson); - } catch (Exception e) { - logger.error("verifyPersonAvailability", e); - throw e; - } - } + return loanRepository.updateLoan( + loanId, + LoanCfg.QUERY_UPDATE_LOAN_WITH_CREATED_ON_BY_ID_FROM_CERTIFIER_VIEW, + parameters, + action ? LoanStatus.APPROVED : LoanStatus.REJECTED, + delivery); + } catch (Exception e) { + logger.error("updateLoanByIdFromCertifiedView", e); + throw e; + } + } - private static final long serialVersionUID = -3608679734068691688L; - final Logger logger = LogManager.getLogger(LoanController.class - ); + /** + * Vefify that person is available to create a new Loan. + * + * @param clazz AvailableCustomersView or AvailableEndorsementsView. + * @param idPerson Identification NUmber + * @return true if is available otherwise false. + * @throws Exception + */ + private boolean verifyPersonAvailability(Class clazz, String idPerson) throws Exception { + logger.debug("verifyPersonAvailability"); + try { + if (null == idPerson || "".equals(idPerson.trim())) { + throw new NullPointerException(clazz + " id is null"); + } - private final LoanTypeRepository loanTypeRepository; - private final LoanRepository loanRepository; - private final LoanFeeNotificationRepository loanFeeNotificationRepository; - private final AddAmountRepository addAmountRepository; - private final LoanToDeliveryByCertifierRepository toDeliveryByCertifierRepository; - private final LoanByRenovationRepository loanByRenovationRepository; - private final SearchPersonAvailableRepository searchPersonAvailableRepository; - private final LoanApprovedDetailViewRepository loanApprovedDetailViewRepository; - private final LoanDetailsRepository loanDetailsRepository; + return null != searchPersonAvailableRepository.findAvailablePersonByPersonId(clazz, idPerson); + } catch (Exception e) { + logger.error("verifyPersonAvailability", e); + throw e; + } + } - private final String user_unavailable = "User unavailable to this operation"; + private static final long serialVersionUID = -3608679734068691688L; + final Logger logger = LogManager.getLogger(LoanController.class + ); - public LoanController() { - this.loanTypeRepository = new LoanTypeRepository(); - this.loanRepository = new LoanRepository(); - this.loanFeeNotificationRepository = new LoanFeeNotificationRepository(); - this.addAmountRepository = new AddAmountRepository(); - this.toDeliveryByCertifierRepository = new LoanToDeliveryByCertifierRepository(); - this.loanByRenovationRepository = new LoanByRenovationRepository(); - this.searchPersonAvailableRepository = new SearchPersonAvailableRepository(); - this.loanApprovedDetailViewRepository = new LoanApprovedDetailViewRepository(); - this.loanDetailsRepository = new LoanDetailsRepository(); - } + private final LoanTypeRepository loanTypeRepository; + private final LoanRepository loanRepository; + private final LoanFeeNotificationRepository loanFeeNotificationRepository; + private final AddAmountRepository addAmountRepository; + private final LoanToDeliveryByCertifierRepository toDeliveryByCertifierRepository; + private final LoanByRenovationRepository loanByRenovationRepository; + private final SearchPersonAvailableRepository searchPersonAvailableRepository; + private final LoanApprovedDetailViewRepository loanApprovedDetailViewRepository; + private final LoanDetailsRepository loanDetailsRepository; + + private final String user_unavailable = "User unavailable to this operation"; + + public LoanController() { + this.loanTypeRepository = new LoanTypeRepository(); + this.loanRepository = new LoanRepository(); + this.loanFeeNotificationRepository = new LoanFeeNotificationRepository(); + this.addAmountRepository = new AddAmountRepository(); + this.toDeliveryByCertifierRepository = new LoanToDeliveryByCertifierRepository(); + this.loanByRenovationRepository = new LoanByRenovationRepository(); + this.searchPersonAvailableRepository = new SearchPersonAvailableRepository(); + this.loanApprovedDetailViewRepository = new LoanApprovedDetailViewRepository(); + this.loanDetailsRepository = new LoanDetailsRepository(); + } } diff --git a/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/login/LoginWSController.java b/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/login/LoginWSController.java index e83c1fb..e1ea756 100644 --- a/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/login/LoginWSController.java +++ b/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/login/LoginWSController.java @@ -1,8 +1,8 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.controller.mobile.controller.login; @@ -24,57 +24,58 @@ import org.apache.logging.log4j.Logger; */ public class LoginWSController implements Serializable { - public UserMxy login(String userName, String password) throws Exception { - logger.debug("login"); + public UserMxy login(String userName, String password) throws Exception { + logger.debug("login"); - UserMxy userMxy; - List preferenceLst; - try { - MobileUser mobileUser = getAuthenticationRepository().findUser(userName, password); + UserMxy userMxy; + List preferenceLst; + try { + MobileUser mobileUser = getAuthenticationRepository().findUser(userName, password); - if (null == mobileUser) { - throw new Exception("Access denied"); - } else { - userMxy = new UserMxy( - mobileUser.getId(), - mobileUser.getUserName(), - mobileUser.getAvatar(), - mobileUser.getOfficeId(), - mobileUser.getRouteId(), - mobileUser.getCertifier(), - mobileUser.getManagement().toString() - ); - } + if (null == mobileUser) { + throw new Exception("Access denied"); + } else { + userMxy = new UserMxy( + mobileUser.getId(), + mobileUser.getUserName(), + mobileUser.getAvatar(), + mobileUser.getOfficeId(), + mobileUser.getRouteId(), + mobileUser.getCertifier(), + mobileUser.getManagement().toString(), + mobileUser.getIdentificadorFolio() + ); + } - List userMobilePreferences = getAuthenticationRepository().findAllMobilePreferenceByUser(userMxy.getId()); + List userMobilePreferences = getAuthenticationRepository().findAllMobilePreferenceByUser(userMxy.getId()); - if (!userMobilePreferences.isEmpty()) { - preferenceLst = new ArrayList<>(); + if (!userMobilePreferences.isEmpty()) { + preferenceLst = new ArrayList<>(); - userMobilePreferences.forEach((preference) -> { - preferenceLst.add(new UserPreferenceMxy(preference.getPreferenceName(), preference.getPreferenceValue())); - }); + userMobilePreferences.forEach((preference) -> { + preferenceLst.add(new UserPreferenceMxy(preference.getPreferenceName(), preference.getPreferenceValue())); + }); - userMxy.setPreferences(preferenceLst); - } - } catch (Exception e) { - logger.error("login", e); - throw e; - } - return userMxy; - } + userMxy.setPreferences(preferenceLst); + } + } catch (Exception e) { + logger.error("login", e); + throw e; + } + return userMxy; + } - public LoginWSController() { - this.authenticationRepository = new AuthenticationRepository(); - } + public LoginWSController() { + this.authenticationRepository = new AuthenticationRepository(); + } - public AuthenticationRepository getAuthenticationRepository() { - return authenticationRepository; - } + public AuthenticationRepository getAuthenticationRepository() { + return authenticationRepository; + } - private static final long serialVersionUID = 2795964728722199660L; - final Logger logger = LogManager.getLogger(LoginWSController.class); + private static final long serialVersionUID = 2795964728722199660L; + final Logger logger = LogManager.getLogger(LoginWSController.class); - private final AuthenticationRepository authenticationRepository; + private final AuthenticationRepository authenticationRepository; } diff --git a/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/login/UserMxy.java b/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/login/UserMxy.java index f230c8c..8e345f3 100644 --- a/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/login/UserMxy.java +++ b/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/login/UserMxy.java @@ -1,8 +1,8 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.controller.mobile.moxy.login; @@ -16,106 +16,117 @@ import java.util.List; */ public class UserMxy extends PersonMxy { - private String userName; - private String officeId; - private String routeId; - private String certifier; - private String management; + private String userName; + private String officeId; + private String routeId; + private String certifier; + private String management; + private String identificadorFolio; - private List preferences; + private List preferences; - public UserMxy() { - } + public UserMxy() { + } - /** - * - * @param id - * @param userName - * @param thumbnail - * @param officeId - * @param routeId - * @param certifier - */ - public UserMxy(String id, String userName, String thumbnail, String officeId, String routeId, String certifier) { - this.id = id; - this.userName = userName; - this.thumbnail = thumbnail; - this.officeId = officeId; - this.routeId = routeId; - this.certifier = certifier; - } + /** + * + * @param id + * @param userName + * @param thumbnail + * @param officeId + * @param routeId + * @param certifier + */ + public UserMxy(String id, String userName, String thumbnail, String officeId, String routeId, String certifier) { + this.id = id; + this.userName = userName; + this.thumbnail = thumbnail; + this.officeId = officeId; + this.routeId = routeId; + this.certifier = certifier; + } - /** - * - * @param id - * @param userName - * @param thumbnail - * @param officeId - * @param routeId - * @param certifier - * @param management - */ - public UserMxy(String id, String userName, String thumbnail, String officeId, String routeId, String certifier, String management) { - this.id = id; - this.userName = userName; - this.thumbnail = thumbnail; - this.officeId = officeId; - this.routeId = routeId; - this.certifier = certifier; - this.management = management; - } + /** + * + * @param id + * @param userName + * @param thumbnail + * @param officeId + * @param routeId + * @param certifier + * @param management + * @param identificadorFolio + */ + public UserMxy(String id, String userName, String thumbnail, String officeId, String routeId, String certifier, String management, String identificadorFolio) { + this.id = id; + this.userName = userName; + this.thumbnail = thumbnail; + this.officeId = officeId; + this.routeId = routeId; + this.certifier = certifier; + this.management = management; + this.identificadorFolio = identificadorFolio; + } - public String getUserName() { - return userName; - } + public String getUserName() { + return userName; + } - public void setUserName(String userName) { - this.userName = userName; - } + public void setUserName(String userName) { + this.userName = userName; + } - public String getOfficeId() { - return officeId; - } + public String getOfficeId() { + return officeId; + } - public void setOfficeId(String officeId) { - this.officeId = officeId; - } + public void setOfficeId(String officeId) { + this.officeId = officeId; + } - public void setPreferences(List preferences) { - this.preferences = preferences; - } + public void setPreferences(List preferences) { + this.preferences = preferences; + } - public List getPreferences() { - return preferences; - } + public List getPreferences() { + return preferences; + } - public String getRouteId() { - return routeId; - } + public String getRouteId() { + return routeId; + } - public void setRouteId(String routeId) { - this.routeId = routeId; - } + public void setRouteId(String routeId) { + this.routeId = routeId; + } - public String getCertifier() { - return certifier; - } + public String getCertifier() { + return certifier; + } - public void setCertifier(String certifier) { - this.certifier = certifier; - } + public void setCertifier(String certifier) { + this.certifier = certifier; + } - public String getManagement() { - return management; - } + public String getManagement() { + return management; + } - public void setManagement(String management) { - this.management = management; - } + public void setManagement(String management) { + this.management = management; + } - @Override - public String toString() { - return "UserMxy{" + "userName=" + userName + ", preferences=" + preferences + '}'; - } + public String getIdentificadorFolio() { + return identificadorFolio; + } + + public void setIdentificadorFolio(String identificadorFolio) { + this.identificadorFolio = identificadorFolio; + } + + @Override + public String toString() { + return "UserMxy{" + "userName=" + userName + ", preferences=" + preferences + '}'; + } } diff --git a/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/repository/views/LoanApprovedDetailViewRepository.java b/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/repository/views/LoanApprovedDetailViewRepository.java index 67b3618..3b18b00 100644 --- a/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/repository/views/LoanApprovedDetailViewRepository.java +++ b/apc-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/repository/views/LoanApprovedDetailViewRepository.java @@ -12,9 +12,14 @@ import com.arrebol.apc.model.ModelParameter; import com.arrebol.apc.model.enums.LoanDetailsType; import com.arrebol.apc.model.views.LoanApprovedDetailView; import com.arrebol.apc.model.ws.parsed.LoanDetailJaxb; +import com.arrebol.apc.model.ws.parsed.LoanRequestedJaxb; +import com.arrebol.apc.model.ws.parsed.PersonJaxb; import java.io.Serializable; import java.math.BigDecimal; +import java.security.Timestamp; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.persistence.Tuple; import org.apache.logging.log4j.LogManager; @@ -145,7 +150,8 @@ public class LoanApprovedDetailViewRepository extends GenericRepository implemen tuple.get("fullNameVendedor", String.class), tuple.get("fullNameCliente", String.class), tuple.get("numeroCuenta", String.class), - tuple.get("fullNameCrobrador", String.class) + tuple.get("fullNameCrobrador", String.class), + tuple.get("folio", String.class) ); results.add(detail); @@ -158,6 +164,73 @@ public class LoanApprovedDetailViewRepository extends GenericRepository implemen } } + /** + * + * @param xmlQuery + * @param parameters + * @return + * @throws Exception + */ + public LoanRequestedJaxb findLoanById(String xmlQuery, List parameters) throws Exception { + logger.debug("Consulta actual recibida: {}", xmlQuery); + logger.debug("findLoanById"); + try { + List tuples = xmlQueryTuple(xmlQuery, parameters); + logger.info("Número de resultados: {}", tuples.size()); + + if (tuples.isEmpty()) { + return null; + } + + Tuple tuple = tuples.get(0); + PersonJaxb customer = new PersonJaxb(tuple.get("customerName", String.class)); + PersonJaxb endorsement = new PersonJaxb(tuple.get("endorsementName", String.class)); + + Object dateValue = tuple.get("strDate"); + String formattedDate = null; + + if (dateValue != null) { + if (dateValue instanceof Timestamp) { + formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") + .format((Timestamp) dateValue); + } else if (dateValue instanceof Date) { + formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") + .format((Date) dateValue); + } else if (dateValue instanceof String) { + formattedDate = (String) dateValue; + } else { + formattedDate = dateValue.toString(); + } + } + + String fachadaCasa = tuple.get("fachadaCasa") != null + ? tuple.get("fachadaCasa", String.class) : ""; + + String descripcion = tuple.get("descripcion") != null + ? tuple.get("descripcion", String.class) : ""; + + String latitud = tuple.get("latitud") != null + ? tuple.get("latitud", String.class) : ""; + + String longitud = tuple.get("longitud") != null + ? tuple.get("longitud", String.class) : ""; + + return new LoanRequestedJaxb( + customer, + endorsement, + formattedDate, + fachadaCasa, + descripcion, + latitud, + longitud, + tuple.get("loanDescription", String.class) + ); + } catch (Exception e) { + logger.error("findLoanById", e); + throw e; + } + } + /** * * @param idLoan diff --git a/apc-controller/src/main/java/com/arrebol/apc/controller/system/employee/EmployeeController.java b/apc-controller/src/main/java/com/arrebol/apc/controller/system/employee/EmployeeController.java index 2c66719..908f511 100644 --- a/apc-controller/src/main/java/com/arrebol/apc/controller/system/employee/EmployeeController.java +++ b/apc-controller/src/main/java/com/arrebol/apc/controller/system/employee/EmployeeController.java @@ -105,6 +105,11 @@ public class EmployeeController implements Serializable { return humanResourceRepository.updateByHumanResourceId(hr, updateAvatar); } + public boolean updateHumanResource(HumanResource hr) { + logger.debug("updateHumanResource"); + return genericEntityRepository.updateAPCEntity(hr); + } + /** * * @param status diff --git a/apc-model/src/main/java/com/arrebol/apc/model/core/HumanResource.java b/apc-model/src/main/java/com/arrebol/apc/model/core/HumanResource.java index efbcf0a..9dc6fc7 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/core/HumanResource.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/core/HumanResource.java @@ -115,6 +115,20 @@ public class HumanResource implements Serializable { @Column(name = "created_by", nullable = false, length = 36) private String createdBy; + @Column(name = "identificador_folio", nullable = false, length = 36) + private String identificadorFolio; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "ultima_modificacion_folio", length = 19) + private Date ultimaModificacionFolio; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn( + name = "usuario_ultima_modificacion_folio", + referencedColumnName = "id" + ) + private User usuarioUltimaModificacionFolio; + @Temporal(TemporalType.TIMESTAMP) @Column(name = "created_on", length = 19) private Date createdOn; @@ -420,6 +434,30 @@ public class HumanResource implements Serializable { this.fullName = fullName; } + public String getIdentificadorFolio() { + return identificadorFolio; + } + + public void setIdentificadorFolio(String identificadorFolio) { + this.identificadorFolio = identificadorFolio; + } + + public Date getUltimaModificacionFolio() { + return ultimaModificacionFolio; + } + + public void setUltimaModificacionFolio(Date ultimaModificacionFolio) { + this.ultimaModificacionFolio = ultimaModificacionFolio; + } + + public User getUsuarioUltimaModificacionFolio() { + return usuarioUltimaModificacionFolio; + } + + public void setUsuarioUltimaModificacionFolio(User usuarioUltimaModificacionFolio) { + this.usuarioUltimaModificacionFolio = usuarioUltimaModificacionFolio; + } + @Override public String toString() { return "HumanResource{" + "firstName=" + firstName + ", secondName=" + secondName + ", lastName=" + lastName + ", middleName=" + middleName + '}'; diff --git a/apc-model/src/main/java/com/arrebol/apc/model/core/constance/LoanCfg.java b/apc-model/src/main/java/com/arrebol/apc/model/core/constance/LoanCfg.java index 021d3a3..301da47 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/core/constance/LoanCfg.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/core/constance/LoanCfg.java @@ -1,8 +1,8 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.model.core.constance; @@ -13,51 +13,52 @@ package com.arrebol.apc.model.core.constance; */ public interface LoanCfg extends GenericCfg { - String QUERY_UPDATE_LOAN_BY_ID = "updateLoanById"; - String QUERY_UPDATE_LOAN_FROM_RENOVATION = "updateLoanFromRenovation"; - String QUERY_UPDATE_LOAN_STATUS_WHERE_ID_IN = "updateLoanStatusWhereIdIn"; - String QUERY_UPDATE_LOAN_FROM_WEB = "updateLoanFromWeb"; - String QUERY_FIND_LOAN_BY_CUSTOMER = "findLoansByCustomer"; - String QUERY_FIND_LOAN_JURIDICAL = "findLoansJuridical"; - String QUERY_FIND_LOAN_ZERO = "findLoansZero"; - String QUERY_FIND_LOAN_FINISHED = "findLoansFinished"; - String QUERY_FIND_LOAN_BY_ENDORSEMENT = "findLoansByEndorsement"; - String QUERY_UPDATE_LOAN_BY_ID_FROM_CERTIFIER_VIEW = "updateLoanByIdFromCertifiedView"; - String QUERY_UPDATE_LOAN_WITH_CREATED_ON_BY_ID_FROM_CERTIFIER_VIEW = "updateLoanWithCreatedOnByIdFromCertifiedView"; - String QUERY_UPDATE_AND_FINISH_LOAN_BY_ID = "updateAndFinishLoanById"; - String QUERY_UPDATE_DISCOUNT_AND_LOAN_BY_ID_FROM_CERTIFIER_VIEW = "updateDiscountAndLoanByIdFromCertifiedView"; - String QUERY_FIND_LOAN_DETAILS_CURDATE_BY_LOAN = "findLoanDetailsPaymentCurdateByLoan"; - String QUERY_DELETE_LOAN_DETAILS_CURDATE_BY_LOAN = "deleteLoanDetailsPaymentCurdateByLoan"; - String QUERY_SEARCH_PAYMENT_DETAILS = "searchPaymentDetails"; - String QUERY_UPDATE_ROUTE_BY_ID = "updateRouteFromLoan"; - String QUERY_FIND_LOAN_DETAILS_FEE_CURDATE_BY_LOAN = "findLoanDetailsFeeCurdateByLoan"; - String QUERY_DELETE_LOAN_DETAILS_FEE_CURDATE_BY_LOAN = "deleteLoanDetailsFeeCurdateByLoan"; - String QUERY_DELETE_LOAN_FEE_NOTIFICATION_CURDATE_BY_LOAN = "deleteLoanFeeNotificationCurdateByLoan"; - String QUERY_DELETE_LOAN_FEE_NOTIFICATION_BY_LOAN = "deleteLoanFeeNotificationByLoan"; - String QUERY_UPDATE_LOAN_BONUS_NEW_CUSTOMER = "updateBonusNewCustomer"; - String QUERY_FIND_LAST_REFERENCE_NUMBER_BY_LOAN = "findLastReferenceNumberByLoan"; - String QUERY_COUNT_LOAN_IN_STATUSES = "countLoanInStatuses"; - String QUERY_COUNT_LOAN_BY_CUSTOMER_IN_STATUSES = "countLoanByCustomerInStatuses"; - String QUERY_SELECT_LOAN_ID_BY_CUSTOMER_IN_STATUSES = "selectLoanIdByCustomerInStatuses"; + String QUERY_UPDATE_LOAN_BY_ID = "updateLoanById"; + String QUERY_UPDATE_LOAN_FROM_RENOVATION = "updateLoanFromRenovation"; + String QUERY_UPDATE_LOAN_STATUS_WHERE_ID_IN = "updateLoanStatusWhereIdIn"; + String QUERY_UPDATE_LOAN_FROM_WEB = "updateLoanFromWeb"; + String QUERY_FIND_LOAN_BY_ID = "findLoansById"; + String QUERY_FIND_LOAN_BY_CUSTOMER = "findLoansByCustomer"; + String QUERY_FIND_LOAN_JURIDICAL = "findLoansJuridical"; + String QUERY_FIND_LOAN_ZERO = "findLoansZero"; + String QUERY_FIND_LOAN_FINISHED = "findLoansFinished"; + String QUERY_FIND_LOAN_BY_ENDORSEMENT = "findLoansByEndorsement"; + String QUERY_UPDATE_LOAN_BY_ID_FROM_CERTIFIER_VIEW = "updateLoanByIdFromCertifiedView"; + String QUERY_UPDATE_LOAN_WITH_CREATED_ON_BY_ID_FROM_CERTIFIER_VIEW = "updateLoanWithCreatedOnByIdFromCertifiedView"; + String QUERY_UPDATE_AND_FINISH_LOAN_BY_ID = "updateAndFinishLoanById"; + String QUERY_UPDATE_DISCOUNT_AND_LOAN_BY_ID_FROM_CERTIFIER_VIEW = "updateDiscountAndLoanByIdFromCertifiedView"; + String QUERY_FIND_LOAN_DETAILS_CURDATE_BY_LOAN = "findLoanDetailsPaymentCurdateByLoan"; + String QUERY_DELETE_LOAN_DETAILS_CURDATE_BY_LOAN = "deleteLoanDetailsPaymentCurdateByLoan"; + String QUERY_SEARCH_PAYMENT_DETAILS = "searchPaymentDetails"; + String QUERY_UPDATE_ROUTE_BY_ID = "updateRouteFromLoan"; + String QUERY_FIND_LOAN_DETAILS_FEE_CURDATE_BY_LOAN = "findLoanDetailsFeeCurdateByLoan"; + String QUERY_DELETE_LOAN_DETAILS_FEE_CURDATE_BY_LOAN = "deleteLoanDetailsFeeCurdateByLoan"; + String QUERY_DELETE_LOAN_FEE_NOTIFICATION_CURDATE_BY_LOAN = "deleteLoanFeeNotificationCurdateByLoan"; + String QUERY_DELETE_LOAN_FEE_NOTIFICATION_BY_LOAN = "deleteLoanFeeNotificationByLoan"; + String QUERY_UPDATE_LOAN_BONUS_NEW_CUSTOMER = "updateBonusNewCustomer"; + String QUERY_FIND_LAST_REFERENCE_NUMBER_BY_LOAN = "findLastReferenceNumberByLoan"; + String QUERY_COUNT_LOAN_IN_STATUSES = "countLoanInStatuses"; + String QUERY_COUNT_LOAN_BY_CUSTOMER_IN_STATUSES = "countLoanByCustomerInStatuses"; + String QUERY_SELECT_LOAN_ID_BY_CUSTOMER_IN_STATUSES = "selectLoanIdByCustomerInStatuses"; - String QUERY_FIND_LOAN_BY_STATUS_PENDING = "findLoansByStatusPending"; - String QUERY_FIND_ALL_LOANS = "findAllLoans"; - String QUERY_FIND_ALL_LOANS_VIEW = "findAllLoansView"; - String QUERY_FIND_ALL_LOANS_VIEW_BY_START_AND_END_DATE = "findAllLoansViewByStartAndEndDate"; - String QUERY_FIND_ALL_LOANS_JURIDICAL_VIEW_BY_START_AND_END_DATE = "findAllLoansJuridicalViewByStartAndEndDate"; - String QUERY_FIND_LOAN_DETAILS_BY_ID = "findLoansDetailById"; - String FIELD_AMOUNT_PAID = "amountPaid"; - String FIELD_AMOUNT_TO_PAY = "amountToPay"; - String FIELD_LAST_REFERENCE_NUMBER = "lastReferenceNumber"; - String FIELD_LOAN_STATUS = "loanStatus"; - String FIELD_NEW_CUSTOMER = "newCustomer"; - String FIELD_CUSTOMER = "customer"; - String FIELD_ENDORSEMENT = "endorsement"; - String FIELD_CUSTOMER_OFFICE = "customer.office"; - String FIELD_DETAILS_LOAN = "loan"; - String FIELD_COMMENTS = "comments"; - String FIELD_ROUTE = "routeCtlg"; - String FIELD_CREATED_ON = "createdOn"; - String FIELD_USER = "idUser"; + String QUERY_FIND_LOAN_BY_STATUS_PENDING = "findLoansByStatusPending"; + String QUERY_FIND_ALL_LOANS = "findAllLoans"; + String QUERY_FIND_ALL_LOANS_VIEW = "findAllLoansView"; + String QUERY_FIND_ALL_LOANS_VIEW_BY_START_AND_END_DATE = "findAllLoansViewByStartAndEndDate"; + String QUERY_FIND_ALL_LOANS_JURIDICAL_VIEW_BY_START_AND_END_DATE = "findAllLoansJuridicalViewByStartAndEndDate"; + String QUERY_FIND_LOAN_DETAILS_BY_ID = "findLoansDetailById"; + String FIELD_AMOUNT_PAID = "amountPaid"; + String FIELD_AMOUNT_TO_PAY = "amountToPay"; + String FIELD_LAST_REFERENCE_NUMBER = "lastReferenceNumber"; + String FIELD_LOAN_STATUS = "loanStatus"; + String FIELD_NEW_CUSTOMER = "newCustomer"; + String FIELD_CUSTOMER = "customer"; + String FIELD_ENDORSEMENT = "endorsement"; + String FIELD_CUSTOMER_OFFICE = "customer.office"; + String FIELD_DETAILS_LOAN = "loan"; + String FIELD_COMMENTS = "comments"; + String FIELD_ROUTE = "routeCtlg"; + String FIELD_CREATED_ON = "createdOn"; + String FIELD_USER = "idUser"; } diff --git a/apc-model/src/main/java/com/arrebol/apc/model/core/constance/LoanDetailsCfg.java b/apc-model/src/main/java/com/arrebol/apc/model/core/constance/LoanDetailsCfg.java index 3022156..9b11759 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/core/constance/LoanDetailsCfg.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/core/constance/LoanDetailsCfg.java @@ -1,8 +1,8 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.model.core.constance; @@ -13,23 +13,24 @@ package com.arrebol.apc.model.core.constance; */ public interface LoanDetailsCfg extends GenericCfg { - String QUERY_FIND_LOAN_DETAILS_BY_LOAN = "findLoanDetailsByLoan"; - String QUERY_FIND_LOAN_DETAILS_FROM_TIKET_BY_LOAN = "findLoanDetailsFromTikedByLoan"; - String QUERY_FIND_FEES_TO_PAY_BY_LOAN_ID = "findFeesToPayByLoanId"; - String QUERY_FIND_ALL_FEES_BY_LOAN_ID = "findAllFeesByLoanId"; - String QUERY_UPDATE_PAID_FEES_STATUS_IN_LOAN_DETAILS_IDS = "updatePaidFeesStatusInLoanDetailIds"; - String QUERY_COUNT_LOAN_DETAILS_IN_CURRDATE = "countLoanDetailsInCurrdate"; - String QUERY_FIND_ALL_TRANSFERS_LOAN_DETAIL = "findAllTransfersLoanDetail"; - String UPDATE_AUTHORIZE_LOAN_DETAIL = "updateAuthorizeTransferStatusInLoanDetailIds"; - String UPDATE_TRANSFER_STATUS_WHERE_ID_IN = "updateTransferStatusWhereIdIn"; - String UPDATE_REJECT_LOAN_DETAIL = "updateRejectTransferStatusInLoanDetailIds"; - String COUNT_LOAN_DETAILS_AUTHORIZE = "countLoanDetailsAuthorize"; + String QUERY_FIND_LOAN_DETAILS_BY_LOAN = "findLoanDetailsByLoan"; + String QUERY_FIND_LOAN_DETAILS_FROM_TIKET_BY_LOAN = "findLoanDetailsFromTikedByLoan"; + String QUERY_FIND_LAST_LOAN_BY_USER = "findLatestFolioByUser"; + String QUERY_FIND_FEES_TO_PAY_BY_LOAN_ID = "findFeesToPayByLoanId"; + String QUERY_FIND_ALL_FEES_BY_LOAN_ID = "findAllFeesByLoanId"; + String QUERY_UPDATE_PAID_FEES_STATUS_IN_LOAN_DETAILS_IDS = "updatePaidFeesStatusInLoanDetailIds"; + String QUERY_COUNT_LOAN_DETAILS_IN_CURRDATE = "countLoanDetailsInCurrdate"; + String QUERY_FIND_ALL_TRANSFERS_LOAN_DETAIL = "findAllTransfersLoanDetail"; + String UPDATE_AUTHORIZE_LOAN_DETAIL = "updateAuthorizeTransferStatusInLoanDetailIds"; + String UPDATE_TRANSFER_STATUS_WHERE_ID_IN = "updateTransferStatusWhereIdIn"; + String UPDATE_REJECT_LOAN_DETAIL = "updateRejectTransferStatusInLoanDetailIds"; + String COUNT_LOAN_DETAILS_AUTHORIZE = "countLoanDetailsAuthorize"; - String FIELD_ID_LOAN = "loan"; - String FIELD_LOAN_DETAILS_TYPE = "loanDetailsType"; - String FIELD_FEE_STATUS = "feeStatus"; - String FIELD_USER = "user"; - String FIELD_COMMENS = "comments"; - String FIELD_TRANSFER_STATUS = "transferStatus"; + String FIELD_ID_LOAN = "loan"; + String FIELD_LOAN_DETAILS_TYPE = "loanDetailsType"; + String FIELD_FEE_STATUS = "feeStatus"; + String FIELD_USER = "user"; + String FIELD_COMMENS = "comments"; + String FIELD_TRANSFER_STATUS = "transferStatus"; } diff --git a/apc-model/src/main/java/com/arrebol/apc/model/loan/Loan.java b/apc-model/src/main/java/com/arrebol/apc/model/loan/Loan.java index 2543c99..11e6c2b 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/loan/Loan.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/loan/Loan.java @@ -121,6 +121,18 @@ public class Loan implements Serializable { @Column(name = "frozen") private ActiveStatus frozen; + @Column(name = "fachada_casa", length = 200) + private String fachadaCasa; + + @Column(name = "descripcion", length = 200) + private String descripcion; + + @Column(name = "latitud", length = 200) + private String latitud; + + @Column(name = "longitud", length = 200) + private String longitud; + @OneToMany( mappedBy = "loan", cascade = CascadeType.ALL, @@ -230,6 +242,44 @@ public class Loan implements Serializable { this.frozen = frozen; } + /** + * + * @param loanType + * @param customer + * @param endorsement + * @param routeCtlg + * @param loanStatus + * @param amountPaid + * @param amountToPay + * @param lastReferenceNumber + * @param createdBy + * @param createdOn + * @param newCustomer + * @param frozen + * @param fachadaCasa + * @param descripcion + * @param latitud + * @param longitud + */ + public Loan(LoanType loanType, People customer, People endorsement, RouteCtlg routeCtlg, LoanStatus loanStatus, BigDecimal amountPaid, BigDecimal amountToPay, Integer lastReferenceNumber, String createdBy, Date createdOn, ActiveStatus newCustomer, ActiveStatus frozen, String fachadaCasa, String descripcion, String latitud, String longitud) { + this.loanType = loanType; + this.customer = customer; + this.endorsement = endorsement; + this.routeCtlg = routeCtlg; + this.loanStatus = loanStatus; + this.amountPaid = amountPaid; + this.amountToPay = amountToPay; + this.lastReferenceNumber = lastReferenceNumber; + this.createdBy = createdBy; + this.createdOn = createdOn; + this.newCustomer = newCustomer; + this.fachadaCasa = fachadaCasa; + this.frozen = frozen; + this.descripcion = descripcion; + this.latitud = latitud; + this.longitud = longitud; + } + /** * * @param id @@ -511,6 +561,38 @@ public class Loan implements Serializable { this.frozen = frozen; } + public String getFachadaCasa() { + return fachadaCasa; + } + + public void setFachadaCasa(String fachadaCasa) { + this.fachadaCasa = fachadaCasa; + } + + public String getDescripcion() { + return descripcion; + } + + public void setDescripcion(String descripcion) { + this.descripcion = descripcion; + } + + public String getLatitud() { + return latitud; + } + + public void setLatitud(String latitud) { + this.latitud = latitud; + } + + public String getLongitud() { + return longitud; + } + + public void setLongitud(String longitud) { + this.longitud = longitud; + } + @Override public String toString() { return "Loan{" + "loanType=" + loanType + ", createdBy=" + createdBy + '}'; diff --git a/apc-model/src/main/java/com/arrebol/apc/model/loan/LoanDetails.java b/apc-model/src/main/java/com/arrebol/apc/model/loan/LoanDetails.java index 9dc0695..36ed49e 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/loan/LoanDetails.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/loan/LoanDetails.java @@ -1,8 +1,8 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.model.loan; @@ -38,308 +38,376 @@ import org.hibernate.annotations.GenericGenerator; @Entity @Table(name = "APC_LOAN_DETAIL", uniqueConstraints = { - @UniqueConstraint(columnNames = {"id", "reference_number"}, name = "apc_loan_details_uk") + @UniqueConstraint(columnNames = {"id", "reference_number"}, name = "apc_loan_details_uk") }) public class LoanDetails implements Serializable { - private static final long serialVersionUID = -6757564734339598051L; + private static final long serialVersionUID = -6757564734339598051L; - @Id - @GeneratedValue(generator = "uuid") - @GenericGenerator(name = "uuid", strategy = "uuid2") - @Column(name = "id", length = 36) - private String id; + @Id + @GeneratedValue(generator = "uuid") + @GenericGenerator(name = "uuid", strategy = "uuid2") + @Column(name = "id", length = 36) + private String id; - @ManyToOne(fetch = FetchType.LAZY, optional = false) - @JoinColumn( - name = "id_loan", - referencedColumnName = "id", - nullable = false - ) - private Loan loan; + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn( + name = "id_loan", + referencedColumnName = "id", + nullable = false + ) + private Loan loan; - @ManyToOne(fetch = FetchType.LAZY, optional = false) - @JoinColumn( - name = "id_user", - referencedColumnName = "id", - nullable = false - ) - private User user; + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn( + name = "id_user", + referencedColumnName = "id", + nullable = false + ) + private User user; - @Enumerated(EnumType.STRING) - @Column(name = "people_type", nullable = false) - private PeopleType peopleType; + @Enumerated(EnumType.STRING) + @Column(name = "people_type", nullable = false) + private PeopleType peopleType; - @Column(name = "payment_amount", nullable = false) - private BigDecimal paymentAmount; + @Column(name = "payment_amount", nullable = false) + private BigDecimal paymentAmount; - @Column(name = "reference_number") - private Integer referenceNumber; + @Column(name = "reference_number") + private Integer referenceNumber; - @Enumerated(EnumType.STRING) - @Column(name = "loan_details_type", nullable = false) - private LoanDetailsType loanDetailsType; + @Enumerated(EnumType.STRING) + @Column(name = "loan_details_type", nullable = false) + private LoanDetailsType loanDetailsType; - @Column(name = "loan_comments", length = 150) - private String comments; + @Column(name = "loan_comments", length = 150) + private String comments; - @Enumerated(EnumType.STRING) - @Column(name = "fee_status") - private FeeStatus feeStatus; + @Column(name = "folio", length = 150) + private String folio; - @Enumerated(EnumType.STRING) - @Column(name = "transfer_status") - private TransferStatus transferStatus; + @Enumerated(EnumType.STRING) + @Column(name = "fee_status") + private FeeStatus feeStatus; - @Column(name = "transfer_number", length = 150) - private String transferNumber; + @Enumerated(EnumType.STRING) + @Column(name = "transfer_status") + private TransferStatus transferStatus; - @Column(name = "created_by", nullable = false, length = 36) - private String createdBy; + @Column(name = "transfer_number", length = 150) + private String transferNumber; - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "created_on", length = 19) - private Date createdOn; + @Column(name = "created_by", nullable = false, length = 36) + private String createdBy; - @Transient - private BigDecimal saldoInsoluto; + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_on", length = 19) + private Date createdOn; - public LoanDetails() { - } + @Transient + private BigDecimal saldoInsoluto; - /** - * - * @param id - * @param createdOn - * @param feeStatus - */ - public LoanDetails(String id, Date createdOn, FeeStatus feeStatus) { - this.id = id; - this.createdOn = createdOn; - this.feeStatus = feeStatus; - } + public LoanDetails() { + } - /** - * Complete constructor. - * - * @param id - * @param loan - * @param peopleType - * @param paymentAmount - * @param loanDetailsType - * @param comments - * @param createdBy - * @param createdOn - */ - public LoanDetails(String id, Loan loan, PeopleType peopleType, BigDecimal paymentAmount, LoanDetailsType loanDetailsType, String comments, String createdBy, Date createdOn) { - this.id = id; - this.loan = loan; - this.peopleType = peopleType; - this.paymentAmount = paymentAmount; - this.loanDetailsType = loanDetailsType; - this.comments = comments; - this.createdBy = createdBy; - this.createdOn = createdOn; - } + /** + * + * @param id + * @param createdOn + * @param feeStatus + */ + public LoanDetails(String id, Date createdOn, FeeStatus feeStatus) { + this.id = id; + this.createdOn = createdOn; + this.feeStatus = feeStatus; + } - /** - * - * @param id - * @param loan - * @param user - * @param peopleType - * @param referenceNumber - * @param paymentAmount - * @param loanDetailsType - * @param comments - * @param createdBy - * @param createdOn - */ - public LoanDetails(String id, Loan loan, User user, PeopleType peopleType, Integer referenceNumber, BigDecimal paymentAmount, LoanDetailsType loanDetailsType, String comments, String createdBy, Date createdOn) { - this.id = id; - this.loan = loan; - this.user = user; - this.peopleType = peopleType; - this.referenceNumber = referenceNumber; - this.paymentAmount = paymentAmount; - this.loanDetailsType = loanDetailsType; - this.comments = comments; - this.createdBy = createdBy; - this.createdOn = createdOn; - } + /** + * Complete constructor. + * + * @param id + * @param loan + * @param peopleType + * @param paymentAmount + * @param loanDetailsType + * @param comments + * @param createdBy + * @param createdOn + */ + public LoanDetails(String id, Loan loan, PeopleType peopleType, BigDecimal paymentAmount, LoanDetailsType loanDetailsType, String comments, String createdBy, Date createdOn) { + this.id = id; + this.loan = loan; + this.peopleType = peopleType; + this.paymentAmount = paymentAmount; + this.loanDetailsType = loanDetailsType; + this.comments = comments; + this.createdBy = createdBy; + this.createdOn = createdOn; + } - /** - * Add new amount. - * - * @param loan - * @param user - * @param peopleType - * @param paymentAmount - * @param referenceNumber - * @param loanDetailsType - * @param createdBy - * @param createdOn - * @param comments - */ - public LoanDetails(Loan loan, User user, PeopleType peopleType, BigDecimal paymentAmount, Integer referenceNumber, LoanDetailsType loanDetailsType, String createdBy, Date createdOn, String comments) { - this.loan = loan; - this.user = user; - this.peopleType = peopleType; - this.paymentAmount = paymentAmount; - this.referenceNumber = referenceNumber; - this.loanDetailsType = loanDetailsType; - this.createdBy = createdBy; - this.createdOn = createdOn; - this.comments = comments; - } + /** + * + * @param id + * @param loan + * @param user + * @param peopleType + * @param referenceNumber + * @param paymentAmount + * @param loanDetailsType + * @param comments + * @param createdBy + * @param createdOn + */ + public LoanDetails(String id, Loan loan, User user, PeopleType peopleType, Integer referenceNumber, BigDecimal paymentAmount, LoanDetailsType loanDetailsType, String comments, String createdBy, Date createdOn) { + this.id = id; + this.loan = loan; + this.user = user; + this.peopleType = peopleType; + this.referenceNumber = referenceNumber; + this.paymentAmount = paymentAmount; + this.loanDetailsType = loanDetailsType; + this.comments = comments; + this.createdBy = createdBy; + this.createdOn = createdOn; + } - /** - * - * @param loan - * @param user - * @param peopleType - * @param paymentAmount - * @param referenceNumber - * @param loanDetailsType - * @param createdBy - * @param createdOn - * @param comments - * @param transferNumber - * @param transferStatus - */ - public LoanDetails(Loan loan, User user, PeopleType peopleType, BigDecimal paymentAmount, Integer referenceNumber, LoanDetailsType loanDetailsType, String createdBy, Date createdOn, String comments, String transferNumber, TransferStatus transferStatus) { - this.loan = loan; - this.user = user; - this.peopleType = peopleType; - this.paymentAmount = paymentAmount; - this.referenceNumber = referenceNumber; - this.loanDetailsType = loanDetailsType; - this.createdBy = createdBy; - this.createdOn = createdOn; - this.comments = comments; - this.transferNumber = transferNumber; - this.transferStatus = transferStatus; - } + /** + * Add new amount. + * + * @param loan + * @param user + * @param peopleType + * @param paymentAmount + * @param referenceNumber + * @param loanDetailsType + * @param createdBy + * @param createdOn + * @param comments + */ + public LoanDetails(Loan loan, User user, PeopleType peopleType, BigDecimal paymentAmount, Integer referenceNumber, LoanDetailsType loanDetailsType, String createdBy, Date createdOn, String comments) { + this.loan = loan; + this.user = user; + this.peopleType = peopleType; + this.paymentAmount = paymentAmount; + this.referenceNumber = referenceNumber; + this.loanDetailsType = loanDetailsType; + this.createdBy = createdBy; + this.createdOn = createdOn; + this.comments = comments; + } - public String getId() { - return id; - } + /** + * Add new amount. + * + * @param loan + * @param user + * @param peopleType + * @param paymentAmount + * @param referenceNumber + * @param loanDetailsType + * @param createdBy + * @param createdOn + * @param comments + * @param folio + */ + public LoanDetails(Loan loan, User user, PeopleType peopleType, BigDecimal paymentAmount, Integer referenceNumber, LoanDetailsType loanDetailsType, String createdBy, Date createdOn, String comments, String folio) { + this.loan = loan; + this.user = user; + this.peopleType = peopleType; + this.paymentAmount = paymentAmount; + this.referenceNumber = referenceNumber; + this.loanDetailsType = loanDetailsType; + this.createdBy = createdBy; + this.createdOn = createdOn; + this.comments = comments; + this.folio = folio; + } - public void setId(String id) { - this.id = id; - } + /** + * + * @param loan + * @param user + * @param peopleType + * @param paymentAmount + * @param referenceNumber + * @param loanDetailsType + * @param createdBy + * @param createdOn + * @param comments + * @param transferNumber + * @param transferStatus + */ + public LoanDetails(Loan loan, User user, PeopleType peopleType, BigDecimal paymentAmount, Integer referenceNumber, LoanDetailsType loanDetailsType, String createdBy, Date createdOn, String comments, String transferNumber, TransferStatus transferStatus) { + this.loan = loan; + this.user = user; + this.peopleType = peopleType; + this.paymentAmount = paymentAmount; + this.referenceNumber = referenceNumber; + this.loanDetailsType = loanDetailsType; + this.createdBy = createdBy; + this.createdOn = createdOn; + this.comments = comments; + this.transferNumber = transferNumber; + this.transferStatus = transferStatus; + } - public Loan getLoan() { - return loan; - } + /** + * + * @param loan + * @param user + * @param peopleType + * @param paymentAmount + * @param referenceNumber + * @param loanDetailsType + * @param createdBy + * @param createdOn + * @param comments + * @param transferNumber + * @param transferStatus + * @param folio + */ + public LoanDetails(Loan loan, User user, PeopleType peopleType, BigDecimal paymentAmount, Integer referenceNumber, LoanDetailsType loanDetailsType, String createdBy, Date createdOn, String comments, String transferNumber, TransferStatus transferStatus, String folio) { + this.loan = loan; + this.user = user; + this.peopleType = peopleType; + this.paymentAmount = paymentAmount; + this.referenceNumber = referenceNumber; + this.loanDetailsType = loanDetailsType; + this.createdBy = createdBy; + this.createdOn = createdOn; + this.comments = comments; + this.transferNumber = transferNumber; + this.transferStatus = transferStatus; + this.folio = folio; + } - public void setLoan(Loan loan) { - this.loan = loan; - } + public String getId() { + return id; + } - public PeopleType getPeopleType() { - return peopleType; - } + public void setId(String id) { + this.id = id; + } - public void setPeopleType(PeopleType peopleType) { - this.peopleType = peopleType; - } + public Loan getLoan() { + return loan; + } - public BigDecimal getPaymentAmount() { - return paymentAmount; - } + public void setLoan(Loan loan) { + this.loan = loan; + } - public void setPaymentAmount(BigDecimal paymentAmount) { - this.paymentAmount = paymentAmount; - } + public PeopleType getPeopleType() { + return peopleType; + } - public Integer getReferenceNumber() { - return referenceNumber; - } + public void setPeopleType(PeopleType peopleType) { + this.peopleType = peopleType; + } - public void setReferenceNumber(Integer referenceNumber) { - this.referenceNumber = referenceNumber; - } + public BigDecimal getPaymentAmount() { + return paymentAmount; + } - public LoanDetailsType getLoanDetailsType() { - return loanDetailsType; - } + public void setPaymentAmount(BigDecimal paymentAmount) { + this.paymentAmount = paymentAmount; + } - public void setLoanDetailsType(LoanDetailsType loanDetailsType) { - this.loanDetailsType = loanDetailsType; - } + public Integer getReferenceNumber() { + return referenceNumber; + } - public String getComments() { - return comments; - } + public void setReferenceNumber(Integer referenceNumber) { + this.referenceNumber = referenceNumber; + } - public void setComments(String comments) { - this.comments = comments; - } + public LoanDetailsType getLoanDetailsType() { + return loanDetailsType; + } - public FeeStatus getFeeStatus() { - return feeStatus; - } + public void setLoanDetailsType(LoanDetailsType loanDetailsType) { + this.loanDetailsType = loanDetailsType; + } - public void setFeeStatus(FeeStatus feeStatus) { - this.feeStatus = feeStatus; - } + public String getComments() { + return comments; + } - public TransferStatus getTransferStatus() { - return transferStatus; - } + public void setComments(String comments) { + this.comments = comments; + } - public void setTransferStatus(TransferStatus transferStatus) { - this.transferStatus = transferStatus; - } + public FeeStatus getFeeStatus() { + return feeStatus; + } - public String getTransferNumber() { - return transferNumber; - } + public void setFeeStatus(FeeStatus feeStatus) { + this.feeStatus = feeStatus; + } - public void setTransferNumber(String transferNumber) { - this.transferNumber = transferNumber; - } + public TransferStatus getTransferStatus() { + return transferStatus; + } - public String getCreatedBy() { - return createdBy; - } + public void setTransferStatus(TransferStatus transferStatus) { + this.transferStatus = transferStatus; + } - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } + public String getTransferNumber() { + return transferNumber; + } - public Date getCreatedOn() { - return createdOn; - } + public void setTransferNumber(String transferNumber) { + this.transferNumber = transferNumber; + } - public void setCreatedOn(Date createdOn) { - this.createdOn = createdOn; - } + public String getCreatedBy() { + return createdBy; + } - public User getUser() { - return user; - } + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } - public void setUser(User user) { - this.user = user; - } + public Date getCreatedOn() { + return createdOn; + } - public BigDecimal getSaldoInsoluto() { - return saldoInsoluto; - } + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } - public void setSaldoInsoluto(BigDecimal saldoInsoluto) { - this.saldoInsoluto = saldoInsoluto; - } + public User getUser() { + return user; + } - public Double getAbonoD() { - return getPaymentAmount().doubleValue(); - } + public void setUser(User user) { + this.user = user; + } - @Override - public String toString() { - return "LoanDetails{" + "referenceNumber=" + referenceNumber + ", comments=" + comments + ", createdBy=" + createdBy + '}'; - } + public BigDecimal getSaldoInsoluto() { + return saldoInsoluto; + } + + public void setSaldoInsoluto(BigDecimal saldoInsoluto) { + this.saldoInsoluto = saldoInsoluto; + } + + public Double getAbonoD() { + return getPaymentAmount().doubleValue(); + } + + public String getFolio() { + return folio; + } + + public void setFolio(String folio) { + this.folio = folio; + } + + @Override + public String toString() { + return "LoanDetails{" + "referenceNumber=" + referenceNumber + ", comments=" + comments + ", createdBy=" + createdBy + '}'; + } } diff --git a/apc-model/src/main/java/com/arrebol/apc/model/loan/LoanType.java b/apc-model/src/main/java/com/arrebol/apc/model/loan/LoanType.java index 9181bd0..4d37a43 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/loan/LoanType.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/loan/LoanType.java @@ -8,6 +8,7 @@ package com.arrebol.apc.model.loan; import com.arrebol.apc.model.core.Office; +import com.arrebol.apc.model.core.User; import com.arrebol.apc.model.enums.ActiveStatus; import com.arrebol.apc.model.enums.DaysInWeekend; import java.io.Serializable; @@ -120,6 +121,16 @@ public class LoanType implements Serializable { @Column(name = "last_updated_by", length = 36) private String lastUpdatedBy; + @ManyToOne(fetch = FetchType.LAZY, optional = true) + @JoinColumn( + name = "last_updated_by", + referencedColumnName = "id", + nullable = true, + insertable = false, + updatable = false + ) + private User lastUserModified; + @Temporal(TemporalType.TIMESTAMP) @Column(name = "last_updated_on", length = 19) private Date lastUpdatedOn; @@ -325,6 +336,14 @@ public class LoanType implements Serializable { this.lastUpdatedBy = lastUpdatedBy; } + public User getLastUserModified() { + return lastUserModified; + } + + public void setLastUserModified(User lastUserModified) { + this.lastUserModified = lastUserModified; + } + public Date getLastUpdatedOn() { return lastUpdatedOn; } diff --git a/apc-model/src/main/java/com/arrebol/apc/model/mobile/access/MobileUser.java b/apc-model/src/main/java/com/arrebol/apc/model/mobile/access/MobileUser.java index 1de0578..b57b7a9 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/mobile/access/MobileUser.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/mobile/access/MobileUser.java @@ -1,8 +1,8 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.model.mobile.access; @@ -26,109 +26,120 @@ import org.hibernate.annotations.Immutable; @Table(name = "APC_SECURITY_AUTHENTICATION_MOBILE") public class MobileUser implements Serializable { - private static final long serialVersionUID = -6025180801746858060L; + private static final long serialVersionUID = -6025180801746858060L; - @Id - @Column(name = "id", length = 36) - private String id; + @Id + @Column(name = "id", length = 36) + private String id; - @Column(name = "user_name", length = 36) - private String userName; + @Column(name = "user_name", length = 36) + private String userName; - @Column(name = "pwd", length = 100) - private String password; + @Column(name = "pwd", length = 100) + private String password; - @Column(name = "avatar", length = 150) - private String avatar; + @Column(name = "avatar", length = 150) + private String avatar; - @Column(name = "id_office", length = 36) - private String officeId; + @Column(name = "id_office", length = 36) + private String officeId; - @Column(name = "id_route", length = 36) - private String routeId; + @Column(name = "id_route", length = 36) + private String routeId; - @Column(name = "certifier", length = 25) - private String certifier; + @Column(name = "certifier", length = 25) + private String certifier; - @Enumerated(EnumType.STRING) - @Column(name = "management", nullable = false) - private ActiveStatus management; + @Enumerated(EnumType.STRING) + @Column(name = "management", nullable = false) + private ActiveStatus management; - public MobileUser() { - } + @Column(name = "identificador_folio", length = 25) + private String identificadorFolio; - public MobileUser(String userName, String password) { - this.userName = userName; - this.password = password; - } + public MobileUser() { + } - public String getId() { - return id; - } + public MobileUser(String userName, String password) { + this.userName = userName; + this.password = password; + } - public void setId(String id) { - this.id = id; - } + public String getId() { + return id; + } - public String getUserName() { - return userName; - } + public void setId(String id) { + this.id = id; + } - public void setUserName(String userName) { - this.userName = userName; - } + public String getUserName() { + return userName; + } - public String getPassword() { - return password; - } + public void setUserName(String userName) { + this.userName = userName; + } - public void setPassword(String password) { - this.password = password; - } + public String getPassword() { + return password; + } - public String getAvatar() { - return avatar; - } + public void setPassword(String password) { + this.password = password; + } - public void setAvatar(String avatar) { - this.avatar = avatar; - } + public String getAvatar() { + return avatar; + } - public String getOfficeId() { - return officeId; - } + public void setAvatar(String avatar) { + this.avatar = avatar; + } - public void setOfficeId(String officeId) { - this.officeId = officeId; - } + public String getOfficeId() { + return officeId; + } - public String getRouteId() { - return routeId; - } + public void setOfficeId(String officeId) { + this.officeId = officeId; + } - public void setRouteId(String routeId) { - this.routeId = routeId; - } + public String getRouteId() { + return routeId; + } - public String getCertifier() { - return certifier; - } + public void setRouteId(String routeId) { + this.routeId = routeId; + } - public void setCertifier(String certifier) { - this.certifier = certifier; - } + public String getCertifier() { + return certifier; + } - public ActiveStatus getManagement() { - return management; - } + public void setCertifier(String certifier) { + this.certifier = certifier; + } - public void setManagement(ActiveStatus management) { - this.management = management; - } + public ActiveStatus getManagement() { + return management; + } - @Override - public String toString() { - return "Authentication{" + "userName=" + userName + '}'; - } + public void setManagement(ActiveStatus management) { + this.management = management; + } + + public String getIdentificadorFolio() { + return identificadorFolio; + } + + public void setIdentificadorFolio(String identificadorFolio) { + this.identificadorFolio = identificadorFolio; + } + + @Override + public String toString() { + return "Authentication{" + "userName=" + userName + '}'; + } } diff --git a/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/LoanDetailJaxb.java b/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/LoanDetailJaxb.java index dafa5d0..d788cfb 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/LoanDetailJaxb.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/LoanDetailJaxb.java @@ -28,6 +28,7 @@ public class LoanDetailJaxb { private String fullNameCliente; private String numeroCuenta; private String fullNameCrobrador; + private String folio; public LoanDetailJaxb() { } @@ -45,7 +46,7 @@ public class LoanDetailJaxb { * @param numeroCuenta * @param fullNameCrobrador */ - public LoanDetailJaxb(String paymentDate, double paymentOfDay, double toPay, String comment, String paymentType, String fullNameVendedor, String fullNameCliente, String numeroCuenta, String fullNameCrobrador) { + public LoanDetailJaxb(String paymentDate, double paymentOfDay, double toPay, String comment, String paymentType, String fullNameVendedor, String fullNameCliente, String numeroCuenta, String fullNameCrobrador, String folio) { this.paymentDate = paymentDate; this.paymentOfDay = paymentOfDay; this.toPay = toPay; @@ -55,6 +56,7 @@ public class LoanDetailJaxb { this.fullNameCliente = fullNameCliente; this.numeroCuenta = numeroCuenta; this.fullNameCrobrador = fullNameCrobrador; + this.folio = folio; } /** @@ -180,6 +182,15 @@ public class LoanDetailJaxb { this.fullNameCrobrador = fullNameCrobrador; } + @XmlElement(name = "folio") + public String getFolio() { + return folio; + } + + public void setFolio(String folio) { + this.folio = folio; + } + @Override public String toString() { return "LoanDetailJaxb{" + "paymentDate=" + paymentDate + ", paymentOfDay=" + paymentOfDay + ", toPay=" + toPay + ", payment=" + payment + '}'; diff --git a/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/LoanRequestedJaxb.java b/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/LoanRequestedJaxb.java index 0baa5f9..d13e5e9 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/LoanRequestedJaxb.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/LoanRequestedJaxb.java @@ -1,8 +1,8 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.model.ws.parsed; @@ -17,96 +17,157 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "loanRequested") public class LoanRequestedJaxb { - private String loanTypeId; - private String officeId; - private String userId; - private String routeId; - private PersonJaxb customer; - private PersonJaxb endorsement; - private String strDate; - private String routeIdNewClient; + private String loanTypeId; + private String officeId; + private String userId; + private String routeId; + private PersonJaxb customer; + private PersonJaxb endorsement; + private String strDate; + private String routeIdNewClient; + private String fachadaCasa; + private String descripcion; + private String latitud; + private String longitud; + private String loanDescription; - public LoanRequestedJaxb() { - } + public LoanRequestedJaxb(PersonJaxb customer, PersonJaxb endorsement, String strDate, String fachadaCasa, String descripcion, String latitud, String longitud, String loanDescription) { + this.customer = customer; + this.endorsement = endorsement; + this.strDate = strDate; + this.fachadaCasa = fachadaCasa; + this.descripcion = descripcion; + this.latitud = latitud; + this.longitud = longitud; + this.loanDescription = loanDescription; + } - @XmlElement(name = "loanTypeId") - public String getLoanTypeId() { - return loanTypeId; - } + public LoanRequestedJaxb() { + } - public void setLoanTypeId(String loanTypeId) { - this.loanTypeId = loanTypeId; - } + @XmlElement(name = "loanTypeId") + public String getLoanTypeId() { + return loanTypeId; + } - @XmlElement(name = "officeId") - public String getOfficeId() { - return officeId; - } + public void setLoanTypeId(String loanTypeId) { + this.loanTypeId = loanTypeId; + } - public void setOfficeId(String officeId) { - this.officeId = officeId; - } + @XmlElement(name = "officeId") + public String getOfficeId() { + return officeId; + } - @XmlElement(name = "userId") - public String getUserId() { - return userId; - } + public void setOfficeId(String officeId) { + this.officeId = officeId; + } - public void setUserId(String userId) { - this.userId = userId; - } + @XmlElement(name = "userId") + public String getUserId() { + return userId; + } - @XmlElement(name = "routeId") - public String getRouteId() { - return routeId; - } + public void setUserId(String userId) { + this.userId = userId; + } - public void setRouteId(String routeId) { - this.routeId = routeId; - } + @XmlElement(name = "routeId") + public String getRouteId() { + return routeId; + } - @XmlElement(name = "customer") - public PersonJaxb getCustomer() { - return customer; - } + public void setRouteId(String routeId) { + this.routeId = routeId; + } - public void setCustomer(PersonJaxb customer) { - this.customer = customer; - } + @XmlElement(name = "customer") + public PersonJaxb getCustomer() { + return customer; + } - @XmlElement(name = "endorsement") - public PersonJaxb getEndorsement() { - return endorsement; - } + public void setCustomer(PersonJaxb customer) { + this.customer = customer; + } - public void setEndorsement(PersonJaxb endorsement) { - this.endorsement = endorsement; - } + @XmlElement(name = "endorsement") + public PersonJaxb getEndorsement() { + return endorsement; + } - @XmlElement(name = "strDate") - public String getStrDate() { - return strDate; - } + public void setEndorsement(PersonJaxb endorsement) { + this.endorsement = endorsement; + } - public void setStrDate(String strDate) { - this.strDate = strDate; - } + @XmlElement(name = "strDate") + public String getStrDate() { + return strDate; + } - @XmlElement(name = "routeIdNewClient") - public String getRouteIdNewClient() { - return routeIdNewClient; - } + public void setStrDate(String strDate) { + this.strDate = strDate; + } - public String chooseRouteId() { - try { - return null == getRouteIdNewClient() || "".equals(getRouteIdNewClient()) ? getRouteId() : getRouteIdNewClient(); - } catch (Exception e) { - return getRouteId(); - } - } + @XmlElement(name = "routeIdNewClient") + public String getRouteIdNewClient() { + return routeIdNewClient; + } - public void setRouteIdNewClient(String routeIdNewClient) { - this.routeIdNewClient = routeIdNewClient; - } + public String chooseRouteId() { + try { + return null == getRouteIdNewClient() || "".equals(getRouteIdNewClient()) ? getRouteId() : getRouteIdNewClient(); + } catch (Exception e) { + return getRouteId(); + } + } + + public void setRouteIdNewClient(String routeIdNewClient) { + this.routeIdNewClient = routeIdNewClient; + } + + @XmlElement(name = "fachadaCasa") + public String getFachadaCasa() { + return fachadaCasa; + } + + public void setFachadaCasa(String fachadaCasa) { + this.fachadaCasa = fachadaCasa; + } + + @XmlElement(name = "descripcion") + public String getDescripcion() { + return descripcion; + } + + public void setDescripcion(String descripcion) { + this.descripcion = descripcion; + } + + @XmlElement(name = "latitud") + public String getLatitud() { + return latitud; + } + + public void setLatitud(String latitud) { + this.latitud = latitud; + } + + @XmlElement(name = "longitud") + public String getLongitud() { + return longitud; + } + + public void setLongitud(String longitud) { + this.longitud = longitud; + } + + @XmlElement(name = "loanDescription") + public String getLoanDescription() { + return loanDescription; + } + + public void setLoanDescription(String loanDescription) { + this.loanDescription = loanDescription; + } } diff --git a/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/NewAmountJaxb.java b/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/NewAmountJaxb.java index 6b0b013..717e0ea 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/NewAmountJaxb.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/NewAmountJaxb.java @@ -1,8 +1,8 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.model.ws.parsed; @@ -18,101 +18,111 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "newAmount") public class NewAmountJaxb { - private String loanId; - private String userId; - private String officeId; - private boolean customer; - private BigDecimal amount; - private String strDate; - private boolean fee; - private String comments; - private Boolean manager; + private String loanId; + private String userId; + private String officeId; + private boolean customer; + private BigDecimal amount; + private String strDate; + private boolean fee; + private String comments; + private Boolean manager; + private String folio; - public NewAmountJaxb() { - } + public NewAmountJaxb() { + } - @XmlAttribute(name = "loanId") - public String getLoanId() { - return loanId; - } + @XmlAttribute(name = "loanId") + public String getLoanId() { + return loanId; + } - public void setLoanId(String loanId) { - this.loanId = loanId; - } + public void setLoanId(String loanId) { + this.loanId = loanId; + } - @XmlAttribute(name = "userId") - public String getUserId() { - return userId; - } + @XmlAttribute(name = "userId") + public String getUserId() { + return userId; + } - public void setUserId(String userId) { - this.userId = userId; - } + public void setUserId(String userId) { + this.userId = userId; + } - @XmlAttribute(name = "officeId") - public String getOfficeId() { - return officeId; - } + @XmlAttribute(name = "officeId") + public String getOfficeId() { + return officeId; + } - public void setOfficeId(String officeId) { - this.officeId = officeId; - } + public void setOfficeId(String officeId) { + this.officeId = officeId; + } - @XmlAttribute(name = "customer") - public boolean isCustomer() { - return customer; - } + @XmlAttribute(name = "customer") + public boolean isCustomer() { + return customer; + } - public void setCustomer(boolean customer) { - this.customer = customer; - } + public void setCustomer(boolean customer) { + this.customer = customer; + } - @XmlAttribute(name = "amount") - public BigDecimal getAmount() { - return amount; - } + @XmlAttribute(name = "amount") + public BigDecimal getAmount() { + return amount; + } - public void setAmount(BigDecimal amount) { - this.amount = amount; - } + public void setAmount(BigDecimal amount) { + this.amount = amount; + } - @XmlAttribute(name = "strDate") - public String getStrDate() { - return strDate; - } + @XmlAttribute(name = "strDate") + public String getStrDate() { + return strDate; + } - public void setStrDate(String strDate) { - this.strDate = strDate; - } + public void setStrDate(String strDate) { + this.strDate = strDate; + } - @XmlAttribute(name = "fee") - public boolean isFee() { - return fee; - } + @XmlAttribute(name = "fee") + public boolean isFee() { + return fee; + } - public void setFee(boolean fee) { - this.fee = fee; - } + public void setFee(boolean fee) { + this.fee = fee; + } - @XmlAttribute(name = "comments") - public String getComments() { - return comments; - } + @XmlAttribute(name = "comments") + public String getComments() { + return comments; + } - public void setComments(String comments) { - this.comments = comments; - } + public void setComments(String comments) { + this.comments = comments; + } - @XmlAttribute(name = "manager") - public Boolean getManager() { - if (null == manager) { - manager = false; - } - return manager; - } + @XmlAttribute(name = "manager") + public Boolean getManager() { + if (null == manager) { + manager = false; + } + return manager; + } - public void setManager(Boolean manager) { - this.manager = manager; - } + public void setManager(Boolean manager) { + this.manager = manager; + } + + @XmlAttribute(name = "folio") + public String getFolio() { + return folio; + } + + public void setFolio(String folio) { + this.folio = folio; + } } diff --git a/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/NewTransferAccountJaxb.java b/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/NewTransferAccountJaxb.java index a765d16..06792a0 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/NewTransferAccountJaxb.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/NewTransferAccountJaxb.java @@ -1,8 +1,8 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.model.ws.parsed; @@ -18,81 +18,90 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "newTransferAccount") public class NewTransferAccountJaxb { - private String loanId; - private String userId; - private String officeId; - private BigDecimal amount; - private String comments; - private String transferReference; - private Boolean manager; + private String loanId; + private String userId; + private String officeId; + private BigDecimal amount; + private String comments; + private String transferReference; + private Boolean manager; + private String folio; - public NewTransferAccountJaxb() { - } + public NewTransferAccountJaxb() { + } - @XmlAttribute(name = "loanId") - public String getLoanId() { - return loanId; - } + @XmlAttribute(name = "loanId") + public String getLoanId() { + return loanId; + } - public void setLoanId(String loanId) { - this.loanId = loanId; - } + public void setLoanId(String loanId) { + this.loanId = loanId; + } - @XmlAttribute(name = "userId") - public String getUserId() { - return userId; - } + @XmlAttribute(name = "userId") + public String getUserId() { + return userId; + } - public void setUserId(String userId) { - this.userId = userId; - } + public void setUserId(String userId) { + this.userId = userId; + } - @XmlAttribute(name = "officeId") - public String getOfficeId() { - return officeId; - } + @XmlAttribute(name = "officeId") + public String getOfficeId() { + return officeId; + } - public void setOfficeId(String officeId) { - this.officeId = officeId; - } + public void setOfficeId(String officeId) { + this.officeId = officeId; + } - @XmlAttribute(name = "amount") - public BigDecimal getAmount() { - return amount; - } + @XmlAttribute(name = "amount") + public BigDecimal getAmount() { + return amount; + } - public void setAmount(BigDecimal amount) { - this.amount = amount; - } + public void setAmount(BigDecimal amount) { + this.amount = amount; + } - @XmlAttribute(name = "comments") - public String getComments() { - return comments; - } + @XmlAttribute(name = "comments") + public String getComments() { + return comments; + } - public void setComments(String comments) { - this.comments = comments; - } + public void setComments(String comments) { + this.comments = comments; + } - @XmlAttribute(name = "transferReference") - public String getTransferReference() { - return transferReference; - } + @XmlAttribute(name = "transferReference") + public String getTransferReference() { + return transferReference; + } - public void setTransferReference(String transferReference) { - this.transferReference = transferReference; - } + public void setTransferReference(String transferReference) { + this.transferReference = transferReference; + } - @XmlAttribute(name = "manager") - public Boolean getManager() { - if (null == manager) { - manager = false; - } - return manager; - } + @XmlAttribute(name = "manager") + public Boolean getManager() { + if (null == manager) { + manager = false; + } + return manager; + } - public void setManager(Boolean manager) { - this.manager = manager; - } + public void setManager(Boolean manager) { + this.manager = manager; + } + @XmlAttribute(name = "folio") + public String getFolio() { + return folio; + } + + public void setFolio(String folio) { + this.folio = folio; + } } diff --git a/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/PersonJaxb.java b/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/PersonJaxb.java index 679ce08..3cd34d2 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/PersonJaxb.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/PersonJaxb.java @@ -1,8 +1,8 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.model.ws.parsed; @@ -17,128 +17,132 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "person") public class PersonJaxb { - private String id; - private String firstName; - private String secondName; - private String lastName; - private String middleName; - private String addressHome; - private String addressWork; - private String phoneHome; - private String phoneWork; - private String thumbnail; - private String companyName; - private boolean createPerson; + private String id; + private String firstName; + private String secondName; + private String lastName; + private String middleName; + private String addressHome; + private String addressWork; + private String phoneHome; + private String phoneWork; + private String thumbnail; + private String companyName; + private boolean createPerson; - public PersonJaxb() { - } + public PersonJaxb(String firstName) { + this.firstName = firstName; + } - @XmlElement(name = "id") - public String getId() { - return id; - } + public PersonJaxb() { + } - public void setId(String id) { - this.id = id; - } + @XmlElement(name = "id") + public String getId() { + return id; + } - @XmlElement(name = "firstName") - public String getFirstName() { - return firstName; - } + public void setId(String id) { + this.id = id; + } - public void setFirstName(String firstName) { - this.firstName = firstName; - } + @XmlElement(name = "firstName") + public String getFirstName() { + return firstName; + } - @XmlElement(name = "secondName") - public String getSecondName() { - return secondName; - } + public void setFirstName(String firstName) { + this.firstName = firstName; + } - public void setSecondName(String secondName) { - this.secondName = secondName; - } + @XmlElement(name = "secondName") + public String getSecondName() { + return secondName; + } - @XmlElement(name = "lastName") - public String getLastName() { - return lastName; - } + public void setSecondName(String secondName) { + this.secondName = secondName; + } - public void setLastName(String lastName) { - this.lastName = lastName; - } + @XmlElement(name = "lastName") + public String getLastName() { + return lastName; + } - @XmlElement(name = "middleName") - public String getMiddleName() { - return middleName; - } + public void setLastName(String lastName) { + this.lastName = lastName; + } - public void setMiddleName(String middleName) { - this.middleName = middleName; - } + @XmlElement(name = "middleName") + public String getMiddleName() { + return middleName; + } - @XmlElement(name = "addressHome") - public String getAddressHome() { - return addressHome; - } + public void setMiddleName(String middleName) { + this.middleName = middleName; + } - public void setAddressHome(String addressHome) { - this.addressHome = addressHome; - } + @XmlElement(name = "addressHome") + public String getAddressHome() { + return addressHome; + } - @XmlElement(name = "addressWork") - public String getAddressWork() { - return addressWork; - } + public void setAddressHome(String addressHome) { + this.addressHome = addressHome; + } - public void setAddressWork(String addressWork) { - this.addressWork = addressWork; - } + @XmlElement(name = "addressWork") + public String getAddressWork() { + return addressWork; + } - @XmlElement(name = "phoneHome") - public String getPhoneHome() { - return phoneHome; - } + public void setAddressWork(String addressWork) { + this.addressWork = addressWork; + } - public void setPhoneHome(String phoneHome) { - this.phoneHome = phoneHome; - } + @XmlElement(name = "phoneHome") + public String getPhoneHome() { + return phoneHome; + } - @XmlElement(name = "phoneWork") - public String getPhoneWork() { - return phoneWork; - } + public void setPhoneHome(String phoneHome) { + this.phoneHome = phoneHome; + } - public void setPhoneWork(String phoneWork) { - this.phoneWork = phoneWork; - } + @XmlElement(name = "phoneWork") + public String getPhoneWork() { + return phoneWork; + } - @XmlElement(name = "thumbnail") - public String getThumbnail() { - return thumbnail; - } + public void setPhoneWork(String phoneWork) { + this.phoneWork = phoneWork; + } - public void setThumbnail(String thumbnail) { - this.thumbnail = thumbnail; - } + @XmlElement(name = "thumbnail") + public String getThumbnail() { + return thumbnail; + } - @XmlElement(name = "companyName") - public String getCompanyName() { - return companyName; - } + public void setThumbnail(String thumbnail) { + this.thumbnail = thumbnail; + } - public void setCompanyName(String companyName) { - this.companyName = companyName; - } + @XmlElement(name = "companyName") + public String getCompanyName() { + return companyName; + } - @XmlElement(name = "createPerson") - public boolean isCreatePerson() { - return createPerson; - } + public void setCompanyName(String companyName) { + this.companyName = companyName; + } - public void setCreatePerson(boolean createPerson) { - this.createPerson = createPerson; - } + @XmlElement(name = "createPerson") + public boolean isCreatePerson() { + return createPerson; + } + + public void setCreatePerson(boolean createPerson) { + this.createPerson = createPerson; + } } diff --git a/apc-model/src/main/resources/com/arrebol/apc/model/queries/loan/loan.details.queries.hbm.xml b/apc-model/src/main/resources/com/arrebol/apc/model/queries/loan/loan.details.queries.hbm.xml index d524081..27acf9f 100644 --- a/apc-model/src/main/resources/com/arrebol/apc/model/queries/loan/loan.details.queries.hbm.xml +++ b/apc-model/src/main/resources/com/arrebol/apc/model/queries/loan/loan.details.queries.hbm.xml @@ -23,7 +23,7 @@ ]]> - + + + + + + + + + fillDatatableEmployee() { - return getController().findEmployeesByType( - getLoggedUser().getOffice(), - HumanResourceStatus.ENEBLED, - getLoggedUser().getUser().getHumanResource().getId()); - } - - - @Override - public void editRow(RowEditEvent event) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } + public void editarIndetificadorDeFolios() { + try { + getSelectedHumanResource().setUltimaModificacionFolio(new Date()); + getSelectedHumanResource().setUsuarioUltimaModificacionFolio(getLoggedUser().getUser()); + getController().updateHumanResource(getSelectedHumanResource()); + logger.info("Se actualizó el identificador de folios correctamente"); + showMessage(FacesMessage.SEVERITY_INFO, "Registro actualizado", "Se actualizó el identificador de folios correctamente"); + setSelectedHumanResource(null); + fillDatatableEmployee(); + } catch (Exception e) { + logger.error("editarIndetificadorDeFolios(): " + e); + showMessage(FacesMessage.SEVERITY_ERROR, "Error", "Ocurrió un error al tratar de editar el identificador de  folios"); + } + } - @Override - public void onRowCancel(RowEditEvent event) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } + public List fillDatatableEmployee() { + return getController().findEmployeesByType(getLoggedUser().getOffice(), HumanResourceStatus.ENEBLED, getLoggedUser().getUser().getHumanResource().getId()); + } - @Override - public void onRowReorder(ReorderEvent event) { - showMessage(FacesMessage.SEVERITY_INFO, "Registro Movido", "De columna: " + (event.getFromIndex() + 1) + " a columna: " + (event.getToIndex() + 1)); - } + @Override + public void editRow(RowEditEvent event) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } - @Override - public void addRow() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } + @Override + public void onRowCancel(RowEditEvent event) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } - @Override - public void deleteRow() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } + @Override + public void onRowReorder(ReorderEvent event) { + showMessage(FacesMessage.SEVERITY_INFO, "Registro Movido", "De columna: " + (event.getFromIndex() + 1) + " a columna: " + (event.getToIndex() + 1)); + } - public EmployeeController getController() { - return controller; - } + @Override + public void addRow() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } - public void setController(EmployeeController controller) { - this.controller = controller; - } + @Override + public void deleteRow() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } - public List getHumanResource() { - return humanResource; - } + public EmployeeController getController() { + return controller; + } - public void setHumanResource(List humanResource) { - this.humanResource = humanResource; - } + public void setController(EmployeeController controller) { + this.controller = controller; + } + public List getHumanResource() { + return humanResource; + } - private EmployeeController controller; + public void setHumanResource(List humanResource) { + this.humanResource = humanResource; + } - private List humanResource; - + public HumanResource getSelectedHumanResource() { + return selectedHumanResource; + } - @PostConstruct() - public void init() { - loadBundlePropertyFile(); - - controller = new EmployeeController(); - + public void setSelectedHumanResource(HumanResource selectedHumanResource) { + this.selectedHumanResource = selectedHumanResource; + } - setHumanResource(fillDatatableEmployee()); - } + final Logger logger = LogManager.getLogger(EmployeeListBean.class); + + private EmployeeController controller; + private List humanResource; + private HumanResource selectedHumanResource; + + @PostConstruct() + public void init() { + loadBundlePropertyFile(); + controller = new EmployeeController(); + setHumanResource(fillDatatableEmployee()); + } } diff --git a/apc-web/src/main/java/com/arrebol/apc/web/beans/system/employee/EmployeeBean.java b/apc-web/src/main/java/com/arrebol/apc/web/beans/system/employee/EmployeeBean.java index c399bf2..bf7be43 100644 --- a/apc-web/src/main/java/com/arrebol/apc/web/beans/system/employee/EmployeeBean.java +++ b/apc-web/src/main/java/com/arrebol/apc/web/beans/system/employee/EmployeeBean.java @@ -47,6 +47,18 @@ public class EmployeeBean extends GenericBean implements Serializable { getSaveHumanResource().setCreatedBy(getLoggedUser().getUser().getId()); getSaveHumanResource().setBalance(BigDecimal.ZERO); + //Se valida si el identificador del folio + if (getSaveHumanResource().getIdentificadorFolio() == null || !getSaveHumanResource().getIdentificadorFolio().equals(getIdentificadorFolio())) { + if (getController().verificarIdentificadorFolio(getIdentificadorFolio())) { + logger.error("Identificador de folio ya asignado"); + buildAndSendMessage(null, "El identificador del folio ya ha sido asignado a otro usuario", FacesMessage.SEVERITY_WARN, "Error"); + return; + } + getSaveHumanResource().setIdentificadorFolio(getIdentificadorFolio()); + getSaveHumanResource().setUltimaModificacionFolio(new Date()); + getSaveHumanResource().setUsuarioUltimaModificacionFolio(getLoggedUser().getUser()); + } + if (getSaveHumanResource().getEmployeeSaving() == null) { getSaveHumanResource().setEmployeeSaving(BigDecimal.ZERO); } @@ -398,6 +410,7 @@ public class EmployeeBean extends GenericBean implements Serializable { private String bonusId; private List bonuses; + private String identificadorFolio; private String updateBonusId; @PostConstruct() @@ -619,4 +632,12 @@ public class EmployeeBean extends GenericBean implements Serializable { this.updateBonusId = updateBonusId; } + public String getIdentificadorFolio() { + return identificadorFolio; + } + + public void setIdentificadorFolio(String identificadorFolio) { + this.identificadorFolio = identificadorFolio; + } + } diff --git a/apc-web/src/main/webapp/app/catalog/loanType/index.xhtml b/apc-web/src/main/webapp/app/catalog/loanType/index.xhtml index 75dded4..988f780 100644 --- a/apc-web/src/main/webapp/app/catalog/loanType/index.xhtml +++ b/apc-web/src/main/webapp/app/catalog/loanType/index.xhtml @@ -28,6 +28,15 @@ + +
+ + + + +
+ + @@ -93,6 +102,16 @@ + + + + + + + + + + diff --git a/apc-web/src/main/webapp/app/system/employee/employeeList.xhtml b/apc-web/src/main/webapp/app/system/employee/employeeList.xhtml index 8d66337..8bd901e 100644 --- a/apc-web/src/main/webapp/app/system/employee/employeeList.xhtml +++ b/apc-web/src/main/webapp/app/system/employee/employeeList.xhtml @@ -25,21 +25,24 @@
-

- - - -

- - +

+ + + +

+ + - + - + - + @@ -63,32 +66,55 @@ - + - + - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + +
- - - - diff --git a/apc-web/src/main/webapp/app/system/employee/main.xhtml b/apc-web/src/main/webapp/app/system/employee/main.xhtml index cf88d1d..6b6d8b6 100644 --- a/apc-web/src/main/webapp/app/system/employee/main.xhtml +++ b/apc-web/src/main/webapp/app/system/employee/main.xhtml @@ -77,6 +77,14 @@ + + + + + diff --git a/apc-ws-rest/pom.xml b/apc-ws-rest/pom.xml index f29f788..ddaeb16 100644 --- a/apc-ws-rest/pom.xml +++ b/apc-ws-rest/pom.xml @@ -195,8 +195,8 @@ Localhost jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=UTC - root - Saladeespera2_ + apoprocomlocalhost + Yj$2Da0z! diff --git a/apc-ws-rest/src/main/java/com/arrebol/apc/ws/loan/LoanWS.java b/apc-ws-rest/src/main/java/com/arrebol/apc/ws/loan/LoanWS.java index 1467b5b..d61a68f 100644 --- a/apc-ws-rest/src/main/java/com/arrebol/apc/ws/loan/LoanWS.java +++ b/apc-ws-rest/src/main/java/com/arrebol/apc/ws/loan/LoanWS.java @@ -1,8 +1,8 @@ /* * Arrebol Consultancy copyright. - * + * * This code belongs to Arrebol Consultancy - * its use, redistribution or modification are prohibited + * its use, redistribution or modification are prohibited * without written authorization from Arrebol Consultancy. */ package com.arrebol.apc.ws.loan; @@ -22,12 +22,12 @@ import com.arrebol.apc.model.enums.TransferStatus; import com.arrebol.apc.model.loan.Loan; import com.arrebol.apc.model.loan.LoanDetails; import com.arrebol.apc.model.system.logs.Bitacora; -import com.arrebol.apc.model.ws.parsed.LoanRequestedJaxb; import com.arrebol.apc.model.views.AvailableCustomersView; import com.arrebol.apc.model.views.AvailableEndorsementsView; import com.arrebol.apc.model.views.LoanToDeliveryByCertifierView; import com.arrebol.apc.model.ws.parsed.FeesToPayByLoanRequestJaxb; import com.arrebol.apc.model.ws.parsed.LoanDetailJaxb; +import com.arrebol.apc.model.ws.parsed.LoanRequestedJaxb; import com.arrebol.apc.model.ws.parsed.NewAmountJaxb; import com.arrebol.apc.model.ws.parsed.NewTransferAccountJaxb; import com.arrebol.apc.model.ws.parsed.RenovationWithEndorsementJaxb; @@ -61,792 +61,828 @@ import org.glassfish.jersey.media.multipart.FormDataParam; @Path("loan") public class LoanWS implements Serializable { - private static final long serialVersionUID = -5416113076264972459L; + private static final long serialVersionUID = -5416113076264972459L; - @GET - @Path("findAllLoans") - @Produces(MediaType.APPLICATION_JSON) - public Response findAllLoanTypeByOffice(@QueryParam("id") String id) { - logger.debug("updateOrderInList"); - Response response; - try { - response = Response.ok(loanController.findAllLoanTypeByOffice(id)).build(); - } catch (Exception e) { - logger.error("updateOrderInList", e); + @GET + @Path("findAllLoans") + @Produces(MediaType.APPLICATION_JSON) + public Response findAllLoanTypeByOffice(@QueryParam("id") String id) { + logger.debug("updateOrderInList"); + Response response; + try { + response = Response.ok(loanController.findAllLoanTypeByOffice(id)).build(); + } catch (Exception e) { + logger.error("updateOrderInList", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } + + @GET + @Path("findAllAvailableCustomersByType") + @Produces(MediaType.APPLICATION_JSON) + public Response findAllAvailableCustomersByType(@QueryParam("name") String name) { + logger.debug("findAllAvailableCustomersByType"); + Response response; + try { + GenericEntity> results + = new GenericEntity>( + loanController.findAllAvailableCustomersByType("%" + name + "%")) { + }; + + response = Response.ok(results).build(); + } catch (Exception e) { + logger.error("findAllAvailableCustomersByType", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } + + @GET + @Path("find-fees-to-pay-by-loan-id") + @Produces(MediaType.APPLICATION_JSON) + public Response findFeesToPayByLoanId(@QueryParam("idLoan") String idLoan) { + logger.debug("findFeesToPayByLoanId"); + Response response; + try { + GenericEntity> results + = new GenericEntity>( + loanController.findFeesToPayByLoanId(idLoan)) { + }; + + response = Response.ok(results).build(); + } catch (Exception e) { + logger.error("findFeesToPayByLoanId", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } + + @PUT + @Path("update-paid-fees-status-in-loan-detail-ids") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response updatePaidFeesStatusInLoanDetailIds(FeesToPayByLoanRequestJaxb feesToPayByLoanRequestJaxb) { + logger.debug("updatePaidFeesStatusInLoanDetailIds"); + + Response response; + try { + if (loanController.updatePaidFeesStatusInLoanDetailIds(feesToPayByLoanRequestJaxb)) { + response = Response.ok().build(); + } else { response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } - - @GET - @Path("findAllAvailableCustomersByType") - @Produces(MediaType.APPLICATION_JSON) - public Response findAllAvailableCustomersByType(@QueryParam("name") String name) { - logger.debug("findAllAvailableCustomersByType"); - Response response; - try { - GenericEntity> results - = new GenericEntity>( - loanController.findAllAvailableCustomersByType("%" + name + "%")) { - }; - - response = Response.ok(results).build(); - } catch (Exception e) { - logger.error("findAllAvailableCustomersByType", e); + } + } catch (Exception e) { + if (e.getMessage().contains("User unavailable to this operation")) { + response = Response.status(Response.Status.CONFLICT).build(); + } else { response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } + } + logger.error("updatePaidFeesStatusInLoanDetailIds", e); - @GET - @Path("find-fees-to-pay-by-loan-id") - @Produces(MediaType.APPLICATION_JSON) - public Response findFeesToPayByLoanId(@QueryParam("idLoan") String idLoan) { - logger.debug("findFeesToPayByLoanId"); - Response response; - try { - GenericEntity> results - = new GenericEntity>( - loanController.findFeesToPayByLoanId(idLoan)) { - }; + } + return response; + } - response = Response.ok(results).build(); - } catch (Exception e) { - logger.error("findFeesToPayByLoanId", e); + @GET + @Path("findAllAvailableEndorsementsByType") + @Produces(MediaType.APPLICATION_JSON) + public Response findAllAvailableEndorsementsByType(@QueryParam("name") String name) { + logger.debug("findAllAvailableEndorsementsByType"); + Response response; + try { + GenericEntity> results + = new GenericEntity>( + loanController.findAllAvailableEndorsementsByType("%" + name + "%")) { + }; + + response = Response.ok(results).build(); + } catch (Exception e) { + logger.error("findAllAvailableEndorsementsByType", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } + + @PUT + @Path("create") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response createLoan(LoanRequestedJaxb loan) { + logger.debug("createLoan"); + + Response response; + try { + if (loanController.createLoan(loan)) { + response = Response.ok().build(); + } else { response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } - - @PUT - @Path("update-paid-fees-status-in-loan-detail-ids") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response updatePaidFeesStatusInLoanDetailIds(FeesToPayByLoanRequestJaxb feesToPayByLoanRequestJaxb) { - logger.debug("updatePaidFeesStatusInLoanDetailIds"); - - Response response; - try { - if (loanController.updatePaidFeesStatusInLoanDetailIds(feesToPayByLoanRequestJaxb)) { - response = Response.ok().build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - } catch (Exception e) { - if (e.getMessage().contains("User unavailable to this operation")) { - response = Response.status(Response.Status.CONFLICT).build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - logger.error("updatePaidFeesStatusInLoanDetailIds", e); - - } - return response; - } - - @GET - @Path("findAllAvailableEndorsementsByType") - @Produces(MediaType.APPLICATION_JSON) - public Response findAllAvailableEndorsementsByType(@QueryParam("name") String name) { - logger.debug("findAllAvailableEndorsementsByType"); - Response response; - try { - GenericEntity> results - = new GenericEntity>( - loanController.findAllAvailableEndorsementsByType("%" + name + "%")) { - }; - - response = Response.ok(results).build(); - } catch (Exception e) { - logger.error("findAllAvailableEndorsementsByType", e); + } + } catch (Exception e) { + if (e.getMessage().contains("User unavailable to this operation")) { + response = Response.status(Response.Status.CONFLICT).build(); + } else { response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } + } + logger.error("createLoan", e); - @PUT - @Path("create") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response createLoan(LoanRequestedJaxb loan) { - logger.debug("createLoan"); + } + return response; + } - Response response; - try { - if (loanController.createLoan(loan)) { - response = Response.ok().build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - } catch (Exception e) { - if (e.getMessage().contains("User unavailable to this operation")) { - response = Response.status(Response.Status.CONFLICT).build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - logger.error("createLoan", e); + @PUT + @Path("create-with-image") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Produces(MediaType.APPLICATION_JSON) + public Response createLoanWithImage( + // LoanRequestedJaxb loan, + @FormDataParam("thumbnail") ThumbnailJaxb thumbnail, + @FormDataParam("thumbnail") FormDataContentDisposition thumbnailMetaData) { + logger.debug("createLoan"); - } - return response; - } - - @PUT - @Path("create-with-image") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Produces(MediaType.APPLICATION_JSON) - public Response createLoanWithImage( - // LoanRequestedJaxb loan, - @FormDataParam("thumbnail") ThumbnailJaxb thumbnail, - @FormDataParam("thumbnail") FormDataContentDisposition thumbnailMetaData) { - logger.debug("createLoan"); - - Response response; - try { - if (true/*loanController.createLoan(loan)*/) { - response = Response.ok().build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - } catch (Exception e) { - if (e.getMessage().contains("User unavailable to this operation")) { - response = Response.status(Response.Status.CONFLICT).build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - logger.error("createLoan", e); - - } - return response; - } - - @PUT - @Path("create-with-image2") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Produces(MediaType.APPLICATION_JSON) - public Response createLoanWithImage2( - // LoanRequestedJaxb loan, - @FormDataParam("file") InputStream file, - @FormDataParam("file") FormDataContentDisposition fileDisposition) { - logger.debug("createLoan"); - - Response response; - try { - if (true/*loanController.createLoan(loan)*/) { - response = Response.ok().build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - } catch (Exception e) { - if (e.getMessage().contains("User unavailable to this operation")) { - response = Response.status(Response.Status.CONFLICT).build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - logger.error("createLoan", e); - - } - return response; - } - - @POST - @Path("saveNewAmount") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response saveNewAmount(NewAmountJaxb newAmountJaxb) { - logger.debug("saveNewAmount"); - Response response; - try { - if (newAmountJaxb.getAmount().compareTo(BigDecimal.ZERO) <= 0 && !newAmountJaxb.getManager()) { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } else { - if (systemPreferenceController.findConfigurationButton(newAmountJaxb.getUserId(), newAmountJaxb.getOfficeId()).isActiveButton()) { - - if (loanController.saveNewAmount(newAmountJaxb)) { - response = Response.ok().build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - } else { - response = Response.status(Response.Status.CONFLICT).build(); - } - } - } catch (Exception e) { - logger.error("saveNewAmount", e); + Response response; + try { + if (true/*loanController.createLoan(loan)*/) { + response = Response.ok().build(); + } else { response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } + } + } catch (Exception e) { + if (e.getMessage().contains("User unavailable to this operation")) { + response = Response.status(Response.Status.CONFLICT).build(); + } else { + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + logger.error("createLoan", e); - @POST - @Path("saveNewTransferAccount") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response saveNewTransferAccount(NewTransferAccountJaxb transfer) { - logger.debug("saveNewTransferAccount"); - Response response; - try { - if (transfer.getAmount().compareTo(BigDecimal.ZERO) <= 0 && !transfer.getManager()) { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } + + @PUT + @Path("create-with-image2") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Produces(MediaType.APPLICATION_JSON) + public Response createLoanWithImage2( + // LoanRequestedJaxb loan, + @FormDataParam("file") InputStream file, + @FormDataParam("file") FormDataContentDisposition fileDisposition) { + logger.debug("createLoan"); + + Response response; + try { + if (true/*loanController.createLoan(loan)*/) { + response = Response.ok().build(); + } else { + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + } catch (Exception e) { + if (e.getMessage().contains("User unavailable to this operation")) { + response = Response.status(Response.Status.CONFLICT).build(); + } else { + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + logger.error("createLoan", e); + + } + return response; + } + + @POST + @Path("saveNewAmount") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response saveNewAmount(NewAmountJaxb newAmountJaxb) { + logger.debug("saveNewAmount"); + Response response; + try { + if (newAmountJaxb.getAmount().compareTo(BigDecimal.ZERO) <= 0 && !newAmountJaxb.getManager()) { + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } else { + if (systemPreferenceController.findConfigurationButton(newAmountJaxb.getUserId(), newAmountJaxb.getOfficeId()).isActiveButton()) { + + if (loanController.saveNewAmount(newAmountJaxb)) { + response = Response.ok().build(); + } else { + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } } else { - if (systemPreferenceController.findConfigurationButton(transfer.getUserId(), transfer.getOfficeId()).isActiveButton()) { - - if (loanController.saveNewTransferAmount(transfer)) { - response = Response.ok().build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - } else { - response = Response.status(Response.Status.CONFLICT).build(); - } + response = Response.status(Response.Status.CONFLICT).build(); } - } catch (Exception e) { - logger.error("saveNewTransferAccount", e); + } + } catch (Exception e) { + logger.error("saveNewAmount", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } + + @POST + @Path("saveNewTransferAccount") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response saveNewTransferAccount(NewTransferAccountJaxb transfer) { + logger.debug("saveNewTransferAccount"); + Response response; + try { + if (transfer.getAmount().compareTo(BigDecimal.ZERO) <= 0 && !transfer.getManager()) { response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } + } else { + if (systemPreferenceController.findConfigurationButton(transfer.getUserId(), transfer.getOfficeId()).isActiveButton()) { - @GET - @Path("findNewCreditLimit") - @Produces(MediaType.APPLICATION_JSON) - public Response findNewCreditLimit(@QueryParam("office") String office, @QueryParam("loan") String loan) { - logger.debug("findNewCreditLimit"); - Response response; - try { - /** - * This method is for get all loan types applying some business - * rules, like number of Fees and if you are ok in 100% you can get - * next loan. - */ - //response = Response.ok(loanController.findNewCreditLimit(office, loan)).build(); - response = Response.ok(loanController.findAllLoansTypeByOffice(office)).build(); - } catch (Exception e) { - logger.error("findNewCreditLimit", e); - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } - - @PUT - @Path("renovation") - @Produces(MediaType.APPLICATION_JSON) - public Response renovation( - @FormParam("loan") String loan, - @FormParam("credit") String credit, - @FormParam("user") String user, - @FormParam("office") String office, - @FormParam("amount") double amount, - @FormParam("currentOwner") String currentOwner) { - logger.debug("renovation"); - - Response response; - try { - if (systemPreferenceController.findConfigurationButton(user, office).isActiveButton()) { - if (validateRenovationData(loan, credit, user)) { - if (loanController.renovation(loan, credit, user, new BigDecimal(amount), null)) { - response = Response.ok().build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } + if (loanController.saveNewTransferAmount(transfer)) { + response = Response.ok().build(); + } else { + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } } else { - response = Response.status(Response.Status.CONFLICT).build(); + response = Response.status(Response.Status.CONFLICT).build(); } - } catch (Exception e) { - logger.error("renovation", e); - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } + } + } catch (Exception e) { + logger.error("saveNewTransferAccount", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } - @PUT - @Path("renovation-has-payment-today") - @Produces(MediaType.APPLICATION_JSON) - public Response renovationHasPaymentToday( - @FormParam("loan") String loan, - @FormParam("credit") String credit, - @FormParam("user") String user, - @FormParam("office") String office, - @FormParam("amount") double amount, - @FormParam("currentOwner") String currentOwner) { - logger.debug("renovationHasPaymentToday"); + @GET + @Path("findNewCreditLimit") + @Produces(MediaType.APPLICATION_JSON) + public Response findNewCreditLimit(@QueryParam("office") String office, @QueryParam("loan") String loan) { + logger.debug("findNewCreditLimit"); + Response response; + try { + /** + * This method is for get all loan types applying some business rules, + * like number of Fees and if you are ok in 100% you can get next loan. + */ + //response = Response.ok(loanController.findNewCreditLimit(office, loan)).build(); + response = Response.ok(loanController.findAllLoansTypeByOffice(office)).build(); + } catch (Exception e) { + logger.error("findNewCreditLimit", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } - Response response; - try { - if (systemPreferenceController.findConfigurationButton(user, office).isActiveButton()) { - if (validateRenovationData(loan, credit, user)) { - if (loanController.renovationHasPaymentToday(loan, credit, user, new BigDecimal(amount), currentOwner, null)) { - response = Response.ok().build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } + @PUT + @Path("renovation") + @Produces(MediaType.APPLICATION_JSON) + public Response renovation( + @FormParam("loan") String loan, + @FormParam("credit") String credit, + @FormParam("user") String user, + @FormParam("office") String office, + @FormParam("amount") double amount, + @FormParam("currentOwner") String currentOwner) { + logger.debug("renovation"); + + Response response; + try { + if (systemPreferenceController.findConfigurationButton(user, office).isActiveButton()) { + if (validateRenovationData(loan, credit, user)) { + if (loanController.renovation(loan, credit, user, new BigDecimal(amount), null)) { + response = Response.ok().build(); + } else { + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } } else { - response = Response.status(Response.Status.CONFLICT).build(); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); } - } catch (Exception e) { - logger.error("renovationHasPaymentToday", e); - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } + } else { + response = Response.status(Response.Status.CONFLICT).build(); + } + } catch (Exception e) { + logger.error("renovation", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } - @GET - @Path("deliveryList") - @Produces(MediaType.APPLICATION_JSON) - public Response deliveryList(@QueryParam("user") String userId) { - logger.debug("deliveryList"); - Response response; - try { - GenericEntity> results - = new GenericEntity< List< LoanToDeliveryByCertifierView>>( - loanController.findLoansByCertifier(userId) - ) { - }; + @PUT + @Path("renovation-has-payment-today") + @Produces(MediaType.APPLICATION_JSON) + public Response renovationHasPaymentToday( + @FormParam("loan") String loan, + @FormParam("credit") String credit, + @FormParam("user") String user, + @FormParam("office") String office, + @FormParam("amount") double amount, + @FormParam("currentOwner") String currentOwner) { + logger.debug("renovationHasPaymentToday"); - response = Response.ok(results).build(); - } catch (Exception e) { - logger.error("deliveryList", e); - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } - - @POST - @Path("certifierAction") - @Produces(MediaType.APPLICATION_JSON) - public Response certifierAction( - @FormParam(value = "id") String id, - @FormParam(value = "user") String user, - @FormParam(value = "office") String office, - @FormParam(value = "comments") String comments, - @FormParam(value = "action") boolean action, - @FormParam(value = "amount") double amount, - @FormParam(value = "discount") double discount) { - logger.debug("certifierAction"); - Response response; - try { - if (systemPreferenceController.findConfigurationButton(user, office).isActiveButton()) { - if (loanController.certifierAction(id, user, comments, action, new BigDecimal(amount), new BigDecimal(discount))) { - response = Response.ok().build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } + Response response; + try { + if (systemPreferenceController.findConfigurationButton(user, office).isActiveButton()) { + if (validateRenovationData(loan, credit, user)) { + if (loanController.renovationHasPaymentToday(loan, credit, user, new BigDecimal(amount), currentOwner, null)) { + response = Response.ok().build(); + } else { + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } } else { - response = Response.status(Response.Status.CONFLICT).build(); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); } - } catch (Exception e) { - logger.error("certifierAction", e); - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } + } else { + response = Response.status(Response.Status.CONFLICT).build(); + } + } catch (Exception e) { + logger.error("renovationHasPaymentToday", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } - @POST - @Path("certifier-action-with-comission") - @Produces(MediaType.APPLICATION_JSON) - public Response certifierActionWithComission( - @FormParam(value = "id") String id, - @FormParam(value = "user") String user, - @FormParam(value = "office") String office, - @FormParam(value = "comments") String comments, - @FormParam(value = "action") boolean action, - @FormParam(value = "amount") double amount, - @FormParam(value = "discount") double discount, - @FormParam(value = "includeComission") boolean includeComission) { - logger.debug("certifierAction"); - Response response; - try { - if (systemPreferenceController.findConfigurationButton(user, office).isActiveButton()) { - if (loanController.certifierAction(id, user, comments, action, new BigDecimal(amount), new BigDecimal(discount), includeComission ? ComissionType.INCLUDED : ComissionType.EXCLUDED)) { - response = Response.ok().build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } + @GET + @Path("deliveryList") + @Produces(MediaType.APPLICATION_JSON) + public Response deliveryList(@QueryParam("user") String userId) { + logger.debug("deliveryList"); + Response response; + try { + GenericEntity> results + = new GenericEntity< List< LoanToDeliveryByCertifierView>>( + loanController.findLoansByCertifier(userId) + ) { + }; + + response = Response.ok(results).build(); + } catch (Exception e) { + logger.error("deliveryList", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } + + @POST + @Path("certifierAction") + @Produces(MediaType.APPLICATION_JSON) + public Response certifierAction( + @FormParam(value = "id") String id, + @FormParam(value = "user") String user, + @FormParam(value = "office") String office, + @FormParam(value = "comments") String comments, + @FormParam(value = "action") boolean action, + @FormParam(value = "amount") double amount, + @FormParam(value = "discount") double discount) { + logger.debug("certifierAction"); + Response response; + try { + if (systemPreferenceController.findConfigurationButton(user, office).isActiveButton()) { + if (loanController.certifierAction(id, user, comments, action, new BigDecimal(amount), new BigDecimal(discount))) { + response = Response.ok().build(); } else { - response = Response.status(Response.Status.CONFLICT).build(); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); } - } catch (Exception e) { - logger.error("certifierAction", e); - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } + } else { + response = Response.status(Response.Status.CONFLICT).build(); + } + } catch (Exception e) { + logger.error("certifierAction", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } - @GET - @Path("approved-details") - @Produces(MediaType.APPLICATION_JSON) - public Response approvedDetailsByIdLoan(@QueryParam("id") String loan) { - logger.debug("approvedDetailsByIdLoan"); - Response response; - try { + @POST + @Path("certifier-action-with-comission") + @Produces(MediaType.APPLICATION_JSON) + public Response certifierActionWithComission( + @FormParam(value = "id") String id, + @FormParam(value = "user") String user, + @FormParam(value = "office") String office, + @FormParam(value = "comments") String comments, + @FormParam(value = "action") boolean action, + @FormParam(value = "amount") double amount, + @FormParam(value = "discount") double discount, + @FormParam(value = "includeComission") boolean includeComission) { + logger.debug("certifierAction"); + Response response; + try { + if (systemPreferenceController.findConfigurationButton(user, office).isActiveButton()) { + if (loanController.certifierAction(id, user, comments, action, new BigDecimal(amount), new BigDecimal(discount), includeComission ? ComissionType.INCLUDED : ComissionType.EXCLUDED)) { + response = Response.ok().build(); + } else { + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + } else { + response = Response.status(Response.Status.CONFLICT).build(); + } + } catch (Exception e) { + logger.error("certifierAction", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } - GenericEntity> results - = new GenericEntity< List< LoanDetailJaxb>>( - loanController.approvedDetailsByIdLoan(loan) - ) { - }; + @GET + @Path("approved-details") + @Produces(MediaType.APPLICATION_JSON) + public Response approvedDetailsByIdLoan(@QueryParam("id") String loan) { + logger.debug("approvedDetailsByIdLoan"); + Response response; + try { - response = Response.ok(results).build(); - } catch (Exception e) { - logger.error("approvedDetailsByIdLoan", e); - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } + GenericEntity> results + = new GenericEntity< List< LoanDetailJaxb>>( + loanController.approvedDetailsByIdLoan(loan) + ) { + }; - @GET - @Path("approved-details-print") - @Produces(MediaType.APPLICATION_JSON) - public Response approvedDetailsFromTiketByIdLoan(@QueryParam("id") String loan) { - logger.debug("approvedDetailsFromTiketByIdLoan"); - Response response; - try { + response = Response.ok(results).build(); + } catch (Exception e) { + logger.error("approvedDetailsByIdLoan", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } - GenericEntity> results - = new GenericEntity< List< LoanDetailJaxb>>( - loanController.approvedDetailsFromTiketByIdLoan(loan) - ) { - }; + @GET + @Path("approved-details-print") + @Produces(MediaType.APPLICATION_JSON) + public Response approvedDetailsFromTiketByIdLoan(@QueryParam("id") String loan) { + logger.debug("approvedDetailsFromTiketByIdLoan"); + Response response; + try { - response = Response.ok(results).build(); - } catch (Exception e) { - logger.error("approvedDetailsFromTiketByIdLoan", e); - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } + GenericEntity> results + = new GenericEntity< List< LoanDetailJaxb>>( + loanController.approvedDetailsFromTiketByIdLoan(loan) + ) { + }; - @PUT - @Path("renovation-with-endorsement") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response renovationWithEndorsement(RenovationWithEndorsementJaxb renovation) { - logger.debug("renovationWithEndorsement"); + response = Response.ok(results).build(); + } catch (Exception e) { + logger.error("approvedDetailsFromTiketByIdLoan", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } - Response response; - try { - if (systemPreferenceController.findConfigurationButton(renovation.getUser(), renovation.getOffice()).isActiveButton()) { - if (validateRenovationData(renovation.getLoan(), renovation.getCredit(), renovation.getUser())) { - if (renovation.isHasPaymentToday()) { - if (loanController.renovationHasPaymentToday(renovation.getLoan(), renovation.getCredit(), renovation.getUser(), new BigDecimal(renovation.getAmount()), renovation.getCurrentOwner(), renovation.getEndorsement())) { - response = Response.ok().build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + @GET + @Path("latest-folio-by-user") + @Produces(MediaType.APPLICATION_JSON) + public Response getLatestFolioByUser(@QueryParam("id") String idUSer) { + logger.debug("getLatestFolioByUser"); + Response response; + try { + GenericEntity> results + = new GenericEntity< List< LoanDetailJaxb>>( + loanController.latestFolioByUser(idUSer) + ) { + }; + response = Response.ok(results).build(); + } catch (Exception e) { + logger.error("getLatestFolioByUser", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } + + @GET + @Path("loan-by-id") + @Produces(MediaType.APPLICATION_JSON) + public Response getLoanById(@QueryParam("id") String idLoan) { + logger.info("getLoanById(" + idLoan + ")"); + try { + LoanRequestedJaxb loan = loanController.loanById(idLoan); + if (loan == null) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + return Response.ok(loan).build(); + } catch (Exception e) { + logger.error("getLoanById", e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } + } + + @PUT + @Path("renovation-with-endorsement") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response renovationWithEndorsement(RenovationWithEndorsementJaxb renovation) { + logger.debug("renovationWithEndorsement"); + + Response response; + try { + if (systemPreferenceController.findConfigurationButton(renovation.getUser(), renovation.getOffice()).isActiveButton()) { + if (validateRenovationData(renovation.getLoan(), renovation.getCredit(), renovation.getUser())) { + if (renovation.isHasPaymentToday()) { + if (loanController.renovationHasPaymentToday(renovation.getLoan(), renovation.getCredit(), renovation.getUser(), new BigDecimal(renovation.getAmount()), renovation.getCurrentOwner(), renovation.getEndorsement())) { + response = Response.ok().build(); + } else { + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + } else { + if (loanController.renovation(renovation.getLoan(), renovation.getCredit(), renovation.getUser(), new BigDecimal(renovation.getAmount()), renovation.getEndorsement())) { + response = Response.ok().build(); + } else { + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + } + } else { + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + } else { + response = Response.status(Response.Status.CONFLICT).build(); + } + } catch (Exception e) { + logger.error("renovationWithEndorsement", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } + + @PUT + @Path("delete-today-payment") + @Produces(MediaType.APPLICATION_JSON) + public Response deleteTodayPayment( + @FormParam(value = "customer") String customerId, + @FormParam(value = "loan") String loanId, + @FormParam(value = "user") String userId, + @FormParam(value = "office") String office, + @FormParam(value = "comments") String comments, + @FormParam(value = "action") String action) { + logger.debug("deleteTodayPayment"); + Response response; + try { + DeleteLoanDetailsJaxb deleteLoanDetailsJaxb = loanController.enebleToDeleteTodayDetails(customerId, userId); + if (deleteLoanDetailsJaxb.getApprovedOrPendingRenovation()) { + Bitacora bitacora = new Bitacora(); + StringBuilder builder = new StringBuilder("Eliminar "); + + builder.append(("DELETE_PAYMENT".equals(action) ? "abono" : "multa")); + + bitacora.setAction(builder.toString()); + bitacora.setCommentsUser(comments); + bitacora.setCreatedBy(userId); + bitacora.setCreatedOn(new Date()); + bitacora.setNameUser("Certificador"); + bitacora.setOffice(new Office(office)); + + switch (action) { + case "DELETE_PAYMENT": + if (deleteLoanDetailsJaxb.getTodayPayment()) { + List details = loanController.getLoanDetailsCurdatebyIdLoan(loanId); + + if (details != null && !details.isEmpty()) { + + Loan loanUpdate = loanController.getLoanById(loanId); + BigDecimal tempMonto = BigDecimal.ZERO; + + for (LoanDetails detail : details) { + loanUpdate.setAmountPaid(loanUpdate.getAmountPaid().subtract(detail.getPaymentAmount())); + loanUpdate.setLastReferenceNumber(loanUpdate.getLastReferenceNumber() - 1); + tempMonto = tempMonto.add(detail.getPaymentAmount()); } - } else { - if (loanController.renovation(renovation.getLoan(), renovation.getCredit(), renovation.getUser(), new BigDecimal(renovation.getAmount()), renovation.getEndorsement())) { - response = Response.ok().build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + + bitacora.setDescription("Un abono del cliente " + loanUpdate.getCustomer().getFullName() + " se borro desde la APP Movil monto $" + tempMonto.toString()); + + if (loanController.deleteLoanDetailsByLoanCurdate(new Loan(loanId))) { + Date date = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.DAY_OF_YEAR, -1); + date = calendar.getTime(); + loanUpdate.setLastUpdatedOn(date); + + loanController.updateLoan(loanUpdate); + + //bitacoraCtrl.saveBitacora(bitacora); } - } - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - } else { - response = Response.status(Response.Status.CONFLICT).build(); - } - } catch (Exception e) { - logger.error("renovationWithEndorsement", e); - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } + } + response = Response.ok().build(); + } else { + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + break; + case "DELETE_FEE": + if (deleteLoanDetailsJaxb.getTodayFee()) { - @PUT - @Path("delete-today-payment") - @Produces(MediaType.APPLICATION_JSON) - public Response deleteTodayPayment( - @FormParam(value = "customer") String customerId, - @FormParam(value = "loan") String loanId, - @FormParam(value = "user") String userId, - @FormParam(value = "office") String office, - @FormParam(value = "comments") String comments, - @FormParam(value = "action") String action) { - logger.debug("deleteTodayPayment"); - Response response; - try { - DeleteLoanDetailsJaxb deleteLoanDetailsJaxb = loanController.enebleToDeleteTodayDetails(customerId, userId); - if (deleteLoanDetailsJaxb.getApprovedOrPendingRenovation()) { - Bitacora bitacora = new Bitacora(); - StringBuilder builder = new StringBuilder("Eliminar "); + List details = loanController.getLoanDetailsFeeCurdatebyIdLoan(loanId); - builder.append(("DELETE_PAYMENT".equals(action) ? "abono" : "multa")); + if (details != null && !details.isEmpty()) { + Loan loanUpdate = loanController.getLoanById(loanId); + BigDecimal tempMonto = BigDecimal.ZERO; - bitacora.setAction(builder.toString()); - bitacora.setCommentsUser(comments); - bitacora.setCreatedBy(userId); - bitacora.setCreatedOn(new Date()); - bitacora.setNameUser("Certificador"); - bitacora.setOffice(new Office(office)); - - switch (action) { - case "DELETE_PAYMENT": - if (deleteLoanDetailsJaxb.getTodayPayment()) { - List details = loanController.getLoanDetailsCurdatebyIdLoan(loanId); - - if (details != null && !details.isEmpty()) { - - Loan loanUpdate = loanController.getLoanById(loanId); - BigDecimal tempMonto = BigDecimal.ZERO; - - for (LoanDetails detail : details) { - loanUpdate.setAmountPaid(loanUpdate.getAmountPaid().subtract(detail.getPaymentAmount())); - loanUpdate.setLastReferenceNumber(loanUpdate.getLastReferenceNumber() - 1); - tempMonto = tempMonto.add(detail.getPaymentAmount()); - } - - bitacora.setDescription("Un abono del cliente " + loanUpdate.getCustomer().getFullName() + " se borro desde la APP Movil monto $" + tempMonto.toString()); - - if (loanController.deleteLoanDetailsByLoanCurdate(new Loan(loanId))) { - Date date = new Date(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.add(Calendar.DAY_OF_YEAR, -1); - date = calendar.getTime(); - loanUpdate.setLastUpdatedOn(date); - - loanController.updateLoan(loanUpdate); - - //bitacoraCtrl.saveBitacora(bitacora); - } - } - response = Response.ok().build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + for (LoanDetails detail : details) { + loanUpdate.setAmountToPay(loanUpdate.getAmountToPay().subtract(detail.getPaymentAmount())); + tempMonto = tempMonto.add(detail.getPaymentAmount()); } - break; - case "DELETE_FEE": - if (deleteLoanDetailsJaxb.getTodayFee()) { + bitacora.setDescription("Una multa del cliente " + loanUpdate.getCustomer().getFullName() + " se borro desde la APP Movil monto $" + tempMonto.toString()); + if (loanController.deleteLoanDetailsFeeByLoanCurdate(loanId)) { + loanController.deleteLoanFeeNotificationByLoanCurdate(loanId); - List details = loanController.getLoanDetailsFeeCurdatebyIdLoan(loanId); + Date date = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.DAY_OF_YEAR, -1); + date = calendar.getTime(); + loanUpdate.setLastUpdatedOn(date); - if (details != null && !details.isEmpty()) { - Loan loanUpdate = loanController.getLoanById(loanId); - BigDecimal tempMonto = BigDecimal.ZERO; - - for (LoanDetails detail : details) { - loanUpdate.setAmountToPay(loanUpdate.getAmountToPay().subtract(detail.getPaymentAmount())); - tempMonto = tempMonto.add(detail.getPaymentAmount()); - } - bitacora.setDescription("Una multa del cliente " + loanUpdate.getCustomer().getFullName() + " se borro desde la APP Movil monto $" + tempMonto.toString()); - if (loanController.deleteLoanDetailsFeeByLoanCurdate(loanId)) { - loanController.deleteLoanFeeNotificationByLoanCurdate(loanId); - - Date date = new Date(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.add(Calendar.DAY_OF_YEAR, -1); - date = calendar.getTime(); - loanUpdate.setLastUpdatedOn(date); - - loanController.updateLoan(loanUpdate); - //bitacoraCtrl.saveBitacora(bitacora); - } - } - response = Response.ok().build(); - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + loanController.updateLoan(loanUpdate); + //bitacoraCtrl.saveBitacora(bitacora); } - break; - default: - response = Response.ok().build(); - } - } else { - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + response = Response.ok().build(); + } else { + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + break; + default: + response = Response.ok().build(); } - } catch (Exception e) { - logger.error("deleteTodayPayment"); + } else { response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } + } + } catch (Exception e) { + logger.error("deleteTodayPayment"); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } - return response; - } + return response; + } - @GET - @Path("eneble-to-delete-today-details") - @Produces(MediaType.APPLICATION_JSON) - public Response enebleToDeleteTodayDetails(@QueryParam("id") String customerId, @QueryParam("user") String userId) { - logger.debug("enebleToDeleteTodayDetails"); - Response response; - try { - response = Response.ok(loanController.enebleToDeleteTodayDetails(customerId, userId)).build(); - } catch (Exception e) { - logger.error("enebleToDeleteTodayDetails"); - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } + @GET + @Path("eneble-to-delete-today-details") + @Produces(MediaType.APPLICATION_JSON) + public Response enebleToDeleteTodayDetails(@QueryParam("id") String customerId, @QueryParam("user") String userId) { + logger.debug("enebleToDeleteTodayDetails"); + Response response; + try { + response = Response.ok(loanController.enebleToDeleteTodayDetails(customerId, userId)).build(); + } catch (Exception e) { + logger.error("enebleToDeleteTodayDetails"); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } - return response; - } + return response; + } - @PUT - @Path("update-loan-type-by-loan-id") - @Produces(MediaType.APPLICATION_JSON) - public Response updateLoanTypeByLoanId(@FormParam("idLoan") String idLoan, - @FormParam("idLoanType") String idLoanType) { - Response response; - GenericAPCResponserJaxb apcResponse = new GenericAPCResponserJaxb(); - try { - if (loanController.updatePaymentTotalLoanById(idLoan, idLoanType)) { - apcResponse.setSuccessful(Boolean.TRUE); - apcResponse.setEnabledSubmit(Boolean.FALSE); - apcResponse.setMessage("Se actualizo el monto del prestamo"); - response = Response.ok().entity(apcResponse).build(); - } else { - apcResponse.setSuccessful(Boolean.FALSE); - apcResponse.setEnabledSubmit(Boolean.FALSE); - apcResponse.setMessage("No se actualizo el monto del prestamo"); - response = Response.ok().entity(apcResponse).build(); - } - } catch (Exception e) { - apcResponse.setSuccessful(Boolean.FALSE); + @PUT + @Path("update-loan-type-by-loan-id") + @Produces(MediaType.APPLICATION_JSON) + public Response updateLoanTypeByLoanId(@FormParam("idLoan") String idLoan, + @FormParam("idLoanType") String idLoanType) { + Response response; + GenericAPCResponserJaxb apcResponse = new GenericAPCResponserJaxb(); + try { + if (loanController.updatePaymentTotalLoanById(idLoan, idLoanType)) { + apcResponse.setSuccessful(Boolean.TRUE); apcResponse.setEnabledSubmit(Boolean.FALSE); - apcResponse.setMessage("Error al actualizar el monto del prestamo"); + apcResponse.setMessage("Se actualizo el monto del prestamo"); response = Response.ok().entity(apcResponse).build(); - logger.error("deleteClosingDay", e); - - } - return response; - } - - @GET - @Path("find-all-transfer-to-authorize") - @Produces(MediaType.APPLICATION_JSON) - public Response findAllTransferToAuthorize() { - logger.debug("findAllTransferToAuthorize"); - Response response; - try { - GenericEntity> results - = new GenericEntity>( - loanController.findAllTransferToAuthorize()) { - }; - - response = Response.ok(results).build(); - } catch (Exception e) { - logger.error("findAllTransferToAuthorize", e); - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } - - @PUT - @Path("update-transfer-list") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response updateTransferList(AuthorizeTransferList authorizeTransferList) { - Response response; - GenericAPCResponserJaxb apcResponse = new GenericAPCResponserJaxb(); - try { - if (loanController.updateTransferList(authorizeTransferList, TransferStatus.AUTHORIZED)) { - apcResponse.setSuccessful(Boolean.TRUE); - apcResponse.setEnabledSubmit(Boolean.FALSE); - String message = authorizeTransferList.getTransferListToUpdateStatus().size() == 1 ? "Se autorizo la transferencia bancaria" : "Se autorizaron las transferencias bancarias"; - apcResponse.setMessage(message); - response = Response.ok().entity(apcResponse).build(); - } else { - apcResponse.setSuccessful(Boolean.FALSE); - apcResponse.setEnabledSubmit(Boolean.FALSE); - String message = authorizeTransferList.getTransferListToUpdateStatus().size() == 1 ? "No se autorizo la trasferencia bancaria" : "No se autorizaron las trasferencias bancaria"; - apcResponse.setMessage(message); - response = Response.ok().entity(apcResponse).build(); - } - } catch (Exception e) { + } else { apcResponse.setSuccessful(Boolean.FALSE); apcResponse.setEnabledSubmit(Boolean.FALSE); - String message = authorizeTransferList.getTransferListToUpdateStatus().size() == 1 ? "Error al autorizar la transferencia bancaria" : "Error al autorizar las transferencias bancaria"; + apcResponse.setMessage("No se actualizo el monto del prestamo"); + response = Response.ok().entity(apcResponse).build(); + } + } catch (Exception e) { + apcResponse.setSuccessful(Boolean.FALSE); + apcResponse.setEnabledSubmit(Boolean.FALSE); + apcResponse.setMessage("Error al actualizar el monto del prestamo"); + response = Response.ok().entity(apcResponse).build(); + logger.error("deleteClosingDay", e); + + } + return response; + } + + @GET + @Path("find-all-transfer-to-authorize") + @Produces(MediaType.APPLICATION_JSON) + public Response findAllTransferToAuthorize() { + logger.debug("findAllTransferToAuthorize"); + Response response; + try { + GenericEntity> results + = new GenericEntity>( + loanController.findAllTransferToAuthorize()) { + }; + + response = Response.ok(results).build(); + } catch (Exception e) { + logger.error("findAllTransferToAuthorize", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } + + @PUT + @Path("update-transfer-list") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response updateTransferList(AuthorizeTransferList authorizeTransferList) { + Response response; + GenericAPCResponserJaxb apcResponse = new GenericAPCResponserJaxb(); + try { + if (loanController.updateTransferList(authorizeTransferList, TransferStatus.AUTHORIZED)) { + apcResponse.setSuccessful(Boolean.TRUE); + apcResponse.setEnabledSubmit(Boolean.FALSE); + String message = authorizeTransferList.getTransferListToUpdateStatus().size() == 1 ? "Se autorizo la transferencia bancaria" : "Se autorizaron las transferencias bancarias"; apcResponse.setMessage(message); - response = Response.ok().entity(apcResponse).build(); - logger.error("updateTransferList", e); - - } - return response; - } - - @GET - @Path("find-all-loans-in-pending-status-to-delivery") - @Produces(MediaType.APPLICATION_JSON) - public Response findAllLoanInPendingStatusToDeliveryView() { - logger.debug("findAllLoanInPendingStatusToDeliveryView"); - Response response; - try { - GenericEntity> results - = new GenericEntity>( - loanController.findAllLoanInPendingStatusToDeliveryView()) { - }; - - response = Response.ok(results).build(); - } catch (Exception e) { - logger.error("findAllLoanInPendingStatusToDeliveryView", e); - response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); - } - return response; - } - - @PUT - @Path("update-loan-pending-status-to-delivery") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response updateLoanPendingStatusToDelivery(UpdateLoanToDeliveryStatusList updateLoanToDeliveryStatusList) { - Response response; - GenericAPCResponserJaxb apcResponse = new GenericAPCResponserJaxb(); - try { - if (loanController.updateLoanPendingStatusToDelivery(updateLoanToDeliveryStatusList, LoanStatus.TO_DELIVERY)) { - apcResponse.setSuccessful(Boolean.TRUE); - apcResponse.setEnabledSubmit(Boolean.FALSE); - String message = updateLoanToDeliveryStatusList.getLoanToDeliveryList().size() == 1 ? "Se liberó el prestamo" : "Se liberaron los prestamos"; - apcResponse.setMessage(message); - response = Response.ok().entity(apcResponse).build(); - } else { - apcResponse.setSuccessful(Boolean.FALSE); - apcResponse.setEnabledSubmit(Boolean.FALSE); - String message = updateLoanToDeliveryStatusList.getLoanToDeliveryList().size() == 1 ? "No se liberó el prestamo" : "No se liberaron los prestamos"; - apcResponse.setMessage(message); - response = Response.ok().entity(apcResponse).build(); - } - } catch (Exception e) { + } else { apcResponse.setSuccessful(Boolean.FALSE); apcResponse.setEnabledSubmit(Boolean.FALSE); - String message = updateLoanToDeliveryStatusList.getLoanToDeliveryList().size() == 1 ? "Error al liberar el prestamo" : "Error al liberar los prestamos"; + String message = authorizeTransferList.getTransferListToUpdateStatus().size() == 1 ? "No se autorizo la trasferencia bancaria" : "No se autorizaron las trasferencias bancaria"; apcResponse.setMessage(message); - response = Response.ok().entity(apcResponse).build(); - logger.error("updateLoanPendingStatusToDelivery", e); + } + } catch (Exception e) { + apcResponse.setSuccessful(Boolean.FALSE); + apcResponse.setEnabledSubmit(Boolean.FALSE); + String message = authorizeTransferList.getTransferListToUpdateStatus().size() == 1 ? "Error al autorizar la transferencia bancaria" : "Error al autorizar las transferencias bancaria"; + apcResponse.setMessage(message); - } - return response; - } + response = Response.ok().entity(apcResponse).build(); + logger.error("updateTransferList", e); - /** - * - * @param loan - * @param credit - * @param user - * @param date yyyy-MM-dd HH:mm:ss - * @return - */ - private boolean validateRenovationData(String loan, String credit, String user) { - if (null == loan || loan.length() != 36) { - return false; - } - if (null == credit || credit.length() != 36) { - return false; - } - return !(null == user || user.length() != 36); - } + } + return response; + } - final Logger logger = LogManager.getLogger(LoanWS.class); - private final LoanController loanController; - private final SystemPreferenceController systemPreferenceController; + @GET + @Path("find-all-loans-in-pending-status-to-delivery") + @Produces(MediaType.APPLICATION_JSON) + public Response findAllLoanInPendingStatusToDeliveryView() { + logger.debug("findAllLoanInPendingStatusToDeliveryView"); + Response response; + try { + GenericEntity> results + = new GenericEntity>( + loanController.findAllLoanInPendingStatusToDeliveryView()) { + }; - public LoanWS() { - this.loanController = new LoanController(); - this.systemPreferenceController = new SystemPreferenceController(); - } + response = Response.ok(results).build(); + } catch (Exception e) { + logger.error("findAllLoanInPendingStatusToDeliveryView", e); + response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); + } + return response; + } + + @PUT + @Path("update-loan-pending-status-to-delivery") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response updateLoanPendingStatusToDelivery(UpdateLoanToDeliveryStatusList updateLoanToDeliveryStatusList) { + Response response; + GenericAPCResponserJaxb apcResponse = new GenericAPCResponserJaxb(); + try { + if (loanController.updateLoanPendingStatusToDelivery(updateLoanToDeliveryStatusList, LoanStatus.TO_DELIVERY)) { + apcResponse.setSuccessful(Boolean.TRUE); + apcResponse.setEnabledSubmit(Boolean.FALSE); + String message = updateLoanToDeliveryStatusList.getLoanToDeliveryList().size() == 1 ? "Se liberó el prestamo" : "Se liberaron los prestamos"; + apcResponse.setMessage(message); + response = Response.ok().entity(apcResponse).build(); + } else { + apcResponse.setSuccessful(Boolean.FALSE); + apcResponse.setEnabledSubmit(Boolean.FALSE); + String message = updateLoanToDeliveryStatusList.getLoanToDeliveryList().size() == 1 ? "No se liberó el prestamo" : "No se liberaron los prestamos"; + apcResponse.setMessage(message); + response = Response.ok().entity(apcResponse).build(); + } + } catch (Exception e) { + apcResponse.setSuccessful(Boolean.FALSE); + apcResponse.setEnabledSubmit(Boolean.FALSE); + String message = updateLoanToDeliveryStatusList.getLoanToDeliveryList().size() == 1 ? "Error al liberar el prestamo" : "Error al liberar los prestamos"; + apcResponse.setMessage(message); + + response = Response.ok().entity(apcResponse).build(); + logger.error("updateLoanPendingStatusToDelivery", e); + + } + return response; + } + + /** + * + * @param loan + * @param credit + * @param user + * @param date yyyy-MM-dd HH:mm:ss + * @return + */ + private boolean validateRenovationData(String loan, String credit, String user) { + if (null == loan || loan.length() != 36) { + return false; + } + if (null == credit || credit.length() != 36) { + return false; + } + return !(null == user || user.length() != 36); + } + + final Logger logger = LogManager.getLogger(LoanWS.class); + private final LoanController loanController; + private final SystemPreferenceController systemPreferenceController; + + public LoanWS() { + this.loanController = new LoanController(); + this.systemPreferenceController = new SystemPreferenceController(); + } }