Search in sources :

Example 1 with CustomerAccountDto

use of org.mifos.customers.util.helpers.CustomerAccountDto in project head by mifos.

the class CollectionSheetEntryAction method getAmountTotalLogs.

private String getAmountTotalLogs(CollectionSheetEntryDecomposedDto decomposedViews) {
    String logMsg = "";
    Double totalCustomerAccountAmountDue = 0.0;
    Double totalCustomerAccountAmountEntered = 0.0;
    Double totalLoanDisBursementAmountEntered = 0.0;
    Double totalLoanEnteredAmount = 0.0;
    Double totalLoanAmountDue = 0.0;
    Double totalLoanDisbursalAmountDue = 0.0;
    Double totalLoanDisbursalAmount = 0.0;
    for (CustomerAccountDto customerAccountDto : decomposedViews.getCustomerAccountViews()) {
        if (customerAccountDto.getCustomerAccountAmountEntered() != null) {
            totalCustomerAccountAmountEntered += Double.parseDouble(customerAccountDto.getCustomerAccountAmountEntered());
        }
        totalCustomerAccountAmountDue += customerAccountDto.getTotalAmountDue().getAmount().doubleValue();
    }
    for (LoanAccountsProductDto loanAccountsProductDto : decomposedViews.getLoanAccountViews()) {
        if (loanAccountsProductDto.getDisBursementAmountEntered() != null) {
            totalLoanDisBursementAmountEntered += Double.parseDouble(loanAccountsProductDto.getDisBursementAmountEntered());
        }
        if (loanAccountsProductDto.getEnteredAmount() != null) {
            totalLoanEnteredAmount += Double.parseDouble(loanAccountsProductDto.getEnteredAmount());
        }
        totalLoanAmountDue += loanAccountsProductDto.getTotalAmountDue();
        totalLoanDisbursalAmountDue += loanAccountsProductDto.getTotalDisbursalAmountDue();
        totalLoanDisbursalAmount += loanAccountsProductDto.getTotalDisburseAmount();
    }
    logMsg += ", totalDisBursementAmountEntered:" + totalLoanDisBursementAmountEntered;
    logMsg += ", totalDisbursalAmount:" + totalLoanDisbursalAmount;
    logMsg += ", totalEnteredAmount:" + totalLoanEnteredAmount;
    logMsg += ", totalAmountDue:" + totalLoanAmountDue;
    logMsg += ", totalDisbursalAmountDue:" + totalLoanDisbursalAmountDue;
    logMsg += ", totalCustomerAccountAmountEntered:" + totalCustomerAccountAmountEntered;
    logMsg += ", totalCustomerAccountAmountDue:" + totalCustomerAccountAmountDue;
    return logMsg;
}
Also used : CustomerAccountDto(org.mifos.customers.util.helpers.CustomerAccountDto) LoanAccountsProductDto(org.mifos.accounts.loan.util.helpers.LoanAccountsProductDto)

Example 2 with CustomerAccountDto

use of org.mifos.customers.util.helpers.CustomerAccountDto in project head by mifos.

the class CollectionSheetEntryDtoPostPreviewValidator method validatePopulatedData.

private ActionErrors validatePopulatedData(final CollectionSheetEntryDto parent, final ActionErrors errors, final Locale locale) {
    List<CollectionSheetEntryDto> children = parent.getCollectionSheetEntryChildren();
    String acCollections = MessageLookup.getLocalizedMessage(CollectionSheetEntryConstants.AC_COLLECTION);
    if (null != children) {
        for (CollectionSheetEntryDto collectionSheetEntryDto : children) {
            validatePopulatedData(collectionSheetEntryDto, errors, locale);
        }
    }
    for (LoanAccountsProductDto accountView : parent.getLoanAccountDetails()) {
        if (accountView.isDisburseLoanAccountPresent() || accountView.getLoanAccountViews().size() > 1) {
            Money enteredAmount = new Money(Money.getDefaultCurrency(), 0.0);
            if (null != accountView.getEnteredAmount() && accountView.isValidAmountEntered()) {
                enteredAmount = new Money(Money.getDefaultCurrency(), getDoubleValue(accountView.getEnteredAmount()));
            }
            Money enteredDisbursalAmount = new Money(Money.getDefaultCurrency(), 0.0);
            if (null != accountView.getDisBursementAmountEntered() && accountView.isValidDisbursementAmount()) {
                enteredDisbursalAmount = new Money(Money.getDefaultCurrency(), getDoubleValue(accountView.getDisBursementAmountEntered()));
            }
            Money totalDueAmount = new Money(Money.getDefaultCurrency(), accountView.getTotalAmountDue());
            Money totalDisburtialAmount = new Money(Money.getDefaultCurrency(), accountView.getTotalDisburseAmount());
            if (totalDisburtialAmount.isGreaterThanZero()) {
                if ((!accountView.isValidDisbursementAmount() || accountView.getDisBursementAmountEntered() == null || !enteredDisbursalAmount.toString().equals(totalDisburtialAmount.toString())) && !enteredDisbursalAmount.isZero()) {
                    errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, accountView.getPrdOfferingShortName(), parent.getCustomerDetail().getDisplayName()));
                }
            }
            if (totalDueAmount.isGreaterThanZero()) {
                if ((!accountView.isValidAmountEntered() || accountView.getEnteredAmount() == null || !enteredAmount.toString().equals(totalDueAmount.toString())) && !enteredAmount.isZero()) {
                    errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, accountView.getPrdOfferingShortName(), parent.getCustomerDetail().getDisplayName()));
                }
            }
            boolean moreThanTwoLoanAccountsToPrepaid = isThereMoreThanTwoLoanAccountsToPrepaid(accountView.getLoanAccountViews());
            if (totalDisburtialAmount.isLessThanOrEqualZero() && totalDueAmount.isLessThanOrEqualZero()) {
                if (!accountView.isValidAmountEntered() || !accountView.isValidDisbursementAmount() || !enteredDisbursalAmount.isZero() || (!moreThanTwoLoanAccountsToPrepaid && !enteredAmount.isZero())) {
                    errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, accountView.getPrdOfferingShortName(), parent.getCustomerDetail().getDisplayName()));
                } else if (moreThanTwoLoanAccountsToPrepaid && !enteredAmount.isZero()) {
                    errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDPREPAYAMOUNT, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDPREPAYAMOUNT, accountView.getPrdOfferingShortName(), parent.getCustomerDetail().getDisplayName()));
                }
            }
        }
    }
    for (SavingsAccountDto savingsAccountDto : parent.getSavingsAccountDetails()) {
        if (!savingsAccountDto.isValidDepositAmountEntered() || !savingsAccountDto.isValidWithDrawalAmountEntered()) {
            errors.add(CollectionSheetEntryConstants.ERRORINVALIDAMOUNT, new ActionMessage(CollectionSheetEntryConstants.ERRORINVALIDAMOUNT, savingsAccountDto.getSavingsOfferingShortName(), parent.getCustomerDetail().getDisplayName()));
        }
    }
    CustomerAccountDto customerAccountDto = parent.getCustomerAccountDetails();
    Double customerAccountAmountEntered = 0.0;
    if (null != customerAccountDto.getCustomerAccountAmountEntered() && customerAccountDto.isValidCustomerAccountAmountEntered()) {
        customerAccountAmountEntered = getDoubleValue(customerAccountDto.getCustomerAccountAmountEntered());
    }
    if (!customerAccountDto.isValidCustomerAccountAmountEntered() || customerAccountAmountEntered < 0.0) {
        errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDACCOLLECTIONS, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDACCOLLECTIONS, acCollections, parent.getCustomerDetail().getDisplayName()));
    }
    return errors;
}
Also used : Money(org.mifos.framework.util.helpers.Money) CustomerAccountDto(org.mifos.customers.util.helpers.CustomerAccountDto) ActionMessage(org.apache.struts.action.ActionMessage) CollectionSheetEntryDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryDto) LoanAccountsProductDto(org.mifos.accounts.loan.util.helpers.LoanAccountsProductDto) SavingsAccountDto(org.mifos.accounts.savings.util.helpers.SavingsAccountDto)

Example 3 with CustomerAccountDto

use of org.mifos.customers.util.helpers.CustomerAccountDto in project head by mifos.

the class BulkEntryActionStrutsTest method getCustomerAccountView.

private CustomerAccountDto getCustomerAccountView(final CustomerBO customer) {
    CustomerAccountDto customerAccountDto = new CustomerAccountDto(customer.getCustomerAccount().getAccountId(), getCurrency());
    List<AccountActionDateEntity> accountAction = new ArrayList<AccountActionDateEntity>();
    accountAction.add(customer.getCustomerAccount().getAccountActionDate(Short.valueOf("1")));
    customerAccountDto.setAccountActionDates(TestObjectFactory.getBulkEntryAccountActionViews(accountAction));
    customerAccountDto.setCustomerAccountAmountEntered("100.0");
    customerAccountDto.setValidCustomerAccountAmountEntered(true);
    return customerAccountDto;
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) CustomerAccountDto(org.mifos.customers.util.helpers.CustomerAccountDto) ArrayList(java.util.ArrayList)

Example 4 with CustomerAccountDto

use of org.mifos.customers.util.helpers.CustomerAccountDto in project head by mifos.

the class TestObjectFactory method getCustomerAccountView.

public static CustomerAccountDto getCustomerAccountView(final CustomerBO customer) throws Exception {
    CustomerAccountDto customerAccountDto = new CustomerAccountDto(customer.getCustomerAccount().getAccountId(), TestUtils.RUPEE);
    List<AccountActionDateEntity> accountAction = getDueActionDatesForAccount(customer.getCustomerAccount().getAccountId(), new java.sql.Date(System.currentTimeMillis()));
    customerAccountDto.setAccountActionDates(getBulkEntryAccountActionViews(accountAction));
    return customerAccountDto;
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) CustomerAccountDto(org.mifos.customers.util.helpers.CustomerAccountDto)

Example 5 with CustomerAccountDto

use of org.mifos.customers.util.helpers.CustomerAccountDto in project head by mifos.

the class CollectionSheetEntryDto method populateCustomerAccountInformation.

public void populateCustomerAccountInformation(final List<CustomerAccountDto> customerAccountList, final List<CollectionSheetEntryInstallmentDto> collectionSheetEntryAccountActionViews, final List<CollectionSheetEntryAccountFeeActionDto> collectionSheetEntryAccountFeeActionDtos) {
    Integer accountId = Integer.valueOf(0);
    for (CustomerAccountDto customerAccountDto : customerAccountList) {
        if (customerDetail.getCustomerId().equals(customerAccountDto.getCustomerId())) {
            accountId = customerAccountDto.getAccountId();
            customerAccountDto.setAccountActionDates(retrieveCustomerSchedule(accountId, customerAccountDto.getCustomerId(), collectionSheetEntryAccountActionViews, collectionSheetEntryAccountFeeActionDtos));
            setCustomerAccountDetails(customerAccountDto);
        }
    }
}
Also used : CustomerAccountDto(org.mifos.customers.util.helpers.CustomerAccountDto)

Aggregations

CustomerAccountDto (org.mifos.customers.util.helpers.CustomerAccountDto)7 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)3 ArrayList (java.util.ArrayList)2 LoanAccountsProductDto (org.mifos.accounts.loan.util.helpers.LoanAccountsProductDto)2 SavingsAccountDto (org.mifos.accounts.savings.util.helpers.SavingsAccountDto)2 CollectionSheetEntryDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryDto)2 Money (org.mifos.framework.util.helpers.Money)2 Date (java.util.Date)1 ActionMessage (org.apache.struts.action.ActionMessage)1 LoanAccountDto (org.mifos.accounts.loan.util.helpers.LoanAccountDto)1 CollectionSheetEntryCustomerAccountInstallmentDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryCustomerAccountInstallmentDto)1 CollectionSheetEntryInstallmentDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryInstallmentDto)1 CollectionSheetEntryLoanInstallmentDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryLoanInstallmentDto)1 CollectionSheetEntrySavingsInstallmentDto (org.mifos.application.collectionsheet.business.CollectionSheetEntrySavingsInstallmentDto)1 CustomerDto (org.mifos.dto.domain.CustomerDto)1