Search in sources :

Example 46 with LocalDate

use of org.joda.time.LocalDate in project head by mifos.

the class SavingsServiceFacadeWebTier method retrieveDepositWithdrawalReferenceData.

@Override
public DepositWithdrawalReferenceDto retrieveDepositWithdrawalReferenceData(Long savingsId, Integer customerId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    try {
        SavingsBO savingsAccount = savingsDao.findById(savingsId);
        String depositDue = savingsAccount.getTotalPaymentDue(customerId).toString();
        String withdrawalDue = "0";
        List<ListElement> clients = new ArrayList<ListElement>();
        if (savingsAccount.isGroupModelWithIndividualAccountability()) {
            List<CustomerBO> activeAndOnHoldClients = new CustomerPersistence().getActiveAndOnHoldChildren(savingsAccount.getCustomer().getSearchId(), savingsAccount.getCustomer().getOfficeId(), CustomerLevel.CLIENT);
            for (CustomerBO client : activeAndOnHoldClients) {
                clients.add(new ListElement(client.getCustomerId(), client.getDisplayName()));
            }
        }
        List<AccountActionEntity> trxnTypes = new ArrayList<AccountActionEntity>();
        trxnTypes.add(new AccountBusinessService().getAccountAction(AccountActionTypes.SAVINGS_DEPOSIT.getValue(), userContext.getLocaleId()));
        trxnTypes.add(new AccountBusinessService().getAccountAction(AccountActionTypes.SAVINGS_WITHDRAWAL.getValue(), userContext.getLocaleId()));
        List<ListElement> transactionTypes = new ArrayList<ListElement>();
        for (AccountActionEntity accountActionEntity : trxnTypes) {
            LookUpValueEntity lookupValue = accountActionEntity.getLookUpValue();
            String messageText = lookupValue.getMessageText();
            if (StringUtils.isBlank(messageText)) {
                messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
            }
            transactionTypes.add(new ListElement(accountActionEntity.getId().intValue(), messageText));
        }
        List<ListElement> depositPaymentTypes = retrieveDepositPaymentTypes(userContext);
        List<ListElement> withdrawalPaymentTypes = new ArrayList<ListElement>();
        List<PaymentTypeEntity> withdrawalPaymentEntityTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(userContext.getLocaleId(), TrxnTypes.savings_withdrawal.getValue());
        for (PaymentTypeEntity paymentTypeEntity : withdrawalPaymentEntityTypes) {
            LookUpValueEntity lookupValue = paymentTypeEntity.getLookUpValue();
            String messageText = lookupValue.getMessageText();
            if (StringUtils.isBlank(messageText)) {
                messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
            }
            withdrawalPaymentTypes.add(new ListElement(paymentTypeEntity.getId().intValue(), messageText));
        }
        boolean backDatedTransactionsAllowed = AccountingRules.isBackDatedTxnAllowed();
        LocalDate defaultTransactionDate = new LocalDate();
        return new DepositWithdrawalReferenceDto(transactionTypes, depositPaymentTypes, withdrawalPaymentTypes, clients, backDatedTransactionsAllowed, defaultTransactionDate, depositDue, withdrawalDue);
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) LocalDate(org.joda.time.LocalDate) AccountActionEntity(org.mifos.accounts.business.AccountActionEntity) PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) ListElement(org.mifos.dto.screen.ListElement) PersistenceException(org.mifos.framework.exceptions.PersistenceException) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) DepositWithdrawalReferenceDto(org.mifos.dto.screen.DepositWithdrawalReferenceDto) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 47 with LocalDate

use of org.joda.time.LocalDate in project head by mifos.

the class LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImplTest method shouldFindNextMatchingDateInclusiveOfDateProvided.

@Test
public void shouldFindNextMatchingDateInclusiveOfDateProvided() {
    // setup
    LocalDate fromAndInclusiveOf = new LocalDate();
    DateTime expectedDateTimeToStartSearchFrom = fromAndInclusiveOf.minusDays(1).toDateMidnight().toDateTime();
    DateTime nextMatchingDate = new DateTime();
    // stubbing
    when(scheduledEvent.nextEventDateAfter(expectedDateTimeToStartSearchFrom)).thenReturn(nextMatchingDate);
    // exercise test
    LocalDate result = loanDisbursementStrategy.findClosestMatchingDateFromAndInclusiveOf(fromAndInclusiveOf);
    // verification
    assertThat(result, is(nextMatchingDate.toLocalDate()));
}
Also used : LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 48 with LocalDate

use of org.joda.time.LocalDate in project head by mifos.

the class LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImplTest method setup.

@Before
public void setup() {
    LocalDate nextValidCustomerMeetingDate = new LocalDate();
    loanDisbursementStrategy = new LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl(scheduledEvent, nextValidCustomerMeetingDate);
}
Also used : LocalDate(org.joda.time.LocalDate) Before(org.junit.Before)

Example 49 with LocalDate

use of org.joda.time.LocalDate in project head by mifos.

the class CenterCustAction method create.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    CenterCustActionForm actionForm = (CenterCustActionForm) form;
    MeetingBO meeting = (MeetingBO) SessionUtils.getAttribute(CustomerConstants.CUSTOMER_MEETING, request);
    LocalDate mfiJoiningDate = new LocalDate(CalendarUtils.getDateFromString(actionForm.getMfiJoiningDate(), getUserContext(request).getPreferredLocale()));
    Address address = actionForm.getAddress();
    AddressDto addressDto = Address.toDto(address);
    MeetingDto meetingDto = meeting.toDto();
    List<CreateAccountFeeDto> accountFeesToBeApplied = new ArrayList<CreateAccountFeeDto>();
    List<ApplicableAccountFeeDto> feesToBeApplied = actionForm.getFeesToApply();
    for (ApplicableAccountFeeDto feeDto : feesToBeApplied) {
        accountFeesToBeApplied.add(new CreateAccountFeeDto(feeDto.getFeeId(), feeDto.getAmount()));
    }
    try {
        CenterCreationDetail centerCreationDetail = new CenterCreationDetail(mfiJoiningDate, actionForm.getDisplayName(), actionForm.getExternalId(), addressDto, actionForm.getLoanOfficerIdValue(), actionForm.getOfficeIdValue(), accountFeesToBeApplied);
        CustomerDetailsDto centerDetails = this.centerServiceFacade.createNewCenter(centerCreationDetail, meetingDto);
        createCenterQuestionnaire.saveResponses(request, actionForm, centerDetails.getId());
        actionForm.setCustomerId(centerDetails.getId().toString());
        actionForm.setGlobalCustNum(centerDetails.getGlobalCustNum());
    } catch (BusinessRuleException e) {
        throw new ApplicationException(e.getMessageKey(), e.getMessageValues());
    }
    return mapping.findForward(ActionForwards.create_success.toString());
}
Also used : CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) Address(org.mifos.framework.business.util.Address) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) LocalDate(org.joda.time.LocalDate) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) MeetingDto(org.mifos.dto.domain.MeetingDto) CenterCreationDetail(org.mifos.dto.domain.CenterCreationDetail) BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 50 with LocalDate

use of org.joda.time.LocalDate in project head by mifos.

the class AccountRegenerateScheduleIntegrationTestCase method testChangeInSecondPeriodOfBiWeeklyMeetingSchedule.

@Test
public void testChangeInSecondPeriodOfBiWeeklyMeetingSchedule() throws Exception {
    List<LocalDate> expectedMeetingDates = new ArrayList<LocalDate>();
    expectedMeetingDates.add(new LocalDate(2008, MAY, 23));
    expectedMeetingDates.add(new LocalDate(2008, JUNE, 6));
    expectedMeetingDates.add(new LocalDate(2008, JUNE, 18));
    expectedMeetingDates.add(new LocalDate(2008, JULY, 2));
    expectedMeetingDates.add(new LocalDate(2008, JULY, 16));
    LocalDate startDate = new LocalDate(2008, MAY, 23);
    LocalDate dateWhenMeetingWillBeChanged = new LocalDate(2008, JUNE, 2);
    MeetingBO meeting = setupWeeklyMeeting(startDate, TestObjectFactory.EVERY_SECOND_WEEK);
    MeetingBO newMeeting = TestObjectFactory.getNewMeeting(RecurrenceType.WEEKLY, TestObjectFactory.EVERY_SECOND_WEEK, MeetingType.CUSTOMER_MEETING, WeekDay.WEDNESDAY);
    testChangeInMeetingScheduleForDates(meeting, newMeeting, startDate, dateWhenMeetingWillBeChanged);
    validateSchedules(expectedMeetingDates);
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Aggregations

LocalDate (org.joda.time.LocalDate)1094 Test (org.testng.annotations.Test)553 BigDecimal (java.math.BigDecimal)401 DateTime (org.joda.time.DateTime)231 ArrayList (java.util.ArrayList)217 Test (org.junit.Test)187 Invoice (org.killbill.billing.invoice.api.Invoice)165 UUID (java.util.UUID)148 Account (org.killbill.billing.account.api.Account)139 InvoiceItem (org.killbill.billing.invoice.api.InvoiceItem)118 DefaultEntitlement (org.killbill.billing.entitlement.api.DefaultEntitlement)104 FixedPriceInvoiceItem (org.killbill.billing.invoice.model.FixedPriceInvoiceItem)101 RecurringInvoiceItem (org.killbill.billing.invoice.model.RecurringInvoiceItem)95 ExpectedInvoiceItemCheck (org.killbill.billing.beatrix.util.InvoiceChecker.ExpectedInvoiceItemCheck)85 DefaultInvoice (org.killbill.billing.invoice.model.DefaultInvoice)82 RepairAdjInvoiceItem (org.killbill.billing.invoice.model.RepairAdjInvoiceItem)71 ItemAdjInvoiceItem (org.killbill.billing.invoice.model.ItemAdjInvoiceItem)69 PlanPhaseSpecifier (org.killbill.billing.catalog.api.PlanPhaseSpecifier)63 Date (java.util.Date)57 MockPlan (org.killbill.billing.catalog.MockPlan)52