Search in sources :

Example 1 with CollectionSheetEntryLoanInstallmentDto

use of org.mifos.application.collectionsheet.business.CollectionSheetEntryLoanInstallmentDto in project head by mifos.

the class TestObjectFactory method getBulkEntryAccountActionView.

public static CollectionSheetEntryInstallmentDto getBulkEntryAccountActionView(final AccountActionDateEntity accountActionDateEntity) {
    CollectionSheetEntryInstallmentDto bulkEntryAccountActionView = null;
    if (accountActionDateEntity instanceof LoanScheduleEntity) {
        LoanScheduleEntity actionDate = (LoanScheduleEntity) accountActionDateEntity;
        CollectionSheetEntryLoanInstallmentDto installmentView = new CollectionSheetEntryLoanInstallmentDto(actionDate.getAccount().getAccountId(), actionDate.getCustomer().getCustomerId(), actionDate.getInstallmentId(), actionDate.getActionDateId(), actionDate.getActionDate(), actionDate.getPrincipal(), actionDate.getPrincipalPaid(), actionDate.getInterest(), actionDate.getInterestPaid(), actionDate.getMiscFee(), actionDate.getMiscFeePaid(), actionDate.getPenalty(), actionDate.getPenaltyPaid(), actionDate.getMiscPenalty(), actionDate.getMiscPenaltyPaid(), TestUtils.RUPEE);
        installmentView.setCollectionSheetEntryAccountFeeActions(getBulkEntryAccountFeeActionViews(accountActionDateEntity));
        bulkEntryAccountActionView = installmentView;
    } else if (accountActionDateEntity instanceof SavingsScheduleEntity) {
        SavingsScheduleEntity actionDate = (SavingsScheduleEntity) accountActionDateEntity;
        CollectionSheetEntrySavingsInstallmentDto installmentView = new CollectionSheetEntrySavingsInstallmentDto(actionDate.getAccount().getAccountId(), actionDate.getCustomer().getCustomerId(), actionDate.getInstallmentId(), actionDate.getActionDateId(), actionDate.getActionDate(), actionDate.getDeposit(), actionDate.getDepositPaid());
        bulkEntryAccountActionView = installmentView;
    } else if (accountActionDateEntity instanceof CustomerScheduleEntity) {
        CustomerScheduleEntity actionDate = (CustomerScheduleEntity) accountActionDateEntity;
        CollectionSheetEntryCustomerAccountInstallmentDto installmentView = new CollectionSheetEntryCustomerAccountInstallmentDto(actionDate.getAccount().getAccountId(), actionDate.getCustomer().getCustomerId(), actionDate.getInstallmentId(), actionDate.getActionDateId(), actionDate.getActionDate(), actionDate.getMiscFee(), actionDate.getMiscFeePaid(), actionDate.getMiscPenalty(), actionDate.getMiscPenaltyPaid(), TestUtils.RUPEE);
        installmentView.setCollectionSheetEntryAccountFeeActions(getBulkEntryAccountFeeActionViews(accountActionDateEntity));
        bulkEntryAccountActionView = installmentView;
    }
    return bulkEntryAccountActionView;
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) CollectionSheetEntryLoanInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryLoanInstallmentDto) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) CollectionSheetEntrySavingsInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntrySavingsInstallmentDto) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) CollectionSheetEntryCustomerAccountInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryCustomerAccountInstallmentDto) CollectionSheetEntryInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryInstallmentDto)

Example 2 with CollectionSheetEntryLoanInstallmentDto

use of org.mifos.application.collectionsheet.business.CollectionSheetEntryLoanInstallmentDto in project head by mifos.

the class ProductDtoComparator method createEntryViewHierarchyFromCollectionSheetData.

private CollectionSheetEntryDto createEntryViewHierarchyFromCollectionSheetData(final List<CollectionSheetCustomerDto> collectionSheetCustomerHierarchy, final MifosCurrency currency) {
    final int countOfCustomers = collectionSheetCustomerHierarchy.size();
    CollectionSheetEntryDto parentView = null;
    for (CollectionSheetCustomerDto customer : collectionSheetCustomerHierarchy) {
        final CustomerDto parentCustomerDetail = new CustomerDto(customer.getCustomerId(), customer.getName(), customer.getParentCustomerId(), customer.getLevelId());
        CollectionSheetEntryDto childView = new CollectionSheetEntryDto(parentCustomerDetail, currency);
        childView.setAttendence(customer.getAttendanceId());
        childView.setCountOfCustomers(countOfCustomers);
        final Integer accountId = customer.getCollectionSheetCustomerAccount().getAccountId();
        final Integer customerId = customer.getCustomerId();
        final Short installmentId = null;
        final Integer actionDateId = null;
        final Date actionDate = null;
        final Money miscFee = new Money(currency, customer.getCollectionSheetCustomerAccount().getTotalCustomerAccountCollectionFee().toString());
        final Money miscFeePaid = new Money(currency, "0.0");
        final Money miscPenalty = new Money(currency, "0.0");
        final Money miscPenaltyPaid = new Money(currency, "0.0");
        final CustomerAccountDto customerAccountDetails = new CustomerAccountDto(customer.getCollectionSheetCustomerAccount().getAccountId(), customer.getCustomerId(), currency);
        customerAccountDetails.setAccountId(customer.getCollectionSheetCustomerAccount().getAccountId());
        // we only create one installment fee and set the total amount due
        // in the miscFee column for now
        final CollectionSheetEntryInstallmentDto installmentView = new CollectionSheetEntryCustomerAccountInstallmentDto(accountId, customerId, installmentId, actionDateId, actionDate, miscFee, miscFeePaid, miscPenalty, miscPenaltyPaid, currency);
        final List<CollectionSheetEntryInstallmentDto> installmentViewList = java.util.Arrays.asList(installmentView);
        customerAccountDetails.setAccountActionDates(installmentViewList);
        childView.setCustomerAccountDetails(customerAccountDetails);
        // saving accounts
        for (CollectionSheetCustomerSavingDto customerSavingDto : customer.getCollectionSheetCustomerSaving()) {
            final Integer savCustomerId = customerSavingDto.getCustomerId();
            final Integer savAccountId = customerSavingDto.getAccountId();
            final String savingProductShortName = customerSavingDto.getProductShortName();
            final Short savOfferingId = customerSavingDto.getProductId();
            final Short savingsTypeId = Short.valueOf("1");
            final Short recommendedAmntUnitId = customerSavingDto.getRecommendedAmountUnitId();
            final SavingsAccountDto savingsAccount = new SavingsAccountDto(savAccountId, savCustomerId, savingProductShortName, savOfferingId, savingsTypeId, recommendedAmntUnitId);
            final Short savInstallmentId = null;
            final Integer savActionDateId = null;
            final Date savActionDate = null;
            final Money savDeposit = new Money(currency, customerSavingDto.getTotalDepositAmount().toString());
            final Money savDepositPaid = new Money(currency, "0.0");
            final CollectionSheetEntryInstallmentDto accountTrxnDetail = new CollectionSheetEntrySavingsInstallmentDto(savAccountId, savCustomerId, savInstallmentId, savActionDateId, savActionDate, savDeposit, savDepositPaid);
            savingsAccount.addAccountTrxnDetail(accountTrxnDetail);
            childView.addSavingsAccountDetail(savingsAccount);
        }
        // special savings accounts to be paid individually by clients
        for (CollectionSheetCustomerSavingDto clientIndividualSavingsAccount : customer.getIndividualSavingAccounts()) {
            final Integer savCustomerId = clientIndividualSavingsAccount.getCustomerId();
            final Integer savAccountId = clientIndividualSavingsAccount.getAccountId();
            final String savingProductShortName = clientIndividualSavingsAccount.getProductShortName();
            final Short savOfferingId = clientIndividualSavingsAccount.getProductId();
            final Short savingsTypeId = Short.valueOf("1");
            final Short recommendedAmntUnitId = Short.valueOf("1");
            final SavingsAccountDto savingsAccount = new SavingsAccountDto(savAccountId, savCustomerId, savingProductShortName, savOfferingId, savingsTypeId, recommendedAmntUnitId);
            final Short savInstallmentId = null;
            final Integer savActionDateId = null;
            final Date savActionDate = null;
            final Money savDeposit = new Money(currency, clientIndividualSavingsAccount.getDepositDue().toString());
            final Money savDepositPaid = new Money(currency, clientIndividualSavingsAccount.getDepositPaid().toString());
            final CollectionSheetEntryInstallmentDto accountTrxnDetail = new CollectionSheetEntrySavingsInstallmentDto(savAccountId, savCustomerId, savInstallmentId, savActionDateId, savActionDate, savDeposit, savDepositPaid);
            savingsAccount.addAccountTrxnDetail(accountTrxnDetail);
            childView.addSavingsAccountDetail(savingsAccount);
        }
        // loan accounts
        for (CollectionSheetCustomerLoanDto customerLoanDto : customer.getCollectionSheetCustomerLoan()) {
            final Integer loanAccountId = customerLoanDto.getAccountId();
            final Integer loanCustomerId = customerLoanDto.getCustomerId();
            final String loanOfferingShortName = customerLoanDto.getProductShortName();
            final Short loanOfferingId = customerLoanDto.getProductId();
            final Short loanInstallmentId = null;
            final Integer loanActionDateId = null;
            final Date loanActionDate = null;
            final Short loanAccountState = customerLoanDto.getAccountStateId();
            final Short interestDeductedAtDisbursement = customerLoanDto.getPayInterestAtDisbursement();
            final Money loanAmount = new Money(currency, customerLoanDto.getTotalDisbursement().toString());
            final Money principal = new Money(currency, customerLoanDto.getTotalRepaymentDue().toString());
            final LoanAccountDto loanAccount = new LoanAccountDto(loanAccountId, loanCustomerId, loanOfferingShortName, loanOfferingId, loanAccountState, interestDeductedAtDisbursement, loanAmount);
            loanAccount.setAmountPaidAtDisbursement(customerLoanDto.getAmountDueAtDisbursement());
            final CollectionSheetEntryInstallmentDto accountTrxnDetail = new CollectionSheetEntryLoanInstallmentDto(loanAccountId, loanCustomerId, loanInstallmentId, loanActionDateId, loanActionDate, principal, new Money(currency), new Money(currency), new Money(currency), new Money(currency), new Money(currency), new Money(currency), new Money(currency), new Money(currency), new Money(currency), currency);
            loanAccount.addTrxnDetails(Arrays.asList(accountTrxnDetail));
            childView.addLoanAccountDetails(loanAccount);
        }
        // center-group-client hierarchy
        if (parentView == null) {
            parentView = childView;
        } else {
            addChildToAppropriateParent(parentView, childView);
        }
    }
    return parentView;
}
Also used : CollectionSheetEntryLoanInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryLoanInstallmentDto) CustomerAccountDto(org.mifos.customers.util.helpers.CustomerAccountDto) CustomerDto(org.mifos.dto.domain.CustomerDto) LoanAccountDto(org.mifos.accounts.loan.util.helpers.LoanAccountDto) Date(java.util.Date) SavingsAccountDto(org.mifos.accounts.savings.util.helpers.SavingsAccountDto) Money(org.mifos.framework.util.helpers.Money) CollectionSheetEntrySavingsInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntrySavingsInstallmentDto) CollectionSheetEntryDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryDto) CollectionSheetEntryCustomerAccountInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryCustomerAccountInstallmentDto) CollectionSheetEntryInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryInstallmentDto)

Aggregations

CollectionSheetEntryCustomerAccountInstallmentDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryCustomerAccountInstallmentDto)2 CollectionSheetEntryInstallmentDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryInstallmentDto)2 CollectionSheetEntryLoanInstallmentDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryLoanInstallmentDto)2 CollectionSheetEntrySavingsInstallmentDto (org.mifos.application.collectionsheet.business.CollectionSheetEntrySavingsInstallmentDto)2 Date (java.util.Date)1 LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)1 LoanAccountDto (org.mifos.accounts.loan.util.helpers.LoanAccountDto)1 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)1 SavingsAccountDto (org.mifos.accounts.savings.util.helpers.SavingsAccountDto)1 CollectionSheetEntryDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryDto)1 CustomerScheduleEntity (org.mifos.customers.business.CustomerScheduleEntity)1 CustomerAccountDto (org.mifos.customers.util.helpers.CustomerAccountDto)1 CustomerDto (org.mifos.dto.domain.CustomerDto)1 Money (org.mifos.framework.util.helpers.Money)1