use of org.mifos.application.meeting.exceptions.MeetingException 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.exceptions.MeetingException 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.exceptions.MeetingException in project head by mifos.
the class MeetingFactory method create.
public MeetingBO create(MeetingDto meetingDto) {
try {
MeetingDetailsDto meetingDetailsDto = meetingDto.getMeetingDetailsDto();
MeetingBO meeting = new MeetingBO(RecurrenceType.fromInt(meetingDetailsDto.getRecurrenceTypeId().shortValue()), meetingDetailsDto.getEvery().shortValue(), meetingDto.getMeetingStartDate().toDateMidnight().toDate(), MeetingType.CUSTOMER_MEETING);
RankOfDay rank = null;
Integer weekOfMonth = meetingDetailsDto.getRecurrenceDetails().getWeekOfMonth();
if (weekOfMonth != null && weekOfMonth > 0) {
rank = RankOfDay.getRankOfDay(meetingDetailsDto.getRecurrenceDetails().getWeekOfMonth());
}
WeekDay weekDay = null;
Integer weekDayNum = meetingDetailsDto.getRecurrenceDetails().getDayOfWeek();
if (weekDayNum != null && weekDayNum > 0) {
weekDay = WeekDay.getWeekDay(meetingDetailsDto.getRecurrenceDetails().getDayOfWeek());
}
if (meetingDetailsDto.getRecurrenceDetails().getDayNumber() > 0) {
meeting.update(meetingDetailsDto.getRecurrenceDetails().getDayNumber().shortValue(), meetingDto.getMeetingPlace());
}
if (rank != null && weekDay != null) {
meeting = new MeetingBO(weekDay, rank, meetingDetailsDto.getEvery().shortValue(), meetingDto.getMeetingStartDate().toDateMidnight().toDate(), MeetingType.CUSTOMER_MEETING, meetingDto.getMeetingPlace());
} else if (weekDay != null) {
meeting = new MeetingBO(weekDay, meetingDetailsDto.getEvery().shortValue(), meetingDto.getMeetingStartDate().toDateMidnight().toDate(), MeetingType.CUSTOMER_MEETING, meetingDto.getMeetingPlace());
}
if (meetingDetailsDto.getRecurrenceTypeId().equals(new Integer(RecurrenceType.DAILY.getValue().shortValue()))) {
meeting = new MeetingBO(meetingDetailsDto.getEvery().shortValue(), meetingDto.getMeetingStartDate().toDateTimeAtStartOfDay().toDate(), MeetingType.CUSTOMER_MEETING, meetingDto.getMeetingPlace());
}
return meeting;
} catch (MeetingException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.application.meeting.exceptions.MeetingException in project head by mifos.
the class GroupLoanAccountServiceFacadeWebTier method createNewMeetingForRepaymentDay.
private MeetingBO createNewMeetingForRepaymentDay(LocalDate disbursementDate, RecurringSchedule recurringSchedule, CustomerBO customer) {
MeetingBO newMeetingForRepaymentDay = null;
final int minDaysInterval = configurationPersistence.getConfigurationValueInteger(MIN_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT_DAY);
final Date repaymentStartDate = disbursementDate.plusDays(minDaysInterval).toDateMidnight().toDateTime().toDate();
try {
if (recurringSchedule.isWeekly()) {
WeekDay weekDay = WeekDay.getWeekDay(recurringSchedule.getDay().shortValue());
Short recurEvery = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(weekDay, recurEvery, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
} else if (recurringSchedule.isMonthly()) {
if (recurringSchedule.isMonthlyOnDayOfMonth()) {
Short dayOfMonth = recurringSchedule.getDay().shortValue();
Short dayRecurMonth = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(dayOfMonth, dayRecurMonth, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
} else {
Short weekOfMonth = recurringSchedule.getDay().shortValue();
Short monthRank = recurringSchedule.getWeek().shortValue();
Short everyMonth = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(weekOfMonth, everyMonth, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace(), monthRank);
}
} else {
Short recurEvery = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(recurEvery, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
}
return newMeetingForRepaymentDay;
} catch (NumberFormatException nfe) {
throw new MifosRuntimeException(nfe);
} catch (MeetingException me) {
throw new BusinessRuleException(me.getKey(), me);
}
}
use of org.mifos.application.meeting.exceptions.MeetingException in project head by mifos.
the class LoanAccountServiceFacadeWebTier method createNewMeetingForRepaymentDay.
private MeetingBO createNewMeetingForRepaymentDay(LocalDate disbursementDate, RecurringSchedule recurringSchedule, CustomerBO customer) {
MeetingBO newMeetingForRepaymentDay = null;
final int minDaysInterval = configurationPersistence.getConfigurationValueInteger(MIN_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT_DAY);
final Date repaymentStartDate = disbursementDate.plusDays(minDaysInterval).toDateMidnight().toDateTime().toDate();
try {
if (recurringSchedule.isWeekly()) {
WeekDay weekDay = WeekDay.getWeekDay(recurringSchedule.getDay().shortValue());
Short recurEvery = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(weekDay, recurEvery, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
} else if (recurringSchedule.isMonthly()) {
if (recurringSchedule.isMonthlyOnDayOfMonth()) {
Short dayOfMonth = recurringSchedule.getDay().shortValue();
Short dayRecurMonth = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(dayOfMonth, dayRecurMonth, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
} else {
Short weekOfMonth = recurringSchedule.getDay().shortValue();
Short monthRank = recurringSchedule.getWeek().shortValue();
Short everyMonth = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(weekOfMonth, everyMonth, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace(), monthRank);
}
} else {
Short recurEvery = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(recurEvery, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
}
return newMeetingForRepaymentDay;
} catch (NumberFormatException nfe) {
throw new MifosRuntimeException(nfe);
} catch (MeetingException me) {
throw new BusinessRuleException(me.getKey(), me);
}
}
Aggregations