use of org.mifos.application.meeting.util.helpers.RecurrenceType in project head by mifos.
the class SavingsProductAssembler method fromDto.
public SavingsOfferingBO fromDto(MifosUser user, SavingsProductDto savingsProductRequest) {
try {
// FIXME - keithw - this is general assembler common to both savings and loans i.e. all products. so
// ProductDao and ProductAssembler
ProductDetailsDto productDetails = savingsProductRequest.getProductDetails();
String name = productDetails.getName();
String shortName = productDetails.getShortName();
String description = productDetails.getDescription();
Integer category = productDetails.getCategory();
ProductCategoryBO productCategory = this.loanProductDao.findActiveProductCategoryById(category);
DateTime startDate = productDetails.getStartDate();
DateTime endDate = productDetails.getEndDate();
ApplicableTo applicableTo = ApplicableTo.fromInt(productDetails.getApplicableFor());
PrdApplicableMasterEntity applicableToEntity = this.loanProductDao.findApplicableProductType(applicableTo);
PrdStatusEntity activeStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.SAVINGS_ACTIVE);
PrdStatusEntity inActiveStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.SAVINGS_INACTIVE);
PrdStatusEntity selectedStatus = activeStatus;
if (productDetails.getStatus() != null && inActiveStatus.getOfferingStatusId().equals(productDetails.getStatus().shortValue())) {
selectedStatus = inActiveStatus;
}
String globalNum = generateProductGlobalNum(user);
// savings specific
SavingsType savingsType = SavingsType.fromInt(savingsProductRequest.getDepositType());
SavingsTypeEntity savingsTypeEntity = this.loanProductDao.retrieveSavingsType(savingsType);
RecommendedAmntUnitEntity recommendedAmntUnitEntity = null;
if (savingsProductRequest.getGroupMandatorySavingsType() != null) {
RecommendedAmountUnit recommendedAmountType = RecommendedAmountUnit.fromInt(savingsProductRequest.getGroupMandatorySavingsType());
recommendedAmntUnitEntity = this.loanProductDao.retrieveRecommendedAmountType(recommendedAmountType);
}
Money amountForDeposit = new Money(Money.getDefaultCurrency(), BigDecimal.valueOf(savingsProductRequest.getAmountForDeposit()));
Money maxWithdrawal = new Money(Money.getDefaultCurrency(), BigDecimal.valueOf(savingsProductRequest.getMaxWithdrawal()));
// interest specific
BigDecimal interestRate = savingsProductRequest.getInterestRate();
InterestCalcType interestCalcType = InterestCalcType.fromInt(savingsProductRequest.getInterestCalculationType());
InterestCalcTypeEntity interestCalcTypeEntity = this.savingsProductDao.retrieveInterestCalcType(interestCalcType);
RecurrenceType recurrence = RecurrenceType.fromInt(savingsProductRequest.getInterestCalculationFrequencyPeriod().shortValue());
Integer every = savingsProductRequest.getInterestCalculationFrequency();
MeetingBO interestCalculationMeeting = new MeetingBO(recurrence, every.shortValue(), new Date(), MeetingType.SAVINGS_INTEREST_CALCULATION_TIME_PERIOD);
Integer interestPostingEveryMonthFreq = savingsProductRequest.getInterestPostingFrequency();
RecurrenceType interestPostingRecurrenceType = null;
if (savingsProductRequest.isDailyPosting()) {
interestPostingRecurrenceType = RecurrenceType.DAILY;
} else {
interestPostingRecurrenceType = RecurrenceType.MONTHLY;
}
MeetingBO interestPostingMeeting = new MeetingBO(interestPostingRecurrenceType, interestPostingEveryMonthFreq.shortValue(), new Date(), MeetingType.SAVINGS_INTEREST_POSTING);
Money minAmountForCalculation = new Money(Money.getDefaultCurrency(), savingsProductRequest.getMinBalanceForInterestCalculation());
GLCodeEntity depositGlEntity = this.generalLedgerDao.findGlCodeById(savingsProductRequest.getDepositGlCode().shortValue());
GLCodeEntity interestGlEntity = this.generalLedgerDao.findGlCodeById(savingsProductRequest.getInterestGlCode().shortValue());
MifosCurrency currency = Money.getDefaultCurrency();
return SavingsOfferingBO.createNew(user.getUserId(), globalNum, name, shortName, description, productCategory, startDate, endDate, applicableToEntity, currency, selectedStatus, savingsTypeEntity, recommendedAmntUnitEntity, amountForDeposit, maxWithdrawal, interestRate, interestCalcTypeEntity, interestCalculationMeeting, interestPostingMeeting, minAmountForCalculation, depositGlEntity, interestGlEntity);
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
} catch (MeetingException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.application.meeting.util.helpers.RecurrenceType in project head by mifos.
the class RecurringScheduledEventFactoryImpl method createScheduledEventFrom.
@Override
public ScheduledEvent createScheduledEventFrom(MeetingBO meeting) {
RecurrenceType period = meeting.getRecurrenceType();
int every = meeting.getRecurAfter();
int dayOfWeek = 0;
if (meeting.getMeetingDetails().getWeekDay() != null) {
dayOfWeek = WeekDay.getJodaDayOfWeekThatMatchesMifosWeekDay(meeting.getMeetingDetails().getWeekDay().getValue());
}
int dayOfMonth = 0;
if (meeting.getMeetingDetails().getDayNumber() != null) {
dayOfMonth = meeting.getMeetingDetails().getDayNumber();
}
int weekOfMonth = 0;
if (meeting.getMeetingDetails().getWeekRank() != null) {
weekOfMonth = meeting.getMeetingDetails().getWeekRank().getValue();
}
return createScheduledEvent(period, every, dayOfWeek, dayOfMonth, weekOfMonth);
}
use of org.mifos.application.meeting.util.helpers.RecurrenceType in project head by mifos.
the class TestObjectFactory method createLoanMeeting.
public static MeetingBO createLoanMeeting(final MeetingBO customerMeeting) {
MeetingBO meetingToReturn = null;
try {
RecurrenceType recurrenceType = RecurrenceType.fromInt(customerMeeting.getMeetingDetails().getRecurrenceType().getRecurrenceId());
MeetingType meetingType = MeetingType.fromInt(customerMeeting.getMeetingType().getMeetingTypeId());
Short recurAfter = customerMeeting.getMeetingDetails().getRecurAfter();
if (recurrenceType.equals(RecurrenceType.MONTHLY)) {
if (customerMeeting.isMonthlyOnDate()) {
meetingToReturn = new MeetingBO(customerMeeting.getMeetingDetails().getMeetingRecurrence().getDayNumber(), recurAfter, customerMeeting.getMeetingStartDate(), meetingType, "meetingPlace");
} else {
meetingToReturn = new MeetingBO(customerMeeting.getMeetingDetails().getWeekDay(), customerMeeting.getMeetingDetails().getWeekRank(), recurAfter, customerMeeting.getMeetingStartDate(), meetingType, "meetingPlace");
}
} else if (recurrenceType.equals(RecurrenceType.WEEKLY)) {
meetingToReturn = new MeetingBO(WeekDay.getWeekDay(customerMeeting.getMeetingDetails().getMeetingRecurrence().getWeekDayValue().getValue()), recurAfter, customerMeeting.getMeetingStartDate(), meetingType, "meetingPlace");
} else {
meetingToReturn = new MeetingBO(recurrenceType, recurAfter, customerMeeting.getMeetingStartDate(), meetingType);
}
meetingToReturn.setMeetingPlace(customerMeeting.getMeetingPlace());
} catch (MeetingException e) {
throw new RuntimeException(e);
}
return meetingToReturn;
}
use of org.mifos.application.meeting.util.helpers.RecurrenceType in project head by mifos.
the class ScheduledEventFactory method createScheduledEventFrom.
public static ScheduledEvent createScheduledEventFrom(final MeetingBO meeting) {
RecurrenceType period = meeting.getRecurrenceType();
int every = meeting.getRecurAfter();
int dayOfWeek = 0;
if (meeting.getMeetingDetails().getWeekDay() != null) {
dayOfWeek = WeekDay.getJodaDayOfWeekThatMatchesMifosWeekDay(meeting.getMeetingDetails().getWeekDay().getValue());
}
int dayOfMonth = 0;
if (meeting.getMeetingDetails().getDayNumber() != null) {
dayOfMonth = meeting.getMeetingDetails().getDayNumber();
}
int weekOfMonth = 0;
if (meeting.getMeetingDetails().getWeekRank() != null) {
weekOfMonth = meeting.getMeetingDetails().getWeekRank().getValue();
}
return createScheduledEvent(period, every, dayOfWeek, dayOfMonth, weekOfMonth);
}
use of org.mifos.application.meeting.util.helpers.RecurrenceType in project head by mifos.
the class FeeServiceFacadeWebTier method createFee.
@Override
public String createFee(FeeCreateDto feeCreateDto) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
try {
FeeCategory feeCategory = (feeCreateDto.getCategoryType() != null) ? FeeCategory.getFeeCategory(feeCreateDto.getCategoryType()) : null;
FeeFrequencyType feeFrequencyType = (feeCreateDto.getFeeFrequencyType() != null) ? FeeFrequencyType.getFeeFrequencyType(feeCreateDto.getFeeFrequencyType()) : null;
FeePayment feePayment = (feeCreateDto.getFeePaymentType() != null) ? FeePayment.getFeePayment(feeCreateDto.getFeePaymentType()) : null;
FeeFormula feeFormula = (feeCreateDto.getFeeFormula() != null) ? FeeFormula.getFeeFormula(feeCreateDto.getFeeFormula()) : null;
RecurrenceType feeRecurrenceType = (feeCreateDto.getFeeRecurrenceType() != null) ? RecurrenceType.fromInt(feeCreateDto.getFeeRecurrenceType()) : null;
FeeCreateRequest feeCreateRequest = new FeeCreateRequest(feeCategory, feeFrequencyType, feeCreateDto.getGlCode(), feePayment, feeFormula, feeCreateDto.getFeeName(), feeCreateDto.isRateFee(), feeCreateDto.isCustomerDefaultFee(), feeCreateDto.getRate(), feeCreateDto.getCurrencyId(), feeCreateDto.getAmount(), feeRecurrenceType, feeCreateDto.getMonthRecurAfter(), feeCreateDto.getWeekRecurAfter());
FeeBO fee = this.feeService.create(feeCreateRequest, userContext);
return fee.getFeeId().toString();
} catch (ApplicationException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
Aggregations