use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class CollectionSheetEntryAction method get.
/**
* This method is called once the search criteria have been entered by the user to generate the bulk entry details
* for a particular customer It retrieves the loan officer office, and parent customer that was selected and sets
* them into the bulk entry business object. The list of attendance types and product list associated with the
* center, and its children are also retrieved
*/
@TransactionDemarcate(joinToken = true)
public ActionForward get(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
logTrackingInfo("get", request, form);
final BulkEntryActionForm collectionSheetEntryActionForm = (BulkEntryActionForm) form;
final CollectionSheetEntryFormDto previousCollectionSheetEntryFormDto = retrieveFromRequestCollectionSheetEntryFormDto(request);
final CollectionSheetEntryFormDtoDecorator dtoDecorator = new CollectionSheetEntryFormDtoDecorator(previousCollectionSheetEntryFormDto);
final CollectionSheetFormEnteredDataDto formEnteredDataDto = new FormEnteredDataAssembler(collectionSheetEntryActionForm, dtoDecorator).toDto();
final MifosCurrency currency = Configuration.getInstance().getSystemConfig().getCurrency();
final CollectionSheetEntryGridDto collectionSheetEntry = collectionSheetServiceFacade.generateCollectionSheetEntryGridView(formEnteredDataDto, currency);
storeOnRequestCollectionSheetEntryDto(request, collectionSheetEntry);
return mapping.findForward(CollectionSheetEntryConstants.GETSUCCESS);
}
use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class LoanBOTestUtils method createLoanAccount.
/**
* Like
* <b>createLoanAccountWithDisbursement(String, CustomerBO, AccountState, Date, LoanOfferingBO, int, Short)</b>
* but differs in various ways.
* <p/>
* This test code needs to be refactored! By creating the loan with a
* set of terms, then directly manipulating instance variables to completely
* change the repayment schedule, it leaves the loan in an inconsistent
* state, which leads one to suspect the validity of any of the 67 unit
* tests that use it.
*
* It has been verified that setActionDate method calls in the loop below
* will set the dates of the installments incorrectly for some if not all
* cases. For certain classes of tests this doesn't matter, but for others
* (involving verifying dates) it does. So BEWARE if you call down through
* this method.
*
* @param globalNum
*/
public static LoanBO createLoanAccount(final String globalNum, final CustomerBO customer, final AccountState state, final Date startDate, final LoanOfferingBO loanOffering) {
Calendar calendar = new GregorianCalendar();
calendar.setTime(startDate);
MeetingBO meeting = TestObjectFactory.createLoanMeeting(customer.getCustomerMeeting().getMeeting());
List<Date> meetingDates = TestObjectFactory.getMeetingDates(customer.getOfficeId(), meeting, 6);
MifosCurrency currency = loanOffering.getCurrency();
AmountFeeBO maintanenceFee = (AmountFeeBO) TestObjectFactory.createPeriodicAmountFee("Mainatnence Fee", FeeCategory.LOAN, "100", RecurrenceType.WEEKLY, Short.valueOf("1"));
IntegrationTestObjectMother.saveFee(maintanenceFee);
BigDecimal loanAmount = BigDecimal.valueOf(DEFAULT_LOAN_AMOUNT);
BigDecimal minAllowedLoanAmount = loanAmount;
BigDecimal maxAllowedLoanAmount = loanAmount;
Double interestRate = loanOffering.getDefInterestRate();
LocalDate disbursementDate = new LocalDate(meetingDates.get(0));
int numberOfInstallments = 6;
int minAllowedNumberOfInstallments = loanOffering.getEligibleInstallmentSameForAllLoan().getMaxNoOfInstall();
int maxAllowedNumberOfInstallments = loanOffering.getEligibleInstallmentSameForAllLoan().getMaxNoOfInstall();
int graceDuration = 0;
Integer sourceOfFundId = null;
Integer loanPurposeId = null;
Integer collateralTypeId = null;
String collateralNotes = null;
String externalId = null;
boolean repaymentScheduleIndependentOfCustomerMeeting = false;
RecurringSchedule recurringSchedule = null;
List<CreateAccountFeeDto> accountFees = new ArrayList<CreateAccountFeeDto>();
accountFees.add(new CreateAccountFeeDto(maintanenceFee.getFeeId().intValue(), maintanenceFee.getFeeAmount().toString()));
CreateLoanAccount createLoanAccount = new CreateLoanAccount(customer.getCustomerId(), loanOffering.getPrdOfferingId().intValue(), state.getValue().intValue(), loanAmount, minAllowedLoanAmount, maxAllowedLoanAmount, interestRate, disbursementDate, null, numberOfInstallments, minAllowedNumberOfInstallments, maxAllowedNumberOfInstallments, graceDuration, sourceOfFundId, loanPurposeId, collateralTypeId, collateralNotes, externalId, repaymentScheduleIndependentOfCustomerMeeting, recurringSchedule, accountFees, new ArrayList<CreateAccountPenaltyDto>());
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
LoanBO loan = IntegrationTestObjectMother.createClientLoan(createLoanAccount);
loan.updateDetails(TestUtils.makeUser());
AccountFeesEntity accountPeriodicFee = new AccountFeesEntity(loan, maintanenceFee, (maintanenceFee).getFeeAmount().getAmountDoubleValue());
AccountTestUtils.addAccountFees(accountPeriodicFee, loan);
loan.setLoanMeeting(meeting);
short i = 0;
for (Date date : meetingDates) {
LoanScheduleEntity actionDate = (LoanScheduleEntity) loan.getAccountActionDate(++i);
actionDate.setPrincipal(new Money(currency, "100.0"));
actionDate.setInterest(new Money(currency, "12.0"));
// the following line overwrites the correct loan schedule dates
// with dates that are not correct!
actionDate.setActionDate(new java.sql.Date(date.getTime()));
actionDate.setPaymentStatus(PaymentStatus.UNPAID);
AccountTestUtils.addAccountActionDate(actionDate, loan);
AccountFeesActionDetailEntity accountFeesaction = new LoanFeeScheduleEntity(actionDate, maintanenceFee, accountPeriodicFee, new Money(currency, "100.0"));
setFeeAmountPaid(accountFeesaction, new Money(currency, "0.0"));
actionDate.addAccountFeesAction(accountFeesaction);
}
loan.setCreatedBy(Short.valueOf("1"));
loan.setCreatedDate(new Date(System.currentTimeMillis()));
setLoanSummary(loan, currency);
return loan;
}
use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class LoanBusinessServiceTest method setupAndInjectDependencies.
@Before
public void setupAndInjectDependencies() {
loanBusinessService = new LoanBusinessService(legacyLoanDao, configService, null, holidayService, scheduleCalculatorAdaptor);
locale = new Locale("en", "GB");
installmentBuilder = new RepaymentScheduleInstallmentBuilder(locale);
rupee = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
officeId = Short.valueOf("1");
}
use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class LoanBusinessServiceTest method originalLoanScheduleShouldPersistMiscFee.
@Test
public void originalLoanScheduleShouldPersistMiscFee() throws PersistenceException {
Set<LoanScheduleEntity> installments = new LinkedHashSet<LoanScheduleEntity>();
MifosCurrency mifosCurrency = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
Money money = new Money(mifosCurrency, "123");
AccountBO accountBO = mock(AccountBO.class);
CustomerBO customerBO = mock(CustomerBO.class);
when(accountBO.getCurrency()).thenReturn(mifosCurrency);
LoanScheduleEntity loanScheduleEntity = new LoanScheduleEntity(accountBO, customerBO, new Short("1"), new java.sql.Date(new Date().getTime()), PaymentStatus.UNPAID, money, money);
loanScheduleEntity.setMiscFee(money);
installments.add(loanScheduleEntity);
when(loanBO.getLoanScheduleEntities()).thenReturn(installments);
loanBusinessService.persistOriginalSchedule(loanBO);
ArrayList<OriginalLoanScheduleEntity> expected = new ArrayList<OriginalLoanScheduleEntity>();
OriginalLoanScheduleEntity originalLoanScheduleEntity = new OriginalLoanScheduleEntity(loanScheduleEntity);
assertEquals(originalLoanScheduleEntity.getMiscFee(), loanScheduleEntity.getMiscFee());
expected.add(originalLoanScheduleEntity);
verify(legacyLoanDao).saveOriginalSchedule(Mockito.argThat(new OriginalLoanScheduleEntitiesMatcher(expected)));
}
use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class LoanBusinessServiceTest method shouldNotModifyPrincipalEvenIfMiscChargeIsPresent.
//Test for the bug fix
@Test
public void shouldNotModifyPrincipalEvenIfMiscChargeIsPresent() {
MifosCurrency rupee = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
RepaymentScheduleInstallment installment1 = getRepaymentScheduleInstallment("25-Sep-2010", 1, "78.6", "20.4", "1", "200", "100", "0");
RepaymentScheduleInstallment installment2 = getRepaymentScheduleInstallment("25-Oct-2010", 2, "182.8", "16.2", "1", "200", "0", "0");
RepaymentScheduleInstallment installment3 = getRepaymentScheduleInstallment("25-Nov-2010", 3, "186.0", "13.0", "1", "200", "0", "0");
RepaymentScheduleInstallment installment4 = getRepaymentScheduleInstallment("25-Dec-2010", 4, "452.6", "8.9", "1", "462.5", "0", "0");
List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3, installment4);
Date disbursementDate = TestUtils.getDate(25, 8, 2010);
final Money loanAmount = new Money(rupee, "1000");
loanBusinessService.applyDailyInterestRates(new LoanScheduleGenerationDto(disbursementDate, loanAmount, 24d, installments), false);
assertInstallment(installment1, "78.6", "20.4");
assertInstallment(installment2, "180.8", "18.2");
assertInstallment(installment3, "183.9", "15.1");
assertInstallment(installment4, "556.7", "11.0");
}
Aggregations