diff --git a/apc-controller-mobile/src/test/resources/apc.cfg.xml b/apc-controller-mobile/src/test/resources/apc.cfg.xml index 1ee5dd4..a6754f2 100644 --- a/apc-controller-mobile/src/test/resources/apc.cfg.xml +++ b/apc-controller-mobile/src/test/resources/apc.cfg.xml @@ -73,11 +73,13 @@ + + diff --git a/apc-controller/src/main/java/com/arrebol/apc/controller/admin/ClosingDayController.java b/apc-controller/src/main/java/com/arrebol/apc/controller/admin/ClosingDayController.java index 252da32..f54d8b6 100644 --- a/apc-controller/src/main/java/com/arrebol/apc/controller/admin/ClosingDayController.java +++ b/apc-controller/src/main/java/com/arrebol/apc/controller/admin/ClosingDayController.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; @@ -19,11 +19,14 @@ 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.views.ClosingDailyDetailFromUserByCurdateView; +import com.arrebol.apc.model.views.ClosingDailyDetailFromUserByLastClosingDayView; import com.arrebol.apc.model.views.LoanByUserPaymentZeroView; import com.arrebol.apc.model.views.TotalCashByCurdateDashboardView; import com.arrebol.apc.model.views.TotalCashByCurdateView; +import com.arrebol.apc.model.views.TotalCashByLastClosingDayView; import com.arrebol.apc.model.views.TotalClosingDayByCurdateView; import com.arrebol.apc.model.views.constance.ClosingDailyDetailFromUserByCurdateCfg; +import com.arrebol.apc.model.views.constance.ClosingDailyDetailFromUserByLastClosingDayCfg; import com.arrebol.apc.model.views.constance.LoanByUserPaymentZeroViewCfg; import com.arrebol.apc.model.views.constance.TotalLoansByOfficeViewCfg; import com.arrebol.apc.repository.GenericEntityRepository; @@ -42,398 +45,437 @@ import org.hibernate.Transaction; * * @author Oscar Armando Vargas Cardenas */ -public class ClosingDayController extends ConnectionManager implements Serializable { +public class ClosingDayController extends ConnectionManager implements Serializable { - /** - * - * Searching all closing day by office. - * - * @param officeId - * @param startDate - * @param endDate - * @return - */ - public List fillClosingDayDatatable(String officeId, Date startDate, Date endDate) { - logger.debug("fillClosingDayDatatable"); - List parameters = new ArrayList<>(); - - Calendar calendar = Calendar.getInstance(); - calendar.setTime(startDate); - calendar.add(Calendar.DAY_OF_YEAR, 1); - startDate = calendar.getTime(); + /** + * + * Searching all closing day by office. + * + * @param officeId + * @param startDate + * @param endDate + * @return + */ + public List fillClosingDayDatatable(String officeId, Date startDate, Date endDate) { + logger.debug("fillClosingDayDatatable"); + List parameters = new ArrayList<>(); - Calendar calendarF = Calendar.getInstance(); - calendarF.setTime(endDate); - calendarF.add(Calendar.DAY_OF_YEAR, 1); - endDate = calendarF.getTime(); - - parameters.add(new ModelParameter(ClosingDayCfg.FIELD_OFFICE, new Office(officeId))); - //parameters.add(new ModelParameter(ClosingDayCfg.FIELD_ACTIVE_STATUS, ActiveStatus.ENEBLED)); - parameters.add(new ModelParameter(ClosingDayCfg.PARAM_START_DATE, startDate)); - parameters.add(new ModelParameter(ClosingDayCfg.PARAM_END_DATE, endDate)); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(startDate); + calendar.add(Calendar.DAY_OF_YEAR, 1); + startDate = calendar.getTime(); - return genericEntityRepository.xmlQueryAPCEntities(ClosingDay.class, ClosingDayCfg.QUERY_FIND_ALL_CLOSING_DAY_BY_OFFICE_BETWEEN_DATES, parameters); - } + Calendar calendarF = Calendar.getInstance(); + calendarF.setTime(endDate); + calendarF.add(Calendar.DAY_OF_YEAR, 1); + endDate = calendarF.getTime(); - /** - * - * @param status - * @param closingDayIdToUpdate - * @param lastUpdatedBy - * @return - */ - public boolean updateClosingDayByStatus(ActiveStatus status, String closingDayIdToUpdate, String lastUpdatedBy) { - logger.debug("updateClosingDayByStatus"); + parameters.add(new ModelParameter(ClosingDayCfg.FIELD_OFFICE, new Office(officeId))); + //parameters.add(new ModelParameter(ClosingDayCfg.FIELD_ACTIVE_STATUS, ActiveStatus.ENEBLED)); + parameters.add(new ModelParameter(ClosingDayCfg.PARAM_START_DATE, startDate)); + parameters.add(new ModelParameter(ClosingDayCfg.PARAM_END_DATE, endDate)); - List parameters = new ArrayList<>(); + return genericEntityRepository.xmlQueryAPCEntities(ClosingDay.class, ClosingDayCfg.QUERY_FIND_ALL_CLOSING_DAY_BY_OFFICE_BETWEEN_DATES, parameters); + } - parameters.add(new ModelParameter(ClosingDayCfg.FIELD_ACTIVE_STATUS, status)); - parameters.add(new ModelParameter(ClosingDayCfg.FIELD_LAST_UPDATED_BY, lastUpdatedBy)); - parameters.add(new ModelParameter(ClosingDayCfg.FIELD_LAST_UPDATED_ON, new Date())); - parameters.add(new ModelParameter(ClosingDayCfg.FIELD_ID, closingDayIdToUpdate)); + /** + * + * @param status + * @param closingDayIdToUpdate + * @param lastUpdatedBy + * @return + */ + public boolean updateClosingDayByStatus(ActiveStatus status, String closingDayIdToUpdate, String lastUpdatedBy) { + logger.debug("updateClosingDayByStatus"); - return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(ClosingDayCfg.QUERY_UPDATE_CLOSING_DAY_BY_STATUS, parameters); - } + List parameters = new ArrayList<>(); - /** - * - * @param closingDay - * @return boolean - */ - public boolean saveClosingDay(ClosingDay closingDay) { - logger.debug("saveClosingDay"); - boolean success = genericEntityRepository.insertAPCEntity(closingDay); + parameters.add(new ModelParameter(ClosingDayCfg.FIELD_ACTIVE_STATUS, status)); + parameters.add(new ModelParameter(ClosingDayCfg.FIELD_LAST_UPDATED_BY, lastUpdatedBy)); + parameters.add(new ModelParameter(ClosingDayCfg.FIELD_LAST_UPDATED_ON, new Date())); + parameters.add(new ModelParameter(ClosingDayCfg.FIELD_ID, closingDayIdToUpdate)); - return success; - } + return genericEntityRepository.xmlUpdateOrDeleteAPCEntity(ClosingDayCfg.QUERY_UPDATE_CLOSING_DAY_BY_STATUS, parameters); + } - /** - * - * Searching TotalCashByCurdateView by id. - * - * @param id - * @return - */ - public TotalCashByCurdateView getTotalCashByCurdateViewById(String id) { - logger.debug("getTotalCashByCurdateViewById"); + /** + * + * @param closingDay + * @return boolean + */ + public boolean saveClosingDay(ClosingDay closingDay) { + logger.debug("saveClosingDay"); + boolean success = genericEntityRepository.insertAPCEntity(closingDay); - return (TotalCashByCurdateView) genericEntityRepository.selectAPCEntityById(TotalCashByCurdateView.class, id); - } + return success; + } - /** - * - * Searching all total money day by office. - * - * @param officeId - * @return - */ - public List getAllTotalCashByCurdateView(String officeId) { - logger.debug("getAllTotalCashByCurdateView"); - List parameters = new ArrayList<>(); + /** + * + * Searching TotalCashByCurdateView by id. + * + * @param id + * @return + */ + public TotalCashByCurdateView getTotalCashByCurdateViewById(String id) { + logger.debug("getTotalCashByCurdateViewById"); - parameters.add(new ModelParameter(ClosingDayCfg.FIELD_VIEW_OFFICE, officeId)); + return (TotalCashByCurdateView) genericEntityRepository.selectAPCEntityById(TotalCashByCurdateView.class, id); + } - return genericEntityRepository.xmlQueryAPCEntities(TotalCashByCurdateView.class, ClosingDayCfg.QUERY_FIND_TOTAL_BY_OFFICE, parameters); - } + /** + * + * Searching TotalCashByLastClosingDayView by id. + * + * @param id + * @return + */ + public TotalCashByLastClosingDayView getTotalCashByLastClosingDayViewById(String id) { + logger.debug("getTotalCashByLastClosingDayViewById"); + return (TotalCashByLastClosingDayView) genericEntityRepository.selectAPCEntityById(TotalCashByLastClosingDayView.class, id); + } - public List getAllTotalCashByCurdateDashboardView(String officeId) { - logger.debug("getAllTotalCashByCurdateDashboardView"); - List parameters = new ArrayList<>(); + /** + * + * Searching all total money day by office. + * + * @param officeId + * @return + */ + public List getAllTotalCashByCurdateView(String officeId) { + logger.debug("getAllTotalCashByCurdateView"); + List parameters = new ArrayList<>(); - parameters.add(new ModelParameter(ClosingDayCfg.FIELD_VIEW_OFFICE, officeId)); + parameters.add(new ModelParameter(ClosingDayCfg.FIELD_VIEW_OFFICE, officeId)); - return genericEntityRepository.xmlQueryAPCEntities(TotalCashByCurdateDashboardView.class, ClosingDayCfg.QUERY_FIND_TOTAL_DASHBOARD_BY_OFFICE, parameters); - } + return genericEntityRepository.xmlQueryAPCEntities(TotalCashByCurdateView.class, ClosingDayCfg.QUERY_FIND_TOTAL_BY_OFFICE, parameters); + } - /** - * - * Searching all TotalClosingDayByCurdateView by curdate. - * - * @param officeId - * @return - */ - public List findAllClosingDayByCurdate(String officeId) { - logger.debug("findAllClosingDayByCurdate"); - List parameters = new ArrayList<>(); + public List getAllTotalCashByCurdateDashboardView(String officeId) { + logger.debug("getAllTotalCashByCurdateDashboardView"); + List parameters = new ArrayList<>(); - parameters.add(new ModelParameter(ClosingDayCfg.FIELD_VIEW_OFFICE, officeId)); + parameters.add(new ModelParameter(ClosingDayCfg.FIELD_VIEW_OFFICE, officeId)); - return genericEntityRepository.xmlQueryAPCEntities(TotalClosingDayByCurdateView.class, ClosingDayCfg.QUERY_FIND_ALL_CLOSING_DAY_BY_CURDATE, parameters); - } + return genericEntityRepository.xmlQueryAPCEntities(TotalCashByCurdateDashboardView.class, ClosingDayCfg.QUERY_FIND_TOTAL_DASHBOARD_BY_OFFICE, parameters); + } - /** - * - * Searching all ClosingDailyDetailFromUserByCurdateView by curdate. - * - * @param userId - * @return - */ - public List findAllClosingDailyDetailFromUserByCurdateView(String userId) { - logger.debug("findAllClosingDailyDetailFromUserByCurdateView"); - List parameters = new ArrayList<>(); + /** + * + * Searching all TotalClosingDayByCurdateView by curdate. + * + * @param officeId + * @return + */ + public List findAllClosingDayByCurdate(String officeId) { + logger.debug("findAllClosingDayByCurdate"); + List parameters = new ArrayList<>(); - parameters.add(new ModelParameter(ClosingDailyDetailFromUserByCurdateCfg.FIELD_VIEW_USER, userId)); + parameters.add(new ModelParameter(ClosingDayCfg.FIELD_VIEW_OFFICE, officeId)); - return genericEntityRepository.xmlQueryAPCEntities(ClosingDailyDetailFromUserByCurdateView.class, ClosingDailyDetailFromUserByCurdateCfg.QUERY_FIND_ALL_DETAILS, parameters); - } + return genericEntityRepository.xmlQueryAPCEntities(TotalClosingDayByCurdateView.class, ClosingDayCfg.QUERY_FIND_ALL_CLOSING_DAY_BY_CURDATE, parameters); + } - /** - * - * Searching all ClosingDailyDetailFromUserByCurdateView by curdate. - * - * @param userId - * @return - */ - public List findAllClosingDailyDetailFromUserCertifierByCurdateView(String userId) { - logger.debug("findAllClosingDailyDetailFromUserCertifierByCurdateView"); - List parameters = new ArrayList<>(); + /** + * + * Searching all ClosingDailyDetailFromUserByCurdateView by curdate. + * + * @param userId + * @return + */ + public List findAllClosingDailyDetailFromUserByCurdateView(String userId) { + logger.debug("findAllClosingDailyDetailFromUserByCurdateView"); + List parameters = new ArrayList<>(); - parameters.add(new ModelParameter(ClosingDailyDetailFromUserByCurdateCfg.FIELD_VIEW_USER, userId)); + parameters.add(new ModelParameter(ClosingDailyDetailFromUserByCurdateCfg.FIELD_VIEW_USER, userId)); - return genericEntityRepository.xmlQueryAPCEntities(ClosingDailyDetailFromUserByCurdateView.class, ClosingDailyDetailFromUserByCurdateCfg.QUERY_FIND_ALL_DETAILS_CERTIFIER, parameters); - } + return genericEntityRepository.xmlQueryAPCEntities(ClosingDailyDetailFromUserByCurdateView.class, ClosingDailyDetailFromUserByCurdateCfg.QUERY_FIND_ALL_DETAILS, parameters); + } - /** - * - * Searching the num by closing day - * - * @param num for closing day - * @return - */ - public Long getClosingDayCurdateByUserId(String userId, String officeid) { - logger.debug("getClosingDayCurdateByUserId"); - List parameters = new ArrayList<>(); + /** + * + * Searching all ClosingDailyDetailFromUserByLastClosingDayView by curdate. + * + * @param userId + * @return + */ + public List findAllClosingDailyDetailFromUserByLastClosingDayView(String userId) { + logger.debug("findAllClosingDailyDetailFromUserByLastClosingDayView"); + List parameters = new ArrayList<>(); + parameters.add(new ModelParameter(ClosingDailyDetailFromUserByLastClosingDayCfg.FIELD_VIEW_USER, userId)); + return genericEntityRepository.xmlQueryAPCEntities(ClosingDailyDetailFromUserByLastClosingDayView.class, ClosingDailyDetailFromUserByLastClosingDayCfg.QUERY_FIND_ALL_DETAILS, parameters); + } - parameters.add(new ModelParameter(ClosingDayCfg.FIELD_USER, new User(userId))); - parameters.add(new ModelParameter(ClosingDayCfg.FIELD_OFFICE, new Office(officeid))); + /** + * + * Searching all ClosingDailyDetailFromUserByCurdateView by curdate. + * + * @param userId + * @return + */ + public List findAllClosingDailyDetailFromUserCertifierByCurdateView(String userId) { + logger.debug("findAllClosingDailyDetailFromUserCertifierByCurdateView"); + List parameters = new ArrayList<>(); - return (Long) genericEntityRepository.xmlQueryAPCEntityUniqueResult(Long.class, ClosingDayCfg.QUERY_COUNT_CLOSING_DATE_BY_USER_AND_OFFICE, parameters); - } + parameters.add(new ModelParameter(ClosingDailyDetailFromUserByCurdateCfg.FIELD_VIEW_USER, userId)); - public Long getLoansCountDailyByUser(String userId) { - logger.debug("getLoansCountDailyByUser"); - List parameters = new ArrayList<>(); + return genericEntityRepository.xmlQueryAPCEntities(ClosingDailyDetailFromUserByCurdateView.class, ClosingDailyDetailFromUserByCurdateCfg.QUERY_FIND_ALL_DETAILS_CERTIFIER, parameters); + } - parameters.add(new ModelParameter(TotalLoansByOfficeViewCfg.FIELD_VIEW_USER, userId)); + /** + * + * Searching all ClosingDailyDetailFromUserByLastClosingDayView by curdate. + * + * @param userId + * @return + */ + public List findAllClosingDailyDetailFromUserCertifierByLastClosingDayView(String userId) { + logger.debug("findAllClosingDailyDetailFromUserCertifierByLastClosingDayView"); + List parameters = new ArrayList<>(); + parameters.add(new ModelParameter(ClosingDailyDetailFromUserByLastClosingDayCfg.FIELD_VIEW_USER, userId)); + return genericEntityRepository.xmlQueryAPCEntities(ClosingDailyDetailFromUserByLastClosingDayView.class, ClosingDailyDetailFromUserByLastClosingDayCfg.QUERY_FIND_ALL_DETAILS_CERTIFIER, parameters); + } - return (Long) genericEntityRepository.xmlQueryAPCEntityUniqueResult(Long.class, TotalLoansByOfficeViewCfg.QUERY_COUNT_ALL_LOANS_BY_USER, parameters); - } + /** + * + * Searching the num by closing day + * + * @param num for closing day + * @return + */ + public Long getClosingDayCurdateByUserId(String userId, String officeid) { + logger.debug("getClosingDayCurdateByUserId"); + List parameters = new ArrayList<>(); - public List getLoansPaymentZeroByUser(String userId) { - logger.debug("getLoansPaymentZeroByUser"); - List parameters = new ArrayList<>(); + parameters.add(new ModelParameter(ClosingDayCfg.FIELD_USER, new User(userId))); + parameters.add(new ModelParameter(ClosingDayCfg.FIELD_OFFICE, new Office(officeid))); - parameters.add(new ModelParameter(LoanByUserPaymentZeroViewCfg.FIELD_VIEW_USER, new User(userId))); + return (Long) genericEntityRepository.xmlQueryAPCEntityUniqueResult(Long.class, ClosingDayCfg.QUERY_COUNT_CLOSING_DATE_BY_USER_AND_OFFICE, parameters); + } - return genericEntityRepository.xmlQueryAPCEntities(LoanByUserPaymentZeroView.class, LoanByUserPaymentZeroViewCfg.QUERY_FIND_ALL_LOANS_PAYMENT_ZERO_BY_USER, parameters); - } + public Long getLoansCountDailyByUser(String userId) { + logger.debug("getLoansCountDailyByUser"); + List parameters = new ArrayList<>(); - /** - * - * @param details - * @return boolean - */ - public boolean saveClosingDayDetail(List details) { - logger.debug("saveClosingDayDetail"); - boolean success = genericEntityRepository.insertManyAPCEntity(details); + parameters.add(new ModelParameter(TotalLoansByOfficeViewCfg.FIELD_VIEW_USER, userId)); - return success; - } + return (Long) genericEntityRepository.xmlQueryAPCEntityUniqueResult(Long.class, TotalLoansByOfficeViewCfg.QUERY_COUNT_ALL_LOANS_BY_USER, parameters); + } - /** - * - * Searching closing day by id. - * - * @param closingDayId - * @return - */ - public ClosingDay getClosingDayById(String closingDayId) { - logger.debug("getClosingDayById"); + public List getLoansPaymentZeroByUser(String userId) { + logger.debug("getLoansPaymentZeroByUser"); + List parameters = new ArrayList<>(); - return (ClosingDay) genericEntityRepository.selectAPCEntityById(ClosingDay.class, closingDayId); - } + parameters.add(new ModelParameter(LoanByUserPaymentZeroViewCfg.FIELD_VIEW_USER, new User(userId))); - public List getClosingDayDetailByIdClosingDay(String closingDay) { - logger.debug("getClosingDayDetailByIdClosingDay"); - List parameters = new ArrayList<>(); + return genericEntityRepository.xmlQueryAPCEntities(LoanByUserPaymentZeroView.class, LoanByUserPaymentZeroViewCfg.QUERY_FIND_ALL_LOANS_PAYMENT_ZERO_BY_USER, parameters); + } - parameters.add(new ModelParameter(ClosingDayDetailCfg.FIELD_CLOSING_DAY, new ClosingDay(closingDay))); + /** + * + * @param details + * @return boolean + */ + public boolean saveClosingDayDetail(List details) { + logger.debug("saveClosingDayDetail"); + boolean success = genericEntityRepository.insertManyAPCEntity(details); - return genericEntityRepository.xmlQueryAPCEntities(ClosingDayDetail.class, ClosingDayDetailCfg.QUERY_FIND_ALL_CLOSING_DAY_DETAIL_BY_ID, parameters); - } + return success; + } - public User getUserById(String userId) { - logger.debug("getUserById"); + /** + * + * Searching closing day by id. + * + * @param closingDayId + * @return + */ + public ClosingDay getClosingDayById(String closingDayId) { + logger.debug("getClosingDayById"); - return (User) genericEntityRepository.selectAPCEntityById(User.class, userId); - } + return (ClosingDay) genericEntityRepository.selectAPCEntityById(ClosingDay.class, closingDayId); + } - /** - * - * @param date - * @return - */ - public boolean existNextPaidClosingDayByCreatedOn(Date date) { - logger.info("existNextPaidClosingDayByCreatedOn"); + public List getClosingDayDetailByIdClosingDay(String closingDay) { + logger.debug("getClosingDayDetailByIdClosingDay"); + List parameters = new ArrayList<>(); - String query = "SELECT cd.id " - + "FROM APC_CLOSING_DAY cd " - + "WHERE DATE(cd.created_on) >= DATE_ADD(DATE(:date), INTERVAL 1 DAY) " - + "AND cd.active_status = 'ENEBLED'"; + parameters.add(new ModelParameter(ClosingDayDetailCfg.FIELD_CLOSING_DAY, new ClosingDay(closingDay))); - return genericEntityRepository.existRecordsUsingSQLQueryFindByCreatedOnField(date, query); - } + return genericEntityRepository.xmlQueryAPCEntities(ClosingDayDetail.class, ClosingDayDetailCfg.QUERY_FIND_ALL_CLOSING_DAY_DETAIL_BY_ID, parameters); + } - /** - * - * @param date - * @return - */ - public boolean existStableSmallBoxByCreatedOn(Date date) { - logger.info("existStableSmallBoxByCreatedOn"); + public User getUserById(String userId) { + logger.debug("getUserById"); - String query = "SELECT ssb.id " - + "FROM APC_STABLE_SMALL_BOX ssb " - + "WHERE DATE(ssb.created_on) = DATE(:date) " - + "AND ssb.active_status = 'ENEBLED'"; + return (User) genericEntityRepository.selectAPCEntityById(User.class, userId); + } - return genericEntityRepository.existRecordsUsingSQLQueryFindByCreatedOnField(date, query); - } + /** + * + * @param date + * @return + */ + public boolean existNextPaidClosingDayByCreatedOn(Date date) { + logger.info("existNextPaidClosingDayByCreatedOn"); - /** - * - * @param userId - * @return - */ - public List findDetailsFromClosingDayCurDate(String userId){ - logger.debug("findDetailsFromClosingDayCurDate"); + String query = "SELECT cd.id " + + "FROM APC_CLOSING_DAY cd " + + "WHERE DATE(cd.created_on) >= DATE_ADD(DATE(:date), INTERVAL 1 DAY) " + + "AND cd.active_status = 'ENEBLED'"; - List rows = new ArrayList<>(); - Transaction transaction = null; + return genericEntityRepository.existRecordsUsingSQLQueryFindByCreatedOnField(date, query); + } - try { - Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - transaction = session.beginTransaction(); + /** + * + * @param date + * @return + */ + public boolean existStableSmallBoxByCreatedOn(Date date) { + logger.info("existStableSmallBoxByCreatedOn"); - rows = session.createNativeQuery(queryClosingDayReport).setParameter("userId", userId).getResultList(); + String query = "SELECT ssb.id " + + "FROM APC_STABLE_SMALL_BOX ssb " + + "WHERE DATE(ssb.created_on) = DATE(:date) " + + "AND ssb.active_status = 'ENEBLED'"; - transaction.commit(); - - } catch (HibernateException e) { - logger.error("Driver", e); - rollback(transaction); - } catch (Exception e) { - logger.error("Method findDetailsFromClosingDayCurDate(" + userId + " " + ") ", e); - rollback(transaction); - } - - return rows; - } - - public List findDetailsFromClosingDayHisotry(String idClosingDay){ - logger.debug("findDetailsFromClosingDayCurDate"); + return genericEntityRepository.existRecordsUsingSQLQueryFindByCreatedOnField(date, query); + } - List rows = new ArrayList<>(); - Transaction transaction = null; + /** + * + * @param userId + * @return + */ + public List findDetailsFromClosingDayCurDate(String userId) { + logger.debug("findDetailsFromClosingDayCurDate"); - try { - Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - transaction = session.beginTransaction(); + List rows = new ArrayList<>(); + Transaction transaction = null; - rows = session.createNativeQuery(queryClosingDayReportHistory).setParameter("idClosingDay", idClosingDay).getResultList(); + try { + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + transaction = session.beginTransaction(); - transaction.commit(); - - } catch (HibernateException e) { - logger.error("Driver", e); - rollback(transaction); - } catch (Exception e) { - logger.error("Method findDetailsFromClosingDayHistory(" + idClosingDay + " " + ") ", e); - rollback(transaction); - } - - return rows; - } - - /** - * - * Searching people. - * - * @param peopleId - * @return - */ - public People findPeopleById(String peopleId) { - logger.debug("findPeopleById"); + rows = session.createNativeQuery(queryClosingDayReport).setParameter("userId", userId).getResultList(); - return (People) genericEntityRepository.selectAPCEntityById(User.class, peopleId); - } - - final Logger logger = LogManager.getLogger(ClosingDayController.class); - private final GenericEntityRepository genericEntityRepository; + transaction.commit(); - public ClosingDayController() { - this.genericEntityRepository = new GenericEntityRepository(); - } - - private final String queryClosingDayReport = - "SELECT " + - "cldd.comments, " + - "cldd.amount, " + - "cldd.type, " + - "cldd.saldo, " + - "cldd.created_on, " + - "cldd.comisionApertura, " + - "cldd.prestamoAnterior, " + - "cldd.route, " + - "CONCAT(hr.first_name,' ',IF(ISNULL(hr.second_name) ,'', CONCAT(hr.second_name, ' ')),hr.last_name,' ', hr.middle_name) AS username, " + - "(SELECT sum(tc.total_amount_payment) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as total_amount_payment, " + - "(SELECT sum(tc.total_amount_deposit) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as total_amount_deposit, " + - "(SELECT sum(tc.transfer_sender) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as transfer_sender, " + - "(SELECT sum(tc.transfer_receiver) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as transfer_receiver, " + - "(SELECT sum(tc.money_daily) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as money_daily, " + - "(SELECT sum(tc.other_expense) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as other_expense, " + - "(SELECT sum(tc.delivery) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as delivery, " + - "(SELECT sum(tc.transfer_pending) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as transfer_pending " + - "FROM " + - " APC_CLOSING_DAILY_DETAIL_FROM_USER_BY_CURDATE_VIEW_REPORT cldd " + - "INNER JOIN " + - " APC_USER u ON u.id = cldd.id_user " + - "INNER JOIN " + - " APC_HUMAN_RESOURCE hr ON hr.id = u.id_human_resource " + - "WHERE " + - " cldd.id_user = :userId " + - "ORDER BY " + - " cldd.created_on ASC"; - - - private final String queryClosingDayReportHistory = -" SELECT " + -" cldd.comments, " + -" cldd.amount, " + -" cldd.type, " + -" cldd.created_on, " + -" cd.amount_expected, " + -" cd.amount_paid, " + -" CONCAT(hr.first_name,' ',IF(ISNULL(hr.second_name) ,'', CONCAT(hr.second_name, ' ')),hr.last_name,' ', hr.middle_name) AS username, " + -" (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Abono' AND cld.id_closing_day = :idClosingDay) as total_amount_payment, " + -" (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Depósito' AND cld.id_closing_day = :idClosingDay) as total_amount_deposit, " + -" (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Transferencia enviada' AND cld.id_closing_day = :idClosingDay) as transfer_sender, " + -" (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Transferencia recibida' AND cld.id_closing_day = :idClosingDay) as transfer_receiver, " + -" (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Inicio' AND cld.id_closing_day = :idClosingDay) as money_daily, " + -" (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Gasto' AND cld.id_closing_day = :idClosingDay) as other_expense, " + -" (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Entrega de préstamo' AND cld.id_closing_day = :idClosingDay) as delivery, " + -" (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Multa' AND cld.id_closing_day = :idClosingDay) as total_amount_fee, " + -" cldd.dateDetail "+ -" FROM " + -" APC_CLOSING_DAY_DETAIL cldd " + -" INNER JOIN " + -" APC_CLOSING_DAY cd on cldd.id_closing_day = cd.id" + -" INNER JOIN" + -" APC_USER u ON u.id = cd.id_user " + -" INNER JOIN " + -" APC_HUMAN_RESOURCE hr ON hr.id = u.id_human_resource " + -" WHERE " + -" cldd.id_closing_day = :idClosingDay" + -" ORDER BY" + -" cldd.created_on ASC; "; + } catch (HibernateException e) { + logger.error("Driver", e); + rollback(transaction); + } catch (Exception e) { + logger.error("Method findDetailsFromClosingDayCurDate(" + userId + " " + ") ", e); + rollback(transaction); + } + + return rows; + } + + public List findDetailsFromClosingDayHisotry(String idClosingDay) { + logger.debug("findDetailsFromClosingDayCurDate"); + + List rows = new ArrayList<>(); + Transaction transaction = null; + + try { + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + transaction = session.beginTransaction(); + + rows = session.createNativeQuery(queryClosingDayReportHistory).setParameter("idClosingDay", idClosingDay).getResultList(); + + transaction.commit(); + + } catch (HibernateException e) { + logger.error("Driver", e); + rollback(transaction); + } catch (Exception e) { + logger.error("Method findDetailsFromClosingDayHistory(" + idClosingDay + " " + ") ", e); + rollback(transaction); + } + + return rows; + } + + /** + * + * Searching people. + * + * @param peopleId + * @return + */ + public People findPeopleById(String peopleId) { + logger.debug("findPeopleById"); + + return (People) genericEntityRepository.selectAPCEntityById(User.class, peopleId); + } + + final Logger logger = LogManager.getLogger(ClosingDayController.class); + private final GenericEntityRepository genericEntityRepository; + + public ClosingDayController() { + this.genericEntityRepository = new GenericEntityRepository(); + } + + private final String queryClosingDayReport + = "SELECT " + + "cldd.comments, " + + "cldd.amount, " + + "cldd.type, " + + "cldd.saldo, " + + "cldd.created_on, " + + "cldd.comisionApertura, " + + "cldd.prestamoAnterior, " + + "cldd.route, " + + "CONCAT(hr.first_name,' ',IF(ISNULL(hr.second_name) ,'', CONCAT(hr.second_name, ' ')),hr.last_name,' ', hr.middle_name) AS username, " + + "(SELECT sum(tc.total_amount_payment) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as total_amount_payment, " + + "(SELECT sum(tc.total_amount_deposit) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as total_amount_deposit, " + + "(SELECT sum(tc.transfer_sender) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as transfer_sender, " + + "(SELECT sum(tc.transfer_receiver) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as transfer_receiver, " + + "(SELECT sum(tc.money_daily) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as money_daily, " + + "(SELECT sum(tc.other_expense) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as other_expense, " + + "(SELECT sum(tc.delivery) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as delivery, " + + "(SELECT sum(tc.transfer_pending) FROM APC_TOTAL_CASH_BY_CURDATE_VIEW tc where id = :userId) as transfer_pending " + + "FROM " + + " APC_CLOSING_DAILY_DETAIL_FROM_USER_BY_LAST_CLOSING_VIEW_REPORT cldd " + + "INNER JOIN " + + " APC_USER u ON u.id = cldd.id_user " + + "INNER JOIN " + + " APC_HUMAN_RESOURCE hr ON hr.id = u.id_human_resource " + + "WHERE " + + " cldd.id_user = :userId " + + "ORDER BY " + + " cldd.created_on ASC"; + + private final String queryClosingDayReportHistory + = " SELECT " + + " cldd.comments, " + + " cldd.amount, " + + " cldd.type, " + + " cldd.created_on, " + + " cd.amount_expected, " + + " cd.amount_paid, " + + " CONCAT(hr.first_name,' ',IF(ISNULL(hr.second_name) ,'', CONCAT(hr.second_name, ' ')),hr.last_name,' ', hr.middle_name) AS username, " + + " (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Abono' AND cld.id_closing_day = :idClosingDay) as total_amount_payment, " + + " (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Depósito' AND cld.id_closing_day = :idClosingDay) as total_amount_deposit, " + + " (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Transferencia enviada' AND cld.id_closing_day = :idClosingDay) as transfer_sender, " + + " (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Transferencia recibida' AND cld.id_closing_day = :idClosingDay) as transfer_receiver, " + + " (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Inicio' AND cld.id_closing_day = :idClosingDay) as money_daily, " + + " (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Gasto' AND cld.id_closing_day = :idClosingDay) as other_expense, " + + " (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Entrega de préstamo' AND cld.id_closing_day = :idClosingDay) as delivery, " + + " (SELECT IFNULL(SUM(cld.amount),0) FROM APC_CLOSING_DAY_DETAIL cld WHERE cld.type='Multa' AND cld.id_closing_day = :idClosingDay) as total_amount_fee, " + + " cldd.dateDetail " + + " FROM " + + " APC_CLOSING_DAY_DETAIL cldd " + + " INNER JOIN " + + " APC_CLOSING_DAY cd on cldd.id_closing_day = cd.id" + + " INNER JOIN" + + " APC_USER u ON u.id = cd.id_user " + + " INNER JOIN " + + " APC_HUMAN_RESOURCE hr ON hr.id = u.id_human_resource " + + " WHERE " + + " cldd.id_closing_day = :idClosingDay" + + " ORDER BY" + + " cldd.created_on ASC; "; } diff --git a/apc-controller/src/test/resources/apc.cfg.xml b/apc-controller/src/test/resources/apc.cfg.xml index 7179e6f..43ac1cc 100644 --- a/apc-controller/src/test/resources/apc.cfg.xml +++ b/apc-controller/src/test/resources/apc.cfg.xml @@ -73,11 +73,13 @@ + + diff --git a/apc-model/src/main/java/com/arrebol/apc/model/views/AdvanceUserDailyDetail.java b/apc-model/src/main/java/com/arrebol/apc/model/views/AdvanceUserDailyDetail.java index 98a0ad5..183829f 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/views/AdvanceUserDailyDetail.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/views/AdvanceUserDailyDetail.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.views; @@ -22,167 +22,141 @@ import org.hibernate.annotations.Immutable; @Entity @Immutable @Table(name = "APC_ADVANCE_USER_DAILY_DETAIL_VIEW") -public class AdvanceUserDailyDetail implements Serializable{ +public class AdvanceUserDailyDetail implements Serializable { - private static final long serialVersionUID = -4849944622024557288L; - - @Id - @Column(name = "id", length = 36) - private String id; - - @Column(name = "id_user") - private String idUser; - - @Column(name = "customer_name") - private String customerName; - - @Column(name = "payment_amount") - private String paymentAmount; - - @Column(name = "created_on") - private Date createdOn; - - @Column(name = "address_business") - private String address; - - @Column(name = "type_ayment") - private String typePayment; - - @Column(name = "amount_paid") - private String amountPaid; - - @Column(name = "amount_to_pay") - private String amountToPay; - - @Column(name = "last_reference_number") - private String lastReference; - - @Column(name = "loan_status") - private String loanStatus; - - @Column(name = "num_fee") - private String numFee; - - @Column(name = "saldo_insoluto") - private String saldoInsoluto; - - @Column(name = "amount_loan") - private String amountLoan; - + private static final long serialVersionUID = -4849944622024557288L; - public String getId() { - return id; - } + @Id + @Column(name = "id", length = 36) + private String id; - public void setId(String id) { - this.id = id; - } + @Column(name = "id_user") + private String idUser; - public String getIdUser() { - return idUser; - } + @Column(name = "customer_name") + private String customerName; - public void setIdUser(String idUser) { - this.idUser = idUser; - } + @Column(name = "payment_amount") + private String paymentAmount; - public String getCustomerName() { - return customerName; - } + @Column(name = "created_on") + private Date createdOn; - public void setCustomerName(String customerName) { - this.customerName = customerName; - } + @Column(name = "address_business") + private String address; - public String getPaymentAmount() { - return paymentAmount; - } + @Column(name = "type_ayment") + private String typePayment; - public void setPaymentAmount(String paymentAmount) { - this.paymentAmount = paymentAmount; - } + @Column(name = "amount_paid") + private String amountPaid; - public Date getCreatedOn() { - return createdOn; - } + @Column(name = "amount_to_pay") + private String amountToPay; - public void setCreatedOn(Date createdOn) { - this.createdOn = createdOn; - } + @Column(name = "last_reference_number") + private String lastReference; - public String getAddress() { - return address; - } + @Column(name = "loan_status") + private String loanStatus; - public void setAddress(String address) { - this.address = address; - } + @Column(name = "num_fee") + private String numFee; - public String getTypePayment() { - return typePayment; - } + public String getId() { + return id; + } - public void setTypePayment(String typePayment) { - this.typePayment = typePayment; - } + public void setId(String id) { + this.id = id; + } - public String getAmountPaid() { - return amountPaid; - } + public String getIdUser() { + return idUser; + } - public void setAmountPaid(String amountPaid) { - this.amountPaid = amountPaid; - } + public void setIdUser(String idUser) { + this.idUser = idUser; + } - public String getAmountToPay() { - return amountToPay; - } + public String getCustomerName() { + return customerName; + } - public void setAmountToPay(String amountToPay) { - this.amountToPay = amountToPay; - } + public void setCustomerName(String customerName) { + this.customerName = customerName; + } - public String getLastReference() { - return lastReference; - } + public String getPaymentAmount() { + return paymentAmount; + } - public void setLastReference(String lastReference) { - this.lastReference = lastReference; - } + public void setPaymentAmount(String paymentAmount) { + this.paymentAmount = paymentAmount; + } - public String getLoanStatus() { - return loanStatus; - } + public Date getCreatedOn() { + return createdOn; + } - public void setLoanStatus(String loanStatus) { - this.loanStatus = loanStatus; - } + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } - public String getNumFee() { - return numFee; - } + public String getAddress() { + return address; + } - public void setNumFee(String numFee) { - this.numFee = numFee; - } + public void setAddress(String address) { + this.address = address; + } - public String getSaldoInsoluto() { - return saldoInsoluto; - } + public String getTypePayment() { + return typePayment; + } - public void setSaldoInsoluto(String saldoInsoluto) { - this.saldoInsoluto = saldoInsoluto; - } + public void setTypePayment(String typePayment) { + this.typePayment = typePayment; + } - public String getAmountLoan() { - return amountLoan; - } + public String getAmountPaid() { + return amountPaid; + } + + public void setAmountPaid(String amountPaid) { + this.amountPaid = amountPaid; + } + + public String getAmountToPay() { + return amountToPay; + } + + public void setAmountToPay(String amountToPay) { + this.amountToPay = amountToPay; + } + + public String getLastReference() { + return lastReference; + } + + public void setLastReference(String lastReference) { + this.lastReference = lastReference; + } + + public String getLoanStatus() { + return loanStatus; + } + + public void setLoanStatus(String loanStatus) { + this.loanStatus = loanStatus; + } + + public String getNumFee() { + return numFee; + } + + public void setNumFee(String numFee) { + this.numFee = numFee; + } - public void setAmountLoan(String amountLoan) { - this.amountLoan = amountLoan; - } - - - - } diff --git a/apc-model/src/main/java/com/arrebol/apc/model/views/ClosingDailyDetailFromUserByCurdateView.java b/apc-model/src/main/java/com/arrebol/apc/model/views/ClosingDailyDetailFromUserByCurdateView.java index 9c57c0a..f27e872 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/views/ClosingDailyDetailFromUserByCurdateView.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/views/ClosingDailyDetailFromUserByCurdateView.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.views; @@ -23,112 +23,112 @@ import org.hibernate.annotations.Immutable; @Entity @Immutable @Table(name = "APC_CLOSING_DAILY_DETAIL_FROM_USER_BY_CURDATE_VIEW") -public class ClosingDailyDetailFromUserByCurdateView implements Serializable{ +public class ClosingDailyDetailFromUserByCurdateView implements Serializable { - private static final long serialVersionUID = -4593609182109393813L; - - @Id - @Column(name = "id", length = 36) - private String id; - - @Column(name = "comments") - private String comments; - - @Column(name = "amount") - private BigDecimal amount; - - @Column(name = "type") - private String type; - - @Column(name = "created_on") - private Date createdOn; - - @Column(name = "id_user") - private String idUser; - - @Column(name = "route") - private String route; - - @Column(name = "fechaFiltro") - private Date fechaFiltro; - - @Column(name = "saldo") - private BigDecimal saldo; - - public ClosingDailyDetailFromUserByCurdateView(){ - - } + private static final long serialVersionUID = -4593609182109393813L; - public String getId() { - return id; - } + @Id + @Column(name = "id", length = 36) + private String id; - public void setId(String id) { - this.id = id; - } + @Column(name = "comments") + private String comments; - public String getComments() { - return comments; - } + @Column(name = "amount") + private BigDecimal amount; - public void setComments(String comments) { - this.comments = comments; - } + @Column(name = "type") + private String type; - public BigDecimal getAmount() { - return amount; - } + @Column(name = "created_on") + private Date createdOn; - public void setAmount(BigDecimal amount) { - this.amount = amount; - } + @Column(name = "id_user") + private String idUser; - public String getType() { - return type; - } + @Column(name = "route") + private String route; - public void setType(String type) { - this.type = type; - } + @Column(name = "fechaFiltro") + private Date fechaFiltro; - public String getIdUser() { - return idUser; - } + @Column(name = "saldo") + private BigDecimal saldo; - public void setIdUser(String idUser) { - this.idUser = idUser; - } + public ClosingDailyDetailFromUserByCurdateView() { - public Date getCreatedOn() { - return createdOn; - } + } - public void setCreatedOn(Date createdOn) { - this.createdOn = createdOn; - } + public String getId() { + return id; + } - public String getRoute() { - return route; - } + public void setId(String id) { + this.id = id; + } - public void setRoute(String route) { - this.route = route; - } + public String getComments() { + return comments; + } - public Date getFechaFiltro() { - return fechaFiltro; - } + public void setComments(String comments) { + this.comments = comments; + } - public void setFechaFiltro(Date fechaFiltro) { - this.fechaFiltro = fechaFiltro; - } + public BigDecimal getAmount() { + return amount; + } - public BigDecimal getSaldo() { - return saldo; - } + public void setAmount(BigDecimal amount) { + this.amount = amount; + } - public void setSaldo(BigDecimal saldo) { - this.saldo = saldo; - } + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getIdUser() { + return idUser; + } + + public void setIdUser(String idUser) { + this.idUser = idUser; + } + + public Date getCreatedOn() { + return createdOn; + } + + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } + + public String getRoute() { + return route; + } + + public void setRoute(String route) { + this.route = route; + } + + public Date getFechaFiltro() { + return fechaFiltro; + } + + public void setFechaFiltro(Date fechaFiltro) { + this.fechaFiltro = fechaFiltro; + } + + public BigDecimal getSaldo() { + return saldo; + } + + public void setSaldo(BigDecimal saldo) { + this.saldo = saldo; + } } diff --git a/apc-model/src/main/java/com/arrebol/apc/model/views/ClosingDailyDetailFromUserByLastClosingDayView.java b/apc-model/src/main/java/com/arrebol/apc/model/views/ClosingDailyDetailFromUserByLastClosingDayView.java new file mode 100644 index 0000000..25533a7 --- /dev/null +++ b/apc-model/src/main/java/com/arrebol/apc/model/views/ClosingDailyDetailFromUserByLastClosingDayView.java @@ -0,0 +1,134 @@ +/* + * Arrebol Consultancy copyright. + * + * This code belongs to Arrebol Consultancy + * its use, redistribution or modification are prohibited + * without written authorization from Arrebol Consultancy. + */ +package com.arrebol.apc.model.views; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import org.hibernate.annotations.Immutable; + +/** + * + * @author Oscar Armando Vargas Cardenas + */ +@Entity +@Immutable +@Table(name = "APC_CLOSING_DAILY_DETAIL_FROM_USER_BY_LAST_CLOSING_DAY_VIEW") +public class ClosingDailyDetailFromUserByLastClosingDayView implements Serializable { + + private static final long serialVersionUID = -4593609182109393813L; + + @Id + @Column(name = "id", length = 36) + private String id; + + @Column(name = "comments") + private String comments; + + @Column(name = "amount") + private BigDecimal amount; + + @Column(name = "type") + private String type; + + @Column(name = "created_on") + private Date createdOn; + + @Column(name = "id_user") + private String idUser; + + @Column(name = "route") + private String route; + + @Column(name = "fechaFiltro") + private Date fechaFiltro; + + @Column(name = "saldo") + private BigDecimal saldo; + + public ClosingDailyDetailFromUserByLastClosingDayView() { + + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments = comments; + } + + public BigDecimal getAmount() { + return amount; + } + + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getIdUser() { + return idUser; + } + + public void setIdUser(String idUser) { + this.idUser = idUser; + } + + public Date getCreatedOn() { + return createdOn; + } + + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } + + public String getRoute() { + return route; + } + + public void setRoute(String route) { + this.route = route; + } + + public Date getFechaFiltro() { + return fechaFiltro; + } + + public void setFechaFiltro(Date fechaFiltro) { + this.fechaFiltro = fechaFiltro; + } + + public BigDecimal getSaldo() { + return saldo; + } + + public void setSaldo(BigDecimal saldo) { + this.saldo = saldo; + } + +} diff --git a/apc-model/src/main/java/com/arrebol/apc/model/views/TotalCashByCurdateView.java b/apc-model/src/main/java/com/arrebol/apc/model/views/TotalCashByCurdateView.java index 6bc7379..8441c77 100644 --- a/apc-model/src/main/java/com/arrebol/apc/model/views/TotalCashByCurdateView.java +++ b/apc-model/src/main/java/com/arrebol/apc/model/views/TotalCashByCurdateView.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.views; @@ -25,148 +25,148 @@ import org.hibernate.annotations.Immutable; @Table(name = "APC_TOTAL_CASH_BY_CURDATE_VIEW") public class TotalCashByCurdateView implements Serializable { - private static final long serialVersionUID = 617629469188727880L; + private static final long serialVersionUID = 617629469188727880L; - @Id - @Column(name = "id", length = 36) - private String id; + @Id + @Column(name = "id", length = 36) + private String id; - @Column(name = "id_office") - private String idOffice; + @Column(name = "id_office") + private String idOffice; - @Column(name = "total_amount_payment") - private BigDecimal paymentDaily; - - @Column(name = "total_amount_deposit") - private BigDecimal depositDaily; + @Column(name = "total_amount_payment") + private BigDecimal paymentDaily; - @Column(name = "transfer_sender") - private BigDecimal transferSender; + @Column(name = "total_amount_deposit") + private BigDecimal depositDaily; - @Column(name = "transfer_receiver") - private BigDecimal transferReceiver; + @Column(name = "transfer_sender") + private BigDecimal transferSender; - @Column(name = "money_daily") - private BigDecimal moneyDaily; + @Column(name = "transfer_receiver") + private BigDecimal transferReceiver; - @Column(name = "other_expense") - private BigDecimal otherExpense; + @Column(name = "money_daily") + private BigDecimal moneyDaily; - @Column(name = "delivery") - private BigDecimal delivery; + @Column(name = "other_expense") + private BigDecimal otherExpense; - @Column(name = "transfer_pending") - private BigDecimal transferPending; + @Column(name = "delivery") + private BigDecimal delivery; - @Transient - private BigDecimal total; + @Column(name = "transfer_pending") + private BigDecimal transferPending; - public TotalCashByCurdateView() { - } + @Transient + private BigDecimal total; - public String getId() { - return id; - } + public TotalCashByCurdateView() { + } - public void setId(String id) { - this.id = id; - } + public String getId() { + return id; + } - public BigDecimal getPaymentDaily() { - return paymentDaily; - } + public void setId(String id) { + this.id = id; + } - public void setPaymentDaily(BigDecimal paymentDaily) { - this.paymentDaily = paymentDaily; - } + public BigDecimal getPaymentDaily() { + return paymentDaily; + } - public BigDecimal getTransferSender() { - return transferSender; - } + public void setPaymentDaily(BigDecimal paymentDaily) { + this.paymentDaily = paymentDaily; + } - public void setTransferSender(BigDecimal transferSender) { - this.transferSender = transferSender; - } + public BigDecimal getTransferSender() { + return transferSender; + } - public BigDecimal getTransferReceiver() { - return transferReceiver; - } + public void setTransferSender(BigDecimal transferSender) { + this.transferSender = transferSender; + } - public void setTransferReceiver(BigDecimal transferReceiver) { - this.transferReceiver = transferReceiver; - } + public BigDecimal getTransferReceiver() { + return transferReceiver; + } - public BigDecimal getMoneyDaily() { - return moneyDaily; - } + public void setTransferReceiver(BigDecimal transferReceiver) { + this.transferReceiver = transferReceiver; + } - public void setMoneyDaily(BigDecimal moneyDaily) { - this.moneyDaily = moneyDaily; - } + public BigDecimal getMoneyDaily() { + return moneyDaily; + } - public BigDecimal getOtherExpense() { - return otherExpense; - } + public void setMoneyDaily(BigDecimal moneyDaily) { + this.moneyDaily = moneyDaily; + } - public void setOtherExpense(BigDecimal otherExpense) { - this.otherExpense = otherExpense; - } + public BigDecimal getOtherExpense() { + return otherExpense; + } - public BigDecimal getDelivery() { - return delivery; - } + public void setOtherExpense(BigDecimal otherExpense) { + this.otherExpense = otherExpense; + } - public void setDelivery(BigDecimal delivery) { - this.delivery = delivery; - } + public BigDecimal getDelivery() { + return delivery; + } - public String getIdOffice() { - return idOffice; - } + public void setDelivery(BigDecimal delivery) { + this.delivery = delivery; + } - public void setIdOffice(String idOffice) { - this.idOffice = idOffice; - } + public String getIdOffice() { + return idOffice; + } - public BigDecimal getTransferPending() { - return transferPending; - } + public void setIdOffice(String idOffice) { + this.idOffice = idOffice; + } - public void setTransferPending(BigDecimal transferPending) { - this.transferPending = transferPending; - } + public BigDecimal getTransferPending() { + return transferPending; + } - public BigDecimal getDepositDaily() { - return depositDaily; - } + public void setTransferPending(BigDecimal transferPending) { + this.transferPending = transferPending; + } - public void setDepositDaily(BigDecimal depositDaily) { - this.depositDaily = depositDaily; - } - - public BigDecimal getTotal() { - if (null == total) { - total = BigDecimal.ZERO; - } - total = BigDecimal.ZERO; - total = total - .add(getPaymentDaily()) - .add(getTransferReceiver()) - .subtract(getTransferSender()) - .add(getMoneyDaily()) - .subtract(getOtherExpense()) - .subtract(getDelivery()); + public BigDecimal getDepositDaily() { + return depositDaily; + } - return total; - } + public void setDepositDaily(BigDecimal depositDaily) { + this.depositDaily = depositDaily; + } - public void setTotal(BigDecimal total) { - this.total = total; - } + public BigDecimal getTotal() { + if (null == total) { + total = BigDecimal.ZERO; + } + total = BigDecimal.ZERO; + total = total + .add(getPaymentDaily()) + .add(getTransferReceiver()) + .subtract(getTransferSender()) + .add(getMoneyDaily()) + .subtract(getOtherExpense()) + .subtract(getDelivery()); - @Override - public String toString() { - return "TotalCashByCurdateView{" + "id=" + id + '}'; - } + return total; + } + + public void setTotal(BigDecimal total) { + this.total = total; + } + + @Override + public String toString() { + return "TotalCashByCurdateView{" + "id=" + id + '}'; + } } diff --git a/apc-model/src/main/java/com/arrebol/apc/model/views/TotalCashByLastClosingDayView.java b/apc-model/src/main/java/com/arrebol/apc/model/views/TotalCashByLastClosingDayView.java new file mode 100644 index 0000000..8239f0f --- /dev/null +++ b/apc-model/src/main/java/com/arrebol/apc/model/views/TotalCashByLastClosingDayView.java @@ -0,0 +1,172 @@ +/* + * Arrebol Consultancy copyright. + * + * This code belongs to Arrebol Consultancy + * its use, redistribution or modification are prohibited + * without written authorization from Arrebol Consultancy. + */ +package com.arrebol.apc.model.views; + +import java.io.Serializable; +import java.math.BigDecimal; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Transient; +import org.hibernate.annotations.Immutable; + +/** + * + * @author Carlos Janitzio Zavala Lopez + */ +@Entity +@Immutable +@Table(name = "APC_TOTAL_CASH_BY_LAST_CLOSING_DAY_VIEW") +public class TotalCashByLastClosingDayView implements Serializable { + + private static final long serialVersionUID = 617629469188727880L; + + @Id + @Column(name = "id", length = 36) + private String id; + + @Column(name = "id_office") + private String idOffice; + + @Column(name = "total_amount_payment") + private BigDecimal paymentDaily; + + @Column(name = "total_amount_deposit") + private BigDecimal depositDaily; + + @Column(name = "transfer_sender") + private BigDecimal transferSender; + + @Column(name = "transfer_receiver") + private BigDecimal transferReceiver; + + @Column(name = "money_daily") + private BigDecimal moneyDaily; + + @Column(name = "other_expense") + private BigDecimal otherExpense; + + @Column(name = "delivery") + private BigDecimal delivery; + + @Column(name = "transfer_pending") + private BigDecimal transferPending; + + @Transient + private BigDecimal total; + + public TotalCashByLastClosingDayView() { + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public BigDecimal getPaymentDaily() { + return paymentDaily; + } + + public void setPaymentDaily(BigDecimal paymentDaily) { + this.paymentDaily = paymentDaily; + } + + public BigDecimal getTransferSender() { + return transferSender; + } + + public void setTransferSender(BigDecimal transferSender) { + this.transferSender = transferSender; + } + + public BigDecimal getTransferReceiver() { + return transferReceiver; + } + + public void setTransferReceiver(BigDecimal transferReceiver) { + this.transferReceiver = transferReceiver; + } + + public BigDecimal getMoneyDaily() { + return moneyDaily; + } + + public void setMoneyDaily(BigDecimal moneyDaily) { + this.moneyDaily = moneyDaily; + } + + public BigDecimal getOtherExpense() { + return otherExpense; + } + + public void setOtherExpense(BigDecimal otherExpense) { + this.otherExpense = otherExpense; + } + + public BigDecimal getDelivery() { + return delivery; + } + + public void setDelivery(BigDecimal delivery) { + this.delivery = delivery; + } + + public String getIdOffice() { + return idOffice; + } + + public void setIdOffice(String idOffice) { + this.idOffice = idOffice; + } + + public BigDecimal getTransferPending() { + return transferPending; + } + + public void setTransferPending(BigDecimal transferPending) { + this.transferPending = transferPending; + } + + public BigDecimal getDepositDaily() { + return depositDaily; + } + + public void setDepositDaily(BigDecimal depositDaily) { + this.depositDaily = depositDaily; + } + + public BigDecimal getTotal() { + if (null == total) { + total = BigDecimal.ZERO; + } + total = BigDecimal.ZERO; + total = total + .add(getPaymentDaily()) + .add(getTransferReceiver()) + .subtract(getTransferSender()) + .add(getMoneyDaily()) + .subtract(getOtherExpense()) + .subtract(getDelivery()); + + return total; + } + + public void setTotal(BigDecimal total) { + this.total = total; + } + + @Override + public String toString() { + return "TotalCashByCurdateView{" + "id=" + id + '}'; + } + +} diff --git a/apc-model/src/main/java/com/arrebol/apc/model/views/constance/ClosingDailyDetailFromUserByLastClosingDayCfg.java b/apc-model/src/main/java/com/arrebol/apc/model/views/constance/ClosingDailyDetailFromUserByLastClosingDayCfg.java new file mode 100644 index 0000000..c6ef217 --- /dev/null +++ b/apc-model/src/main/java/com/arrebol/apc/model/views/constance/ClosingDailyDetailFromUserByLastClosingDayCfg.java @@ -0,0 +1,23 @@ +/* + * Arrebol Consultancy copyright. + * + * This code belongs to Arrebol Consultancy + * its use, redistribution or modification are prohibited + * without written authorization from Arrebol Consultancy. + */ +package com.arrebol.apc.model.views.constance; + +import com.arrebol.apc.model.core.constance.GenericCfg; + +/** + * + * @author Oscar Armando Vargas Cardenas + */ +public interface ClosingDailyDetailFromUserByLastClosingDayCfg extends GenericCfg { + + String QUERY_FIND_ALL_DETAILS = "findAllClosingDailyDetailFromUserByLastClosingDayView"; + String QUERY_FIND_ALL_DETAILS_CERTIFIER = "findAllClosingDailyDetailFromUserCertifierByLastClosingDayView"; + + String FIELD_VIEW_USER = "idUser"; + +} diff --git a/apc-model/src/main/resources/apc.cfg.xml b/apc-model/src/main/resources/apc.cfg.xml index 6216683..1b730ff 100644 --- a/apc-model/src/main/resources/apc.cfg.xml +++ b/apc-model/src/main/resources/apc.cfg.xml @@ -73,11 +73,13 @@ + + @@ -185,6 +187,7 @@ + diff --git a/apc-model/src/main/resources/com/arrebol/apc/model/queries/view/total.closing.daily.detail.from.user.by.last.closing.day.view.hbm.xml b/apc-model/src/main/resources/com/arrebol/apc/model/queries/view/total.closing.daily.detail.from.user.by.last.closing.day.view.hbm.xml new file mode 100644 index 0000000..bf2ea01 --- /dev/null +++ b/apc-model/src/main/resources/com/arrebol/apc/model/queries/view/total.closing.daily.detail.from.user.by.last.closing.day.view.hbm.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + diff --git a/apc-web/src/main/java/com/arrebol/apc/web/beans/admin/ClosingDayBean.java b/apc-web/src/main/java/com/arrebol/apc/web/beans/admin/ClosingDayBean.java index 8a6ea61..cfbc243 100644 --- a/apc-web/src/main/java/com/arrebol/apc/web/beans/admin/ClosingDayBean.java +++ b/apc-web/src/main/java/com/arrebol/apc/web/beans/admin/ClosingDayBean.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.web.beans.admin; @@ -13,15 +13,14 @@ import com.arrebol.apc.controller.admin.ClosingDayController; import com.arrebol.apc.controller.admin.LoanController; import com.arrebol.apc.model.admin.ClosingDay; import com.arrebol.apc.model.admin.ClosingDayDetail; -import com.arrebol.apc.model.catalog.RouteCtlg; 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.system.logs.Bitacora; -import com.arrebol.apc.model.views.ClosingDailyDetailFromUserByCurdateView; +import com.arrebol.apc.model.views.ClosingDailyDetailFromUserByLastClosingDayView; import com.arrebol.apc.model.views.LoanByUserPaymentZeroView; import com.arrebol.apc.model.views.TotalCashByCurdateDashboardView; -import com.arrebol.apc.model.views.TotalCashByCurdateView; +import com.arrebol.apc.model.views.TotalCashByLastClosingDayView; import com.arrebol.apc.model.views.TotalClosingDayByCurdateView; import com.arrebol.apc.web.beans.Datatable; import com.arrebol.apc.web.beans.GenericBean; @@ -30,7 +29,6 @@ import com.itextpdf.text.Chunk; import com.itextpdf.text.Document; import com.itextpdf.text.Element; import com.itextpdf.text.FontFactory; -import com.itextpdf.text.Image; import com.itextpdf.text.PageSize; import com.itextpdf.text.Paragraph; import com.itextpdf.text.pdf.PdfPCell; @@ -43,7 +41,6 @@ import java.io.Serializable; import java.math.BigDecimal; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.time.ZoneId; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -67,1215 +64,1193 @@ import org.primefaces.event.RowEditEvent; @ViewScoped public class ClosingDayBean extends GenericBean implements Serializable, Datatable { - public void searchHistoricalAction() { - try { - if (getStarDate().after(getEndDate())) { - showMessage(FacesMessage.SEVERITY_ERROR, getBundlePropertyFile().getString("generic.start.date"), getBundlePropertyFile().getString("generic.end.date.error")); - } else { - setClosingDay(getClosingDayCtrl().fillClosingDayDatatable(getLoggedUser().getOffice().getId(), getStarDate(), getEndDate())); - } - } catch (Exception e) { - } - } + public void searchHistoricalAction() { + try { + if (getStarDate().after(getEndDate())) { + showMessage(FacesMessage.SEVERITY_ERROR, getBundlePropertyFile().getString("generic.start.date"), getBundlePropertyFile().getString("generic.end.date.error")); + } else { + setClosingDay(getClosingDayCtrl().fillClosingDayDatatable(getLoggedUser().getOffice().getId(), getStarDate(), getEndDate())); + } + } catch (Exception e) { + } + } - public List fillDatatableClosingDay() { + public List fillDatatableClosingDay() { - return getClosingDayCtrl().fillClosingDayDatatable(getLoggedUser().getOffice().getId(), getStarDate(), getEndDate()); - } + return getClosingDayCtrl().fillClosingDayDatatable(getLoggedUser().getOffice().getId(), getStarDate(), getEndDate()); + } - /** - * - * @param outcome - * @return - */ - public String detailClosingDay(String outcome) { - return outcome; - } + /** + * + * @param outcome + * @return + */ + public String detailClosingDay(String outcome) { + return outcome; + } - public List getUsers() { + public List getUsers() { - return genericCtrl.getAllUsersByOffice(getLoggedUser().getOffice().getId()); - } + return genericCtrl.getAllUsersByOffice(getLoggedUser().getOffice().getId()); + } - public List fillDatatableClosingDetails(String idUser) { + public List fillDatatableClosingDetails(String idUser) { + return closingDayCtrl.findAllClosingDailyDetailFromUserByLastClosingDayView(idUser); + } - return closingDayCtrl.findAllClosingDailyDetailFromUserByCurdateView(idUser); - } + public List getLoansPaymentZeroByUser(String idUser) { - public List getLoansPaymentZeroByUser(String idUser) { + return closingDayCtrl.getLoansPaymentZeroByUser(idUser); + } - return closingDayCtrl.getLoansPaymentZeroByUser(idUser); - } + public void getResumen() { - public void getResumen() { + List listTotal = closingDayCtrl.getAllTotalCashByCurdateDashboardView(getLoggedUser().getOffice().getId()); + totalAmount = BigDecimal.ZERO; + totalTransferSender = BigDecimal.ZERO; + totalTransferReceiver = BigDecimal.ZERO; + totalMoneyDaily = BigDecimal.ZERO; + totalDelivery = BigDecimal.ZERO; + totalFinal = BigDecimal.ZERO; + totalCaja = BigDecimal.ZERO; + totalOtherExpense = BigDecimal.ZERO; + deposit = BigDecimal.ZERO; - List listTotal = closingDayCtrl.getAllTotalCashByCurdateDashboardView(getLoggedUser().getOffice().getId()); - totalAmount = BigDecimal.ZERO; - totalTransferSender = BigDecimal.ZERO; - totalTransferReceiver = BigDecimal.ZERO; - totalMoneyDaily = BigDecimal.ZERO; - totalDelivery = BigDecimal.ZERO; - totalFinal = BigDecimal.ZERO; - totalCaja = BigDecimal.ZERO; - totalOtherExpense = BigDecimal.ZERO; - deposit = BigDecimal.ZERO; + for (TotalCashByCurdateDashboardView temp : listTotal) { + totalAmount = totalAmount.add(temp.getPaymentDaily()); + totalTransferSender = totalTransferSender.add(temp.getTransferSender()); + totalTransferReceiver = totalTransferReceiver.add(temp.getTransferReceiver()); + totalMoneyDaily = totalMoneyDaily.add(temp.getMoneyDaily()); + totalDelivery = totalDelivery.add(temp.getDelivery()); + deposit = deposit.add(temp.getDepositDaily()); + totalFinal = totalFinal.add(temp.getTotal()); + totalOtherExpense = totalOtherExpense.add(temp.getOtherExpense()); + } - for (TotalCashByCurdateDashboardView temp : listTotal) { - totalAmount = totalAmount.add(temp.getPaymentDaily()); - totalTransferSender = totalTransferSender.add(temp.getTransferSender()); - totalTransferReceiver = totalTransferReceiver.add(temp.getTransferReceiver()); - totalMoneyDaily = totalMoneyDaily.add(temp.getMoneyDaily()); - totalDelivery = totalDelivery.add(temp.getDelivery()); - deposit = deposit.add(temp.getDepositDaily()); - totalFinal = totalFinal.add(temp.getTotal()); - totalOtherExpense = totalOtherExpense.add(temp.getOtherExpense()); - } + List closingTotal = closingDayCtrl.findAllClosingDayByCurdate(getLoggedUser().getOffice().getId()); + if (closingTotal != null && !closingTotal.isEmpty()) { + for (TotalClosingDayByCurdateView temp : closingTotal) { + totalCaja = totalCaja.add(temp.getAmountPaid()); + } + } - List closingTotal = closingDayCtrl.findAllClosingDayByCurdate(getLoggedUser().getOffice().getId()); - if (closingTotal != null && !closingTotal.isEmpty()) { - for (TotalClosingDayByCurdateView temp : closingTotal) { - totalCaja = totalCaja.add(temp.getAmountPaid()); - } - } + } - } + public void getCashTotal() { - public void getCashTotal() { - - - if(userId.equalsIgnoreCase("")){ - FacesMessage msg = new FacesMessage("ERROR", "Debes de elegir un usuario para poder ver sus totales"); - FacesContext.getCurrentInstance().addMessage(null, msg); - imprimirStatus = true; - userId = ""; - return; - } - if(loanCtrl.countLoanDetailsAuthorize(userId)>0){ - FacesMessage msg = new FacesMessage("Depositos pendientes", "No se puede realizar el corte de caja, autorice todas los depositos pendientes"); - FacesContext.getCurrentInstance().addMessage(null, msg); - userId = ""; - return; - } + if (userId.equalsIgnoreCase("")) { + FacesMessage msg = new FacesMessage("ERROR", "Debes de elegir un usuario para poder ver sus totales"); + FacesContext.getCurrentInstance().addMessage(null, msg); + imprimirStatus = true; + userId = ""; + return; + } + if (loanCtrl.countLoanDetailsAuthorize(userId) > 0) { + FacesMessage msg = new FacesMessage("Depositos pendientes", "No se puede realizar el corte de caja, autorice todas los depositos pendientes"); + FacesContext.getCurrentInstance().addMessage(null, msg); + userId = ""; + return; + } - if (closingDayCtrl.getClosingDayCurdateByUserId(userId, getLoggedUser().getOffice().getId()) > 0) { - FacesMessage msg = new FacesMessage("Corte encontrado", "El usuario ya tiene un corte registrado el día de hoy."); - FacesContext.getCurrentInstance().addMessage(null, msg); - userId = ""; - return; - } - totales = new TotalCashByCurdateView(); - totales.setMoneyDaily(BigDecimal.ZERO); - totales.setPaymentDaily(BigDecimal.ZERO); - totales.setTransferReceiver(BigDecimal.ZERO); - totales.setTransferSender(BigDecimal.ZERO); - totales.setDelivery(BigDecimal.ZERO); - totales.setTransferPending(BigDecimal.ZERO); - totales.setOtherExpense(BigDecimal.ZERO); - totales.setDepositDaily(BigDecimal.ZERO); - total = BigDecimal.ZERO.toString(); - totalCustomerWithOutAction = new Long(0); - comments = ""; - TotalCashByCurdateView temp; - temp = closingDayCtrl.getTotalCashByCurdateViewById(userId); - if (temp != null) { - totales = temp; - total = temp.getTotal().toString(); - } + totales = new TotalCashByLastClosingDayView(); + totales.setMoneyDaily(BigDecimal.ZERO); + totales.setPaymentDaily(BigDecimal.ZERO); + totales.setTransferReceiver(BigDecimal.ZERO); + totales.setTransferSender(BigDecimal.ZERO); + totales.setDelivery(BigDecimal.ZERO); + totales.setTransferPending(BigDecimal.ZERO); + totales.setOtherExpense(BigDecimal.ZERO); + totales.setDepositDaily(BigDecimal.ZERO); + total = BigDecimal.ZERO.toString(); + totalCustomerWithOutAction = new Long(0); + comments = ""; + TotalCashByLastClosingDayView temp; + temp = closingDayCtrl.getTotalCashByLastClosingDayViewById(userId); + if (temp != null) { + totales = temp; + total = temp.getTotal().toString(); + } - if (closingDetail != null && !closingDetail.isEmpty()) { - closingDetail.clear(); - } + if (closingDetail != null && !closingDetail.isEmpty()) { + closingDetail.clear(); + } - User userObj = closingDayCtrl.getUserById(userId); - - - if (userObj.getCertifier().equals(ActiveStatus.DISABLED)) { - closingDetail = fillDatatableClosingDetails(userId); - } else { - closingDetail = closingDayCtrl.findAllClosingDailyDetailFromUserCertifierByCurdateView(userId); - } + User userObj = closingDayCtrl.getUserById(userId); - totalCustomerWithOutAction = closingDayCtrl.getLoansCountDailyByUser(userId); - paymentoZeroDetail = getLoansPaymentZeroByUser(userId); - - imprimirStatus = false; - // imprimirStatus(); - } - - public void imprimir() { - if (userId.equalsIgnoreCase("")) { - FacesMessage msg = new FacesMessage("ERROR", "Debes de elegir un usuario para poder imprimir el corte."); - FacesContext.getCurrentInstance().addMessage(null, msg); - userId = ""; - imprimirStatus = true; - return; - } - Document document = new Document(PageSize.LETTER); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - PdfWriter.getInstance(document, baos); - List results = new ArrayList<>(); - results = closingDayCtrl.findDetailsFromClosingDayCurDate(userId); - document.open(); + if (userObj.getCertifier().equals(ActiveStatus.DISABLED)) { + closingDetail = fillDatatableClosingDetails(userId); + } else { + closingDetail = closingDayCtrl.findAllClosingDailyDetailFromUserCertifierByLastClosingDayView(userId); + } - DateFormat formatter = new SimpleDateFormat("dd/MM/yy"); - DateFormat formatter2 = new SimpleDateFormat("dd/MM/yyyy HH:mm:SS"); - formatter2.setTimeZone(TimeZone.getTimeZone("GMT-6")); + totalCustomerWithOutAction = closingDayCtrl.getLoansCountDailyByUser(userId); + paymentoZeroDetail = getLoansPaymentZeroByUser(userId); - Paragraph printDate = new Paragraph("Fecha de impresión: " + formatter.format(new Date()), FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.DARK_GRAY)); - printDate.setAlignment(Element.ALIGN_RIGHT); - document.add(printDate); + imprimirStatus = false; + // imprimirStatus(); + } + + public void imprimir() { + if (userId.equalsIgnoreCase("")) { + FacesMessage msg = new FacesMessage("ERROR", "Debes de elegir un usuario para poder imprimir el corte."); + FacesContext.getCurrentInstance().addMessage(null, msg); + userId = ""; + imprimirStatus = true; + return; + } + Document document = new Document(PageSize.LETTER); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + PdfWriter.getInstance(document, baos); + List results = new ArrayList<>(); + results = closingDayCtrl.findDetailsFromClosingDayCurDate(userId); + document.open(); + + DateFormat formatter = new SimpleDateFormat("dd/MM/yy"); + DateFormat formatter2 = new SimpleDateFormat("dd/MM/yyyy HH:mm:SS"); + formatter2.setTimeZone(TimeZone.getTimeZone("GMT-6")); + + Paragraph printDate = new Paragraph("Fecha de impresión: " + formatter.format(new Date()), FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.DARK_GRAY)); + printDate.setAlignment(Element.ALIGN_RIGHT); + document.add(printDate); // Image imagen = Image.getInstance("other sources/resources/serenity-layout/images/apc_card.png"); // imagen.scaleAbsoluteWidth(100f); // document.add(imagen); - - Paragraph title = new Paragraph("Corte del día", FontFactory.getFont("arial", 18, Font.BOLD, BaseColor.DARK_GRAY)); - title.setAlignment(Element.ALIGN_CENTER); - document.add(title); - - document.add(Chunk.NEWLINE); - - Object[] res = (Object[]) results.get(0); - BigDecimal totalesRep = BigDecimal.ZERO; - BigDecimal recuperado = BigDecimal.ZERO; - BigDecimal transEnv = BigDecimal.ZERO; - BigDecimal transRec = BigDecimal.ZERO; - BigDecimal inicio = BigDecimal.ZERO; - BigDecimal gastos = BigDecimal.ZERO; - BigDecimal depositos = BigDecimal.ZERO; - BigDecimal entrPrestamos = BigDecimal.ZERO; - - - PdfPTable tableGen = new PdfPTable(4); - tableGen.setWidthPercentage(100); - tableGen.setTotalWidth(new float[]{100f, 170f, 140f, 150f}); - tableGen.setLockedWidth(true); - - PdfPCell cellGen = new PdfPCell(new Paragraph("Asesor: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph(res[8] == null ? "" : res[8].toString(), - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(3); - tableGen.addCell(cellGen); - - cellGen = new PdfPCell(new Paragraph("Monto recuperado: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - recuperado = new BigDecimal(res[9] == null ? "0.0" : res[9].toString()); - cellGen = new PdfPCell(new Paragraph(res[9] != null ? "$" + res[9].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph("Monto enviado por transferencia: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - transEnv = new BigDecimal(res[11] == null ? "0.0" : res[11].toString()); - cellGen = new PdfPCell(new Paragraph(res[11] != null ? "$" + res[11].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - - cellGen = new PdfPCell(new Paragraph("Monto de inicio: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - inicio = new BigDecimal(res[13] == null ? "0.0" : res[13].toString()); - cellGen = new PdfPCell(new Paragraph(res[13] != null ? "$" + res[13].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph("Monto recibido por transferencia: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - transRec = new BigDecimal(res[12] == null ? "0.0" : res[12].toString()); - cellGen = new PdfPCell(new Paragraph(res[12] != null ? "$" + res[12].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - - cellGen = new PdfPCell(new Paragraph("Entrega de préstamos: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - entrPrestamos = new BigDecimal(res[15] == null ? "0.0" : res[15].toString()); - cellGen = new PdfPCell(new Paragraph(res[15] != null ? "$" + res[15].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph("Gastos: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - gastos = new BigDecimal(res[14] == null ? "0.0" : res[14].toString()); - cellGen = new PdfPCell(new Paragraph(res[14] != null ? "$" + res[14].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - - cellGen = new PdfPCell(new Paragraph("Depósitos: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - depositos = new BigDecimal(res[10] == null ? "0.0" : res[10].toString()); - cellGen = new PdfPCell(new Paragraph(res[10] != null ? "$" + res[10].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - totalesRep = totalesRep.add(recuperado).subtract(transEnv).add(transRec).add(inicio).subtract(gastos).subtract(entrPrestamos); - cellGen = new PdfPCell(new Paragraph("Total: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph(totalesRep != null ? "$" + totalesRep.toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - - - - cellGen = new PdfPCell(new Paragraph("Monto Esperado: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph(totales.getTotal() != null ? "$" + totales.getTotal().toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph("Monto Entregado: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph(new BigDecimal(total) != null ? "$" + new BigDecimal(total).toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - - document.add(tableGen); - document.add(Chunk.NEWLINE); - - PdfPTable table = new PdfPTable(7); - table.setTotalWidth(new float[]{60, 60, 60, 60, 170, 60, 100}); + Paragraph title = new Paragraph("Corte del día", FontFactory.getFont("arial", 18, Font.BOLD, BaseColor.DARK_GRAY)); + title.setAlignment(Element.ALIGN_CENTER); + document.add(title); - table.setLockedWidth(true); - PdfPCell cell = new PdfPCell(new Paragraph("Detalles del corte", - FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.WHITE))); + document.add(Chunk.NEWLINE); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - cell.setBackgroundColor(new BaseColor( 4, 193, 10 )); - cell.setColspan(7); - table.addCell(cell); + Object[] res = (Object[]) results.get(0); + BigDecimal totalesRep = BigDecimal.ZERO; + BigDecimal recuperado = BigDecimal.ZERO; + BigDecimal transEnv = BigDecimal.ZERO; + BigDecimal transRec = BigDecimal.ZERO; + BigDecimal inicio = BigDecimal.ZERO; + BigDecimal gastos = BigDecimal.ZERO; + BigDecimal depositos = BigDecimal.ZERO; + BigDecimal entrPrestamos = BigDecimal.ZERO; - cell = new PdfPCell(new Paragraph("Detalle", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); + PdfPTable tableGen = new PdfPTable(4); + tableGen.setWidthPercentage(100); + tableGen.setTotalWidth(new float[]{100f, 170f, 140f, 150f}); + tableGen.setLockedWidth(true); + + PdfPCell cellGen = new PdfPCell(new Paragraph("Asesor: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph(res[8] == null ? "" : res[8].toString(), + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(3); + tableGen.addCell(cellGen); + + cellGen = new PdfPCell(new Paragraph("Monto recuperado: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + recuperado = new BigDecimal(res[9] == null ? "0.0" : res[9].toString()); + cellGen = new PdfPCell(new Paragraph(res[9] != null ? "$" + res[9].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph("Monto enviado por transferencia: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + transEnv = new BigDecimal(res[11] == null ? "0.0" : res[11].toString()); + cellGen = new PdfPCell(new Paragraph(res[11] != null ? "$" + res[11].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + + cellGen = new PdfPCell(new Paragraph("Monto de inicio: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + inicio = new BigDecimal(res[13] == null ? "0.0" : res[13].toString()); + cellGen = new PdfPCell(new Paragraph(res[13] != null ? "$" + res[13].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph("Monto recibido por transferencia: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + transRec = new BigDecimal(res[12] == null ? "0.0" : res[12].toString()); + cellGen = new PdfPCell(new Paragraph(res[12] != null ? "$" + res[12].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + + cellGen = new PdfPCell(new Paragraph("Entrega de préstamos: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + entrPrestamos = new BigDecimal(res[15] == null ? "0.0" : res[15].toString()); + cellGen = new PdfPCell(new Paragraph(res[15] != null ? "$" + res[15].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph("Gastos: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + gastos = new BigDecimal(res[14] == null ? "0.0" : res[14].toString()); + cellGen = new PdfPCell(new Paragraph(res[14] != null ? "$" + res[14].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + + cellGen = new PdfPCell(new Paragraph("Depósitos: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + depositos = new BigDecimal(res[10] == null ? "0.0" : res[10].toString()); + cellGen = new PdfPCell(new Paragraph(res[10] != null ? "$" + res[10].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + totalesRep = totalesRep.add(recuperado).subtract(transEnv).add(transRec).add(inicio).subtract(gastos).subtract(entrPrestamos); + cellGen = new PdfPCell(new Paragraph("Total: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph(totalesRep != null ? "$" + totalesRep.toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + + cellGen = new PdfPCell(new Paragraph("Monto Esperado: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph(totales.getTotal() != null ? "$" + totales.getTotal().toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph("Monto Entregado: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph(new BigDecimal(total) != null ? "$" + new BigDecimal(total).toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + + document.add(tableGen); + document.add(Chunk.NEWLINE); + + PdfPTable table = new PdfPTable(7); + table.setTotalWidth(new float[]{60, 60, 60, 60, 170, 60, 100}); + + table.setLockedWidth(true); + PdfPCell cell = new PdfPCell(new Paragraph("Detalles del corte", + FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.WHITE))); + + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setBackgroundColor(new BaseColor(4, 193, 10)); + cell.setColspan(7); + table.addCell(cell); + + cell = new PdfPCell(new Paragraph("Detalle", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setColspan(1); + table.addCell(cell); + + cell = new PdfPCell(new Paragraph("P. anterior", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setColspan(1); + table.addCell(cell); + + cell = new PdfPCell(new Paragraph("C. apertura", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setColspan(1); + table.addCell(cell); + + cell = new PdfPCell(new Paragraph("Monto", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setColspan(1); + table.addCell(cell); + + cell = new PdfPCell(new Paragraph("Saldo insoluto", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setColspan(1); + table.addCell(cell); + + cell = new PdfPCell(new Paragraph("Tipo", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setColspan(1); + table.addCell(cell); + + cell = new PdfPCell(new Paragraph("Fecha", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setColspan(1); + table.addCell(cell); + + for (Object result : results) { + Object[] tmp = (Object[]) result; + // Detalle + cell = new PdfPCell(new Paragraph(tmp[0] == null ? "" : tmp[0].toString(), + FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(1); table.addCell(cell); - - cell = new PdfPCell(new Paragraph("P. anterior", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); + //Préstamo anterior + cell = new PdfPCell(new Paragraph(tmp[6] != null ? "$" + tmp[6].toString() : "$0.00", + FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(1); table.addCell(cell); - - cell = new PdfPCell(new Paragraph("C. apertura", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); + // Comisión por apertura + cell = new PdfPCell(new Paragraph(tmp[5] != null ? "$" + tmp[5].toString() : "$0.00", + FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(1); table.addCell(cell); - - cell = new PdfPCell(new Paragraph("Monto", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); + // Monto + cell = new PdfPCell(new Paragraph(tmp[1] != null ? "$" + tmp[1].toString() : "$0.00", + FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(1); table.addCell(cell); - - cell = new PdfPCell(new Paragraph("Saldo insoluto", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); + // Saldo insoluto + cell = new PdfPCell(new Paragraph(tmp[3] != null ? "$" + tmp[3].toString() : "$0.00", + FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(1); table.addCell(cell); - - cell = new PdfPCell(new Paragraph("Tipo", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); + // Tipo + cell = new PdfPCell(new Paragraph(tmp[2] == null ? "" : tmp[2].toString(), + FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(1); table.addCell(cell); - - cell = new PdfPCell(new Paragraph("Fecha", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); + // Fecha + cell = new PdfPCell(new Paragraph(tmp[4] == null ? "" : formatter2.format((Date) tmp[4]), + FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(1); table.addCell(cell); + } - for(Object result : results){ - Object[] tmp = (Object[]) result; - // Detalle - cell = new PdfPCell(new Paragraph(tmp[0] == null ? "" : tmp[0].toString(), - FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_LEFT); - cell.setColspan(1); - table.addCell(cell); - //Préstamo anterior - cell = new PdfPCell(new Paragraph(tmp[6] != null ? "$" + tmp[6].toString() : "$0.00", - FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_LEFT); - cell.setColspan(1); - table.addCell(cell); - // Comisión por apertura - cell = new PdfPCell(new Paragraph(tmp[5] != null ? "$" + tmp[5].toString() : "$0.00", - FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_LEFT); - cell.setColspan(1); - table.addCell(cell); - // Monto - cell = new PdfPCell(new Paragraph(tmp[1] != null ? "$" + tmp[1].toString() : "$0.00", - FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_LEFT); - cell.setColspan(1); - table.addCell(cell); - // Saldo insoluto - cell = new PdfPCell(new Paragraph(tmp[3] != null ? "$" + tmp[3].toString() : "$0.00", - FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_LEFT); - cell.setColspan(1); - table.addCell(cell); - // Tipo - cell = new PdfPCell(new Paragraph(tmp[2] == null ? "" : tmp[2].toString(), - FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_LEFT); - cell.setColspan(1); - table.addCell(cell); - // Fecha - cell = new PdfPCell(new Paragraph(tmp[4] == null ? "" : formatter2.format((Date) tmp[4]), - FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_LEFT); - cell.setColspan(1); - table.addCell(cell); - } + document.add(table); - document.add(table); + document.add(Chunk.NEWLINE); + document.add(Chunk.NEWLINE); + document.add(Chunk.NEWLINE); + document.add(Chunk.NEWLINE); - document.add(Chunk.NEWLINE); - document.add(Chunk.NEWLINE); - document.add(Chunk.NEWLINE); - document.add(Chunk.NEWLINE); + document.add(new Paragraph(" __________________________ __________________________")); + document.add(new Paragraph(" Firma Nombre y firma cajero responsable")); + document.add(new Paragraph(" " + res[8] == null ? "" : res[8].toString())); - document.add(new Paragraph(" __________________________ __________________________")); - document.add(new Paragraph(" Firma Nombre y firma cajero responsable")); - document.add(new Paragraph(" " + res[8] == null ? "" : res[8].toString())); + } catch (Exception e) { + System.out.print("Error 1: " + e.getMessage()); + } - } catch (Exception e) { - System.out.print("Error 1: " + e.getMessage()); - } + document.close(); + FacesContext context = FacesContext.getCurrentInstance(); + Object response = context.getExternalContext().getResponse(); + if (response instanceof HttpServletResponse) { + HttpServletResponse hrs = (HttpServletResponse) response; + hrs.setContentType("application/pdf"); + //hrs.setHeader("Content-disposition", "attachment"); + hrs.setHeader("Content-disposition", "attachment;filename=corte_del_día.pdf"); + hrs.setContentLength(baos.size()); + try { + ServletOutputStream out = hrs.getOutputStream(); + baos.writeTo(out); + out.flush(); - document.close(); - FacesContext context = FacesContext.getCurrentInstance(); - Object response = context.getExternalContext().getResponse(); - if (response instanceof HttpServletResponse) { - HttpServletResponse hrs = (HttpServletResponse) response; - hrs.setContentType("application/pdf"); - //hrs.setHeader("Content-disposition", "attachment"); - hrs.setHeader("Content-disposition", "attachment;filename=corte_del_día.pdf"); - hrs.setContentLength(baos.size()); - try { - ServletOutputStream out = hrs.getOutputStream(); - baos.writeTo(out); - out.flush(); + } catch (IOException e) { + System.out.print("Error 2: " + e.getMessage()); + } + context.responseComplete(); + } + } - } catch (IOException e) { - System.out.print("Error 2: " + e.getMessage()); - } - context.responseComplete(); - } - } - - public void imprimirHistory() { - - Document document = new Document(PageSize.LETTER); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - PdfWriter.getInstance(document, baos); - List results = new ArrayList<>(); - results = closingDayCtrl.findDetailsFromClosingDayHisotry(selectedClosingDay.getId()); - document.open(); - DateFormat formatter2 = new SimpleDateFormat("dd/MM/yyyy HH:mm:SS"); - formatter2.setTimeZone(TimeZone.getTimeZone("GMT-6")); + public void imprimirHistory() { - Object[] res = (Object[]) results.get(0); - BigDecimal totalesRep = BigDecimal.ZERO; - BigDecimal recuperado = BigDecimal.ZERO; - BigDecimal transEnv = BigDecimal.ZERO; - BigDecimal transRec = BigDecimal.ZERO; - BigDecimal inicio = BigDecimal.ZERO; - BigDecimal gastos = BigDecimal.ZERO; - BigDecimal depositos = BigDecimal.ZERO; - BigDecimal entrPrestamos = BigDecimal.ZERO; - - Paragraph printDate = new Paragraph("Fecha de impresión: " +res[3], FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.DARK_GRAY)); - printDate.setAlignment(Element.ALIGN_RIGHT); - document.add(printDate); + Document document = new Document(PageSize.LETTER); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + PdfWriter.getInstance(document, baos); + List results = new ArrayList<>(); + results = closingDayCtrl.findDetailsFromClosingDayHisotry(selectedClosingDay.getId()); + document.open(); + DateFormat formatter2 = new SimpleDateFormat("dd/MM/yyyy HH:mm:SS"); + formatter2.setTimeZone(TimeZone.getTimeZone("GMT-6")); + + Object[] res = (Object[]) results.get(0); + BigDecimal totalesRep = BigDecimal.ZERO; + BigDecimal recuperado = BigDecimal.ZERO; + BigDecimal transEnv = BigDecimal.ZERO; + BigDecimal transRec = BigDecimal.ZERO; + BigDecimal inicio = BigDecimal.ZERO; + BigDecimal gastos = BigDecimal.ZERO; + BigDecimal depositos = BigDecimal.ZERO; + BigDecimal entrPrestamos = BigDecimal.ZERO; + + Paragraph printDate = new Paragraph("Fecha de impresión: " + res[3], FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.DARK_GRAY)); + printDate.setAlignment(Element.ALIGN_RIGHT); + document.add(printDate); // Image imagen = Image.getInstance("other sources/resources/serenity-layout/images/apc_card.png"); // imagen.scaleAbsoluteWidth(100f); // document.add(imagen); - - Paragraph title = new Paragraph("Corte del día", FontFactory.getFont("arial", 18, Font.BOLD, BaseColor.DARK_GRAY)); - title.setAlignment(Element.ALIGN_CENTER); - document.add(title); - - document.add(Chunk.NEWLINE); - - - - - PdfPTable tableGen = new PdfPTable(4); - tableGen.setWidthPercentage(100); - tableGen.setTotalWidth(new float[]{100f, 170f, 140f, 150f}); - tableGen.setLockedWidth(true); - - PdfPCell cellGen = new PdfPCell(new Paragraph("Asesor: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph(res[6] == null ? "" : res[6].toString(), - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(3); - tableGen.addCell(cellGen); - - cellGen = new PdfPCell(new Paragraph("Monto recuperado: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - recuperado = new BigDecimal(res[7] == null ? "0.0" : res[7].toString()); - cellGen = new PdfPCell(new Paragraph(res[7] != null ? "$" + res[7].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph("Monto enviado por transferencia: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - transEnv = new BigDecimal(res[11] == null ? "0.0" : res[11].toString()); - cellGen = new PdfPCell(new Paragraph(res[11] != null ? "$" + res[11].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - - cellGen = new PdfPCell(new Paragraph("Monto de inicio: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - inicio = new BigDecimal(res[10] == null ? "0.0" : res[10].toString()); - cellGen = new PdfPCell(new Paragraph(res[10] != null ? "$" + res[10].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph("Monto recibido por transferencia: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - transRec = new BigDecimal(res[11] == null ? "0.0" : res[11].toString()); - cellGen = new PdfPCell(new Paragraph(res[11] != null ? "$" + res[11].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - - cellGen = new PdfPCell(new Paragraph("Entrega de préstamos: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - entrPrestamos = new BigDecimal(res[13] == null ? "0.0" : res[13].toString()); - cellGen = new PdfPCell(new Paragraph(res[13] != null ? "$" + res[13].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph("Gastos: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - gastos = new BigDecimal(res[12] == null ? "0.0" : res[12].toString()); - cellGen = new PdfPCell(new Paragraph(res[12] != null ? "$" + res[12].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - - cellGen = new PdfPCell(new Paragraph("Depósitos: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - depositos = new BigDecimal(res[8] == null ? "0.0" : res[8].toString()); - cellGen = new PdfPCell(new Paragraph(res[8] != null ? "$" + res[8].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - totalesRep = totalesRep.add(recuperado).subtract(transEnv).add(transRec).add(inicio).subtract(gastos).subtract(entrPrestamos); - cellGen = new PdfPCell(new Paragraph("Total: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph(totalesRep != null ? "$" + totalesRep.toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - - - - cellGen = new PdfPCell(new Paragraph("Monto Esperado: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph(res[4] != null ? "$" + res[4].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph("Monto Entregado: ", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - cellGen = new PdfPCell(new Paragraph(res[5] != null ? "$" + res[5].toString() : "$0.00", - FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); - cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); - cellGen.setBorder(0); - cellGen.setColspan(1); - tableGen.addCell(cellGen); - - document.add(tableGen); - document.add(Chunk.NEWLINE); - - PdfPTable table = new PdfPTable(7); - table.setTotalWidth(new float[]{60, 60, 60, 60, 170, 60, 100}); + Paragraph title = new Paragraph("Corte del día", FontFactory.getFont("arial", 18, Font.BOLD, BaseColor.DARK_GRAY)); + title.setAlignment(Element.ALIGN_CENTER); + document.add(title); - table.setLockedWidth(true); - PdfPCell cell = new PdfPCell(new Paragraph("Detalles del corte", - FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.WHITE))); + document.add(Chunk.NEWLINE); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - cell.setBackgroundColor(new BaseColor( 4, 193, 10 )); - cell.setColspan(7); + PdfPTable tableGen = new PdfPTable(4); + tableGen.setWidthPercentage(100); + tableGen.setTotalWidth(new float[]{100f, 170f, 140f, 150f}); + tableGen.setLockedWidth(true); + + PdfPCell cellGen = new PdfPCell(new Paragraph("Asesor: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph(res[6] == null ? "" : res[6].toString(), + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(3); + tableGen.addCell(cellGen); + + cellGen = new PdfPCell(new Paragraph("Monto recuperado: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + recuperado = new BigDecimal(res[7] == null ? "0.0" : res[7].toString()); + cellGen = new PdfPCell(new Paragraph(res[7] != null ? "$" + res[7].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph("Monto enviado por transferencia: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + transEnv = new BigDecimal(res[11] == null ? "0.0" : res[11].toString()); + cellGen = new PdfPCell(new Paragraph(res[11] != null ? "$" + res[11].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + + cellGen = new PdfPCell(new Paragraph("Monto de inicio: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + inicio = new BigDecimal(res[10] == null ? "0.0" : res[10].toString()); + cellGen = new PdfPCell(new Paragraph(res[10] != null ? "$" + res[10].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph("Monto recibido por transferencia: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + transRec = new BigDecimal(res[11] == null ? "0.0" : res[11].toString()); + cellGen = new PdfPCell(new Paragraph(res[11] != null ? "$" + res[11].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + + cellGen = new PdfPCell(new Paragraph("Entrega de préstamos: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + entrPrestamos = new BigDecimal(res[13] == null ? "0.0" : res[13].toString()); + cellGen = new PdfPCell(new Paragraph(res[13] != null ? "$" + res[13].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph("Gastos: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + gastos = new BigDecimal(res[12] == null ? "0.0" : res[12].toString()); + cellGen = new PdfPCell(new Paragraph(res[12] != null ? "$" + res[12].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + + cellGen = new PdfPCell(new Paragraph("Depósitos: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + depositos = new BigDecimal(res[8] == null ? "0.0" : res[8].toString()); + cellGen = new PdfPCell(new Paragraph(res[8] != null ? "$" + res[8].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + totalesRep = totalesRep.add(recuperado).subtract(transEnv).add(transRec).add(inicio).subtract(gastos).subtract(entrPrestamos); + cellGen = new PdfPCell(new Paragraph("Total: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph(totalesRep != null ? "$" + totalesRep.toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + + cellGen = new PdfPCell(new Paragraph("Monto Esperado: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph(res[4] != null ? "$" + res[4].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph("Monto Entregado: ", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + cellGen = new PdfPCell(new Paragraph(res[5] != null ? "$" + res[5].toString() : "$0.00", + FontFactory.getFont("arial", 8, Font.PLAIN, BaseColor.BLACK))); + cellGen.setHorizontalAlignment(Element.ALIGN_LEFT); + cellGen.setBorder(0); + cellGen.setColspan(1); + tableGen.addCell(cellGen); + + document.add(tableGen); + document.add(Chunk.NEWLINE); + + PdfPTable table = new PdfPTable(7); + table.setTotalWidth(new float[]{60, 60, 60, 60, 170, 60, 100}); + + table.setLockedWidth(true); + PdfPCell cell = new PdfPCell(new Paragraph("Detalles del corte", + FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.WHITE))); + + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setBackgroundColor(new BaseColor(4, 193, 10)); + cell.setColspan(7); + table.addCell(cell); + + cell = new PdfPCell(new Paragraph("Detalle", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setColspan(1); + table.addCell(cell); + + cell = new PdfPCell(new Paragraph("P. anterior", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setColspan(1); + table.addCell(cell); + + cell = new PdfPCell(new Paragraph("C. apertura", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setColspan(1); + table.addCell(cell); + + cell = new PdfPCell(new Paragraph("Monto", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setColspan(1); + table.addCell(cell); + + cell = new PdfPCell(new Paragraph("Saldo insoluto", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setColspan(1); + table.addCell(cell); + + cell = new PdfPCell(new Paragraph("Tipo", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setColspan(1); + table.addCell(cell); + + cell = new PdfPCell(new Paragraph("Fecha", + FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell.setColspan(1); + table.addCell(cell); + + for (Object result : results) { + Object[] tmp = (Object[]) result; + // Detalle + cell = new PdfPCell(new Paragraph(tmp[0] == null ? "" : tmp[0].toString(), + FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); + cell.setColspan(1); table.addCell(cell); - - cell = new PdfPCell(new Paragraph("Detalle", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell = new PdfPCell(new Paragraph("", + FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); + cell.setColspan(1); + table.addCell(cell); + cell = new PdfPCell(new Paragraph("", + FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(1); table.addCell(cell); - cell = new PdfPCell(new Paragraph("P. anterior", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); + // Monto + cell = new PdfPCell(new Paragraph(tmp[1] != null ? "$" + tmp[1].toString() : "$0.00", + FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(1); table.addCell(cell); - cell = new PdfPCell(new Paragraph("C. apertura", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); + cell = new PdfPCell(new Paragraph("", + FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(1); table.addCell(cell); - cell = new PdfPCell(new Paragraph("Monto", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); + // Tipo + cell = new PdfPCell(new Paragraph(tmp[2] == null ? "" : tmp[2].toString(), + FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(1); table.addCell(cell); - - cell = new PdfPCell(new Paragraph("Saldo insoluto", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); + // Fecha + cell = new PdfPCell(new Paragraph(tmp[15] == null ? "" : formatter2.format((Date) tmp[15]), + FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); + cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(1); table.addCell(cell); + } - cell = new PdfPCell(new Paragraph("Tipo", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - cell.setColspan(1); - table.addCell(cell); + document.add(table); - cell = new PdfPCell(new Paragraph("Fecha", - FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_CENTER); - cell.setColspan(1); - table.addCell(cell); + document.add(Chunk.NEWLINE); + document.add(Chunk.NEWLINE); + document.add(Chunk.NEWLINE); + document.add(Chunk.NEWLINE); - for(Object result : results){ - Object[] tmp = (Object[]) result; - // Detalle - cell = new PdfPCell(new Paragraph(tmp[0] == null ? "" : tmp[0].toString(), - FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_LEFT); - cell.setColspan(1); - table.addCell(cell); - cell = new PdfPCell(new Paragraph( "", - FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_LEFT); - cell.setColspan(1); - table.addCell(cell); - cell = new PdfPCell(new Paragraph( "", - FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_LEFT); - cell.setColspan(1); - table.addCell(cell); - - - // Monto - cell = new PdfPCell(new Paragraph(tmp[1] != null ? "$" + tmp[1].toString() : "$0.00", - FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_LEFT); - cell.setColspan(1); - table.addCell(cell); - - cell = new PdfPCell(new Paragraph( "", - FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_LEFT); - cell.setColspan(1); - table.addCell(cell); - - // Tipo - cell = new PdfPCell(new Paragraph(tmp[2] == null ? "" : tmp[2].toString(), - FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_LEFT); - cell.setColspan(1); - table.addCell(cell); - // Fecha - cell = new PdfPCell(new Paragraph(tmp[15] == null ? "" : formatter2.format((Date) tmp[15]), - FontFactory.getFont("arial", 6, Font.PLAIN, BaseColor.BLACK))); - cell.setHorizontalAlignment(Element.ALIGN_LEFT); - cell.setColspan(1); - table.addCell(cell); - } - - document.add(table); - - document.add(Chunk.NEWLINE); - document.add(Chunk.NEWLINE); - document.add(Chunk.NEWLINE); - document.add(Chunk.NEWLINE); + document.add(new Paragraph(" __________________________ __________________________")); + document.add(new Paragraph(" Firma Nombre y firma cajero responsable")); + document.add(new Paragraph(" " + res[6] == null ? "" : res[6].toString())); - document.add(new Paragraph(" __________________________ __________________________")); - document.add(new Paragraph(" Firma Nombre y firma cajero responsable")); - document.add(new Paragraph(" " + res[6] == null ? "" : res[6].toString())); + } catch (Exception e) { + System.out.print("Error 1: " + e.getMessage()); + } - } catch (Exception e) { - System.out.print("Error 1: " + e.getMessage()); - } + document.close(); + FacesContext context = FacesContext.getCurrentInstance(); + Object response = context.getExternalContext().getResponse(); + if (response instanceof HttpServletResponse) { + HttpServletResponse hrs = (HttpServletResponse) response; + hrs.setContentType("application/pdf"); + //hrs.setHeader("Content-disposition", "attachment"); + hrs.setHeader("Content-disposition", "attachment;filename=corte_del_día.pdf"); + hrs.setContentLength(baos.size()); + try { + ServletOutputStream out = hrs.getOutputStream(); + baos.writeTo(out); + out.flush(); - document.close(); - FacesContext context = FacesContext.getCurrentInstance(); - Object response = context.getExternalContext().getResponse(); - if (response instanceof HttpServletResponse) { - HttpServletResponse hrs = (HttpServletResponse) response; - hrs.setContentType("application/pdf"); - //hrs.setHeader("Content-disposition", "attachment"); - hrs.setHeader("Content-disposition", "attachment;filename=corte_del_día.pdf"); - hrs.setContentLength(baos.size()); - try { - ServletOutputStream out = hrs.getOutputStream(); - baos.writeTo(out); - out.flush(); + } catch (IOException e) { + System.out.print("Error 2: " + e.getMessage()); + } + context.responseComplete(); + } + } - } catch (IOException e) { - System.out.print("Error 2: " + e.getMessage()); - } - context.responseComplete(); - } - } + @Override + public void editRow(RowEditEvent event) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } - @Override - public void editRow(RowEditEvent event) { - 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 onRowCancel(RowEditEvent event) { - 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)); + } - @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 addRow() { + if (userId.equalsIgnoreCase("")) { + FacesMessage msg = new FacesMessage("ERROR", "Debes de elegir un usuario para poder generar el corte."); + FacesContext.getCurrentInstance().addMessage(null, msg); + imprimirStatus = true; + userId = ""; + return; + } + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.set(Calendar.HOUR_OF_DAY, 12); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); - @Override - public void addRow() { - if (userId.equalsIgnoreCase("")) { - FacesMessage msg = new FacesMessage("ERROR", "Debes de elegir un usuario para poder generar el corte."); + if (!(dayOfWeek == Calendar.SUNDAY) && !(userId.equalsIgnoreCase("aad0c673-eb93-11ea-b7e1-02907d0fb4e6"))) { + if (totalCustomerWithOutAction.compareTo(new Long(0)) == 1) { + FacesMessage msg = new FacesMessage("ERROR", "El asesor debe de realizar una acción en todos sus préstamos."); FacesContext.getCurrentInstance().addMessage(null, msg); - imprimirStatus = true; - userId = ""; return; - } - Calendar calendar = Calendar.getInstance(); - calendar.setTime(new Date()); - calendar.set(Calendar.HOUR_OF_DAY, 12); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MILLISECOND, 0); - int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); + } + } - if (!(dayOfWeek == Calendar.SUNDAY) && !(userId.equalsIgnoreCase("aad0c673-eb93-11ea-b7e1-02907d0fb4e6"))) { - if (totalCustomerWithOutAction.compareTo(new Long(0)) == 1) { - FacesMessage msg = new FacesMessage("ERROR", "El asesor debe de realizar una acción en todos sus préstamos."); - FacesContext.getCurrentInstance().addMessage(null, msg); - return; + if (totales.getTotal().compareTo(new BigDecimal(total)) != 0) { + if (comments == null || comments.trim().equals("")) { + FacesMessage msg = new FacesMessage("ERROR", "Es necesario capturar las observaciones."); + FacesContext.getCurrentInstance().addMessage(null, msg); + return; + } + } + + User userData = null; + for (User us : user) { + if (us.getId().equalsIgnoreCase(userId)) { + userData = us; + break; + } + } + + ClosingDay closingSave = new ClosingDay(); + closingSave.setActiveStatus(ActiveStatus.ENEBLED); + closingSave.setAmountExpected(totales.getTotal()); + closingSave.setAmountPaid(new BigDecimal(total)); + closingSave.setOffice(new Office(getLoggedUser().getOffice().getId())); + closingSave.setUser(new User(userId)); + closingSave.setCreatedBy(getLoggedUser().getId()); + closingSave.setCreatedOn(new Date()); + closingSave.setComments(comments); + closingSave.setRouteCtlg(userData.getHumanResource().getHumanResourceHasRoutes().get(0).getRouteCtlg()); + if (closingDayCtrl.saveClosingDay(closingSave)) { + if (closingDetail != null && !closingDetail.isEmpty()) { + List detail = new ArrayList(); + + for (ClosingDailyDetailFromUserByLastClosingDayView info : closingDetail) { + ClosingDayDetail detailInfo = new ClosingDayDetail(); + detailInfo.setAmount(info.getAmount()); + detailInfo.setClosingDay(closingSave); + detailInfo.setComments(info.getComments()); + detailInfo.setCreatedBy(getLoggedUser().getId()); + detailInfo.setCreatedOn(new Date()); + detailInfo.setDateDetail(info.getCreatedOn()); + detailInfo.setType(info.getType()); + detail.add(detailInfo); } - } - - if (totales.getTotal().compareTo(new BigDecimal(total)) != 0) { - if (comments == null || comments.trim().equals("")) { - FacesMessage msg = new FacesMessage("ERROR", "Es necesario capturar las observaciones."); - FacesContext.getCurrentInstance().addMessage(null, msg); - return; + closingDayCtrl.saveClosingDayDetail(detail); + } + + } + getResumen(); + totales = new TotalCashByLastClosingDayView(); + totales.setMoneyDaily(BigDecimal.ZERO); + totales.setPaymentDaily(BigDecimal.ZERO); + totales.setTransferReceiver(BigDecimal.ZERO); + totales.setTransferSender(BigDecimal.ZERO); + totales.setDelivery(BigDecimal.ZERO); + totales.setTotal(BigDecimal.ZERO); + totales.setTransferPending(BigDecimal.ZERO); + totales.setOtherExpense(BigDecimal.ZERO); + totales.setDepositDaily(BigDecimal.ZERO); + total = BigDecimal.ZERO.toString(); + totalBox = BigDecimal.ZERO; + totalCustomerWithOutAction = new Long(0); + totalBox = genericCtrl.findAllSmallBox(getLoggedUser().getOffice().getId()); + comments = ""; + closingDetail.clear(); + paymentoZeroDetail.clear(); + FacesMessage msg = new FacesMessage("Nuevo corte registrado", "Se agregó correctamente"); + FacesContext.getCurrentInstance().addMessage(null, msg); + } + + @Override + public void deleteRow() { + try { + if (closingDayCtrl.existStableSmallBoxByCreatedOn(selectedClosingDay.getCreatedOn())) { + showMessage(FacesMessage.SEVERITY_WARN, "Corte del día", "No se puede borrar porque ya se realizo el cuadre de caja chica del día."); + } else { + boolean delete = true; + delete = selectedClosingDay.getActiveStatus() == ActiveStatus.ENEBLED ? true : false; + + if (delete) { + Bitacora bitacora = new Bitacora(); + ClosingDay closing = closingDayCtrl.getClosingDayById(selectedClosingDay.getId()); + bitacora.setAction("Eliminar corte del día"); + bitacora.setCommentsUser(commentsBitacora); + bitacora.setCreatedBy(getLoggedUser().getUser().getId()); + bitacora.setCreatedOn(new Date()); + bitacora.setNameUser(getLoggedUser().getUser().getUserName()); + bitacora.setOffice(new Office(getLoggedUser().getOffice().getId())); + bitacora.setDescription("Se eliminó el corte del asesor " + closing.getUser().getUserName() + " con monto $" + + selectedClosingDay.getAmountPaid() + " y fecha " + closing.getCreatedOn()); + closingDayCtrl.updateClosingDayByStatus(ActiveStatus.DISABLED, selectedClosingDay.getId(), getLoggedUser().getUser().getId()); + //closingDay.remove(selectedClosingDay); + searchHistoricalAction(); + bitacoraCtrl.saveBitacora(bitacora); + commentsBitacora = ""; + selectedClosingDay = null; + showMessage(FacesMessage.SEVERITY_INFO, "Corte del día", "Se eliminó correctamente."); } - } - - User userData = null; - for(User us : user){ - if(us.getId().equalsIgnoreCase(userId)){ - userData = us; - break; - } - } - - ClosingDay closingSave = new ClosingDay(); - closingSave.setActiveStatus(ActiveStatus.ENEBLED); - closingSave.setAmountExpected(totales.getTotal()); - closingSave.setAmountPaid(new BigDecimal(total)); - closingSave.setOffice(new Office(getLoggedUser().getOffice().getId())); - closingSave.setUser(new User(userId)); - closingSave.setCreatedBy(getLoggedUser().getId()); - closingSave.setCreatedOn(new Date()); - closingSave.setComments(comments); - closingSave.setRouteCtlg(userData.getHumanResource().getHumanResourceHasRoutes().get(0).getRouteCtlg()); - if (closingDayCtrl.saveClosingDay(closingSave)) { - if (closingDetail != null && !closingDetail.isEmpty()) { - List detail = new ArrayList(); - - for (ClosingDailyDetailFromUserByCurdateView info : closingDetail) { - ClosingDayDetail detailInfo = new ClosingDayDetail(); - detailInfo.setAmount(info.getAmount()); - detailInfo.setClosingDay(closingSave); - detailInfo.setComments(info.getComments()); - detailInfo.setCreatedBy(getLoggedUser().getId()); - detailInfo.setCreatedOn(new Date()); - detailInfo.setDateDetail(info.getCreatedOn()); - detailInfo.setType(info.getType()); - detail.add(detailInfo); - } - closingDayCtrl.saveClosingDayDetail(detail); - } - - } - getResumen(); - totales = new TotalCashByCurdateView(); - totales.setMoneyDaily(BigDecimal.ZERO); - totales.setPaymentDaily(BigDecimal.ZERO); - totales.setTransferReceiver(BigDecimal.ZERO); - totales.setTransferSender(BigDecimal.ZERO); - totales.setDelivery(BigDecimal.ZERO); - totales.setTotal(BigDecimal.ZERO); - totales.setTransferPending(BigDecimal.ZERO); - totales.setOtherExpense(BigDecimal.ZERO); - totales.setDepositDaily(BigDecimal.ZERO); - total = BigDecimal.ZERO.toString(); - totalBox = BigDecimal.ZERO; - totalCustomerWithOutAction = new Long(0); - totalBox = genericCtrl.findAllSmallBox(getLoggedUser().getOffice().getId()); - comments = ""; - closingDetail.clear(); - paymentoZeroDetail.clear(); - FacesMessage msg = new FacesMessage("Nuevo corte registrado", "Se agregó correctamente"); - FacesContext.getCurrentInstance().addMessage(null, msg); - } - - @Override - public void deleteRow() { - try { - if (closingDayCtrl.existStableSmallBoxByCreatedOn(selectedClosingDay.getCreatedOn())) { - showMessage(FacesMessage.SEVERITY_WARN, "Corte del día", "No se puede borrar porque ya se realizo el cuadre de caja chica del día."); - } else { - boolean delete = true; - delete = selectedClosingDay.getActiveStatus() == ActiveStatus.ENEBLED ? true : false; - - if (delete) { - Bitacora bitacora = new Bitacora(); - ClosingDay closing = closingDayCtrl.getClosingDayById(selectedClosingDay.getId()); - bitacora.setAction("Eliminar corte del día"); - bitacora.setCommentsUser(commentsBitacora); - bitacora.setCreatedBy(getLoggedUser().getUser().getId()); - bitacora.setCreatedOn(new Date()); - bitacora.setNameUser(getLoggedUser().getUser().getUserName()); - bitacora.setOffice(new Office(getLoggedUser().getOffice().getId())); - bitacora.setDescription("Se eliminó el corte del asesor " + closing.getUser().getUserName() + " con monto $" - + selectedClosingDay.getAmountPaid() + " y fecha " + closing.getCreatedOn()); - closingDayCtrl.updateClosingDayByStatus(ActiveStatus.DISABLED, selectedClosingDay.getId(), getLoggedUser().getUser().getId()); - //closingDay.remove(selectedClosingDay); - searchHistoricalAction(); - bitacoraCtrl.saveBitacora(bitacora); - commentsBitacora = ""; - selectedClosingDay = null; - showMessage(FacesMessage.SEVERITY_INFO, "Corte del día", "Se eliminó correctamente."); - } - } - } catch (Exception e) { - } - } - - public ClosingDayController getClosingDayCtrl() { - return closingDayCtrl; - } - - public void setClosingDayCtrl(ClosingDayController closingDayCtrl) { - this.closingDayCtrl = closingDayCtrl; - } - - public List getClosingDay() { - return closingDay; - } - - public void setClosingDay(List closingDay) { - this.closingDay = closingDay; - } - - public List getUser() { - return user; - } - - public void setUser(List user) { - this.user = user; - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public String getAmount() { - return amount; - } - - public void setAmount(String amount) { - this.amount = amount; - } - - public ClosingDay getSelectedClosingDay() { - return selectedClosingDay; - } - - public void setSelectedClosingDay(ClosingDay selectedClosingDay) { - this.selectedClosingDay = selectedClosingDay; - } - - public TotalCashByCurdateView getTotales() { - return totales; - } - - public void setTotales(TotalCashByCurdateView totales) { - this.totales = totales; - } - - public String getTotal() { - return total; - } - - public void setTotal(String total) { - this.total = total; - } - - public BigDecimal getTotalAmount() { - return totalAmount; - } - - public void setTotalAmount(BigDecimal totalAmount) { - this.totalAmount = totalAmount; - } - - public BigDecimal getTotalTransferSender() { - return totalTransferSender; - } - - public void setTotalTransferSender(BigDecimal totalTransferSender) { - this.totalTransferSender = totalTransferSender; - } - - public BigDecimal getTotalTransferReceiver() { - return totalTransferReceiver; - } - - public void setTotalTransferReceiver(BigDecimal totalTransferReceiver) { - this.totalTransferReceiver = totalTransferReceiver; - } - - public BigDecimal getTotalMoneyDaily() { - return totalMoneyDaily; - } - - public void setTotalMoneyDaily(BigDecimal totalMoneyDaily) { - this.totalMoneyDaily = totalMoneyDaily; - } + } + } catch (Exception e) { + } + } - public BigDecimal getTotalDelivery() { - return totalDelivery; - } + public ClosingDayController getClosingDayCtrl() { + return closingDayCtrl; + } - public void setTotalDelivery(BigDecimal totalDelivery) { - this.totalDelivery = totalDelivery; - } + public void setClosingDayCtrl(ClosingDayController closingDayCtrl) { + this.closingDayCtrl = closingDayCtrl; + } - public BigDecimal getTotalFinal() { - return totalFinal; - } + public List getClosingDay() { + return closingDay; + } - public void setTotalFinal(BigDecimal totalFinal) { - this.totalFinal = totalFinal; - } + public void setClosingDay(List closingDay) { + this.closingDay = closingDay; + } - public BigDecimal getTotalCaja() { - return totalCaja; - } + public List getUser() { + return user; + } - public void setTotalCaja(BigDecimal totalCaja) { - this.totalCaja = totalCaja; - } + public void setUser(List user) { + this.user = user; + } - public BigDecimal getTotalOtherExpense() { - return totalOtherExpense; - } + public String getUserId() { + return userId; + } - public void setTotalOtherExpense(BigDecimal totalOtherExpense) { - this.totalOtherExpense = totalOtherExpense; - } - - public String getComments() { - return comments; - } - - public void setComments(String comments) { - this.comments = comments; - } - - public GenericController getGenericCtrl() { - return genericCtrl; - } - - public void setGenericCtrl(GenericController genericCtrl) { - this.genericCtrl = genericCtrl; - } + public void setUserId(String userId) { + this.userId = userId; + } - public List getClosingDetail() { - return closingDetail; - } + public String getAmount() { + return amount; + } - public void setClosingDetail(List closingDetail) { - this.closingDetail = closingDetail; - } - - public BigDecimal getTotalBox() { - return totalBox; - } - - public void setTotalBox(BigDecimal totalBox) { - this.totalBox = totalBox; - } - - public Long getTotalCustomerWithOutAction() { - return totalCustomerWithOutAction; - } - - public void setTotalCustomerWithOutAction(Long totalCustomerWithOutAction) { - this.totalCustomerWithOutAction = totalCustomerWithOutAction; - } - - public List getPaymentoZeroDetail() { - return paymentoZeroDetail; - } - - public void setPaymentoZeroDetail(List paymentoZeroDetail) { - this.paymentoZeroDetail = paymentoZeroDetail; - } - - public BigDecimal getDeposit() { - return deposit; - } - - public void setDeposit(BigDecimal deposit) { - this.deposit = deposit; - } - - public String getCommentsBitacora() { - return commentsBitacora; - } - - public void setCommentsBitacora(String commentsBitacora) { - this.commentsBitacora = commentsBitacora; - } - - public LoanController getLoanCtrl() { - return loanCtrl; - } - - public void setLoanCtrl(LoanController loanCtrl) { - this.loanCtrl = loanCtrl; - } - - public boolean getImprimirStatus() { - return imprimirStatus; - } - - public void setImprimirStatus(boolean imprimirStatus) { - this.imprimirStatus = imprimirStatus; - } - - - - private ClosingDayController closingDayCtrl; - private GenericController genericCtrl; - private BitacoraController bitacoraCtrl; - private LoanController loanCtrl; - - private List closingDay; - private List user; - - private String userId; - private String amount; - private String total; - - private BigDecimal totalAmount; - private BigDecimal totalTransferSender; - private BigDecimal totalTransferReceiver; - private BigDecimal totalMoneyDaily; - private BigDecimal totalDelivery; - private BigDecimal totalFinal; - private BigDecimal totalCaja; - private BigDecimal totalOtherExpense; - private BigDecimal totalBox; - private Long totalCustomerWithOutAction; - private BigDecimal deposit; - - private String commentsBitacora; - - private String comments; - private boolean imprimirStatus; - - private TotalCashByCurdateView totales; - - private ClosingDay selectedClosingDay; - - private List closingDetail; - private List paymentoZeroDetail; - - @PostConstruct - public void init() { - loadBundlePropertyFile(); - - loanCtrl = new LoanController(); - closingDayCtrl = new ClosingDayController(); - bitacoraCtrl = new BitacoraController(); - genericCtrl = new GenericController(); - - //initOneWeekBeforeToCurrdate(); - initThisWeekToCurrdate(); - - imprimirStatus = true; - closingDay = fillDatatableClosingDay(); - commentsBitacora = ""; - user = getUsers(); - getResumen(); - comments = ""; - totalBox = genericCtrl.findAllSmallBox(getLoggedUser().getOffice().getId()); - } + public void setAmount(String amount) { + this.amount = amount; + } + + public ClosingDay getSelectedClosingDay() { + return selectedClosingDay; + } + + public void setSelectedClosingDay(ClosingDay selectedClosingDay) { + this.selectedClosingDay = selectedClosingDay; + } + + public TotalCashByLastClosingDayView getTotales() { + return totales; + } + + public void setTotales(TotalCashByLastClosingDayView totales) { + this.totales = totales; + } + + public String getTotal() { + return total; + } + + public void setTotal(String total) { + this.total = total; + } + + public BigDecimal getTotalAmount() { + return totalAmount; + } + + public void setTotalAmount(BigDecimal totalAmount) { + this.totalAmount = totalAmount; + } + + public BigDecimal getTotalTransferSender() { + return totalTransferSender; + } + + public void setTotalTransferSender(BigDecimal totalTransferSender) { + this.totalTransferSender = totalTransferSender; + } + + public BigDecimal getTotalTransferReceiver() { + return totalTransferReceiver; + } + + public void setTotalTransferReceiver(BigDecimal totalTransferReceiver) { + this.totalTransferReceiver = totalTransferReceiver; + } + + public BigDecimal getTotalMoneyDaily() { + return totalMoneyDaily; + } + + public void setTotalMoneyDaily(BigDecimal totalMoneyDaily) { + this.totalMoneyDaily = totalMoneyDaily; + } + + public BigDecimal getTotalDelivery() { + return totalDelivery; + } + + public void setTotalDelivery(BigDecimal totalDelivery) { + this.totalDelivery = totalDelivery; + } + + public BigDecimal getTotalFinal() { + return totalFinal; + } + + public void setTotalFinal(BigDecimal totalFinal) { + this.totalFinal = totalFinal; + } + + public BigDecimal getTotalCaja() { + return totalCaja; + } + + public void setTotalCaja(BigDecimal totalCaja) { + this.totalCaja = totalCaja; + } + + public BigDecimal getTotalOtherExpense() { + return totalOtherExpense; + } + + public void setTotalOtherExpense(BigDecimal totalOtherExpense) { + this.totalOtherExpense = totalOtherExpense; + } + + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments = comments; + } + + public GenericController getGenericCtrl() { + return genericCtrl; + } + + public void setGenericCtrl(GenericController genericCtrl) { + this.genericCtrl = genericCtrl; + } + + public List getClosingDetail() { + return closingDetail; + } + + public void setClosingDetail(List closingDetail) { + this.closingDetail = closingDetail; + } + + public BigDecimal getTotalBox() { + return totalBox; + } + + public void setTotalBox(BigDecimal totalBox) { + this.totalBox = totalBox; + } + + public Long getTotalCustomerWithOutAction() { + return totalCustomerWithOutAction; + } + + public void setTotalCustomerWithOutAction(Long totalCustomerWithOutAction) { + this.totalCustomerWithOutAction = totalCustomerWithOutAction; + } + + public List getPaymentoZeroDetail() { + return paymentoZeroDetail; + } + + public void setPaymentoZeroDetail(List paymentoZeroDetail) { + this.paymentoZeroDetail = paymentoZeroDetail; + } + + public BigDecimal getDeposit() { + return deposit; + } + + public void setDeposit(BigDecimal deposit) { + this.deposit = deposit; + } + + public String getCommentsBitacora() { + return commentsBitacora; + } + + public void setCommentsBitacora(String commentsBitacora) { + this.commentsBitacora = commentsBitacora; + } + + public LoanController getLoanCtrl() { + return loanCtrl; + } + + public void setLoanCtrl(LoanController loanCtrl) { + this.loanCtrl = loanCtrl; + } + + public boolean getImprimirStatus() { + return imprimirStatus; + } + + public void setImprimirStatus(boolean imprimirStatus) { + this.imprimirStatus = imprimirStatus; + } + + private ClosingDayController closingDayCtrl; + private GenericController genericCtrl; + private BitacoraController bitacoraCtrl; + private LoanController loanCtrl; + + private List closingDay; + private List user; + + private String userId; + private String amount; + private String total; + + private BigDecimal totalAmount; + private BigDecimal totalTransferSender; + private BigDecimal totalTransferReceiver; + private BigDecimal totalMoneyDaily; + private BigDecimal totalDelivery; + private BigDecimal totalFinal; + private BigDecimal totalCaja; + private BigDecimal totalOtherExpense; + private BigDecimal totalBox; + private Long totalCustomerWithOutAction; + private BigDecimal deposit; + + private String commentsBitacora; + + private String comments; + private boolean imprimirStatus; + + private TotalCashByLastClosingDayView totales; + + private ClosingDay selectedClosingDay; + + private List closingDetail; + private List paymentoZeroDetail; + + @PostConstruct + public void init() { + loadBundlePropertyFile(); + + loanCtrl = new LoanController(); + closingDayCtrl = new ClosingDayController(); + bitacoraCtrl = new BitacoraController(); + genericCtrl = new GenericController(); + + //initOneWeekBeforeToCurrdate(); + initThisWeekToCurrdate(); + + imprimirStatus = true; + closingDay = fillDatatableClosingDay(); + commentsBitacora = ""; + user = getUsers(); + getResumen(); + comments = ""; + totalBox = genericCtrl.findAllSmallBox(getLoggedUser().getOffice().getId()); + } } diff --git a/apc-web/src/main/java/com/arrebol/apc/web/beans/admin/LoanPendingBean.java b/apc-web/src/main/java/com/arrebol/apc/web/beans/admin/LoanPendingBean.java index 8474a8e..1b8cbb7 100644 --- a/apc-web/src/main/java/com/arrebol/apc/web/beans/admin/LoanPendingBean.java +++ b/apc-web/src/main/java/com/arrebol/apc/web/beans/admin/LoanPendingBean.java @@ -70,13 +70,13 @@ public class LoanPendingBean extends GenericBean implements Serializable, Datata } public void approvedLoan() { - loanCtrl.updateLoanByStatus(LoanStatus.TO_DELIVERY, selectedLoan.getId(), getLoggedUser().getUser().getId()); - loanCtrl.updateLoanByUserByStatus(LoanStatus.TO_DELIVERY, selectedLoan); + loanCtrl.updateLoanByStatus(LoanStatus.APPROVED, selectedLoan.getId(), getLoggedUser().getUser().getId()); + loanCtrl.updateLoanByUserByStatus(LoanStatus.APPROVED, selectedLoan); loan.remove(selectedLoan); selectedLoan = null; selectedLoan = null; - showMessage(FacesMessage.SEVERITY_INFO, "Cambio de estatus", "la venta se cambió a estatus 'A conciliar' de forma correcta."); + showMessage(FacesMessage.SEVERITY_INFO, "Cambio de estatus", "la venta se cambió a estatus 'Aprobado' de forma correcta."); } @Override diff --git a/apc-web/src/main/webapp/dashboard.xhtml b/apc-web/src/main/webapp/dashboard.xhtml index fe2d6c6..4d49c7e 100644 --- a/apc-web/src/main/webapp/dashboard.xhtml +++ b/apc-web/src/main/webapp/dashboard.xhtml @@ -166,6 +166,86 @@ + +
+
+

Detalle de avance del día por asesor

+ + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+