From 7ae73a230e0715945668f9885815588e45566ca6 Mon Sep 17 00:00:00 2001 From: "Brayan.Gonzalez" Date: Wed, 6 Aug 2025 19:08:07 -0600 Subject: [PATCH] =?UTF-8?q?-=20CAPTURA=20DE=20LA=20LOCALIZACI=C3=93N=20DE?= =?UTF-8?q?=20LOS=20PAGOS=20Y=20ACTUALIZACI=C3=93N=20DEL=20WS=20PARA=20LA?= =?UTF-8?q?=20CAPTURA=20Y=20RETORNO=20DE=20LOS=20NUEVOS=20DATOS=C2=A0=20-?= =?UTF-8?q?=20CARGADO=20DE=20LISTADO=20DE=20LAS=20VENTAS=20APROBADAS=20PAR?= =?UTF-8?q?A=20LA=20VISUALIZACI=C3=93N=20DE=20LA=20LOCALIZACI=C3=93N=20DE?= =?UTF-8?q?=20LA=20VENTA=C2=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/loan/LoanController.java | 8 +- .../LoanApprovedDetailViewRepository.java | 4 +- .../apc/controller/admin/LoanController.java | 1060 +++++++++-------- .../apc/model/core/constance/LoanCfg.java | 1 + .../arrebol/apc/model/loan/LoanDetails.java | 34 +- .../apc/model/ws/parsed/LoanDetailJaxb.java | 27 +- .../apc/model/ws/parsed/NewAmountJaxb.java | 20 + .../ws/parsed/NewTransferAccountJaxb.java | 21 + .../queries/loan/loan.details.queries.hbm.xml | 28 +- .../model/queries/loan/loan.queries.hbm.xml | 14 + .../web/beans/dashboard/DashboardBean.java | 72 +- apc-web/src/main/webapp/WEB-INF/web.xml | 16 +- apc-web/src/main/webapp/dashboard.xhtml | 52 + 13 files changed, 806 insertions(+), 551 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 82b6c45..7693381 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 @@ -500,7 +500,9 @@ public class LoanController implements Serializable { newAmountJaxb.getUserId(), date, newAmountJaxb.getComments(), - newAmountJaxb.getFolio() + newAmountJaxb.getFolio(), + newAmountJaxb.getLongitud(), + newAmountJaxb.getLatitud() ); BigDecimal newAmountPaid, newAmountToPay; @@ -577,7 +579,9 @@ public class LoanController implements Serializable { 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() + transfer.getFolio(), + transfer.getLongitud(), + transfer.getLatitud() ); BigDecimal newAmountPaid = loan.getAmountPaid().add(amountWithoutIVA); 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 3b18b00..439be67 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 @@ -151,7 +151,9 @@ public class LoanApprovedDetailViewRepository extends GenericRepository implemen tuple.get("fullNameCliente", String.class), tuple.get("numeroCuenta", String.class), tuple.get("fullNameCrobrador", String.class), - tuple.get("folio", String.class) + tuple.get("folio", String.class), + tuple.get("longitud", String.class), + tuple.get("latitud", String.class) ); results.add(detail); diff --git a/apc-controller/src/main/java/com/arrebol/apc/controller/admin/LoanController.java b/apc-controller/src/main/java/com/arrebol/apc/controller/admin/LoanController.java index 55f89b5..e72cc51 100644 --- a/apc-controller/src/main/java/com/arrebol/apc/controller/admin/LoanController.java +++ b/apc-controller/src/main/java/com/arrebol/apc/controller/admin/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.admin; @@ -39,525 +39,539 @@ import org.apache.logging.log4j.Logger; */ public class LoanController implements Serializable { - /** - * - * Searching all loan by status pending. - * - * @param officeId - * @return - */ - public List fillLoanByStatusPendingDatatable(String officeId) { - logger.debug("fillLoanByStatusPendingDatatable"); - List parameters = new ArrayList<>(); - - //parameters.add(new ModelParameter(LoanCfg.FIELD_CUSTOMER_OFFICE, new Office(officeId))); - return genericEntityRepository.xmlQueryAPCEntities(Loan.class, LoanCfg.QUERY_FIND_LOAN_BY_STATUS_PENDING, parameters); - } - - /** - * - * Searching all loan - * - * @return - */ - public List fillAllLoansDatatable() { - logger.debug("fillAllLoansDatatable"); - List parameters = new ArrayList<>(); - return genericEntityRepository.xmlQueryAPCEntities(Loan.class, LoanCfg.QUERY_FIND_ALL_LOANS, parameters); - } - - /** - * - * Searching all loan - * - * @return - */ - public List fillAllLoansViewDatatable() { - logger.debug("fillAllLoansViewDatatable"); - List parameters = new ArrayList<>(); - return genericEntityRepository.xmlQueryAPCEntities(HistoryLoanView.class, LoanCfg.QUERY_FIND_ALL_LOANS_VIEW, parameters); - } - - /** - * - * @param startDate - * @param endDate - * @return - */ - public List fillAllLoansViewDatatable(Date startDate, Date endDate) { - logger.debug("fillAllLoansViewDatatable from start and end date"); - try { - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanCfg.PARAM_START_DATE, startDate)); - parameters.add(new ModelParameter(LoanCfg.PARAM_END_DATE, endDate)); - - return genericEntityRepository.xmlQueryAPCEntities(HistoryLoanView.class, LoanCfg.QUERY_FIND_ALL_LOANS_VIEW_BY_START_AND_END_DATE, parameters); - } catch (Exception e) { - logger.info("fillAllLoansViewDatatable from start and end date", e); - return new ArrayList<>(); - } - } - - /** - * - * @param startDate - * @param endDate - * @return - */ - public List fillAllLoansJuridicalViewDatatable(Date startDate, Date endDate) { - logger.debug("fillAllLoansJuridicalViewDatatable from start and end date"); - try { - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanCfg.PARAM_START_DATE, startDate)); - parameters.add(new ModelParameter(LoanCfg.PARAM_END_DATE, endDate)); - - return genericEntityRepository.xmlQueryAPCEntities(HistoryLoanView.class, LoanCfg.QUERY_FIND_ALL_LOANS_JURIDICAL_VIEW_BY_START_AND_END_DATE, parameters); - } catch (Exception e) { - logger.info("fillAllLoansJuridicalViewDatatable from start and end date", e); - return new ArrayList<>(); - } - } - - /** - * - * Searching loan by id. - * - * @param loanId - * @return - */ - public Loan getLoanById(String loanId) { - logger.debug("getLoanById"); - - return (Loan) genericEntityRepository.selectAPCEntityById(Loan.class, loanId); - } - - /** - * - * @param status - * @param loanIdToUpdate - * @param lastUpdatedBy - * @return - */ - public boolean updateLoanByStatus(LoanStatus status, String loanIdToUpdate, String lastUpdatedBy) { - logger.debug("updateLoanByStatus"); - - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, status)); - parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, new BigDecimal(0))); - parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, 0)); - parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, lastUpdatedBy)); - parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, new Date())); - parameters.add(new ModelParameter(LoanCfg.FIELD_ID, loanIdToUpdate)); - - return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_UPDATE_LOAN_FROM_RENOVATION, parameters); - } - - /** - * - * @param status - * @param loanIdToUpdate - * @param lastUpdatedBy - * @return - */ - public boolean updateLoanByStatusWeb(LoanStatus status, String loanIdToUpdate, String lastUpdatedBy) { - logger.debug("updateLoanByStatusWeb"); - - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, status)); - parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, lastUpdatedBy)); - parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, new Date())); - parameters.add(new ModelParameter(LoanCfg.FIELD_ID, loanIdToUpdate)); - - return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_UPDATE_LOAN_FROM_WEB, parameters); - } - - /** - * - * Searching all loan details by id. - * - * @param loanId - * @return - */ - public List getLoanDetailsbyId(String loanId) { - logger.debug("getLoanDetailsbyId"); - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanId))); - - return genericEntityRepository.xmlQueryAPCEntities(LoanDetails.class, LoanCfg.QUERY_FIND_LOAN_DETAILS_BY_ID, parameters); - } - - public LoanDetails getLoanDetailbyId(String loanDetailsId) { - logger.debug("getLoanDetailbyId"); - - return (LoanDetails) genericEntityRepository.selectAPCEntityById(LoanDetails.class, loanDetailsId); - } - - public boolean updateAuthorizeLoanDetailById(String loanDetailId) { - logger.debug("updateAuthorizeLoanDetailById"); - - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID, loanDetailId)); - - return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanDetailsCfg.UPDATE_AUTHORIZE_LOAN_DETAIL, parameters); - } - - public Long countLoanDetailsAuthorize(String user) { - logger.debug("countLoanDetailsAutorize"); - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_USER, user)); - return (Long) genericEntityRepository.xmlQueryAPCEntityUniqueResult(Long.class, LoanDetailsCfg.COUNT_LOAN_DETAILS_AUTHORIZE, parameters); - - } - - public boolean updateRejectLoanDetailById(String loanDetailId) { - logger.debug("updateAuthorizeLoanDetailById"); - - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID, loanDetailId)); - - return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanDetailsCfg.UPDATE_REJECT_LOAN_DETAIL, parameters); - } - - public List fillAllTransfersLoanDetails() { - logger.debug("findAllTransfersLoanDetail"); - - return genericEntityRepository.xmlQueryAPCEntities(LoanDetails.class, LoanDetailsCfg.QUERY_FIND_ALL_TRANSFERS_LOAN_DETAIL); - } - - /** - * - * Searching all loan details by id. - * - * @param loanId - * @return - */ - public List getLoanDetailsCurdatebyIdLoan(String loanId) { - logger.debug("getLoanDetailsCurdatebyIdLoan"); - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanId))); - - return genericEntityRepository.xmlQueryAPCEntities(LoanDetails.class, LoanCfg.QUERY_FIND_LOAN_DETAILS_CURDATE_BY_LOAN, parameters); - } - - /** - * - * @param loan - * @return boolean - */ - public boolean saveLoan(Loan loan) { - logger.debug("saveLoan"); - boolean success = genericEntityRepository.insertAPCEntity(loan); - - return success; - } - - /** - * - * @param loan - * @return boolean - */ - public boolean updateLoan(Loan loan) { - logger.debug("updateLoan"); - boolean success = genericEntityRepository.updateAPCEntity(loan); - - return success; - } - - /** - * - * @param loan - * @return boolean - */ - public boolean updateLoanByUser(LoanByUser loan) { - logger.debug("updateLoanByUser"); - boolean success = genericEntityRepository.updateAPCEntity(loan); - - return success; - } - - /** - * - * @param loan - * @return boolean - */ - public boolean saveLoanNotificationFee(LoanFeeNotification notification) { - logger.debug("saveLoanNotificationFee"); - boolean success = genericEntityRepository.insertAPCEntity(notification); - - return success; - } - - /** - * - * @param loan detail - * @return boolean - */ - public boolean saveLoanDetail(LoanDetails loan) { - logger.debug("saveLoanDetail"); - boolean success = genericEntityRepository.insertAPCEntity(loan); - - return success; - } - - /** - * - * @param loanByUser - * @return boolean - */ - public boolean saveLoanByUser(LoanByUser loanByUser) { - logger.debug("saveLoanByUser"); - boolean success = genericEntityRepository.insertAPCEntity(loanByUser); - - return success; - } - - /** - * - * @param status - * @param loanIdToUpdate - * @return - */ - public boolean updateLoanByUserByStatus(LoanStatus status, Loan loanIdToUpdate) { - logger.debug("updateLoanByUserByStatus"); - - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN_BY_USER_STATUS, status)); - parameters.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN, loanIdToUpdate)); - - return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanByUserCfg.QUERY_UPDATE_LOAN_BY_USER_BY_LOAND_ID, parameters); - } - - /** - * - * Searching the loan by renovation by id - * - * @param loanId - * @return - */ - public LoanByRenovation getLoanByRenovationByIdLoanNew(Loan loan) { - logger.debug("getLoanByRenovationByIdLoanNew"); - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LOAN_NEW, loan)); - - return (LoanByRenovation) genericEntityRepository.xmlQueryAPCEntityUniqueResult(LoanByRenovation.class, LoanByRenovationCfg.QUERY_FIND_LOAN_RENOVATION_BY_NEW_LOAN_ID, parameters); - } - - /** - * - * @param status - * @param loanIdToUpdate - * @param lastUpdatedBy - * @return - */ - public boolean updateLoanByRenovationByStatus(LoanRenovationStatus status, Loan loanIdToUpdate, String lastUpdatedBy) { - logger.debug("updateLoanByRenovationByStatus"); - - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LOAN_RENOVATION_STATUS, status)); - parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LOAN_NEW, loanIdToUpdate)); - parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_COMMENTS, "Se rechazó la renovación")); - parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LAST_UPDATED_BY, new User(lastUpdatedBy))); - parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LAST_UPDATED_ON, new Date())); - - return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanByRenovationCfg.QUERY_UPDATE_LOAN_RENOVATION_WEB, parameters); - } - - /** - * - * @param userId - * @param loanIdToUpdate - * @return - */ - public boolean updateLoandByUserByUserId(String userId, Loan loanIdToUpdate) { - logger.debug("updateLoandByUserByUserId"); - - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanByUserCfg.FIELD_USER, new User(userId))); - parameters.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN, loanIdToUpdate)); - - return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanByUserCfg.QUERY_UPDATE_LOAN_BY_USER_BU_USER_ID, parameters); - } - - /** - * - * Searching the loan by user by id - * - * @param loan - * @return - */ - public LoanByUser getLoanByUserByIdLoan(Loan loan) { - logger.debug("getLoanByUserByIdLoan"); - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN, loan)); - - return (LoanByUser) genericEntityRepository.xmlQueryAPCEntityUniqueResult(LoanByUser.class, LoanByUserCfg.QUERY_FIND_LOAN_BY_USER_BY_LOAND_ID, parameters); - } - - /** - * - * @param loanByUser - * @return boolean - */ - public boolean deleteLoanByUser(LoanByUser loanByUser) { - logger.debug("deleteLoanByUser"); - boolean success = genericEntityRepository.deleteAPCEntityById(loanByUser); - - return success; - } - - /** - * - * @param loanByUser - * @return boolean - */ - public boolean deleteLoanDetails(LoanDetails loanDetail) { - logger.debug("deleteLoanDetails"); - boolean success = genericEntityRepository.deleteAPCEntityById(loanDetail); - - return success; - } - - /** - * - * @param userId - * @param loanIdToUpdate - * @return - */ - public boolean deleteLoanDetailsByLoanCurdate(Loan loanIdToUpdate) { - logger.debug("updateLoandByUserByUserId"); - - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, loanIdToUpdate)); - - return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_DELETE_LOAN_DETAILS_CURDATE_BY_LOAN, parameters); - } - - /** - * - * @param route - * @param routeIdToUpdate - * @param lastUpdatedBy - * @return - */ - public boolean updateRouteById(RouteCtlg route, String routeIdToUpdate, String lastUpdatedBy) { - logger.debug("updateRouteById"); - - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanCfg.FIELD_ROUTE, route)); - parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, lastUpdatedBy)); - // parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, new Date())); - parameters.add(new ModelParameter(LoanCfg.FIELD_ID, routeIdToUpdate)); - - return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_UPDATE_ROUTE_BY_ID, parameters); - } - - public boolean updatePeopleRoute(RouteCtlg route, People people) { - people.setRouteCtlg(route); - return genericEntityRepository.updateAPCEntity(people); - } - - /** - * - * Searching all loan details by id. - * - * @param loanId - * @return - */ - public List getLoanDetailsFeeCurdatebyIdLoan(String loanId) { - logger.debug("getLoanDetailsFeeCurdatebyIdLoan"); - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanId))); - - return genericEntityRepository.xmlQueryAPCEntities(LoanDetails.class, LoanCfg.QUERY_FIND_LOAN_DETAILS_FEE_CURDATE_BY_LOAN, parameters); - } - - /** - * - * @param userId - * @param loanIdToUpdate - * @return - */ - public boolean deleteLoanDetailsFeeByLoanCurdate(Loan loanIdToUpdate) { - logger.debug("deleteLoanDetailsFeeByLoanCurdate"); - - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, loanIdToUpdate)); - - return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_DELETE_LOAN_DETAILS_FEE_CURDATE_BY_LOAN, parameters); - } - - /** - * - * @param userId - * @param loanIdToUpdate - * @return - */ - public boolean deleteLoanFeeNotificationByLoanCurdate(Loan loanIdToUpdate) { - logger.debug("deleteLoanFeeNotificationByLoanCurdate"); - - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, loanIdToUpdate)); - - return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_DELETE_LOAN_FEE_NOTIFICATION_CURDATE_BY_LOAN, parameters); - } - - /** - * Borra los registros de LoanFeeNotifications del préstamo que recibe - * - * @param loanIdToUpdate - * @return - */ - public boolean deleteLoanFeeNotificationByLoan(Loan loanIdToUpdate) { - logger.debug("deleteLoanFeeNotification"); - - List parameters = new ArrayList<>(); - parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, loanIdToUpdate)); - - return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_DELETE_LOAN_FEE_NOTIFICATION_BY_LOAN, parameters); - } - - /** - * - * @param status - * @param loanIdToUpdate - * @param lastUpdatedBy - * @return - */ - public boolean updateBonusNewCustomer(ActiveStatus status, String loanIdToUpdate, String lastUpdatedBy) { - logger.debug("updateBonusNewCustomer"); - - List parameters = new ArrayList<>(); - - parameters.add(new ModelParameter(LoanCfg.FIELD_NEW_CUSTOMER, status)); - parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, lastUpdatedBy)); - parameters.add(new ModelParameter(LoanCfg.FIELD_ID, loanIdToUpdate)); - - return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_UPDATE_LOAN_BONUS_NEW_CUSTOMER, parameters); - } - - final Logger logger = LogManager.getLogger(LoanController.class); - private final GenericEntityRepository genericEntityRepository; - - public LoanController() { - this.genericEntityRepository = new GenericEntityRepository(); - } + /** + * + * Searching all loan by status pending. + * + * @param officeId + * @return + */ + public List fillLoanByStatusPendingDatatable(String officeId) { + logger.debug("fillLoanByStatusPendingDatatable"); + List parameters = new ArrayList<>(); + + //parameters.add(new ModelParameter(LoanCfg.FIELD_CUSTOMER_OFFICE, new Office(officeId))); + return genericEntityRepository.xmlQueryAPCEntities(Loan.class, LoanCfg.QUERY_FIND_LOAN_BY_STATUS_PENDING, parameters); + } + + /** + * + * Searching all loan by status pending. + * + * @param officeId + * @return + */ + public List fillLoanByStatusApprovedDatatable(String officeId) { + logger.debug("fillLoanByStatusApprovedDatatable"); + List parameters = new ArrayList<>(); + parameters.add(new ModelParameter("id", officeId)); + return genericEntityRepository.xmlQueryAPCEntities(Loan.class, LoanCfg.QUERY_FIND_LOAN_BY_STATUS_APPROVED, parameters); + } + + /** + * + * Searching all loan + * + * @return + */ + public List fillAllLoansDatatable() { + logger.debug("fillAllLoansDatatable"); + List parameters = new ArrayList<>(); + return genericEntityRepository.xmlQueryAPCEntities(Loan.class, LoanCfg.QUERY_FIND_ALL_LOANS, parameters); + } + + /** + * + * Searching all loan + * + * @return + */ + public List fillAllLoansViewDatatable() { + logger.debug("fillAllLoansViewDatatable"); + List parameters = new ArrayList<>(); + return genericEntityRepository.xmlQueryAPCEntities(HistoryLoanView.class, LoanCfg.QUERY_FIND_ALL_LOANS_VIEW, parameters); + } + + /** + * + * @param startDate + * @param endDate + * @return + */ + public List fillAllLoansViewDatatable(Date startDate, Date endDate) { + logger.debug("fillAllLoansViewDatatable from start and end date"); + try { + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanCfg.PARAM_START_DATE, startDate)); + parameters.add(new ModelParameter(LoanCfg.PARAM_END_DATE, endDate)); + + return genericEntityRepository.xmlQueryAPCEntities(HistoryLoanView.class, LoanCfg.QUERY_FIND_ALL_LOANS_VIEW_BY_START_AND_END_DATE, parameters); + } catch (Exception e) { + logger.info("fillAllLoansViewDatatable from start and end date", e); + return new ArrayList<>(); + } + } + + /** + * + * @param startDate + * @param endDate + * @return + */ + public List fillAllLoansJuridicalViewDatatable(Date startDate, Date endDate) { + logger.debug("fillAllLoansJuridicalViewDatatable from start and end date"); + try { + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanCfg.PARAM_START_DATE, startDate)); + parameters.add(new ModelParameter(LoanCfg.PARAM_END_DATE, endDate)); + + return genericEntityRepository.xmlQueryAPCEntities(HistoryLoanView.class, LoanCfg.QUERY_FIND_ALL_LOANS_JURIDICAL_VIEW_BY_START_AND_END_DATE, parameters); + } catch (Exception e) { + logger.info("fillAllLoansJuridicalViewDatatable from start and end date", e); + return new ArrayList<>(); + } + } + + /** + * + * Searching loan by id. + * + * @param loanId + * @return + */ + public Loan getLoanById(String loanId) { + logger.debug("getLoanById"); + + return (Loan) genericEntityRepository.selectAPCEntityById(Loan.class, loanId); + } + + /** + * + * @param status + * @param loanIdToUpdate + * @param lastUpdatedBy + * @return + */ + public boolean updateLoanByStatus(LoanStatus status, String loanIdToUpdate, String lastUpdatedBy) { + logger.debug("updateLoanByStatus"); + + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, status)); + parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, new BigDecimal(0))); + parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, 0)); + parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, lastUpdatedBy)); + parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, new Date())); + parameters.add(new ModelParameter(LoanCfg.FIELD_ID, loanIdToUpdate)); + + return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_UPDATE_LOAN_FROM_RENOVATION, parameters); + } + + /** + * + * @param status + * @param loanIdToUpdate + * @param lastUpdatedBy + * @return + */ + public boolean updateLoanByStatusWeb(LoanStatus status, String loanIdToUpdate, String lastUpdatedBy) { + logger.debug("updateLoanByStatusWeb"); + + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, status)); + parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, lastUpdatedBy)); + parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, new Date())); + parameters.add(new ModelParameter(LoanCfg.FIELD_ID, loanIdToUpdate)); + + return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_UPDATE_LOAN_FROM_WEB, parameters); + } + + /** + * + * Searching all loan details by id. + * + * @param loanId + * @return + */ + public List getLoanDetailsbyId(String loanId) { + logger.debug("getLoanDetailsbyId"); + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanId))); + + return genericEntityRepository.xmlQueryAPCEntities(LoanDetails.class, LoanCfg.QUERY_FIND_LOAN_DETAILS_BY_ID, parameters); + } + + public LoanDetails getLoanDetailbyId(String loanDetailsId) { + logger.debug("getLoanDetailbyId"); + + return (LoanDetails) genericEntityRepository.selectAPCEntityById(LoanDetails.class, loanDetailsId); + } + + public boolean updateAuthorizeLoanDetailById(String loanDetailId) { + logger.debug("updateAuthorizeLoanDetailById"); + + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID, loanDetailId)); + + return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanDetailsCfg.UPDATE_AUTHORIZE_LOAN_DETAIL, parameters); + } + + public Long countLoanDetailsAuthorize(String user) { + logger.debug("countLoanDetailsAutorize"); + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_USER, user)); + return (Long) genericEntityRepository.xmlQueryAPCEntityUniqueResult(Long.class, LoanDetailsCfg.COUNT_LOAN_DETAILS_AUTHORIZE, parameters); + + } + + public boolean updateRejectLoanDetailById(String loanDetailId) { + logger.debug("updateAuthorizeLoanDetailById"); + + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID, loanDetailId)); + + return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanDetailsCfg.UPDATE_REJECT_LOAN_DETAIL, parameters); + } + + public List fillAllTransfersLoanDetails() { + logger.debug("findAllTransfersLoanDetail"); + + return genericEntityRepository.xmlQueryAPCEntities(LoanDetails.class, LoanDetailsCfg.QUERY_FIND_ALL_TRANSFERS_LOAN_DETAIL); + } + + /** + * + * Searching all loan details by id. + * + * @param loanId + * @return + */ + public List getLoanDetailsCurdatebyIdLoan(String loanId) { + logger.debug("getLoanDetailsCurdatebyIdLoan"); + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanId))); + + return genericEntityRepository.xmlQueryAPCEntities(LoanDetails.class, LoanCfg.QUERY_FIND_LOAN_DETAILS_CURDATE_BY_LOAN, parameters); + } + + /** + * + * @param loan + * @return boolean + */ + public boolean saveLoan(Loan loan) { + logger.debug("saveLoan"); + boolean success = genericEntityRepository.insertAPCEntity(loan); + + return success; + } + + /** + * + * @param loan + * @return boolean + */ + public boolean updateLoan(Loan loan) { + logger.debug("updateLoan"); + boolean success = genericEntityRepository.updateAPCEntity(loan); + + return success; + } + + /** + * + * @param loan + * @return boolean + */ + public boolean updateLoanByUser(LoanByUser loan) { + logger.debug("updateLoanByUser"); + boolean success = genericEntityRepository.updateAPCEntity(loan); + + return success; + } + + /** + * + * @param loan + * @return boolean + */ + public boolean saveLoanNotificationFee(LoanFeeNotification notification) { + logger.debug("saveLoanNotificationFee"); + boolean success = genericEntityRepository.insertAPCEntity(notification); + + return success; + } + + /** + * + * @param loan detail + * @return boolean + */ + public boolean saveLoanDetail(LoanDetails loan) { + logger.debug("saveLoanDetail"); + boolean success = genericEntityRepository.insertAPCEntity(loan); + + return success; + } + + /** + * + * @param loanByUser + * @return boolean + */ + public boolean saveLoanByUser(LoanByUser loanByUser) { + logger.debug("saveLoanByUser"); + boolean success = genericEntityRepository.insertAPCEntity(loanByUser); + + return success; + } + + /** + * + * @param status + * @param loanIdToUpdate + * @return + */ + public boolean updateLoanByUserByStatus(LoanStatus status, Loan loanIdToUpdate) { + logger.debug("updateLoanByUserByStatus"); + + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN_BY_USER_STATUS, status)); + parameters.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN, loanIdToUpdate)); + + return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanByUserCfg.QUERY_UPDATE_LOAN_BY_USER_BY_LOAND_ID, parameters); + } + + /** + * + * Searching the loan by renovation by id + * + * @param loanId + * @return + */ + public LoanByRenovation getLoanByRenovationByIdLoanNew(Loan loan) { + logger.debug("getLoanByRenovationByIdLoanNew"); + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LOAN_NEW, loan)); + + return (LoanByRenovation) genericEntityRepository.xmlQueryAPCEntityUniqueResult(LoanByRenovation.class, LoanByRenovationCfg.QUERY_FIND_LOAN_RENOVATION_BY_NEW_LOAN_ID, parameters); + } + + /** + * + * @param status + * @param loanIdToUpdate + * @param lastUpdatedBy + * @return + */ + public boolean updateLoanByRenovationByStatus(LoanRenovationStatus status, Loan loanIdToUpdate, String lastUpdatedBy) { + logger.debug("updateLoanByRenovationByStatus"); + + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LOAN_RENOVATION_STATUS, status)); + parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LOAN_NEW, loanIdToUpdate)); + parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_COMMENTS, "Se rechazó la renovación")); + parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LAST_UPDATED_BY, new User(lastUpdatedBy))); + parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LAST_UPDATED_ON, new Date())); + + return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanByRenovationCfg.QUERY_UPDATE_LOAN_RENOVATION_WEB, parameters); + } + + /** + * + * @param userId + * @param loanIdToUpdate + * @return + */ + public boolean updateLoandByUserByUserId(String userId, Loan loanIdToUpdate) { + logger.debug("updateLoandByUserByUserId"); + + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanByUserCfg.FIELD_USER, new User(userId))); + parameters.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN, loanIdToUpdate)); + + return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanByUserCfg.QUERY_UPDATE_LOAN_BY_USER_BU_USER_ID, parameters); + } + + /** + * + * Searching the loan by user by id + * + * @param loan + * @return + */ + public LoanByUser getLoanByUserByIdLoan(Loan loan) { + logger.debug("getLoanByUserByIdLoan"); + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN, loan)); + + return (LoanByUser) genericEntityRepository.xmlQueryAPCEntityUniqueResult(LoanByUser.class, LoanByUserCfg.QUERY_FIND_LOAN_BY_USER_BY_LOAND_ID, parameters); + } + + /** + * + * @param loanByUser + * @return boolean + */ + public boolean deleteLoanByUser(LoanByUser loanByUser) { + logger.debug("deleteLoanByUser"); + boolean success = genericEntityRepository.deleteAPCEntityById(loanByUser); + + return success; + } + + /** + * + * @param loanByUser + * @return boolean + */ + public boolean deleteLoanDetails(LoanDetails loanDetail) { + logger.debug("deleteLoanDetails"); + boolean success = genericEntityRepository.deleteAPCEntityById(loanDetail); + + return success; + } + + /** + * + * @param userId + * @param loanIdToUpdate + * @return + */ + public boolean deleteLoanDetailsByLoanCurdate(Loan loanIdToUpdate) { + logger.debug("updateLoandByUserByUserId"); + + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, loanIdToUpdate)); + + return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_DELETE_LOAN_DETAILS_CURDATE_BY_LOAN, parameters); + } + + /** + * + * @param route + * @param routeIdToUpdate + * @param lastUpdatedBy + * @return + */ + public boolean updateRouteById(RouteCtlg route, String routeIdToUpdate, String lastUpdatedBy) { + logger.debug("updateRouteById"); + + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanCfg.FIELD_ROUTE, route)); + parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, lastUpdatedBy)); + // parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, new Date())); + parameters.add(new ModelParameter(LoanCfg.FIELD_ID, routeIdToUpdate)); + + return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_UPDATE_ROUTE_BY_ID, parameters); + } + + public boolean updatePeopleRoute(RouteCtlg route, People people) { + people.setRouteCtlg(route); + return genericEntityRepository.updateAPCEntity(people); + } + + /** + * + * Searching all loan details by id. + * + * @param loanId + * @return + */ + public List getLoanDetailsFeeCurdatebyIdLoan(String loanId) { + logger.debug("getLoanDetailsFeeCurdatebyIdLoan"); + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanId))); + + return genericEntityRepository.xmlQueryAPCEntities(LoanDetails.class, LoanCfg.QUERY_FIND_LOAN_DETAILS_FEE_CURDATE_BY_LOAN, parameters); + } + + /** + * + * @param userId + * @param loanIdToUpdate + * @return + */ + public boolean deleteLoanDetailsFeeByLoanCurdate(Loan loanIdToUpdate) { + logger.debug("deleteLoanDetailsFeeByLoanCurdate"); + + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, loanIdToUpdate)); + + return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_DELETE_LOAN_DETAILS_FEE_CURDATE_BY_LOAN, parameters); + } + + /** + * + * @param userId + * @param loanIdToUpdate + * @return + */ + public boolean deleteLoanFeeNotificationByLoanCurdate(Loan loanIdToUpdate) { + logger.debug("deleteLoanFeeNotificationByLoanCurdate"); + + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, loanIdToUpdate)); + + return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_DELETE_LOAN_FEE_NOTIFICATION_CURDATE_BY_LOAN, parameters); + } + + /** + * Borra los registros de LoanFeeNotifications del préstamo que recibe + * + * @param loanIdToUpdate + * @return + */ + public boolean deleteLoanFeeNotificationByLoan(Loan loanIdToUpdate) { + logger.debug("deleteLoanFeeNotification"); + + List parameters = new ArrayList<>(); + parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, loanIdToUpdate)); + + return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_DELETE_LOAN_FEE_NOTIFICATION_BY_LOAN, parameters); + } + + /** + * + * @param status + * @param loanIdToUpdate + * @param lastUpdatedBy + * @return + */ + public boolean updateBonusNewCustomer(ActiveStatus status, String loanIdToUpdate, String lastUpdatedBy) { + logger.debug("updateBonusNewCustomer"); + + List parameters = new ArrayList<>(); + + parameters.add(new ModelParameter(LoanCfg.FIELD_NEW_CUSTOMER, status)); + parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, lastUpdatedBy)); + parameters.add(new ModelParameter(LoanCfg.FIELD_ID, loanIdToUpdate)); + + return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(LoanCfg.QUERY_UPDATE_LOAN_BONUS_NEW_CUSTOMER, parameters); + } + + final Logger logger = LogManager.getLogger(LoanController.class); + private final GenericEntityRepository genericEntityRepository; + + public LoanController() { + this.genericEntityRepository = new GenericEntityRepository(); + } } 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 301da47..287560e 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 @@ -42,6 +42,7 @@ public interface LoanCfg extends GenericCfg { String QUERY_SELECT_LOAN_ID_BY_CUSTOMER_IN_STATUSES = "selectLoanIdByCustomerInStatuses"; String QUERY_FIND_LOAN_BY_STATUS_PENDING = "findLoansByStatusPending"; + String QUERY_FIND_LOAN_BY_STATUS_APPROVED = "findLoansByStatusApproved"; 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"; 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 36ed49e..deb1245 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 @@ -86,6 +86,12 @@ public class LoanDetails implements Serializable { @Column(name = "folio", length = 150) private String folio; + @Column(name = "longitud", length = 150) + private String longitud; + + @Column(name = "latitud", length = 150) + private String latitud; + @Enumerated(EnumType.STRING) @Column(name = "fee_status") private FeeStatus feeStatus; @@ -209,8 +215,10 @@ public class LoanDetails implements Serializable { * @param createdOn * @param comments * @param folio + * @param longitud + * @param latitud */ - public LoanDetails(Loan loan, User user, PeopleType peopleType, BigDecimal paymentAmount, Integer referenceNumber, LoanDetailsType loanDetailsType, String createdBy, Date createdOn, String comments, String folio) { + public LoanDetails(Loan loan, User user, PeopleType peopleType, BigDecimal paymentAmount, Integer referenceNumber, LoanDetailsType loanDetailsType, String createdBy, Date createdOn, String comments, String folio, String longitud, String latitud) { this.loan = loan; this.user = user; this.peopleType = peopleType; @@ -221,6 +229,8 @@ public class LoanDetails implements Serializable { this.createdOn = createdOn; this.comments = comments; this.folio = folio; + this.longitud = longitud; + this.latitud = latitud; } /** @@ -265,8 +275,10 @@ public class LoanDetails implements Serializable { * @param transferNumber * @param transferStatus * @param folio + * @param longitud + * @param latitud */ - 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) { + 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, String longitud, String latitud) { this.loan = loan; this.user = user; this.peopleType = peopleType; @@ -279,6 +291,8 @@ public class LoanDetails implements Serializable { this.transferNumber = transferNumber; this.transferStatus = transferStatus; this.folio = folio; + this.longitud = longitud; + this.latitud = latitud; } public String getId() { @@ -405,6 +419,22 @@ public class LoanDetails implements Serializable { this.folio = folio; } + public String getLongitud() { + return longitud; + } + + public void setLongitud(String longitud) { + this.longitud = longitud; + } + + public String getLatitud() { + return latitud; + } + + public void setLatitud(String latitud) { + this.latitud = latitud; + } + @Override public String toString() { return "LoanDetails{" + "referenceNumber=" + referenceNumber + ", comments=" + comments + ", createdBy=" + createdBy + '}'; 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 d788cfb..9aac666 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 @@ -29,6 +29,8 @@ public class LoanDetailJaxb { private String numeroCuenta; private String fullNameCrobrador; private String folio; + private String longitud; + private String latitud; public LoanDetailJaxb() { } @@ -45,8 +47,11 @@ public class LoanDetailJaxb { * @param fullNameCliente * @param numeroCuenta * @param fullNameCrobrador + * @param folio + * @param longitud + * @param latitud */ - public LoanDetailJaxb(String paymentDate, double paymentOfDay, double toPay, String comment, String paymentType, String fullNameVendedor, String fullNameCliente, String numeroCuenta, String fullNameCrobrador, String folio) { + public LoanDetailJaxb(String paymentDate, double paymentOfDay, double toPay, String comment, String paymentType, String fullNameVendedor, String fullNameCliente, String numeroCuenta, String fullNameCrobrador, String folio, String longitud, String latitud) { this.paymentDate = paymentDate; this.paymentOfDay = paymentOfDay; this.toPay = toPay; @@ -57,6 +62,8 @@ public class LoanDetailJaxb { this.numeroCuenta = numeroCuenta; this.fullNameCrobrador = fullNameCrobrador; this.folio = folio; + this.longitud = longitud; + this.latitud = latitud; } /** @@ -191,6 +198,24 @@ public class LoanDetailJaxb { this.folio = folio; } + @XmlElement(name = "longitud") + public String getLongitud() { + return longitud; + } + + public void setLongitud(String longitud) { + this.longitud = longitud; + } + + @XmlElement(name = "latitud") + public String getLatitud() { + return latitud; + } + + public void setLatitud(String latitud) { + this.latitud = latitud; + } + @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/NewAmountJaxb.java b/apc-model/src/main/java/com/arrebol/apc/model/ws/parsed/NewAmountJaxb.java index 717e0ea..9e934a9 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 @@ -28,6 +28,8 @@ public class NewAmountJaxb { private String comments; private Boolean manager; private String folio; + private String longitud; + private String latitud; public NewAmountJaxb() { } @@ -125,4 +127,22 @@ public class NewAmountJaxb { this.folio = folio; } + @XmlAttribute(name = "longitud") + public String getLongitud() { + return longitud; + } + + public void setLongitud(String longitud) { + this.longitud = longitud; + } + + @XmlAttribute(name = "latitud") + public String getLatitud() { + return latitud; + } + + public void setLatitud(String latitud) { + this.latitud = latitud; + } + } 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 06792a0..582a106 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 @@ -26,6 +26,8 @@ public class NewTransferAccountJaxb { private String transferReference; private Boolean manager; private String folio; + private String longitud; + private String latitud; public NewTransferAccountJaxb() { } @@ -104,4 +106,23 @@ public class NewTransferAccountJaxb { public void setFolio(String folio) { this.folio = folio; } + + @XmlAttribute(name = "longitud") + public String getLongitud() { + return longitud; + } + + public void setLongitud(String longitud) { + this.longitud = longitud; + } + + @XmlAttribute(name = "latitud") + public String getLatitud() { + return latitud; + } + + public void setLatitud(String latitud) { + this.latitud = latitud; + } + } 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 27acf9f..3c22a45 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 @@ -32,19 +32,21 @@ lt.paymentTotal AS amountToPay, ld.comments AS comments, CONCAT(per.firstName, ' ', - IFNULL(CONCAT(per.secondName, ' '), ''), + CASE WHEN per.secondName IS NULL THEN '' ELSE CONCAT(per.secondName, ' ') END, per.lastName, ' ', per.middleName) AS fullNameVendedor, CONCAT(peo.firstName, ' ', - IFNULL(CONCAT(peo.secondName, ' '), ''), + CASE WHEN peo.secondName IS NULL THEN '' ELSE CONCAT(peo.secondName, ' ') END, peo.lastName, ' ', - IFNULL(peo.middleName, '')) AS fullNameCliente, - CONCAT(IFNULL(peo.contrato, ''), ' - ', IFNULL(rut.route, '')) AS numeroCuenta, + COALESCE(peo.middleName, '')) AS fullNameCliente, + CONCAT(COALESCE(peo.contrato, ''), ' - ', COALESCE(rut.route, '')) AS numeroCuenta, CONCAT(perv.firstName, ' ', - IFNULL(CONCAT(perv.secondName, ' '), ''), + CASE WHEN perv.secondName IS NULL THEN '' ELSE CONCAT(perv.secondName, ' ') END, perv.lastName, ' ', perv.middleName) AS fullNameCrobrador, - ld.folio AS folio + COALESCE(CAST(ld.folio AS string), '') AS folio, + COALESCE(CAST(ld.longitud AS string), '') AS longitud, + COALESCE(CAST(ld.latitud AS string), '') AS latitud FROM LoanDetails ld INNER JOIN Loan l ON ld.loan = l.id @@ -72,19 +74,21 @@ lt.paymentTotal AS amountToPay, ld.comments AS comments, CONCAT(per.firstName, ' ', - IFNULL(CONCAT(per.secondName, ' '), ''), + CASE WHEN per.secondName IS NULL THEN '' ELSE CONCAT(per.secondName, ' ') END, per.lastName, ' ', per.middleName) AS fullNameVendedor, CONCAT(peo.firstName, ' ', - IFNULL(CONCAT(peo.secondName, ' '), ''), + CASE WHEN peo.secondName IS NULL THEN '' ELSE CONCAT(peo.secondName, ' ') END, peo.lastName, ' ', - IFNULL(peo.middleName, '')) AS fullNameCliente, - CONCAT(IFNULL(peo.contrato, ''), ' - ', IFNULL(rut.route, '')) AS numeroCuenta, + COALESCE(peo.middleName, '')) AS fullNameCliente, + CONCAT(COALESCE(peo.contrato, ''), ' - ', COALESCE(rut.route, '')) AS numeroCuenta, CONCAT(perv.firstName, ' ', - IFNULL(CONCAT(perv.secondName, ' '), ''), + CASE WHEN perv.secondName IS NULL THEN '' ELSE CONCAT(perv.secondName, ' ') END, perv.lastName, ' ', perv.middleName) AS fullNameCrobrador, - ld.folio AS folio + COALESCE(CAST(ld.folio AS string), '') AS folio, + COALESCE(CAST(ld.longitud AS string), '') AS longitud, + COALESCE(CAST(ld.latitud AS string), '') AS latitud FROM LoanDetails ld INNER JOIN Loan l ON ld.loan = l.id diff --git a/apc-model/src/main/resources/com/arrebol/apc/model/queries/loan/loan.queries.hbm.xml b/apc-model/src/main/resources/com/arrebol/apc/model/queries/loan/loan.queries.hbm.xml index 0728347..326245c 100644 --- a/apc-model/src/main/resources/com/arrebol/apc/model/queries/loan/loan.queries.hbm.xml +++ b/apc-model/src/main/resources/com/arrebol/apc/model/queries/loan/loan.queries.hbm.xml @@ -148,6 +148,20 @@ ]]> + + + + ventas = getLoanCtrl().fillLoanByStatusApprovedDatatable(getLoggedUser().getOffice().getId()); + for (Loan u : ventas) { + if (u.getLatitud() != null && u.getLongitud() != null) { + try { + double lat = Double.parseDouble(u.getLatitud().trim()); + double lng = Double.parseDouble(u.getLongitud().trim()); + if (lat >= -90 && lat <= 90 && lng >= -180 && lng <= 180) { + LatLng coord = new LatLng(lat, lng); + Marker marker = new Marker(coord, u.getLoanType().getLoanTypeName()); + getMapaDeVentas().addOverlay(marker); + } + } catch (NumberFormatException e) { + System.err.println("Coordenadas inválidas para préstamo ID: " + u.getId()); + } + } + } + } catch (Exception e) { + System.err.println("cargarMapaDeVentas(): " + e); + showMessage(FacesMessage.SEVERITY_WARN, "Error", "Ocurrió un error al tratar de cargar el mapa"); + } + } + public String detailCustomer(String outcome) { return outcome; } @@ -1684,6 +1713,38 @@ public class DashboardBean extends GenericBean implements Serializable { this.peopleCtrl = peopleCtrl; } + public MapModel getMapaDeVentas() { + return mapaDeVentas; + } + + public void setMapaDeVentas(MapModel mapaDeVentas) { + this.mapaDeVentas = mapaDeVentas; + } + + public String getMapaUbicacionInicial() { + return mapaUbicacionInicial; + } + + public void setMapaUbicacionInicial(String mapaUbicacionInicial) { + this.mapaUbicacionInicial = mapaUbicacionInicial; + } + + public List getVentasActivasList() { + return ventasActivasList; + } + + public void setVentasActivasList(List ventasActivasList) { + this.ventasActivasList = ventasActivasList; + } + + public Loan getSelectedVenta() { + return selectedVenta; + } + + public void setSelectedVenta(Loan selectedVenta) { + this.selectedVenta = selectedVenta; + } + @Inject private CustomerWithoutRenovationViewService customerWithoutRenovationViewService; @@ -1740,6 +1801,7 @@ public class DashboardBean extends GenericBean implements Serializable { private List advancesDetail; private List loan; private List loanJuridical; + private List ventasActivasList; private List loanZero; private List loanFinished; private List loanEndorsement; @@ -1754,16 +1816,19 @@ public class DashboardBean extends GenericBean implements Serializable { private Loan selectedLoan; private Loan selectedLoanJuridical; + private Loan selectedVenta; private LoanDetailZeroView selectedLoanZero; private LoanFinishedView selectedLoanFinished; private Loan selectedLoanEndorsement; private GenericValidationController genericValidateController; private Date lastStableSmallBox; - private boolean stableSmallBoxToday; - + //private boolean stableSmallBoxToday; private String plantillaHTML; + private MapModel mapaDeVentas; + private String mapaUbicacionInicial; + @Inject private CustomerService customerService; @@ -1823,6 +1888,9 @@ public class DashboardBean extends GenericBean implements Serializable { getResumenLoans(); getLoansJuridical(); getLoansZero(); + setVentasActivasList(getLoanCtrl().fillLoanByStatusApprovedDatatable(getLoggedUser().getOffice().getId())); + setMapaUbicacionInicial("20.6590175,105.2110526"); + cargarMapaDeVentas(); } public boolean getAction() { diff --git a/apc-web/src/main/webapp/WEB-INF/web.xml b/apc-web/src/main/webapp/WEB-INF/web.xml index 199d61a..53e54c1 100644 --- a/apc-web/src/main/webapp/WEB-INF/web.xml +++ b/apc-web/src/main/webapp/WEB-INF/web.xml @@ -34,7 +34,7 @@ - + org.apache.webbeans.servlet.WebBeansConfigurationListener @@ -141,7 +141,7 @@ system.employee - + Views only available when logged has a USER CREATE grant /app/system/user/add/main.jsf @@ -150,7 +150,7 @@ system.user.create - + Views only available when logged has a USER SETTINGS grant /app/system/user/setting/main.jsf @@ -159,7 +159,7 @@ system.user.admin - + Views only available when logged has a USER ACCESS grant /app/system/user/access/main.jsf @@ -178,7 +178,7 @@ -