use of org.joda.time.LocalDate in project head by mifos.
the class CollectionSheetDaoHibernateIntegrationTest method testShouldRetrieveCustomerHierarchyWithAGroupAsRootByBranchId.
@Test
public void testShouldRetrieveCustomerHierarchyWithAGroupAsRootByBranchId() throws Exception {
// setup
final Integer customerId = group.getCustomerId();
final LocalDate transactionDate = new LocalDate();
// exercise test
final List<CollectionSheetCustomerDto> customerHierarchy = collectionSheetDao.findCustomerHierarchy(customerId, transactionDate);
// verification
Assert.assertNotNull(customerHierarchy);
Assert.assertFalse(customerHierarchy.isEmpty());
Assert.assertNotNull(customerHierarchy.get(0));
Assert.assertNotNull(customerHierarchy.get(0));
Assert.assertEquals(group.getCustomerId(), customerHierarchy.get(0).getCustomerId());
Assert.assertEquals(group.getDisplayName(), customerHierarchy.get(0).getName());
Assert.assertEquals(group.getSearchId(), customerHierarchy.get(0).getSearchId());
Assert.assertEquals(group.getLevel().getValue(), customerHierarchy.get(0).getLevelId());
Assert.assertNull("group should have no attendance against them", customerHierarchy.get(0).getAttendanceId());
Assert.assertNotNull(customerHierarchy.get(1));
Assert.assertEquals(client.getCustomerId(), customerHierarchy.get(1).getCustomerId());
Assert.assertEquals(client.getDisplayName(), customerHierarchy.get(1).getName());
Assert.assertEquals(client.getSearchId(), customerHierarchy.get(1).getSearchId());
Assert.assertEquals(client.getLevel().getValue(), customerHierarchy.get(1).getLevelId());
Assert.assertNull("client should have no attendance against them", customerHierarchy.get(1).getAttendanceId());
}
use of org.joda.time.LocalDate in project head by mifos.
the class CollectionSheetDaoHibernateIntegrationTest method testShouldFindAccountCollectionFeesForCustomerAccounts.
@Test
@Ignore
public void testShouldFindAccountCollectionFeesForCustomerAccounts() {
// setup
final Short branchId = center.getOffice().getOfficeId();
final String searchId = center.getSearchId() + ".%";
final LocalDate transactionDate = new LocalDate();
// exercise test
Map<Integer, List<CollectionSheetCustomerAccountCollectionDto>> allCustomerAccountCollectionFees = collectionSheetDao.findAccountCollectionsOnCustomerAccount(branchId, searchId, transactionDate, center.getCustomerId());
// verification
Assert.assertNotNull(allCustomerAccountCollectionFees);
final List<CollectionSheetCustomerAccountCollectionDto> accountCollections = allCustomerAccountCollectionFees.get(group.getCustomerId());
Assert.assertNotNull(accountCollections);
Assert.assertThat(accountCollections.size(), is(1));
Assert.assertThat(accountCollections.get(0).getAccountId(), is(group.getCustomerAccount().getAccountId()));
Assert.assertThat(accountCollections.get(0).getCustomerId(), is(group.getCustomerId()));
Assert.assertThat(accountCollections.get(0).getMiscFeesDue(), is(new BigDecimal("0.0000")));
Assert.assertThat(accountCollections.get(0).getMiscFeesPaid(), is(new BigDecimal("0.0000")));
Assert.assertThat(accountCollections.get(0).getAccountCollectionPayment(), is(Double.valueOf("0.0")));
}
use of org.joda.time.LocalDate in project head by mifos.
the class SavingsApplyAdjustmentAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
clearActionForm(form);
doCleanUp(request);
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
Long savingsId = Long.valueOf(savings.getAccountId());
savings = this.savingsDao.findById(savingsId);
savings.setUserContext(uc);
String paymentIdParam = request.getParameter("paymentId");
Integer paymentId;
if (paymentIdParam == null) {
AccountPaymentEntity payment = savings.getLastPmnt();
paymentId = (payment == null) ? null : payment.getPaymentId();
} else {
paymentId = Integer.valueOf(paymentIdParam);
}
SavingsAdjustmentReferenceDto savingsAdjustmentDto = this.savingsServiceFacade.retrieveAdjustmentReferenceData(savingsId, paymentId);
if (savingsAdjustmentDto.isDepositOrWithdrawal()) {
AccountPaymentEntity payment = (paymentId == null) ? savings.findMostRecentPaymentByPaymentDate() : savings.findPaymentById(paymentId);
AccountActionEntity accountAction = legacyMasterDao.getPersistentObject(AccountActionEntity.class, new SavingsHelper().getPaymentActionType(payment));
Hibernate.initialize(savings.findMostRecentPaymentByPaymentDate().getAccountTrxns());
SessionUtils.setAttribute(SavingsConstants.ACCOUNT_ACTION, accountAction, request);
SessionUtils.setAttribute(SavingsConstants.CLIENT_NAME, savingsAdjustmentDto.getClientName(), request);
SessionUtils.setAttribute(SavingsConstants.IS_LAST_PAYMENT_VALID, Constants.YES, request);
SessionUtils.setAttribute(SavingsConstants.ADJUSTMENT_AMOUNT, payment.getAmount().getAmount(), request);
SavingsApplyAdjustmentActionForm actionForm = (SavingsApplyAdjustmentActionForm) form;
actionForm.setPaymentId(paymentId);
actionForm.setTrxnDate(new LocalDate(payment.getPaymentDate()));
} else {
SessionUtils.setAttribute(SavingsConstants.IS_LAST_PAYMENT_VALID, Constants.NO, request);
}
SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
return mapping.findForward("load_success");
}
use of org.joda.time.LocalDate in project head by mifos.
the class SavingsClosureAction method close.
@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward close(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
SavingsClosureActionForm actionForm = (SavingsClosureActionForm) form;
AccountPaymentEntity payment = (AccountPaymentEntity) SessionUtils.getAttribute(SavingsConstants.ACCOUNT_PAYMENT, request);
SavingsBO savingsInSession = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
Long savingsId = Long.valueOf(savingsInSession.getAccountId());
SavingsBO savings = this.savingsDao.findById(savingsId);
checkVersionMismatch(savingsInSession.getVersionNo(), savings.getVersionNo());
savings.setUserContext(getUserContext(request));
UserContext userContext = getUserContext(request);
Long customerId = null;
if (actionForm.getCustomerId() != null) {
customerId = Long.valueOf(actionForm.getCustomerId());
}
LocalDate dateOfWithdrawal = new LocalDate(payment.getPaymentDate());
Double amount = payment.getAmount().getAmountDoubleValue();
Integer modeOfPayment = payment.getPaymentType().getId().intValue();
String receiptId = payment.getReceiptNumber();
LocalDate dateOfReceipt = null;
if (payment.getReceiptDate() != null) {
dateOfReceipt = new LocalDate(payment.getReceiptDate());
}
Locale preferredLocale = userContext.getPreferredLocale();
SavingsWithdrawalDto closeAccount = new SavingsWithdrawalDto(savingsId, customerId, dateOfWithdrawal, amount, modeOfPayment, receiptId, dateOfReceipt, preferredLocale);
this.savingsServiceFacade.closeSavingsAccount(savingsId, actionForm.getNotes(), closeAccount);
SessionUtils.removeAttribute(SavingsConstants.ACCOUNT_PAYMENT, request);
closeSavingsQuestionnaire.saveResponses(request, actionForm, savingsInSession.getAccountId());
return mapping.findForward("close_success");
}
use of org.joda.time.LocalDate in project head by mifos.
the class SavingsDepositWithdrawalAction method makePayment.
@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward makePayment(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
SavingsBO savedAccount = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
SavingsBO savings = savingsDao.findById(savedAccount.getAccountId());
checkVersionMismatch(savedAccount.getVersionNo(), savings.getVersionNo());
savings.setVersionNo(savedAccount.getVersionNo());
SavingsDepositWithdrawalActionForm actionForm = (SavingsDepositWithdrawalActionForm) form;
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
Date trxnDate = getDateFromString(actionForm.getTrxnDate(), uc.getPreferredLocale());
monthClosingServiceFacade.validateTransactionDate(trxnDate);
Date meetingDate = new CustomerPersistence().getLastMeetingDateForCustomer(savings.getCustomer().getCustomerId());
boolean repaymentIndependentOfMeetingEnabled = new ConfigurationPersistence().isRepaymentIndepOfMeetingEnabled();
if (!savings.isTrxnDateValid(trxnDate, meetingDate, repaymentIndependentOfMeetingEnabled)) {
throw new AccountException(AccountConstants.ERROR_INVALID_TRXN);
}
Long savingsId = Long.valueOf(savings.getAccountId());
Long customerId = Long.valueOf(savings.getCustomer().getCustomerId());
if (StringUtils.isNotBlank(actionForm.getCustomerId())) {
customerId = Long.valueOf(actionForm.getCustomerId());
}
Locale preferredLocale = uc.getPreferredLocale();
LocalDate dateOfDepositOrWithdrawalTransaction = new LocalDate(trxnDate);
Double amount = Double.valueOf(actionForm.getAmount());
Integer modeOfPayment = Integer.valueOf(actionForm.getPaymentTypeId());
String receiptId = actionForm.getReceiptId();
LocalDate dateOfReceipt = null;
if (StringUtils.isNotBlank(actionForm.getReceiptDate())) {
dateOfReceipt = new LocalDate(getDateFromString(actionForm.getReceiptDate(), preferredLocale));
}
try {
Short trxnTypeId = Short.valueOf(actionForm.getTrxnTypeId());
if (trxnTypeId.equals(AccountActionTypes.SAVINGS_DEPOSIT.getValue())) {
SavingsDepositDto savingsDeposit = new SavingsDepositDto(savingsId, customerId, dateOfDepositOrWithdrawalTransaction, amount, modeOfPayment, receiptId, dateOfReceipt, preferredLocale);
this.savingsServiceFacade.deposit(savingsDeposit);
} else if (trxnTypeId.equals(AccountActionTypes.SAVINGS_WITHDRAWAL.getValue())) {
SavingsWithdrawalDto savingsWithdrawal = new SavingsWithdrawalDto(savingsId, customerId, dateOfDepositOrWithdrawalTransaction, amount, modeOfPayment, receiptId, dateOfReceipt, preferredLocale);
this.savingsServiceFacade.withdraw(savingsWithdrawal);
}
} catch (BusinessRuleException e) {
throw new AccountException(e.getMessageKey(), e);
}
return mapping.findForward(ActionForwards.account_details_page.toString());
}
Aggregations