use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class LoanBusinessServiceTest method shouldGenerateWeeklyInstallmentScheduleFromRepaymentScheduleUsingDailyInterest.
@Test
public void shouldGenerateWeeklyInstallmentScheduleFromRepaymentScheduleUsingDailyInterest() {
MifosCurrency rupee = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
RepaymentScheduleInstallment installment1 = getRepaymentScheduleInstallment("01-Sep-2010", 1, "194.4", "4.6", "1", "100", "0", "0");
RepaymentScheduleInstallment installment2 = getRepaymentScheduleInstallment("08-Sep-2010", 2, "195.3", "3.7", "1", "200", "0", "0");
RepaymentScheduleInstallment installment3 = getRepaymentScheduleInstallment("15-Sep-2010", 3, "196.2", "2.8", "1", "200", "0", "0");
RepaymentScheduleInstallment installment4 = getRepaymentScheduleInstallment("22-Sep-2010", 4, "414.1", "1.9", "1", "417.0", "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, "94.4", "4.6");
assertInstallment(installment2, "194.8", "4.2");
assertInstallment(installment3, "195.7", "3.3");
assertInstallment(installment4, "515.0", "2.4");
}
use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class ViewOrganizationSettingsServiceFacadeWebTier method getCurrencies.
private List<Properties> getCurrencies() {
List<Properties> currencies = new ArrayList<Properties>();
for (MifosCurrency currency : AccountingRules.getCurrencies()) {
Properties currencyRules = new Properties();
currencyRules.setProperty("code", currency.getCurrencyCode());
currencyRules.setProperty("digitsAfterDecimal", AccountingRules.getDigitsAfterDecimal(currency).toString());
currencyRules.setProperty("finalRoundOffMultiple", AccountingRules.getFinalRoundOffMultiple(currency).toString());
currencyRules.setProperty("initialRoundOffMultiple", AccountingRules.getInitialRoundOffMultiple(currency).toString());
currencies.add(currencyRules);
}
return currencies;
}
use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class SavingsServiceFacadeWebTier method determinePostingPeriodResult.
private InterestPostingPeriodResult determinePostingPeriodResult(CalendarPeriod postingPeriod, SavingsBO savingsAccount, List<EndOfDayDetail> allEndOfDayDetailsForAccount) {
List<SavingsProductHistoricalInterestDetail> historicalInterestDetails = savingsAccount.getHistoricalInterestDetailsForPeriod(postingPeriod);
MifosCurrency currencyInUse = savingsAccount.getCurrency();
Money startingBalanceForPeriod = calculateAccountBalanceOn(postingPeriod.getStartDate(), allEndOfDayDetailsForAccount, currencyInUse);
InterestCalcType interestCalcType = savingsAccount.getInterestCalcType();
int accountingNumberOfInterestDaysInYear = AccountingRules.getNumberOfInterestDays();
SavingsInterestDetail interestDetail = new SavingsInterestDetail(interestCalcType, savingsAccount.getInterestRate(), accountingNumberOfInterestDaysInYear, savingsAccount.getMinAmntForInt());
InterestScheduledEvent interestCalculationEvent = new SavingsInterestScheduledEventFactory().createScheduledEventFrom(savingsAccount.getInterestCalculationMeeting());
return doCalculateInterestForPostingPeriod(postingPeriod, startingBalanceForPeriod, historicalInterestDetails, allEndOfDayDetailsForAccount, interestDetail, interestCalculationEvent);
}
use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class SavingsServiceFacadeWebTier method withdrawalMakesBalanceNegativeOnDate.
private boolean withdrawalMakesBalanceNegativeOnDate(SavingsBO savingsAccount, Money amount, LocalDate trxnDate) {
List<EndOfDayDetail> allEndOfDayDetailsForAccount = savingsDao.retrieveAllEndOfDayDetailsFor(savingsAccount.getCurrency(), savingsAccount.getAccountId().longValue());
MifosCurrency currencyInUse = savingsAccount.getCurrency();
Money balanceOnDateOfWithdrawal = calculateAccountBalanceOn(trxnDate.plusDays(1), allEndOfDayDetailsForAccount, currencyInUse);
return amount.isGreaterThan(balanceOnDateOfWithdrawal);
}
use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class AccountingRules method getMifosCurrency.
public static MifosCurrency getMifosCurrency(String currencyCode, ConfigurationPersistence configurationPersistence) {
MifosCurrency currency = configurationPersistence.getCurrency(currencyCode);
if (currency == null) {
throw new RuntimeException("Can't find in the database the currency define in the config file " + currencyCode);
}
Short digitsAfterDecimal = getDigitsAfterDecimal(currency);
BigDecimal amountToBeRoundedTo = getAmountToBeRoundedTo(currency.getRoundingAmount());
return new MifosCurrency(currency.getCurrencyId(), currency.getCurrencyName(), amountToBeRoundedTo, currencyCode);
}
Aggregations