Compare commits

...

3 Commits

22 changed files with 1970 additions and 1587 deletions

View File

@ -1,16 +1,19 @@
/* /*
* Arrebol Consultancy copyright. * Arrebol Consultancy copyright.
* *
* This code belongs to Arrebol Consultancy * 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. * without written authorization from Arrebol Consultancy.
*/ */
package com.arrebol.apc.controller.mobile.controller.customer; package com.arrebol.apc.controller.mobile.controller.customer;
import com.arrebol.apc.controller.mobile.repository.views.CustomerWithoutRenovationViewRepository;
import com.arrebol.apc.controller.mobile.repository.views.LoanByUserViewRepository; import com.arrebol.apc.controller.mobile.repository.views.LoanByUserViewRepository;
import com.arrebol.apc.model.ModelParameter; import com.arrebol.apc.model.ModelParameter;
import com.arrebol.apc.model.core.constance.CustomerWithoutRenovationViewCfg;
import com.arrebol.apc.model.core.constance.LoanByUserViewCfg; import com.arrebol.apc.model.core.constance.LoanByUserViewCfg;
import com.arrebol.apc.model.enums.PreferenceValue; import com.arrebol.apc.model.enums.PreferenceValue;
import com.arrebol.apc.model.views.CustomerWithoutRenovationView;
import com.arrebol.apc.model.views.LoanByUserView; import com.arrebol.apc.model.views.LoanByUserView;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
@ -24,40 +27,65 @@ import org.apache.logging.log4j.Logger;
*/ */
public class CustomerController implements Serializable { public class CustomerController implements Serializable {
/** /**
* *
* @param orderList * @param orderList
* @param userId * @param userId
* @return * @return
* @throws Exception * @throws Exception
*/ */
public List<LoanByUserView> findAllLoansByUserId(String orderList, String userId) throws Exception { public List<LoanByUserView> findAllLoansByUserId(String orderList, String userId) throws Exception {
try { try {
List<ModelParameter> parameters = new ArrayList<>(); List<ModelParameter> parameters = new ArrayList<>();
boolean isByOrderInList = PreferenceValue.ORDER_IN_LIST.toString().equals(orderList); boolean isByOrderInList = PreferenceValue.ORDER_IN_LIST.toString().equals(orderList);
parameters.add(new ModelParameter(LoanByUserViewCfg.FIELD_USER_ID, userId)); parameters.add(new ModelParameter(LoanByUserViewCfg.FIELD_USER_ID, userId));
return loanByUserViewRepository return loanByUserViewRepository
.findAllLoansByUserId( .findAllLoansByUserId(
isByOrderInList isByOrderInList
? LoanByUserViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ID_BY_ORDER_LIST ? LoanByUserViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ID_BY_ORDER_LIST
: LoanByUserViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ID_BY_CUSTOMER_NAME, : LoanByUserViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ID_BY_CUSTOMER_NAME,
parameters parameters
); );
} catch (Exception e) { } catch (Exception e) {
logger.error("findAllLoansByUserId", e); logger.error("findAllLoansByUserId", e);
throw e; throw e;
} }
} }
private static final long serialVersionUID = -6689182942800786108L; /**
final Logger logger = LogManager.getLogger(CustomerController.class); *
* @param idRoute
* @return
* @throws Exception
*/
public List<CustomerWithoutRenovationView> findAllNonRenewingCustomersByRuteId(String idRoute) throws Exception {
try {
List<ModelParameter> parameters = new ArrayList<>();
private final LoanByUserViewRepository loanByUserViewRepository; parameters.add(new ModelParameter(CustomerWithoutRenovationViewCfg.FIELD_RUTE_ID, idRoute));
public CustomerController() { return customerWithoutRenovationViewRepository
this.loanByUserViewRepository = new LoanByUserViewRepository(); .nonRenewingCustomersByRuteId(
} CustomerWithoutRenovationViewCfg.QUERY_FIND_ALL_UNRENEWED_CUSTOMERS_BY_ROUTE,
parameters
);
} catch (Exception e) {
logger.error("findAllLoansByUserId", e);
throw e;
}
}
private static final long serialVersionUID = -6689182942800786108L;
final Logger logger = LogManager.getLogger(CustomerController.class);
private final LoanByUserViewRepository loanByUserViewRepository;
private final CustomerWithoutRenovationViewRepository customerWithoutRenovationViewRepository;
public CustomerController() {
this.loanByUserViewRepository = new LoanByUserViewRepository();
this.customerWithoutRenovationViewRepository = new CustomerWithoutRenovationViewRepository();
}
} }

View File

@ -1,8 +1,8 @@
/* /*
* Arrebol Consultancy copyright. * Arrebol Consultancy copyright.
* *
* This code belongs to Arrebol Consultancy * 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. * without written authorization from Arrebol Consultancy.
*/ */
package com.arrebol.apc.controller.mobile.controller.exchange; package com.arrebol.apc.controller.mobile.controller.exchange;
@ -22,6 +22,7 @@ import com.arrebol.apc.model.ws.parsed.Exchange;
import com.arrebol.apc.model.ws.parsed.ExchangeJaxb; import com.arrebol.apc.model.ws.parsed.ExchangeJaxb;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
@ -33,133 +34,138 @@ import org.apache.logging.log4j.Logger;
*/ */
public class ExchangeEnebledUsersController implements Serializable { public class ExchangeEnebledUsersController implements Serializable {
/** /**
* *
* @param userId * @param userId
* @param officeId * @param officeId
* @return * @return
* @throws Exception * @throws Exception
*/ */
public List<ExchangeEnebledUsersView> findEnebledUsersToUserId(String userId, String officeId) throws Exception { public List<ExchangeEnebledUsersView> findEnebledUsersToUserId(String userId, String officeId) throws Exception {
logger.debug("exchangeEnebledUsersViewRepository"); logger.debug("exchangeEnebledUsersViewRepository");
try { try {
List<ModelParameter> parameters = new ArrayList<>(); List<ModelParameter> parameters = new ArrayList<>();
parameters.add( parameters.add(
new ModelParameter( new ModelParameter(
ExchangeEnebledUsersViewCfg.PARAM_OFFICE_ID, ExchangeEnebledUsersViewCfg.PARAM_OFFICE_ID,
officeId officeId
) )
); );
parameters.add( parameters.add(
new ModelParameter( new ModelParameter(
ExchangeEnebledUsersViewCfg.FIELD_VIEW_ID, ExchangeEnebledUsersViewCfg.FIELD_VIEW_ID,
userId userId
) )
); );
return exchangeEnebledUsersViewRepository.findEnebledUsersToUserId( return exchangeEnebledUsersViewRepository.findEnebledUsersToUserId(
ExchangeEnebledUsersViewCfg.QUERY_FIND_ENEBLED_USERS_TO_USER_ID, ExchangeEnebledUsersViewCfg.QUERY_FIND_ENEBLED_USERS_TO_USER_ID,
parameters parameters
); );
} catch (Exception e) { } catch (Exception e) {
logger.error("findEnebledUsersToUserId", e); logger.error("findEnebledUsersToUserId", e);
throw e; throw e;
} }
} }
/** /**
* *
* @param jaxb * @param jaxb
* @return * @return
* @throws Exception * @throws Exception
*/ */
public boolean newExchange(ExchangeJaxb jaxb) throws Exception { public boolean newExchange(ExchangeJaxb jaxb) throws Exception {
logger.debug("newExchange"); logger.debug("newExchange");
try { try {
Transfer transfer = new Transfer( Transfer transfer = new Transfer(
new User(jaxb.getSenderId()), new User(jaxb.getSenderId()),
new User(jaxb.getReceiverId()), new User(jaxb.getReceiverId()),
ActiveStatus.ENEBLED, ActiveStatus.ENEBLED,
ActionStatus.PENDING, ActionStatus.PENDING,
jaxb.getAmount(), jaxb.getAmount(),
new Office(jaxb.getOfficeId()), new Office(jaxb.getOfficeId()),
jaxb.getSenderId()); jaxb.getSenderId());
return transferRepository.addTransfer(transfer); return transferRepository.addTransfer(transfer);
} catch (Exception e) { } catch (Exception e) {
logger.error("newExchange", e); logger.error("newExchange", e);
throw e; throw e;
} }
} }
/** /**
* *
* @param transerId * @param transerId
* @param userId * @param userId
* @param isApproved * @param isApproved
* @return * @return
* @throws Exception * @throws Exception
*/ */
public boolean updateExchange(String transerId, String userId, boolean isApproved) throws Exception { public boolean updateExchange(String transerId, String userId, boolean isApproved) throws Exception {
logger.debug("updateExchange"); logger.debug("updateExchange");
try { try {
List<ModelParameter> parameters = new ArrayList<>(); List<ModelParameter> parameters = new ArrayList<>();
parameters.add(new ModelParameter(TransferCfg.FIELD_ACTION_STATUS, isApproved ? ActionStatus.APPROVED : ActionStatus.REJECTED)); parameters.add(new ModelParameter(TransferCfg.FIELD_ACTION_STATUS, isApproved ? ActionStatus.APPROVED : ActionStatus.REJECTED));
parameters.add(new ModelParameter(TransferCfg.FIELD_LAST_UPDATED_BY, userId)); parameters.add(new ModelParameter(TransferCfg.FIELD_LAST_UPDATED_BY, userId));
parameters.add(new ModelParameter(TransferCfg.FIELD_LAST_UPDATED_ON, new Date())); Date date = new Date();
parameters.add(new ModelParameter(TransferCfg.FIELD_ID, transerId)); Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, -7);
date = calendar.getTime();
parameters.add(new ModelParameter(TransferCfg.FIELD_LAST_UPDATED_ON, date));
parameters.add(new ModelParameter(TransferCfg.FIELD_ID, transerId));
return transferRepository.updateTransfer(TransferCfg.QUERY_UPDATE_TRANSFER_BY_ACTION, parameters); return transferRepository.updateTransfer(TransferCfg.QUERY_UPDATE_TRANSFER_BY_ACTION, parameters);
} catch (Exception e) { } catch (Exception e) {
logger.error("updateExchange", e); logger.error("updateExchange", e);
throw e; throw e;
} }
} }
/** /**
* *
* @param userId * @param userId
* @return * @return
* @throws Exception * @throws Exception
*/ */
public List<Exchange> exchangesByUsers(String userId) throws Exception { public List<Exchange> exchangesByUsers(String userId) throws Exception {
logger.debug("exchangesByUsers"); logger.debug("exchangesByUsers");
try { try {
List<ModelParameter> parameters = new ArrayList<>(); List<ModelParameter> parameters = new ArrayList<>();
parameters.add( parameters.add(
new ModelParameter( new ModelParameter(
TransferCfg.FIELD_USER_TRANSMITTER, TransferCfg.FIELD_USER_TRANSMITTER,
new User(userId) new User(userId)
) )
); );
parameters.add(
new ModelParameter(
TransferCfg.FIELD_USER_RECEIVER,
new User(userId)
)
);
return transferRepository.findAllTransferByUserIdAndCurdate(TransferCfg.QUERY_FIND_ALL_TRANSFER_BY_USER_ID_AND_CURDATE, parameters); parameters.add(
} catch (Exception e) { new ModelParameter(
logger.error("exchangesByUsers", e); TransferCfg.FIELD_USER_RECEIVER,
throw e; new User(userId)
} )
} );
private static final long serialVersionUID = 2625775904919860613L; return transferRepository.findAllTransferByUserIdAndCurdate(TransferCfg.QUERY_FIND_ALL_TRANSFER_BY_USER_ID_AND_CURDATE, parameters);
final Logger logger = LogManager.getLogger(ExchangeEnebledUsersController.class); } catch (Exception e) {
logger.error("exchangesByUsers", e);
throw e;
}
}
private final ExchangeEnebledUsersViewRepository exchangeEnebledUsersViewRepository; private static final long serialVersionUID = 2625775904919860613L;
private final TransferRepository transferRepository; final Logger logger = LogManager.getLogger(ExchangeEnebledUsersController.class);
public ExchangeEnebledUsersController() { private final ExchangeEnebledUsersViewRepository exchangeEnebledUsersViewRepository;
this.exchangeEnebledUsersViewRepository = new ExchangeEnebledUsersViewRepository(); private final TransferRepository transferRepository;
this.transferRepository = new TransferRepository();
} public ExchangeEnebledUsersController() {
this.exchangeEnebledUsersViewRepository = new ExchangeEnebledUsersViewRepository();
this.transferRepository = new TransferRepository();
}
} }

View File

@ -284,6 +284,12 @@ public class LoanController implements Serializable {
String comments = "Se pago " + precio + texto; String comments = "Se pago " + precio + texto;
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, -7);
date = calendar.getTime();
LoanDetails details = new LoanDetails( LoanDetails details = new LoanDetails(
UUID.randomUUID().toString(), UUID.randomUUID().toString(),
new Loan(feesToPayByLoanRequestJaxb.getIdLoan()), new Loan(feesToPayByLoanRequestJaxb.getIdLoan()),
@ -294,7 +300,7 @@ public class LoanController implements Serializable {
LoanDetailsType.PAYMENT, LoanDetailsType.PAYMENT,
comments, comments,
feesToPayByLoanRequestJaxb.getIdUser(), feesToPayByLoanRequestJaxb.getIdUser(),
new Date()); date);
parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID, ids)); parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID, ids));
@ -408,9 +414,6 @@ public class LoanController implements Serializable {
throw new Exception(user_unavailable); throw new Exception(user_unavailable);
} }
//DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();//dateFormat.parse(jaxb.getStrDate());
LoanByUser loanByUser = new LoanByUser( LoanByUser loanByUser = new LoanByUser(
new LoanByUserId(null, jaxb.getUserId()), new LoanByUserId(null, jaxb.getUserId()),
LoanStatus.PENDING, LoanStatus.PENDING,
@ -420,6 +423,12 @@ public class LoanController implements Serializable {
LoanType loanType = loanTypeRepository.findLoanType(jaxb.getLoanTypeId()); LoanType loanType = loanTypeRepository.findLoanType(jaxb.getLoanTypeId());
RouteCtlg routeCtlg = new RouteCtlg(jaxb.getRouteId()); RouteCtlg routeCtlg = new RouteCtlg(jaxb.getRouteId());
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, -7);
date = calendar.getTime();
Loan loan = new Loan( Loan loan = new Loan(
new LoanType(loanType.getId()), new LoanType(loanType.getId()),
null, null,
@ -548,7 +557,13 @@ public class LoanController implements Serializable {
LoanFeeNotification notification = null; LoanFeeNotification notification = null;
try { try {
Date date = new Date(); Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, -7);
date = calendar.getTime();
List<ModelParameter> parameters = new ArrayList<>(); List<ModelParameter> parameters = new ArrayList<>();
Loan loan = loanRepository.findLoanById(transfer.getLoanId()); Loan loan = loanRepository.findLoanById(transfer.getLoanId());
@ -712,7 +727,12 @@ public class LoanController implements Serializable {
PersonJaxb endorsement) throws Exception { PersonJaxb endorsement) throws Exception {
logger.debug("renovation"); logger.debug("renovation");
try { try {
Date date = new Date(); Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, -7);
date = calendar.getTime();
Loan currentLoan = loanRepository.findLoanById(loan); Loan currentLoan = loanRepository.findLoanById(loan);
LoanType newCredit = loanTypeRepository.findLoanType(credit); LoanType newCredit = loanTypeRepository.findLoanType(credit);
@ -844,7 +864,12 @@ public class LoanController implements Serializable {
PersonJaxb endorsement) throws Exception { PersonJaxb endorsement) throws Exception {
logger.debug("renovationHasPaymentToday"); logger.debug("renovationHasPaymentToday");
try { try {
Date date = new Date(); Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, -7);
date = calendar.getTime();
Loan currentLoan = loanRepository.findLoanById(loan); Loan currentLoan = loanRepository.findLoanById(loan);
LoanType newCredit = loanTypeRepository.findLoanType(credit); LoanType newCredit = loanTypeRepository.findLoanType(credit);
@ -972,6 +997,12 @@ public class LoanController implements Serializable {
totalAmountPaid = loan.getAmountPaid().add(discount); totalAmountPaid = loan.getAmountPaid().add(discount);
newLastReferenceNumber = loan.getLastReferenceNumber() + 1; newLastReferenceNumber = loan.getLastReferenceNumber() + 1;
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, -7);
date = calendar.getTime();
loanDetails = new LoanDetails( loanDetails = new LoanDetails(
new Loan(loanByRenovation.getLoanOld().getId()), new Loan(loanByRenovation.getLoanOld().getId()),
new User(user), new User(user),
@ -980,7 +1011,7 @@ public class LoanController implements Serializable {
newLastReferenceNumber, newLastReferenceNumber,
LoanDetailsType.RENOVATION_PAYMENT, LoanDetailsType.RENOVATION_PAYMENT,
user, user,
new Date(), date,
"Retención de " + discount + " el la entrega del crédito renovado"); "Retención de " + discount + " el la entrega del crédito renovado");
} }
@ -1055,6 +1086,12 @@ public class LoanController implements Serializable {
totalAmountPaid = loan.getAmountPaid().add(discount); totalAmountPaid = loan.getAmountPaid().add(discount);
newLastReferenceNumber = loan.getLastReferenceNumber() + 1; newLastReferenceNumber = loan.getLastReferenceNumber() + 1;
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, -7);
date = calendar.getTime();
loanDetails = new LoanDetails( loanDetails = new LoanDetails(
new Loan(loanByRenovation.getLoanOld().getId()), new Loan(loanByRenovation.getLoanOld().getId()),
new User(user), new User(user),
@ -1063,7 +1100,7 @@ public class LoanController implements Serializable {
newLastReferenceNumber, newLastReferenceNumber,
LoanDetailsType.RENOVATION_PAYMENT, LoanDetailsType.RENOVATION_PAYMENT,
user, user,
new Date(), date,
"Retención de " + discount + " el la entrega del crédito renovado"); "Retención de " + discount + " el la entrega del crédito renovado");
} }
@ -1269,11 +1306,17 @@ public class LoanController implements Serializable {
loans.add(new Loan(row.getIdLoan())); loans.add(new Loan(row.getIdLoan()));
}); });
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, -7);
date = calendar.getTime();
loanParams.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, loanStatus)); loanParams.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, loanStatus));
loanParams.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, new BigDecimal(0))); loanParams.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, new BigDecimal(0)));
loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, 0)); loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, 0));
loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, updateLoanToDeliveryStatusList.getIdUpdateUser())); loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, updateLoanToDeliveryStatusList.getIdUpdateUser()));
loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, new Date())); loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, date));
loanParams.add(new ModelParameter(LoanCfg.FIELD_ID, ids)); loanParams.add(new ModelParameter(LoanCfg.FIELD_ID, ids));
loanByUserParams.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN_BY_USER_STATUS, loanStatus)); loanByUserParams.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN_BY_USER_STATUS, loanStatus));
@ -1300,7 +1343,12 @@ public class LoanController implements Serializable {
logger.debug("updateLoanByIdFromCertifiedView"); logger.debug("updateLoanByIdFromCertifiedView");
try { try {
List<ModelParameter> parameters = new ArrayList<>(); List<ModelParameter> parameters = new ArrayList<>();
Date date = new Date(); Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, -7);
date = calendar.getTime();
parameters.add( parameters.add(
new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, action ? LoanStatus.APPROVED : LoanStatus.REJECTED) new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, action ? LoanStatus.APPROVED : LoanStatus.REJECTED)

View File

@ -1,8 +1,8 @@
/* /*
* Arrebol Consultancy copyright. * Arrebol Consultancy copyright.
* *
* This code belongs to Arrebol Consultancy * 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. * without written authorization from Arrebol Consultancy.
*/ */
package com.arrebol.apc.controller.mobile.repository.loan; package com.arrebol.apc.controller.mobile.repository.loan;
@ -23,6 +23,7 @@ import com.arrebol.apc.model.loan.LoanDetails;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
@ -35,185 +36,197 @@ import org.hibernate.query.Query;
*/ */
public class LoanByRenovationRepository extends GenericRepository implements Serializable { public class LoanByRenovationRepository extends GenericRepository implements Serializable {
private static final long serialVersionUID = 1357519239619447184L; private static final long serialVersionUID = 1357519239619447184L;
final Logger logger = LogManager.getLogger(LoanByRenovationRepository.class); final Logger logger = LogManager.getLogger(LoanByRenovationRepository.class);
/** /**
* *
* @param newLoanId * @param newLoanId
* @return * @return
* @throws Exception * @throws Exception
*/ */
public LoanByRenovation findLoanRenovationByNewLoanId(String newLoanId) throws Exception { public LoanByRenovation findLoanRenovationByNewLoanId(String newLoanId) throws Exception {
logger.debug("findLoanRenovationByNewLoanId"); logger.debug("findLoanRenovationByNewLoanId");
try { try {
List<ModelParameter> parameters = new ArrayList<>(); List<ModelParameter> parameters = new ArrayList<>();
parameters.add( parameters.add(
new ModelParameter(LoanByRenovationCfg.FIELD_LOAN_NEW, new Loan(newLoanId)) new ModelParameter(LoanByRenovationCfg.FIELD_LOAN_NEW, new Loan(newLoanId))
); );
return (LoanByRenovation) createNamedQueryUniqueResult( return (LoanByRenovation) createNamedQueryUniqueResult(
LoanByRenovation.class, LoanByRenovation.class,
LoanByRenovationCfg.QUERY_FIND_LOAN_RENOVATION_BY_NEW_LOAN_ID, LoanByRenovationCfg.QUERY_FIND_LOAN_RENOVATION_BY_NEW_LOAN_ID,
parameters); parameters);
} catch (Exception e) { } catch (Exception e) {
logger.error("findLoanRenovationByNewLoanId", e); logger.error("findLoanRenovationByNewLoanId", e);
throw e; throw e;
} }
} }
/** /**
* *
* @param loanByRenovation * @param loanByRenovation
* @param userId * @param userId
* @param comments * @param comments
* @param action * @param action
* @param amount * @param amount
* @param discount * @param discount
* @param loanDetails * @param loanDetails
* @param totalAmountPaid * @param totalAmountPaid
* @param newLastReferenceNumber * @param newLastReferenceNumber
* @param comission * @param comission
* @return * @return
* @throws Exception * @throws Exception
*/ */
public boolean updateLoanRenovationFromCerfierView( public boolean updateLoanRenovationFromCerfierView(
LoanByRenovation loanByRenovation, LoanByRenovation loanByRenovation,
String userId, String userId,
String comments, String comments,
boolean action, boolean action,
BigDecimal amount, BigDecimal amount,
BigDecimal discount, BigDecimal discount,
LoanDetails loanDetails, LoanDetails loanDetails,
BigDecimal totalAmountPaid, BigDecimal totalAmountPaid,
Integer newLastReferenceNumber, Integer newLastReferenceNumber,
ComissionType comission) throws Exception { ComissionType comission) throws Exception {
logger.debug("updateLoanRenovationFromCerfierView"); logger.debug("updateLoanRenovationFromCerfierView");
boolean success = false; boolean success = false;
try { try {
openConnection(); openConnection();
Date lastUpdatedOn = new Date(); Date date2 = new Date();
List<ModelParameter> parameters = new ArrayList<>(); Calendar calendar2 = Calendar.getInstance();
calendar2.setTime(date2);
calendar2.add(Calendar.HOUR_OF_DAY, -7);
date2 = calendar2.getTime();
// Update loanByRenovation details in Renovation table Date lastUpdatedOn = date2;
parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LOAN_RENOVATION_STATUS, action ? LoanRenovationStatus.APPROVED : LoanRenovationStatus.REJECTED)); List<ModelParameter> parameters = new ArrayList<>();
parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_COMMENTS, comments));
parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LAST_UPDATED_BY, userId));
parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LAST_UPDATED_ON, lastUpdatedOn));
parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_ID, loanByRenovation.getId()));
if (0 < executeQuery(LoanByRenovationCfg.QUERY_UPDATE_LOAN_RENOVATION, parameters)) { // Update loanByRenovation details in Renovation table
parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LOAN_RENOVATION_STATUS, action ? LoanRenovationStatus.APPROVED : LoanRenovationStatus.REJECTED));
parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_COMMENTS, comments));
parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LAST_UPDATED_BY, userId));
parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_LAST_UPDATED_ON, lastUpdatedOn));
parameters.add(new ModelParameter(LoanByRenovationCfg.FIELD_ID, loanByRenovation.getId()));
parameters.clear(); if (0 < executeQuery(LoanByRenovationCfg.QUERY_UPDATE_LOAN_RENOVATION, parameters)) {
// Update NEW loan details in Loan table parameters.clear();
parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, action ? LoanStatus.APPROVED : LoanStatus.REJECTED));
parameters.add(new ModelParameter(LoanCfg.FIELD_COMMENTS, comments));
parameters.add(new ModelParameter(LoanCfg.FIELD_CREATED_ON, lastUpdatedOn));
parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, userId));
parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, lastUpdatedOn));
parameters.add(new ModelParameter(LoanCfg.FIELD_ID, loanByRenovation.getLoanNew().getId()));
if (0 < executeQuery(LoanCfg.QUERY_UPDATE_LOAN_WITH_CREATED_ON_BY_ID_FROM_CERTIFIER_VIEW, parameters)) { // Update NEW loan details in Loan table
parameters.clear(); parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, action ? LoanStatus.APPROVED : LoanStatus.REJECTED));
parameters.add(new ModelParameter(LoanCfg.FIELD_COMMENTS, comments));
parameters.add(new ModelParameter(LoanCfg.FIELD_CREATED_ON, lastUpdatedOn));
parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, userId));
parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, lastUpdatedOn));
parameters.add(new ModelParameter(LoanCfg.FIELD_ID, loanByRenovation.getLoanNew().getId()));
// Update OLD loan details in Loan table if (0 < executeQuery(LoanCfg.QUERY_UPDATE_LOAN_WITH_CREATED_ON_BY_ID_FROM_CERTIFIER_VIEW, parameters)) {
String commentsOldLoan = action ? "Crédito renovado" : "El certificador rechazo la renovación de este crédito"; parameters.clear();
String strQuery = LoanCfg.QUERY_UPDATE_LOAN_BY_ID_FROM_CERTIFIER_VIEW;
if (action && null != loanDetails && null != totalAmountPaid && null != newLastReferenceNumber) { // Update OLD loan details in Loan table
parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, totalAmountPaid)); String commentsOldLoan = action ? "Crédito renovado" : "El certificador rechazo la renovación de este crédito";
parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, newLastReferenceNumber)); String strQuery = LoanCfg.QUERY_UPDATE_LOAN_BY_ID_FROM_CERTIFIER_VIEW;
strQuery = LoanCfg.QUERY_UPDATE_DISCOUNT_AND_LOAN_BY_ID_FROM_CERTIFIER_VIEW; if (action && null != loanDetails && null != totalAmountPaid && null != newLastReferenceNumber) {
} parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, totalAmountPaid));
parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, newLastReferenceNumber));
parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, action ? LoanStatus.FINISH : LoanStatus.APPROVED)); strQuery = LoanCfg.QUERY_UPDATE_DISCOUNT_AND_LOAN_BY_ID_FROM_CERTIFIER_VIEW;
parameters.add(new ModelParameter(LoanCfg.FIELD_COMMENTS, commentsOldLoan)); }
parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, userId));
parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, lastUpdatedOn));
parameters.add(new ModelParameter(LoanCfg.FIELD_ID, loanByRenovation.getLoanOld().getId()));
if (0 < executeQuery(strQuery, parameters)) { parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, action ? LoanStatus.FINISH : LoanStatus.APPROVED));
parameters.add(new ModelParameter(LoanCfg.FIELD_COMMENTS, commentsOldLoan));
parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, userId));
parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, lastUpdatedOn));
parameters.add(new ModelParameter(LoanCfg.FIELD_ID, loanByRenovation.getLoanOld().getId()));
// Update OLD loanByUser details in Loan By User Table if (0 < executeQuery(strQuery, parameters)) {
List<ModelParameter> params = new ArrayList<>();
params.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN, new Loan(loanByRenovation.getLoanOld().getId()))); // Update OLD loanByUser details in Loan By User Table
params.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN_BY_USER_STATUS, action ? LoanStatus.FINISH : LoanStatus.APPROVED)); List<ModelParameter> params = new ArrayList<>();
Query query1 = getSession().createNamedQuery(LoanByUserCfg.QUERY_UPDATE_LOAN_BY_USER_BY_LOAND_ID); params.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN, new Loan(loanByRenovation.getLoanOld().getId())));
params.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN_BY_USER_STATUS, action ? LoanStatus.FINISH : LoanStatus.APPROVED));
params.forEach((param) -> { Query query1 = getSession().createNamedQuery(LoanByUserCfg.QUERY_UPDATE_LOAN_BY_USER_BY_LOAND_ID);
query1.setParameter(param.getParameter(), param.getValue());
});
query1.executeUpdate(); params.forEach((param) -> {
query1.setParameter(param.getParameter(), param.getValue());
});
// Update NEW loanByUser details in Loan By User Table query1.executeUpdate();
params.clear();
params.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN, new Loan(loanByRenovation.getLoanNew().getId()))); // Update NEW loanByUser details in Loan By User Table
params.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN_BY_USER_STATUS, action ? LoanStatus.APPROVED : LoanStatus.REJECTED)); params.clear();
Query query2 = getSession().createNamedQuery(LoanByUserCfg.QUERY_UPDATE_LOAN_BY_USER_BY_LOAND_ID); params.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN, new Loan(loanByRenovation.getLoanNew().getId())));
params.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN_BY_USER_STATUS, action ? LoanStatus.APPROVED : LoanStatus.REJECTED));
params.forEach((param) -> { Query query2 = getSession().createNamedQuery(LoanByUserCfg.QUERY_UPDATE_LOAN_BY_USER_BY_LOAND_ID);
query2.setParameter(param.getParameter(), param.getValue());
});
query2.executeUpdate(); params.forEach((param) -> {
query2.setParameter(param.getParameter(), param.getValue());
});
if (action) { query2.executeUpdate();
// Insert new loanDetails (discount) in Loan Details table
if (null != loanDetails) {
getSession().save(loanDetails);
}
// Insert delivery details (To know cash that certifier deliveried) in Delivery Table if (action) {
Delivery delivery = new Delivery( // Insert new loanDetails (discount) in Loan Details table
new User(userId), if (null != loanDetails) {
new Loan(loanByRenovation.getLoanNew().getId()), getSession().save(loanDetails);
amount, }
userId,
new Date(),
comission
);
getSession().save(delivery); Date date = new Date();
} Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, -7);
date = calendar.getTime();
flushAndClear(); // Insert delivery details (To know cash that certifier deliveried) in Delivery Table
closeConnection(); Delivery delivery = new Delivery(
new User(userId),
new Loan(loanByRenovation.getLoanNew().getId()),
amount,
userId,
date,
comission
);
logger.info("Certifier delivery the loan details: " + loanByRenovation); getSession().save(delivery);
success = true; }
} else {
rollback(); flushAndClear();
} closeConnection();
} else {
rollback(); logger.info("Certifier delivery the loan details: " + loanByRenovation);
} success = true;
} else {
rollback();
}
} else { } else {
rollback(); rollback();
} }
return success; } else {
} catch (Exception e) {
rollback(); rollback();
logger.error("updateLoanRenovationFromCerfierView", e); }
throw e; return success;
} } catch (Exception e) {
} rollback();
logger.error("updateLoanRenovationFromCerfierView", e);
throw e;
}
}
private int executeQuery(String xmlQuery, List<ModelParameter> parameters) { private int executeQuery(String xmlQuery, List<ModelParameter> parameters) {
Query query = getSession().createNamedQuery(xmlQuery); Query query = getSession().createNamedQuery(xmlQuery);
parameters.forEach((param) -> { parameters.forEach((param) -> {
query.setParameter(param.getParameter(), param.getValue()); query.setParameter(param.getParameter(), param.getValue());
}); });
return query.executeUpdate(); return query.executeUpdate();
} }
} }

View File

@ -1,8 +1,8 @@
/* /*
* Arrebol Consultancy copyright. * Arrebol Consultancy copyright.
* *
* This code belongs to Arrebol Consultancy * 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. * without written authorization from Arrebol Consultancy.
*/ */
package com.arrebol.apc.controller.mobile.repository.loan; package com.arrebol.apc.controller.mobile.repository.loan;
@ -16,6 +16,7 @@ import com.arrebol.apc.model.loan.LoanDetails;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.persistence.Tuple; import javax.persistence.Tuple;
@ -31,169 +32,175 @@ import org.hibernate.query.Query;
*/ */
public class LoanDetailsRepository extends GenericRepository implements Serializable { public class LoanDetailsRepository extends GenericRepository implements Serializable {
/** /**
* *
* @param details * @param details
* @return * @return
* @throws Exception * @throws Exception
*/ */
public boolean saveLoanDetails(LoanDetails details) throws Exception { public boolean saveLoanDetails(LoanDetails details) throws Exception {
logger.debug("saveLoanDetails"); logger.debug("saveLoanDetails");
try { try {
return save(details); return save(details);
} catch (Exception e) { } catch (Exception e) {
logger.error("saveLoanDetails", e); logger.error("saveLoanDetails", e);
throw e; throw e;
} }
} }
public List<LoanDetails> findFeesToPayByLoanId(String xmlQuery, List<ModelParameter> parameters) throws Exception { public List<LoanDetails> findFeesToPayByLoanId(String xmlQuery, List<ModelParameter> parameters) throws Exception {
logger.debug("findFeesToPayByLoanId"); logger.debug("findFeesToPayByLoanId");
List<LoanDetails> results = new ArrayList<>(); List<LoanDetails> results = new ArrayList<>();
try { try {
List<Tuple> tuples = xmlQueryTuple(xmlQuery, parameters); List<Tuple> tuples = xmlQueryTuple(xmlQuery, parameters);
tuples.forEach((tuple) -> { tuples.forEach((tuple) -> {
results.add(new LoanDetails(tuple.get("id", String.class), tuple.get("createdOn", Date.class), tuple.get("feeStatus", FeeStatus.class))); results.add(new LoanDetails(tuple.get("id", String.class), tuple.get("createdOn", Date.class), tuple.get("feeStatus", FeeStatus.class)));
});
} catch (Exception e) {
logger.error("findFeesToPayByLoanId", e);
throw e;
}
return results;
}
/**
*
* @param xmlQuery
* @param parameters
* @return
* @throws Exception
*/
public List<LoanDetails> findLoanDetailsByLoanId(String xmlQuery, List<ModelParameter> parameters) throws Exception {
logger.debug("findLoanDetailsByLoanId");
List<LoanDetails> results = new ArrayList<>();
try {
results = createNamedQueryResultList(LoanDetails.class, xmlQuery, parameters);
} catch (Exception e) {
logger.error("findLoanDetailsByLoanId", e);
throw e;
}
return results;
}
/**
*
* @param xmlQuery
* @param parameters
* @param loanDetails
* @return
* @throws Exception
*/
public boolean updatePaidFeesStatusInLoanDetailIds(String xmlQuery, List<ModelParameter> parameters, LoanDetails loanDetails) throws Exception {
boolean success = false;
Session sssn = null;
Transaction trnsctn = null;
try {
sssn = HibernateUtil.getSessionFactory().getCurrentSession();
trnsctn = sssn.beginTransaction();
Loan loan = sssn.get(Loan.class, loanDetails.getLoan().getId());
if (null != parameters && !parameters.isEmpty()) {
Query query = sssn.createNamedQuery(xmlQuery);
parameters.forEach((param) -> {
query.setParameter(param.getParameter(), param.getValue());
}); });
} catch (Exception e) { query.executeUpdate();
logger.error("findFeesToPayByLoanId", e); logger.debug("Query update executed");
throw e; }
} BigDecimal totalFees = loan.getAmountPaid().add(loanDetails.getPaymentAmount());
return results; loanDetails.setReferenceNumber(loan.getLastReferenceNumber() + 1);
}
/** sssn.save(loanDetails);
*
* @param xmlQuery
* @param parameters
* @return
* @throws Exception
*/
public List<LoanDetails> findLoanDetailsByLoanId(String xmlQuery, List<ModelParameter> parameters) throws Exception {
logger.debug("findLoanDetailsByLoanId");
List<LoanDetails> results = new ArrayList<>(); loan.setAmountPaid(totalFees);
try { loan.setLastReferenceNumber(loan.getLastReferenceNumber() + 1);
results = createNamedQueryResultList(LoanDetails.class, xmlQuery, parameters); loan.setLastUpdatedBy(loanDetails.getCreatedBy());
} catch (Exception e) {
logger.error("findLoanDetailsByLoanId", e);
throw e;
}
return results; Date date = new Date();
} Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, -7);
date = calendar.getTime();
loan.setLastUpdatedOn(date);
/** sssn.update(loan);
*
* @param xmlQuery
* @param parameters
* @param loanDetails
* @return
* @throws Exception
*/
public boolean updatePaidFeesStatusInLoanDetailIds(String xmlQuery, List<ModelParameter> parameters, LoanDetails loanDetails) throws Exception {
boolean success = false;
Session sssn = null; trnsctn.commit();
Transaction trnsctn = null;
try {
sssn = HibernateUtil.getSessionFactory().getCurrentSession();
trnsctn = sssn.beginTransaction();
Loan loan = sssn.get(Loan.class, loanDetails.getLoan().getId()); logger.info("Entity updated");
success = true;
if (null != parameters && !parameters.isEmpty()) { } catch (Exception e) {
Query query = sssn.createNamedQuery(xmlQuery); logger.error("Method updatePaidFeesStatusInLoanDetailIds() ", e);
parameters.forEach((param) -> { if (null != trnsctn) {
query.setParameter(param.getParameter(), param.getValue()); trnsctn.rollback();
}); }
query.executeUpdate(); throw e;
logger.debug("Query update executed"); }
} /* finally {
BigDecimal totalFees = loan.getAmountPaid().add(loanDetails.getPaymentAmount());
loanDetails.setReferenceNumber(loan.getLastReferenceNumber() + 1);
sssn.save(loanDetails);
loan.setAmountPaid(totalFees);
loan.setLastReferenceNumber(loan.getLastReferenceNumber() + 1);
loan.setLastUpdatedBy(loanDetails.getCreatedBy());
loan.setLastUpdatedOn(new Date());
sssn.update(loan);
trnsctn.commit();
logger.info("Entity updated");
success = true;
} catch (Exception e) {
logger.error("Method updatePaidFeesStatusInLoanDetailIds() ", e);
if (null != trnsctn) {
trnsctn.rollback();
}
throw e;
}
/* finally {
if (null != sssn) { if (null != sssn) {
sssn.close(); sssn.close();
} }
}*/ }*/
return success; return success;
} }
/** /**
* *
* @param hbmQuery * @param hbmQuery
* @param params * @param params
* @return * @return
*/ */
public Long countLoandDetails(String hbmQuery, List<ModelParameter> params) { public Long countLoandDetails(String hbmQuery, List<ModelParameter> params) {
Long count; Long count;
Transaction transaction = null; Transaction transaction = null;
try { try {
Session session = HibernateUtil.getSessionFactory().getCurrentSession(); Session session = HibernateUtil.getSessionFactory().getCurrentSession();
transaction = session.beginTransaction(); transaction = session.beginTransaction();
Query query = session.createNamedQuery(hbmQuery); Query query = session.createNamedQuery(hbmQuery);
params.forEach((param) -> { params.forEach((param) -> {
query.setParameter(param.getParameter(), param.getValue()); query.setParameter(param.getParameter(), param.getValue());
}); });
count = (Long) query.getSingleResult(); count = (Long) query.getSingleResult();
transaction.commit(); transaction.commit();
return count; return count;
} catch (Exception e) { } catch (Exception e) {
logger.error("countLoandDetails", e); logger.error("countLoandDetails", e);
if (null != transaction) { if (null != transaction) {
transaction.rollback(); transaction.rollback();
} }
throw e; throw e;
} }
} }
/** /**
* *
* @param hbmQuery * @param hbmQuery
* @param parameters * @param parameters
* @return * @return
* @throws Exception * @throws Exception
*/ */
public boolean updateLoanDetails(String hbmQuery, List<ModelParameter> parameters) throws Exception { public boolean updateLoanDetails(String hbmQuery, List<ModelParameter> parameters) throws Exception {
try { try {
return updateCreateNamedQuery(hbmQuery, parameters); return updateCreateNamedQuery(hbmQuery, parameters);
} catch (Exception e) { } catch (Exception e) {
logger.error("Method updateLoanDetails", e); logger.error("Method updateLoanDetails", e);
throw e; throw e;
} }
} }
private static final long serialVersionUID = -6088464996350747643L; private static final long serialVersionUID = -6088464996350747643L;
final Logger logger = LogManager.getLogger(LoanDetailsRepository.class); final Logger logger = LogManager.getLogger(LoanDetailsRepository.class);
} }

View File

@ -0,0 +1,54 @@
/*
* 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.controller.mobile.repository.views;
import com.arrebol.apc.controller.mobile.repository.GenericRepository;
import com.arrebol.apc.model.ModelParameter;
import com.arrebol.apc.model.views.CustomerWithoutRenovationView;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
*
* @author Carlos Janitzio Zavala Lopez <janitzio.zavala@arrebol.com.mx>
*/
public class CustomerWithoutRenovationViewRepository extends GenericRepository implements Serializable {
/**
*
* @param xmlQuery
* @param parameters
* @return
* @throws Exception
*/
public List<CustomerWithoutRenovationView> nonRenewingCustomersByRuteId(String xmlQuery, List<ModelParameter> parameters) throws Exception {
logger.debug("nonRenewingCustomersByRuteId");
List<CustomerWithoutRenovationView> results = new ArrayList<>();
try {
results = createNamedQueryResultList(
CustomerWithoutRenovationView.class,
xmlQuery,
parameters
);
} catch (Exception e) {
logger.error("nonRenewingCustomersByRuteId", e);
throw e;
}
return results;
}
private static final long serialVersionUID = 5669198954766725476L;
final Logger logger = LogManager.getLogger(CustomerWithoutRenovationViewRepository.class);
}

View File

@ -220,6 +220,7 @@
<mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/customer.without.renovation.view.queries.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" />

View File

@ -216,6 +216,7 @@
<mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/customer.without.renovation.view.queries.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" />

View File

@ -80,8 +80,8 @@
<id>Localhost</id> <id>Localhost</id>
<properties> <properties>
<hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5</hibernate.connection.url> <hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5</hibernate.connection.url>
<hibernate.connection.username>apoprocomlocalhost</hibernate.connection.username> <hibernate.connection.username>root</hibernate.connection.username>
<hibernate.connection.password>Yj$2Da0z!</hibernate.connection.password> <hibernate.connection.password>root</hibernate.connection.password>
<hibernate.connection.min_size>10</hibernate.connection.min_size> <hibernate.connection.min_size>10</hibernate.connection.min_size>
<hibernate.connection.max_size>40</hibernate.connection.max_size> <hibernate.connection.max_size>40</hibernate.connection.max_size>
<hibernate.connection.timeout>1800</hibernate.connection.timeout> <hibernate.connection.timeout>1800</hibernate.connection.timeout>

View File

@ -113,7 +113,7 @@ public class OtherExpense implements Serializable {
Date date = new Date(); Date date = new Date();
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(date); calendar.setTime(date);
calendar.add(Calendar.DAY_OF_YEAR, -1); calendar.add(Calendar.HOUR, -7);
date = calendar.getTime(); date = calendar.getTime();
this.createdOn = date; this.createdOn = date;
} }

View File

@ -1,8 +1,8 @@
/* /*
* Arrebol Consultancy copyright. * Arrebol Consultancy copyright.
* *
* This code belongs to Arrebol Consultancy * 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. * without written authorization from Arrebol Consultancy.
*/ */
package com.arrebol.apc.model.admin; package com.arrebol.apc.model.admin;
@ -13,8 +13,8 @@ import com.arrebol.apc.model.enums.ActionStatus;
import com.arrebol.apc.model.enums.ActiveStatus; import com.arrebol.apc.model.enums.ActiveStatus;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -41,257 +41,263 @@ import org.hibernate.annotations.GenericGenerator;
@Table(name = "APC_TRANSFER") @Table(name = "APC_TRANSFER")
public class Transfer implements Serializable { public class Transfer implements Serializable {
private static final long serialVersionUID = -1304758262604329766L; private static final long serialVersionUID = -1304758262604329766L;
@Id @Id
@GeneratedValue(generator = "uuid") @GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2") @GenericGenerator(name = "uuid", strategy = "uuid2")
@Column(name = "id", length = 36) @Column(name = "id", length = 36)
private String id; private String id;
@ManyToOne(fetch = FetchType.LAZY, optional = false) @ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn( @JoinColumn(
name = "id_user_transmitter", name = "id_user_transmitter",
referencedColumnName = "id", referencedColumnName = "id",
nullable = false nullable = false
) )
private User userTransmitter; private User userTransmitter;
@ManyToOne(fetch = FetchType.LAZY, optional = false) @ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn( @JoinColumn(
name = "id_user_receiver", name = "id_user_receiver",
referencedColumnName = "id", referencedColumnName = "id",
nullable = false nullable = false
) )
private User userReceiver; private User userReceiver;
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@Column(name = "active_status", nullable = false) @Column(name = "active_status", nullable = false)
private ActiveStatus activeStatus; private ActiveStatus activeStatus;
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@Column(name = "action_status", nullable = false) @Column(name = "action_status", nullable = false)
private ActionStatus actionStatus; private ActionStatus actionStatus;
@Column(name = "amount_to_transfer", nullable = false) @Column(name = "amount_to_transfer", nullable = false)
private BigDecimal amountToTransfer; private BigDecimal amountToTransfer;
@ManyToOne(fetch = FetchType.LAZY, optional = false) @ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn( @JoinColumn(
name = "id_office", name = "id_office",
referencedColumnName = "id", referencedColumnName = "id",
nullable = false nullable = false
) )
private Office office; private Office office;
@Column(name = "created_by", nullable = false, length = 36) @Column(name = "created_by", nullable = false, length = 36)
private String createdBy; private String createdBy;
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
@Column(name = "created_on", length = 19) @Column(name = "created_on", length = 19)
private Date createdOn; private Date createdOn;
@Column(name = "last_updated_by", length = 36) @Column(name = "last_updated_by", length = 36)
private String lastUpdatedBy; private String lastUpdatedBy;
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
@Column(name = "last_updated_on", length = 19) @Column(name = "last_updated_on", length = 19)
private Date lastUpdatedOn; private Date lastUpdatedOn;
public Transfer() { public Transfer() {
} }
/** /**
* *
* @param userTransmitter * @param userTransmitter
* @param userReceiver * @param userReceiver
* @param activeStatus * @param activeStatus
* @param actionStatus * @param actionStatus
* @param amountToTransfer * @param amountToTransfer
* @param office * @param office
* @param createdBy * @param createdBy
*/ */
public Transfer(User userTransmitter, User userReceiver, ActiveStatus activeStatus, ActionStatus actionStatus, BigDecimal amountToTransfer, Office office, String createdBy) { public Transfer(User userTransmitter, User userReceiver, ActiveStatus activeStatus, ActionStatus actionStatus, BigDecimal amountToTransfer, Office office, String createdBy) {
this.userTransmitter = userTransmitter; this.userTransmitter = userTransmitter;
this.userReceiver = userReceiver; this.userReceiver = userReceiver;
this.activeStatus = activeStatus; this.activeStatus = activeStatus;
this.actionStatus = actionStatus; this.actionStatus = actionStatus;
this.amountToTransfer = amountToTransfer; this.amountToTransfer = amountToTransfer;
this.office = office; this.office = office;
this.createdBy = createdBy; this.createdBy = createdBy;
this.createdOn = new Date(); Date date = new Date();
} Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR, -7);
date = calendar.getTime();
this.createdOn = date;
}
/** /**
* *
* @param id * @param id
*/ */
public Transfer(String id) { public Transfer(String id) {
this.id = id; this.id = id;
} }
public Transfer(String id, User userTransmitter, User userReceiver, ActiveStatus activeStatus, ActionStatus actionStatus, BigDecimal amountToTransfer, Office office, String createdBy) { public Transfer(String id, User userTransmitter, User userReceiver, ActiveStatus activeStatus, ActionStatus actionStatus, BigDecimal amountToTransfer, Office office, String createdBy) {
this.id = id; this.id = id;
this.userTransmitter = userTransmitter; this.userTransmitter = userTransmitter;
this.userReceiver = userReceiver; this.userReceiver = userReceiver;
this.activeStatus = activeStatus; this.activeStatus = activeStatus;
this.actionStatus = actionStatus; this.actionStatus = actionStatus;
this.amountToTransfer = amountToTransfer; this.amountToTransfer = amountToTransfer;
this.office = office; this.office = office;
this.createdBy = createdBy; this.createdBy = createdBy;
this.createdOn = new Date(); this.createdOn = new Date();
} }
public Transfer(String id, User userTransmitter, User userReceiver, ActiveStatus activeStatus, ActionStatus actionStatus, BigDecimal amountToTransfer, Office office, String createdBy, Date createdOn) { public Transfer(String id, User userTransmitter, User userReceiver, ActiveStatus activeStatus, ActionStatus actionStatus, BigDecimal amountToTransfer, Office office, String createdBy, Date createdOn) {
this.id = id; this.id = id;
this.userTransmitter = userTransmitter; this.userTransmitter = userTransmitter;
this.userReceiver = userReceiver; this.userReceiver = userReceiver;
this.activeStatus = activeStatus; this.activeStatus = activeStatus;
this.actionStatus = actionStatus; this.actionStatus = actionStatus;
this.amountToTransfer = amountToTransfer; this.amountToTransfer = amountToTransfer;
this.office = office; this.office = office;
this.createdBy = createdBy; this.createdBy = createdBy;
this.createdOn = createdOn; this.createdOn = createdOn;
} }
public String getId() { public String getId() {
return id; return id;
} }
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
public User getUserTransmitter() { public User getUserTransmitter() {
return userTransmitter; return userTransmitter;
} }
public void setUserTransmitter(User userTransmitter) { public void setUserTransmitter(User userTransmitter) {
this.userTransmitter = userTransmitter; this.userTransmitter = userTransmitter;
} }
public User getUserReceiver() { public User getUserReceiver() {
return userReceiver; return userReceiver;
} }
public void setUserReceiver(User userReceiver) { public void setUserReceiver(User userReceiver) {
this.userReceiver = userReceiver; this.userReceiver = userReceiver;
} }
public ActiveStatus getActiveStatus() { public ActiveStatus getActiveStatus() {
return activeStatus; return activeStatus;
} }
public void setActiveStatus(ActiveStatus activeStatus) { public void setActiveStatus(ActiveStatus activeStatus) {
this.activeStatus = activeStatus; this.activeStatus = activeStatus;
} }
public ActionStatus getActionStatus() { public ActionStatus getActionStatus() {
return actionStatus; return actionStatus;
} }
public void setActionStatus(ActionStatus actionStatus) { public void setActionStatus(ActionStatus actionStatus) {
this.actionStatus = actionStatus; this.actionStatus = actionStatus;
} }
public BigDecimal getAmountToTransfer() { public BigDecimal getAmountToTransfer() {
return amountToTransfer; return amountToTransfer;
} }
public void setAmountToTransfer(BigDecimal amountToTransfer) { public void setAmountToTransfer(BigDecimal amountToTransfer) {
this.amountToTransfer = amountToTransfer; this.amountToTransfer = amountToTransfer;
} }
public String getCreatedBy() { public String getCreatedBy() {
return createdBy; return createdBy;
} }
public void setCreatedBy(String createdBy) { public void setCreatedBy(String createdBy) {
this.createdBy = createdBy; this.createdBy = createdBy;
} }
public Date getCreatedOn() { public Date getCreatedOn() {
return createdOn; return createdOn;
} }
public void setCreatedOn(Date createdOn) { public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn; this.createdOn = createdOn;
} }
public String getLastUpdatedBy() { public String getLastUpdatedBy() {
return lastUpdatedBy; return lastUpdatedBy;
} }
public void setLastUpdatedBy(String lastUpdatedBy) { public void setLastUpdatedBy(String lastUpdatedBy) {
this.lastUpdatedBy = lastUpdatedBy; this.lastUpdatedBy = lastUpdatedBy;
} }
public Date getLastUpdatedOn() { public Date getLastUpdatedOn() {
return lastUpdatedOn; return lastUpdatedOn;
} }
public void setLastUpdatedOn(Date lastUpdatedOn) { public void setLastUpdatedOn(Date lastUpdatedOn) {
this.lastUpdatedOn = lastUpdatedOn; this.lastUpdatedOn = lastUpdatedOn;
} }
public Office getOffice() { public Office getOffice() {
return office; return office;
} }
public void setOffice(Office office) { public void setOffice(Office office) {
this.office = office; this.office = office;
} }
public String getUserReceiverRoutes(){ public String getUserReceiverRoutes() {
String routes = ""; String routes = "";
routes = userReceiver.getHumanResource().getHumanResourceHasRoutes().stream().map((py) -> py.getRouteCtlg().getRoute()).collect(Collectors.joining(", ")); routes = userReceiver.getHumanResource().getHumanResourceHasRoutes().stream().map((py) -> py.getRouteCtlg().getRoute()).collect(Collectors.joining(", "));
return routes; return routes;
} }
public String getUserTransmitterRoutes(){ public String getUserTransmitterRoutes() {
String routes = ""; String routes = "";
routes = userTransmitter.getHumanResource().getHumanResourceHasRoutes().stream().map((py) -> py.getRouteCtlg().getRoute()).collect(Collectors.joining(", ")); routes = userTransmitter.getHumanResource().getHumanResourceHasRoutes().stream().map((py) -> py.getRouteCtlg().getRoute()).collect(Collectors.joining(", "));
return routes; return routes;
} }
public boolean getAction(Date lastStableSmallBox) {
Date date = createdOn;
boolean action = true;
try {
SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd");
String dateStr = dt1.format(date); public boolean getAction(Date lastStableSmallBox) {
date = dt1.parse(dateStr); Date date = createdOn;
boolean action = true;
try {
SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd");
action = date.after(lastStableSmallBox); String dateStr = dt1.format(date);
date = dt1.parse(dateStr);
} catch (Exception ex) { action = date.after(lastStableSmallBox);
Logger.getLogger(ExpenseCompany.class.getName()).log(Level.SEVERE, null, ex);
}
return action;
}
public boolean getActive() { } catch (Exception ex) {
if (activeStatus == ActiveStatus.ENEBLED) { Logger.getLogger(ExpenseCompany.class.getName()).log(Level.SEVERE, null, ex);
return true; }
} else { return action;
return false; }
}
} public boolean getActive() {
if (activeStatus == ActiveStatus.ENEBLED) {
public String conditionEnabled() { return true;
if(getActiveStatus() == ActiveStatus.DISABLED) } else {
return "grayRow"; return false;
else }
return null; }
}
public String conditionEnabled() {
@Override if (getActiveStatus() == ActiveStatus.DISABLED) {
public String toString() { return "grayRow";
return "Transfer{" + "activeStatus=" + activeStatus + ", actionStatus=" + actionStatus + ", createdOn=" + createdOn + '}'; } else {
} return null;
}
}
@Override
public String toString() {
return "Transfer{" + "activeStatus=" + activeStatus + ", actionStatus=" + actionStatus + ", createdOn=" + createdOn + '}';
}
} }

View File

@ -0,0 +1,19 @@
/*
* 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.core.constance;
/**
*
* @author Carlos Janitzio Zavala Lopez <janitzio.zavala@arrebol.com.mx>
*/
public interface CustomerWithoutRenovationViewCfg extends GenericCfg {
String QUERY_FIND_ALL_UNRENEWED_CUSTOMERS_BY_ROUTE = "findAllNonRenewingCustomersByRuteIdList";
String FIELD_RUTE_ID = "idRoute";
}

View File

@ -0,0 +1,137 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.arrebol.apc.model.views;
import java.io.Serializable;
import java.util.Date;
/**
*
* @author Oscar
*/
public class CustomerWithoutRenovationSimpleDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String personName;
private Date lastLoan;
private String amountPaid;
private String amountToPay;
private String saldoInsoluto;
private String actionNumber;
private String numFee;
private String addressHome;
private String addressBusiness;
private String companyName;
private String strPaymentDate;
// Constructor
public CustomerWithoutRenovationSimpleDTO() {
}
// Constructor desde entidad
public CustomerWithoutRenovationSimpleDTO(CustomerWithoutRenovationView entity) {
this.personName = entity.getPersonName();
this.lastLoan = entity.getLastLoan();
this.amountPaid = entity.getAmountPaid();
this.amountToPay = entity.getAmountToPay();
this.saldoInsoluto = entity.getSaldoInsoluto();
this.actionNumber = entity.getActionNumber();
this.numFee = entity.getNumFee();
this.addressHome = entity.getAddressHome();
this.addressBusiness = entity.getAddressBusiness();
this.companyName = entity.getCompanyName();
this.strPaymentDate = entity.getStrPaymentDate();
}
public String getPersonName() {
return personName;
}
public void setPersonName(String personName) {
this.personName = personName;
}
public Date getLastLoan() {
return lastLoan;
}
public void setLastLoan(Date lastLoan) {
this.lastLoan = lastLoan;
}
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 getSaldoInsoluto() {
return saldoInsoluto;
}
public void setSaldoInsoluto(String saldoInsoluto) {
this.saldoInsoluto = saldoInsoluto;
}
public String getActionNumber() {
return actionNumber;
}
public void setActionNumber(String actionNumber) {
this.actionNumber = actionNumber;
}
public String getNumFee() {
return numFee;
}
public void setNumFee(String numFee) {
this.numFee = numFee;
}
public String getAddressHome() {
return addressHome;
}
public void setAddressHome(String addressHome) {
this.addressHome = addressHome;
}
public String getAddressBusiness() {
return addressBusiness;
}
public void setAddressBusiness(String addressBusiness) {
this.addressBusiness = addressBusiness;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getStrPaymentDate() {
return strPaymentDate;
}
public void setStrPaymentDate(String strPaymentDate) {
this.strPaymentDate = strPaymentDate;
}
}

View File

@ -1,8 +1,8 @@
/* /*
* Arrebol Consultancy copyright. * Arrebol Consultancy copyright.
* *
* This code belongs to Arrebol Consultancy * 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. * without written authorization from Arrebol Consultancy.
*/ */
package com.arrebol.apc.model.views; package com.arrebol.apc.model.views;
@ -30,197 +30,203 @@ import org.hibernate.annotations.Immutable;
@Table(name = "APC_CUSTOMERS_WITHOUT_RENOVATION_VIEW") @Table(name = "APC_CUSTOMERS_WITHOUT_RENOVATION_VIEW")
public class CustomerWithoutRenovationView implements Serializable { public class CustomerWithoutRenovationView implements Serializable {
private static final long serialVersionUID = 3731003393000465083L; private static final long serialVersionUID = 3731003393000465083L;
@Id @Id
@Column(name = "id", length = 36) @Column(name = "id", length = 36)
private String id; private String id;
@Column(name = "available_person") @Column(name = "available_person")
private String personName; private String personName;
@Column(name = "route_name") @Column(name = "route_name")
private String routeName; private String routeName;
@Column(name = "last_loan") @Column(name = "id_route")
@Temporal(javax.persistence.TemporalType.DATE) private String idRoute;
private Date lastLoan;
@Column(name = "amount_paid")
private String amountPaid;
@Column(name = "amount_to_pay")
private String amountToPay;
@Column(name = "saldo_insoluto")
private String saldoInsoluto;
@Column(name = "action_number") @Column(name = "last_loan")
private String actionNumber; @Temporal(javax.persistence.TemporalType.DATE)
private Date lastLoan;
@Column(name = "num_fee")
private String numFee;
@Column(name = "address_home")
private String addressHome;
@Column(name = "address_business")
private String addressBusiness;
@Column(name = "company_name")
private String companyName;
@ManyToOne(fetch = FetchType.LAZY, optional = false) @Column(name = "amount_paid")
@JoinColumn( private String amountPaid;
name = "id_office",
referencedColumnName = "id",
nullable = false
)
private Office office;
@Column(name = "str_payment_date", length = 22) @Column(name = "amount_to_pay")
private String strPaymentDate; private String amountToPay;
public String getId() { @Column(name = "saldo_insoluto")
return id; private String saldoInsoluto;
}
public void setId(String id) { @Column(name = "action_number")
this.id = id; private String actionNumber;
}
public String getPersonName() { @Column(name = "num_fee")
return personName; private String numFee;
}
public void setPersonName(String personName) { @Column(name = "address_home")
this.personName = personName; private String addressHome;
}
public String getRouteName() { @Column(name = "address_business")
return routeName; private String addressBusiness;
}
public void setRouteName(String routeName) { @Column(name = "company_name")
this.routeName = routeName; private String companyName;
}
public Date getLastLoan() { @ManyToOne(fetch = FetchType.LAZY, optional = false)
return lastLoan; @JoinColumn(
} name = "id_office",
referencedColumnName = "id",
nullable = false
)
private Office office;
public void setLastLoan(Date lastLoan) { @Column(name = "str_payment_date", length = 22)
this.lastLoan = lastLoan; private String strPaymentDate;
}
public Office getOffice() { public String getId() {
return office; return id;
} }
public void setOffice(Office office) { public void setId(String id) {
this.office = office; this.id = id;
} }
public String getStrPaymentDate() { public String getPersonName() {
return strPaymentDate; return personName;
} }
public void setStrPaymentDate(String strPaymentDate) { public void setPersonName(String personName) {
this.strPaymentDate = strPaymentDate; this.personName = personName;
} }
public String getAmountPaid() { public String getRouteName() {
return amountPaid; return routeName;
} }
public void setAmountPaid(String amountPaid) { public void setRouteName(String routeName) {
this.amountPaid = amountPaid; this.routeName = routeName;
} }
public String getAmountToPay() { public Date getLastLoan() {
return amountToPay; return lastLoan;
} }
public void setAmountToPay(String amountToPay) { public void setLastLoan(Date lastLoan) {
this.amountToPay = amountToPay; this.lastLoan = lastLoan;
} }
public String getSaldoInsoluto() { public Office getOffice() {
return saldoInsoluto; return office;
} }
public void setSaldoInsoluto(String saldoInsoluto) { public void setOffice(Office office) {
this.saldoInsoluto = saldoInsoluto; this.office = office;
} }
public String getActionNumber() { public String getStrPaymentDate() {
return actionNumber; return strPaymentDate;
} }
public void setActionNumber(String actionNumber) { public void setStrPaymentDate(String strPaymentDate) {
this.actionNumber = actionNumber; this.strPaymentDate = strPaymentDate;
} }
public String getNumFee() { public String getAmountPaid() {
return numFee; return amountPaid;
} }
public void setNumFee(String numFee) { public void setAmountPaid(String amountPaid) {
this.numFee = numFee; this.amountPaid = amountPaid;
} }
public String getAddressHome() { public String getAmountToPay() {
return addressHome; return amountToPay;
} }
public void setAddressHome(String addressHome) { public void setAmountToPay(String amountToPay) {
this.addressHome = addressHome; this.amountToPay = amountToPay;
} }
public String getAddressBusiness() { public String getSaldoInsoluto() {
return addressBusiness; return saldoInsoluto;
} }
public void setAddressBusiness(String addressBusiness) { public void setSaldoInsoluto(String saldoInsoluto) {
this.addressBusiness = addressBusiness; this.saldoInsoluto = saldoInsoluto;
} }
public String getCompanyName() { public String getActionNumber() {
return companyName; return actionNumber;
} }
public void setCompanyName(String companyName) { public void setActionNumber(String actionNumber) {
this.companyName = companyName; this.actionNumber = actionNumber;
} }
@Override public String getNumFee() {
public int hashCode() { return numFee;
int hash = 7; }
hash = 61 * hash + Objects.hashCode(this.id);
return hash;
}
@Override public void setNumFee(String numFee) {
public boolean equals(Object obj) { this.numFee = numFee;
if (this == obj) { }
return true;
} public String getAddressHome() {
if (obj == null) { return addressHome;
return false; }
}
if (getClass() != obj.getClass()) { public void setAddressHome(String addressHome) {
return false; this.addressHome = addressHome;
} }
final CustomerWithoutRenovationView other = (CustomerWithoutRenovationView) obj;
if (!Objects.equals(this.id, other.id)) { public String getAddressBusiness() {
return false; return addressBusiness;
} }
return true;
} public void setAddressBusiness(String addressBusiness) {
this.addressBusiness = addressBusiness;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getIdRoute() {
return idRoute;
}
public void setIdRoute(String idRoute) {
this.idRoute = idRoute;
}
@Override
public int hashCode() {
int hash = 7;
hash = 61 * hash + Objects.hashCode(this.id);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final CustomerWithoutRenovationView other = (CustomerWithoutRenovationView) obj;
if (!Objects.equals(this.id, other.id)) {
return false;
}
return true;
}
} }

View File

@ -222,6 +222,7 @@
<mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/customer.without.renovation.view.queries.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" />

View File

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"https://hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<query name="findAllNonRenewingCustomersByRuteIdList">
<![CDATA[
SELECT
view
FROM CustomerWithoutRenovationView view
WHERE
idRoute = :idRoute
ORDER BY personName DESC
]]>
</query>
</hibernate-mapping>

View File

@ -140,8 +140,8 @@
<id>Localhost</id> <id>Localhost</id>
<properties> <properties>
<hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5</hibernate.connection.url> <hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5</hibernate.connection.url>
<hibernate.connection.username>apoprocomlocalhost</hibernate.connection.username> <hibernate.connection.username>root</hibernate.connection.username>
<hibernate.connection.password>Yj$2Da0z!</hibernate.connection.password> <hibernate.connection.password>root</hibernate.connection.password>
</properties> </properties>
</profile> </profile>
<profile> <profile>

View File

@ -206,11 +206,11 @@
</properties> </properties>
</profile> </profile>
<profile> <profile>
<id>Localhost-Mobile-APP</id> <id>Localhost</id>
<properties> <properties>
<hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5</hibernate.connection.url> <hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=GMT-5</hibernate.connection.url>
<hibernate.connection.username>apoprocommobilelocalhost</hibernate.connection.username> <hibernate.connection.username>root</hibernate.connection.username>
<hibernate.connection.password>0Ps$6%q8</hibernate.connection.password> <hibernate.connection.password>root</hibernate.connection.password>
</properties> </properties>
</profile> </profile>
<profile> <profile>

View File

@ -1,20 +1,25 @@
/* /*
* Arrebol Consultancy copyright. * Arrebol Consultancy copyright.
* *
* This code belongs to Arrebol Consultancy * 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. * without written authorization from Arrebol Consultancy.
*/ */
package com.arrebol.apc.ws.customer; package com.arrebol.apc.ws.customer;
import com.arrebol.apc.controller.mobile.controller.customer.CustomerController; import com.arrebol.apc.controller.mobile.controller.customer.CustomerController;
import com.arrebol.apc.model.views.CustomerWithoutRenovationSimpleDTO;
import com.arrebol.apc.model.views.CustomerWithoutRenovationView;
import com.arrebol.apc.model.views.LoanByUserView; import com.arrebol.apc.model.views.LoanByUserView;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import javax.ws.rs.FormParam; import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.GenericEntity; import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@ -28,32 +33,59 @@ import org.apache.logging.log4j.Logger;
@Path("customer") @Path("customer")
public class CustomerWS implements Serializable { public class CustomerWS implements Serializable {
private static final long serialVersionUID = -5280895557294295716L; private static final long serialVersionUID = -5280895557294295716L;
@POST @POST
@Path("list") @Path("list")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public Response findAllLoansByUserId(@FormParam("orderList") String orderList, @FormParam("userId") String userId) { public Response findAllLoansByUserId(@FormParam("orderList") String orderList, @FormParam("userId") String userId) {
logger.debug("findAllLoansByUserId"); logger.debug("findAllLoansByUserId");
Response response; Response response;
try { try {
GenericEntity<List<LoanByUserView>> list = new GenericEntity<List<LoanByUserView>>(controller.findAllLoansByUserId(orderList, userId)) { GenericEntity<List<LoanByUserView>> list = new GenericEntity<List<LoanByUserView>>(controller.findAllLoansByUserId(orderList, userId)) {
}; };
response = Response.ok(list).build(); response = Response.ok(list).build();
} catch (Exception e) { } catch (Exception e) {
logger.error("findAllLoansByUserId", e); logger.error("findAllLoansByUserId", e);
response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); response = Response.status(Response.Status.NOT_ACCEPTABLE).build();
} }
return response; return response;
} }
final Logger logger = LogManager.getLogger(CustomerWS.class); @GET
private final CustomerController controller; @Path("nonRenewingCustomersByRuteId")
@Produces(MediaType.APPLICATION_JSON)
public Response findAllNonRenewingCustomersByRuteId(@QueryParam("idRoute") String idRoute) {
logger.debug("findAllNonRenewingCustomersByRuteId");
public CustomerWS() { Response response;
this.controller = new CustomerController(); try {
} List<CustomerWithoutRenovationView> originalList = controller.findAllNonRenewingCustomersByRuteId(idRoute);
// Convertir a DTOs
List<CustomerWithoutRenovationSimpleDTO> simplifiedList = originalList.stream()
.map(CustomerWithoutRenovationSimpleDTO::new)
.collect(Collectors.toList());
GenericEntity<List<CustomerWithoutRenovationSimpleDTO>> list
= new GenericEntity<List<CustomerWithoutRenovationSimpleDTO>>(simplifiedList) {
};
response = Response.ok(list).build();
} catch (Exception e) {
logger.error("findAllNonRenewingCustomersByRuteId", e);
response = Response.status(Response.Status.NOT_ACCEPTABLE).build();
}
return response;
}
final Logger logger = LogManager.getLogger(CustomerWS.class);
private final CustomerController controller;
public CustomerWS() {
this.controller = new CustomerController();
}
} }

View File

@ -1,8 +1,8 @@
/* /*
* Arrebol Consultancy copyright. * Arrebol Consultancy copyright.
* *
* This code belongs to Arrebol Consultancy * 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. * without written authorization from Arrebol Consultancy.
*/ */
package com.arrebol.apc.ws.gasoline; package com.arrebol.apc.ws.gasoline;
@ -14,6 +14,7 @@ import com.arrebol.apc.model.core.User;
import com.arrebol.apc.model.enums.GenericStatus; import com.arrebol.apc.model.enums.GenericStatus;
import com.arrebol.apc.model.gasoline.Gasoline; import com.arrebol.apc.model.gasoline.Gasoline;
import java.io.Serializable; import java.io.Serializable;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
import javax.ws.rs.FormParam; import javax.ws.rs.FormParam;
@ -32,45 +33,51 @@ import org.apache.logging.log4j.Logger;
@Path("gasoline") @Path("gasoline")
public class GasolineWS implements Serializable { public class GasolineWS implements Serializable {
@PUT @PUT
@Path("save-new-gasoline-payment") @Path("save-new-gasoline-payment")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public Response saveNewGasolinePayment(@FormParam("idUser") String idUser, public Response saveNewGasolinePayment(@FormParam("idUser") String idUser,
@FormParam("idOffice") String idOffice, @FormParam("idOffice") String idOffice,
@FormParam("idRoute") String idRoute, @FormParam("idRoute") String idRoute,
@FormParam("total") Double total, @FormParam("total") Double total,
@FormParam("km") Double km, @FormParam("km") Double km,
@FormParam("quantity") Double quantity, @FormParam("quantity") Double quantity,
@FormParam("description") String description) { @FormParam("description") String description) {
Response response; Response response;
try { try {
GasolineController controller = new GasolineController(); GasolineController controller = new GasolineController();
Gasoline gasoline = new Gasoline( Date date = new Date();
UUID.randomUUID().toString(), Calendar calendar = Calendar.getInstance();
new User(idUser), calendar.setTime(date);
new Office(idOffice), calendar.add(Calendar.HOUR_OF_DAY, -7);
new RouteCtlg(idRoute), date = calendar.getTime();
quantity,
km,
total,
GenericStatus.ENABLED,
description,
idUser,
new Date());
if (controller.saveNewGasolinePayment(gasoline)) { Gasoline gasoline = new Gasoline(
response = Response.ok().build(); UUID.randomUUID().toString(),
} else { new User(idUser),
response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); new Office(idOffice),
} new RouteCtlg(idRoute),
} catch (Exception e) { quantity,
logger.error("saveNewGasolineEntry"); km,
total,
GenericStatus.ENABLED,
description,
idUser,
date);
if (controller.saveNewGasolinePayment(gasoline)) {
response = Response.ok().build();
} else {
response = Response.status(Response.Status.NOT_ACCEPTABLE).build(); response = Response.status(Response.Status.NOT_ACCEPTABLE).build();
} }
return response; } catch (Exception e) {
} logger.error("saveNewGasolineEntry");
response = Response.status(Response.Status.NOT_ACCEPTABLE).build();
}
return response;
}
private static final long serialVersionUID = -5280895557294295916L; private static final long serialVersionUID = -5280895557294295916L;
final Logger logger = LogManager.getLogger(getClass()); final Logger logger = LogManager.getLogger(getClass());
} }

File diff suppressed because it is too large Load Diff

View File

@ -216,6 +216,7 @@
<mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/loan.in.pending.status.to.delivery.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/loan/loan.employee.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/current.customer.by.loan.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/customer.without.renovation.view.queries.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/views/availables.owners.view.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/reports/user.week.report.hbm.xml" />
<mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" /> <mapping resource="com/arrebol/apc/model/queries/mobile/gasoline/gasoline.hbm.xml" />