use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class CollectionSheetServiceFacadeWebTier method loadAllActiveBranchesAndSubsequentDataIfApplicable.
@Override
public CollectionSheetEntryFormDto loadAllActiveBranchesAndSubsequentDataIfApplicable(final UserContext userContext) {
final Short branchId = userContext.getBranchId();
final Short centerHierarchyExists = ClientRules.getCenterHierarchyExists() ? Constants.YES : Constants.NO;
List<OfficeDetailsDto> activeBranches = new ArrayList<OfficeDetailsDto>();
List<ListItem<Short>> paymentTypesDtoList = new ArrayList<ListItem<Short>>();
List<CustomerDto> customerList = new ArrayList<CustomerDto>();
List<PersonnelDto> loanOfficerList = new ArrayList<PersonnelDto>();
Short reloadFormAutomatically = Constants.YES;
final Short backDatedTransactionAllowed = Constants.NO;
try {
final List<PaymentTypeEntity> paymentTypesList = legacyMasterDao.findMasterDataEntitiesWithLocale(PaymentTypeEntity.class);
paymentTypesDtoList = convertToPaymentTypesListItemDto(paymentTypesList);
activeBranches = officePersistence.getActiveOffices(branchId);
if (activeBranches.size() == 1) {
loanOfficerList = legacyPersonnelDao.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId());
if (loanOfficerList.size() == 1) {
Short customerLevel;
if (centerHierarchyExists.equals(Constants.YES)) {
customerLevel = Short.valueOf(CustomerLevel.CENTER.getValue());
} else {
customerLevel = Short.valueOf(CustomerLevel.GROUP.getValue());
}
customerList = customerPersistence.getActiveParentList(loanOfficerList.get(0).getPersonnelId(), customerLevel, branchId);
if (customerList.size() == 1) {
reloadFormAutomatically = Constants.YES;
}
reloadFormAutomatically = Constants.NO;
}
}
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
return new CollectionSheetEntryFormDto(activeBranches, paymentTypesDtoList, loanOfficerList, customerList, reloadFormAutomatically, centerHierarchyExists, backDatedTransactionAllowed);
}
use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class AccountingServiceFacadeWebTier method updateFinancialYear.
@Override
public FinancialYearBO updateFinancialYear(FinancialYearBO oldFinancialYearBO, UserContext context) {
FinancialYearBO newFinancialYearBO = null;
//updating current financial year as Inactive
accountingDao.savingFinancialYearBO(oldFinancialYearBO);
this.hibernateTransactionHelper.flushSession();
//creating new Finincial year
Calendar calendar = new GregorianCalendar();
newFinancialYearBO = new FinancialYearBO();
newFinancialYearBO.setFinancialYearStartDate(nextYear(oldFinancialYearBO.getFinancialYearStartDate(), calendar));
newFinancialYearBO.setFinancialYearEndDate(nextYear(oldFinancialYearBO.getFinancialYearEndDate(), calendar));
try {
newFinancialYearBO.setCreatedDate(DateUtils.getLocaleDate(context.getPreferredLocale(), DateUtils.getCurrentDate(context.getPreferredLocale())));
} catch (InvalidDateException e) {
throw new MifosRuntimeException(e);
}
newFinancialYearBO.setCreatedBy(context.getId());
newFinancialYearBO.setStatus(SimpleAccountingConstants.ACTIVE);
calendar.setTime(newFinancialYearBO.getFinancialYearStartDate());
newFinancialYearBO.setFinancialYearId(Integer.parseInt(calendar.get(calendar.YEAR) + "" + calendar.get(calendar.YEAR)));
newFinancialYearBO = accountingDao.savingFinancialYearBO(newFinancialYearBO);
this.hibernateTransactionHelper.flushSession();
return newFinancialYearBO;
}
use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class AdminServiceFacadeWebTier method updateSavingsProduct.
@Override
public PrdOfferingDto updateSavingsProduct(SavingsProductDto savingsProductRequest) {
SavingsOfferingBO savingsProductForUpdate = this.savingsProductDao.findById(savingsProductRequest.getProductDetails().getId());
// enforced by integrity constraints on table also.
if (savingsProductForUpdate.isDifferentName(savingsProductRequest.getProductDetails().getName())) {
this.savingsProductDao.validateProductWithSameNameDoesNotExist(savingsProductRequest.getProductDetails().getName());
}
if (savingsProductForUpdate.isDifferentShortName(savingsProductRequest.getProductDetails().getShortName())) {
this.savingsProductDao.validateProductWithSameShortNameDoesNotExist(savingsProductRequest.getProductDetails().getShortName());
}
// domain rule validation - put on domain entity
if (savingsProductForUpdate.isDifferentStartDate(savingsProductRequest.getProductDetails().getStartDate())) {
validateStartDateIsNotBeforeToday(savingsProductRequest.getProductDetails().getStartDate());
validateStartDateIsNotOverOneYearFromToday(savingsProductRequest.getProductDetails().getStartDate());
validateEndDateIsPastStartDate(savingsProductRequest.getProductDetails().getStartDate(), savingsProductRequest.getProductDetails().getEndDate());
}
boolean activeOrInactiveSavingsAccountExist = this.savingsProductDao.activeOrInactiveSavingsAccountsExistForProduct(savingsProductRequest.getProductDetails().getId());
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
SavingsOfferingBO newSavingsDetails = new SavingsProductAssembler(this.loanProductDao, this.savingsProductDao, this.generalLedgerDao).fromDto(user, savingsProductRequest);
savingsProductForUpdate.updateDetails(userContext);
HibernateTransactionHelper transactionHelper = new HibernateTransactionHelperForStaticHibernateUtil();
try {
transactionHelper.startTransaction();
transactionHelper.beginAuditLoggingFor(savingsProductForUpdate);
if (activeOrInactiveSavingsAccountExist) {
LocalDate updateDate = new LocalDate();
savingsProductForUpdate.updateProductDetails(newSavingsDetails.getPrdOfferingName(), newSavingsDetails.getPrdOfferingShortName(), newSavingsDetails.getDescription(), newSavingsDetails.getPrdCategory(), newSavingsDetails.getStartDate(), newSavingsDetails.getEndDate(), newSavingsDetails.getPrdStatus());
savingsProductForUpdate.updateSavingsDetails(newSavingsDetails.getRecommendedAmount(), newSavingsDetails.getRecommendedAmntUnit(), newSavingsDetails.getMaxAmntWithdrawl(), newSavingsDetails.getInterestRate(), newSavingsDetails.getMinAmntForInt(), updateDate);
} else {
savingsProductForUpdate.updateDetailsOfProductNotInUse(newSavingsDetails.getPrdOfferingName(), newSavingsDetails.getPrdOfferingShortName(), newSavingsDetails.getDescription(), newSavingsDetails.getPrdCategory(), newSavingsDetails.getStartDate(), newSavingsDetails.getEndDate(), newSavingsDetails.getPrdApplicableMaster(), newSavingsDetails.getPrdStatus());
savingsProductForUpdate.updateDetailsOfSavingsProductNotInUse(newSavingsDetails.getSavingsType(), newSavingsDetails.getRecommendedAmount(), newSavingsDetails.getRecommendedAmntUnit(), newSavingsDetails.getMaxAmntWithdrawl(), newSavingsDetails.getInterestRate(), newSavingsDetails.getInterestCalcType(), newSavingsDetails.getTimePerForInstcalc(), newSavingsDetails.getFreqOfPostIntcalc(), newSavingsDetails.getMinAmntForInt());
}
this.savingsProductDao.save(savingsProductForUpdate);
transactionHelper.commitTransaction();
return savingsProductForUpdate.toDto();
} catch (Exception e) {
transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
transactionHelper.closeSession();
}
}
use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class AdminServiceFacadeWebTier method retrieveNotAllowedProductsForMix.
@Override
public List<PrdOfferingDto> retrieveNotAllowedProductsForMix(Integer productTypeId, Integer productId) {
try {
List<PrdOfferingDto> notAllowedProductDtos = new ArrayList<PrdOfferingDto>();
List<PrdOfferingBO> allowedProducts = new PrdOfferingPersistence().getNotAllowedPrdOfferingsForMixProduct(productId.toString(), productTypeId.toString());
for (PrdOfferingBO product : allowedProducts) {
notAllowedProductDtos.add(product.toDto());
}
return notAllowedProductDtos;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class AdminServiceFacadeWebTier method updateAcceptedPaymentTypes.
@Override
public void updateAcceptedPaymentTypes(String[] chosenAcceptedFees, String[] chosenAcceptedLoanDisbursements, String[] chosenAcceptedLoanRepayments, String[] chosenAcceptedSavingDeposits, String[] chosenAcceptedSavingWithdrawals) {
LegacyAcceptedPaymentTypeDao persistence = legacyAcceptedPaymentTypeDao;
List<AcceptedPaymentType> deletedPaymentTypeList = new ArrayList<AcceptedPaymentType>();
List<AcceptedPaymentType> addedPaymentTypeList = new ArrayList<AcceptedPaymentType>();
List<PaymentTypeDto> allPayments = getAllPaymentTypes(null);
AcceptedPaymentTypeDto oldAcceptedPaymentTypeDto = retrieveAcceptedPaymentTypes();
for (int i = 0; i < TrxnTypes.values().length; i++) {
TrxnTypes transactionType = TrxnTypes.values()[i];
List<PaymentTypeDto> selectedPaymentTypes = new ArrayList<PaymentTypeDto>();
List<PaymentTypeDto> outList = null;
if (transactionType == TrxnTypes.fee) {
selectedPaymentTypes = populateSelectedPayments(chosenAcceptedFees, allPayments);
outList = oldAcceptedPaymentTypeDto.getOutFeeList();
} else if (transactionType == TrxnTypes.loan_disbursement) {
selectedPaymentTypes = populateSelectedPayments(chosenAcceptedLoanDisbursements, allPayments);
outList = oldAcceptedPaymentTypeDto.getOutDisbursementList();
} else if (transactionType == TrxnTypes.loan_repayment) {
selectedPaymentTypes = populateSelectedPayments(chosenAcceptedLoanRepayments, allPayments);
outList = oldAcceptedPaymentTypeDto.getOutRepaymentList();
} else if (transactionType == TrxnTypes.savings_deposit) {
selectedPaymentTypes = populateSelectedPayments(chosenAcceptedSavingDeposits, allPayments);
outList = oldAcceptedPaymentTypeDto.getOutDepositList();
} else if (transactionType == TrxnTypes.savings_withdrawal) {
selectedPaymentTypes = populateSelectedPayments(chosenAcceptedSavingWithdrawals, allPayments);
outList = oldAcceptedPaymentTypeDto.getOutWithdrawalList();
} else {
throw new MifosRuntimeException("Unknown account action for accepted payment type " + transactionType.toString());
}
process(selectedPaymentTypes, outList, deletedPaymentTypeList, addedPaymentTypeList, persistence, transactionType);
}
try {
if (addedPaymentTypeList.size() > 0) {
persistence.addAcceptedPaymentTypes(addedPaymentTypeList);
StaticHibernateUtil.commitTransaction();
}
if (deletedPaymentTypeList.size() > 0) {
persistence.deleteAcceptedPaymentTypes(deletedPaymentTypeList);
StaticHibernateUtil.commitTransaction();
}
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
Aggregations