use of org.mifos.customers.business.CustomerBO in project head by mifos.
the class LoanAccountServiceFacadeWebTier method assembleLoanAccountDetail.
private LoanAccountDetail assembleLoanAccountDetail(CreateLoanAccount loanAccountInfo) {
CustomerBO customer = this.customerDao.findCustomerById(loanAccountInfo.getCustomerId());
LoanOfferingBO loanProduct = this.loanProductDao.findById(loanAccountInfo.getProductId());
Money loanAmount = new Money(loanProduct.getCurrency(), loanAccountInfo.getLoanAmount());
AccountState accountStateType = AccountState.fromShort(loanAccountInfo.getAccountState().shortValue());
FundBO fund = null;
if (loanAccountInfo.getSourceOfFundId() != null) {
fund = this.fundDao.findById(loanAccountInfo.getSourceOfFundId().shortValue());
}
return new LoanAccountDetail(customer, loanProduct, loanAmount, accountStateType, fund);
}
use of org.mifos.customers.business.CustomerBO in project head by mifos.
the class MeetingServiceFacadeWebTier method updateCustomerMeeting.
@Override
public void updateCustomerMeeting(MeetingDto meetingUpdateRequest, Integer customerId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = userContextFactory.create(user);
MeetingBO meeting = meetingFactory.create(meetingUpdateRequest);
meeting.updateDetails(userContext);
CustomerBO customer = this.customerDao.findCustomerById(customerId);
customer.updateDetails(userContext);
customerService.updateCustomerMeetingSchedule(meeting, customer);
}
use of org.mifos.customers.business.CustomerBO in project head by mifos.
the class GroupServiceFacadeWebTier method retrieveGroupFormCreationData.
@Override
public GroupFormCreationDto retrieveGroupFormCreationData(GroupCreation groupCreation) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
CustomerBO parentCustomer = null;
Short parentOfficeId = groupCreation.getOfficeId();
CustomerApplicableFeesDto applicableFees = CustomerApplicableFeesDto.empty();
List<PersonnelDto> personnelList = new ArrayList<PersonnelDto>();
CenterCreation centerCreation;
boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
if (isCenterHierarchyExists) {
parentCustomer = this.customerDao.findCenterBySystemId(groupCreation.getParentSystemId());
parentOfficeId = parentCustomer.getOffice().getOfficeId();
centerCreation = new CenterCreation(parentOfficeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
MeetingBO customerMeeting = parentCustomer.getCustomerMeetingValue();
List<FeeBO> fees = customerDao.retrieveFeesApplicableToGroupsRefinedBy(customerMeeting);
applicableFees = CustomerApplicableFeesDto.toDto(fees, userContext);
} else {
centerCreation = new CenterCreation(groupCreation.getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
personnelList = this.personnelDao.findActiveLoanOfficersForOffice(centerCreation);
List<FeeBO> fees = customerDao.retrieveFeesApplicableToGroups();
applicableFees = CustomerApplicableFeesDto.toDto(fees, userContext);
}
List<ApplicableAccountFeeDto> applicableDefaultAccountFees = new ArrayList<ApplicableAccountFeeDto>();
for (FeeDto fee : applicableFees.getDefaultFees()) {
applicableDefaultAccountFees.add(new ApplicableAccountFeeDto(fee.getFeeIdValue().intValue(), fee.getFeeName(), fee.getAmount(), fee.isRemoved(), fee.isWeekly(), fee.isMonthly(), fee.isPeriodic(), fee.getFeeSchedule()));
}
List<ApplicableAccountFeeDto> applicableDefaultAdditionalFees = new ArrayList<ApplicableAccountFeeDto>();
for (FeeDto fee : applicableFees.getAdditionalFees()) {
applicableDefaultAdditionalFees.add(new ApplicableAccountFeeDto(fee.getFeeIdValue().intValue(), fee.getFeeName(), fee.getAmount(), fee.isRemoved(), fee.isWeekly(), fee.isMonthly(), fee.isPeriodic(), fee.getFeeSchedule()));
}
List<PersonnelDto> formedByPersonnel = customerDao.findLoanOfficerThatFormedOffice(centerCreation.getOfficeId());
return new GroupFormCreationDto(isCenterHierarchyExists, personnelList, formedByPersonnel, applicableDefaultAccountFees, applicableDefaultAdditionalFees);
}
use of org.mifos.customers.business.CustomerBO in project head by mifos.
the class SaveCollectionSheetStructureValidator method execute.
public void execute(SaveCollectionSheetDto saveCollectionSheet) throws SaveCollectionSheetException {
saveCollectionSheetCustomers = saveCollectionSheet.getSaveCollectionSheetCustomers();
Boolean isTopCustomer = true;
for (SaveCollectionSheetCustomerDto saveCollectionSheetCustomer : saveCollectionSheetCustomers) {
CustomerBO customer;
Integer currentErrorCount = validationErrors.size();
try {
customer = customerPersistence.getCustomer(saveCollectionSheetCustomer.getCustomerId());
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
if (customer == null) {
if (isTopCustomer) {
addValidationError(InvalidSaveCollectionSheetReason.INVALID_TOP_CUSTOMER, "Customer Id: " + saveCollectionSheetCustomer.getCustomerId());
throw new SaveCollectionSheetException(validationErrors, validationErrorsExtended);
}
addValidationError(InvalidSaveCollectionSheetReason.CUSTOMER_NOT_FOUND, "Customer Id: " + saveCollectionSheetCustomer.getCustomerId());
} else {
if (isTopCustomer) {
topCustomer = customer;
}
validateCustomer(customer, saveCollectionSheetCustomer);
}
if (currentErrorCount.compareTo(validationErrors.size()) == 0) {
validateAttendanceType(customer, saveCollectionSheetCustomer.getAttendanceId());
validateSaveCollectionSheetCustomerAccount(saveCollectionSheetCustomer.getCustomerId(), saveCollectionSheetCustomer.getSaveCollectionSheetCustomerAccount());
validateSaveCollectionSheetCustomerLoans(saveCollectionSheetCustomer.getCustomerId(), saveCollectionSheetCustomer.getSaveCollectionSheetCustomerLoans());
validateSaveCollectionSheetCustomerSavings(saveCollectionSheetCustomer.getCustomerId(), saveCollectionSheetCustomer.getSaveCollectionSheetCustomerSavings(), ValidationAccountTypes.SAVINGS);
validateSaveCollectionSheetCustomerSavings(saveCollectionSheetCustomer.getCustomerId(), saveCollectionSheetCustomer.getSaveCollectionSheetCustomerIndividualSavings(), ValidationAccountTypes.INDIVIDUAL_SAVINGS);
}
isTopCustomer = false;
}
LocalDate validMeetingDate = getValidMeetingDateForTopCustomer(topCustomer.getCustomerId());
if (saveCollectionSheet.getTransactionDate().compareTo(validMeetingDate) != 0) {
addValidationError(InvalidSaveCollectionSheetReason.INVALID_DATE, "Transaction Date: " + saveCollectionSheet.getTransactionDate());
throw new SaveCollectionSheetException(validationErrors, validationErrorsExtended);
}
if (validationErrors.size() > 0) {
throw new SaveCollectionSheetException(validationErrors, validationErrorsExtended);
}
}
use of org.mifos.customers.business.CustomerBO in project head by mifos.
the class SavingsServiceFacadeWebTier method retrieveDepositWithdrawalReferenceData.
@Override
public DepositWithdrawalReferenceDto retrieveDepositWithdrawalReferenceData(Long savingsId, Integer customerId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
SavingsBO savingsAccount = savingsDao.findById(savingsId);
String depositDue = savingsAccount.getTotalPaymentDue(customerId).toString();
String withdrawalDue = "0";
List<ListElement> clients = new ArrayList<ListElement>();
if (savingsAccount.isGroupModelWithIndividualAccountability()) {
List<CustomerBO> activeAndOnHoldClients = new CustomerPersistence().getActiveAndOnHoldChildren(savingsAccount.getCustomer().getSearchId(), savingsAccount.getCustomer().getOfficeId(), CustomerLevel.CLIENT);
for (CustomerBO client : activeAndOnHoldClients) {
clients.add(new ListElement(client.getCustomerId(), client.getDisplayName()));
}
}
List<AccountActionEntity> trxnTypes = new ArrayList<AccountActionEntity>();
trxnTypes.add(new AccountBusinessService().getAccountAction(AccountActionTypes.SAVINGS_DEPOSIT.getValue(), userContext.getLocaleId()));
trxnTypes.add(new AccountBusinessService().getAccountAction(AccountActionTypes.SAVINGS_WITHDRAWAL.getValue(), userContext.getLocaleId()));
List<ListElement> transactionTypes = new ArrayList<ListElement>();
for (AccountActionEntity accountActionEntity : trxnTypes) {
LookUpValueEntity lookupValue = accountActionEntity.getLookUpValue();
String messageText = lookupValue.getMessageText();
if (StringUtils.isBlank(messageText)) {
messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
}
transactionTypes.add(new ListElement(accountActionEntity.getId().intValue(), messageText));
}
List<ListElement> depositPaymentTypes = retrieveDepositPaymentTypes(userContext);
List<ListElement> withdrawalPaymentTypes = new ArrayList<ListElement>();
List<PaymentTypeEntity> withdrawalPaymentEntityTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(userContext.getLocaleId(), TrxnTypes.savings_withdrawal.getValue());
for (PaymentTypeEntity paymentTypeEntity : withdrawalPaymentEntityTypes) {
LookUpValueEntity lookupValue = paymentTypeEntity.getLookUpValue();
String messageText = lookupValue.getMessageText();
if (StringUtils.isBlank(messageText)) {
messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
}
withdrawalPaymentTypes.add(new ListElement(paymentTypeEntity.getId().intValue(), messageText));
}
boolean backDatedTransactionsAllowed = AccountingRules.isBackDatedTxnAllowed();
LocalDate defaultTransactionDate = new LocalDate();
return new DepositWithdrawalReferenceDto(transactionTypes, depositPaymentTypes, withdrawalPaymentTypes, clients, backDatedTransactionsAllowed, defaultTransactionDate, depositDue, withdrawalDue);
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
Aggregations