Search in sources :

Example 11 with CollectionSheetEntryDto

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

the class BulkEntryTag method generateTagData.

private void generateTagData(final CollectionSheetEntryGridDto bulkEntry, final List<ProductDto> loanProducts, final List<ProductDto> savingsProducts, final List<CustomValueListElementDto> custAttTypes, final String method, final StringBuilder builder) throws SystemException {
    UserContext userContext = (UserContext) pageContext.getSession().getAttribute(Constants.USERCONTEXT);
    BulkEntryDisplayHelper bulkEntryDisplayHelper = new BulkEntryDisplayHelper();
    builder.append(bulkEntryDisplayHelper.buildTableHeadings(loanProducts, savingsProducts, userContext.getPreferredLocale()));
    CollectionSheetEntryDto bulkEntryParentView = bulkEntry.getBulkEntryParent();
    Money[] totals = null;
    boolean centerHierachyExists = ClientRules.getCenterHierarchyExists();
    if (centerHierachyExists) {
        totals = bulkEntryDisplayHelper.buildForCenter(bulkEntryParentView, loanProducts, savingsProducts, custAttTypes, builder, method, userContext);
    } else {
        totals = bulkEntryDisplayHelper.buildForGroup(bulkEntryParentView, loanProducts, savingsProducts, custAttTypes, builder, method, userContext);
    }
    int columnSize = 2 * (loanProducts.size() + savingsProducts.size()) + 7;
    builder.append(bulkEntryDisplayHelper.getEndTable(columnSize));
    builder.append(bulkEntryDisplayHelper.buildTotals(bulkEntryParentView.getCurrency(), totals, loanProducts.size(), savingsProducts.size(), method, userContext));
}
Also used : Money(org.mifos.framework.util.helpers.Money) UserContext(org.mifos.security.util.UserContext) BulkEntryDisplayHelper(org.mifos.application.collectionsheet.struts.uihelpers.BulkEntryDisplayHelper) CollectionSheetEntryDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryDto)

Example 12 with CollectionSheetEntryDto

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

the class BulkEntryDisplayHelper method buildForCenter.

public Money[] buildForCenter(final CollectionSheetEntryDto centerEntry, final List<ProductDto> loanProducts, final List<ProductDto> savingsProducts, final List<CustomValueListElementDto> custAttTypes, final StringBuilder builder, final String method, final UserContext userContext) {
    int rowIndex = 0;
    final int totalProductsSize = 2 * (loanProducts.size() + savingsProducts.size());
    final Money[] centerTotals = new Money[(totalProductsSize + 1)];
    Money[] groupTotals = new Money[(totalProductsSize + 1)];
    for (int i = 0; i < centerTotals.length; i++) {
        centerTotals[i] = new Money(centerEntry.getCurrency());
    }
    final MifosCurrency currency = centerEntry.getCurrency();
    final String accountLabel = getLocalizedMessage(CollectionSheetEntryConstants.ACCOUNTS_GROUP_CENTER);
    final List<CollectionSheetEntryDto> groupEntries = centerEntry.getCollectionSheetEntryChildren();
    for (CollectionSheetEntryDto groupEntry : groupEntries) {
        groupTotals = new Money[(totalProductsSize + 1)];
        int groupInitialAccNum = rowIndex;
        final List<CollectionSheetEntryDto> clientEntries = groupEntry.getCollectionSheetEntryChildren();
        final int clientCount = clientEntries.size();
        final String groupName = groupEntry.getCustomerDetail().getDisplayName();
        buildGroupName(builder, groupName, totalProductsSize + 1);
        for (CollectionSheetEntryDto clientEntry : clientEntries) {
            final int levelId = 1;
            buildClientRow(clientEntry, loanProducts, savingsProducts, clientCount, groupInitialAccNum, rowIndex, groupTotals, clientEntry.getCustomerDetail().getDisplayName(), builder, method, levelId, currency);
            generateAttendance(builder, custAttTypes, rowIndex, clientEntry, method);
            BulkEntryTagUIHelper.getInstance().generateEndTR(builder);
            rowIndex++;
        }
        final int levelId = 2;
        final String groupLabel = getLabel(ConfigurationConstants.GROUP, userContext);
        final String formattedGroupAccountStr = accountLabel.format(accountLabel, groupLabel);
        final String groupAccountStr = " " + formattedGroupAccountStr + " ";
        buildClientRow(groupEntry, loanProducts, savingsProducts, clientCount, groupInitialAccNum, rowIndex, groupTotals, groupAccountStr, builder, method, levelId, currency);
        BulkEntryTagUIHelper.getInstance().generateEmptyTD(builder, true);
        BulkEntryTagUIHelper.getInstance().generateEndTR(builder);
        rowIndex++;
        getTotalForRow(builder, groupEntry, groupTotals, rowIndex, method, userContext, loanProducts.size(), savingsProducts.size());
        for (int i = 0; i < groupTotals.length; i++) {
            if (groupTotals[i] != null) {
                centerTotals[i] = centerTotals[i].add(groupTotals[i]);
            }
        }
    }
    final int levelId = 3;
    final String center = getLabel(ConfigurationConstants.CENTER, userContext);
    final String formattedCenterAccountStr = accountLabel.format(accountLabel, center);
    final String centerAccountStr = " " + formattedCenterAccountStr + " ";
    buildClientRow(centerEntry, loanProducts, savingsProducts, 0, 0, rowIndex, groupTotals, centerAccountStr, builder, method, levelId, currency);
    BulkEntryTagUIHelper.getInstance().generateEmptyTD(builder, true);
    BulkEntryTagUIHelper.getInstance().generateEndTR(builder);
    getTotalForRow(builder, centerEntry, centerTotals, rowIndex, method, userContext, loanProducts.size(), savingsProducts.size());
    return centerTotals;
}
Also used : Money(org.mifos.framework.util.helpers.Money) MifosCurrency(org.mifos.application.master.business.MifosCurrency) CollectionSheetEntryDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryDto)

Example 13 with CollectionSheetEntryDto

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

the class BulkEntryDisplayHelper method buildForGroup.

public Money[] buildForGroup(final CollectionSheetEntryDto parent, final List<ProductDto> loanProducts, final List<ProductDto> savingsProducts, final List<CustomValueListElementDto> custAttTypes, final StringBuilder builder, final String method, final UserContext userContext) {
    int rowIndex = 0;
    int totalProductsSize = 2 * (loanProducts.size() + savingsProducts.size());
    Money[] groupTotals = new Money[(totalProductsSize + 1)];
    MifosCurrency currency = parent.getCurrency();
    Locale locale = userContext.getPreferredLocale();
    String account = getLocalizedMessage(CollectionSheetEntryConstants.ACCOUNTS_GROUP_CENTER);
    String group = getLabel(ConfigurationConstants.GROUP, userContext);
    String groupAccountStr = account.format(account, group);
    groupAccountStr = " " + groupAccountStr + " ";
    for (CollectionSheetEntryDto child : parent.getCollectionSheetEntryChildren()) {
        buildClientRow(child, loanProducts, savingsProducts, parent.getCollectionSheetEntryChildren().size(), 0, rowIndex, groupTotals, child.getCustomerDetail().getDisplayName(), builder, method, 1, currency);
        generateAttendance(builder, custAttTypes, rowIndex, child, method);
        BulkEntryTagUIHelper.getInstance().generateEndTR(builder);
        rowIndex++;
    }
    buildClientRow(parent, loanProducts, savingsProducts, parent.getCollectionSheetEntryChildren().size(), 0, rowIndex, groupTotals, groupAccountStr, builder, method, 2, currency);
    BulkEntryTagUIHelper.getInstance().generateEmptyTD(builder, true);
    BulkEntryTagUIHelper.getInstance().generateEndTR(builder);
    rowIndex++;
    getTotalForRow(builder, parent, groupTotals, rowIndex, method, userContext, loanProducts.size(), savingsProducts.size());
    return groupTotals;
}
Also used : Locale(java.util.Locale) Money(org.mifos.framework.util.helpers.Money) MifosCurrency(org.mifos.application.master.business.MifosCurrency) CollectionSheetEntryDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryDto)

Example 14 with CollectionSheetEntryDto

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

the class BulkEntryActionStrutsTest method getSuccessfulBulkEntry.

private CollectionSheetEntryGridDto getSuccessfulBulkEntry() throws Exception {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    Date startDate = new Date(System.currentTimeMillis());
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    client = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
    LoanOfferingBO loanOffering1 = TestObjectFactory.createLoanOffering(startDate, meeting);
    LoanOfferingBO loanOffering2 = TestObjectFactory.createLoanOffering("Loan2345", "313f", ApplicableTo.CLIENTS, startDate, PrdStatus.LOAN_ACTIVE, 300.0, 1.2, 3, InterestType.FLAT, meeting);
    groupAccount = TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering1);
    clientAccount = getLoanAccount(AccountState.LOAN_APPROVED, startDate, 1, loanOffering2);
    Date currentDate = new Date(System.currentTimeMillis());
    // 2010-01-18: JohnW - This use of TestObjectFactory.createSavingsProduct used to break a number of
    // business rules.
    // E.g all the savings products were set up as applicable for Groups and "per individual" which is wrong for
    // centers and clients. In the case of the client being wrongly set up as "Per Individual" it now triggers save
    // collection sheet validation (which checks that the account associated with the client marked "per individual"
    // matches its parent group or center)
    // Also, when creating the center savings accounts (which is effectively "per individual") and the group savings
    // account which is "per individual" the saving_schedule entries for the client are not written (they are in the
    // production code).
    //
    // Considered using/updating the savingsProductBuilder functionality but that doesn't deal with the
    // "per individual" aspect either (update: it does, but still problem with builder creating installments).
    // Decided not to try and fix it up (good deal of effort involved) but rather change the
    // TestObjectFactory.createSavingsProduct to accept a RecommendedAmountUnit parameter.
    // Unfortunately it wouldn't allow a null parameter (which is valid for centers and clients) through so, where
    // necessary, I picked a value that worked for the test but was wrong in a business rule sense (just as its
    // always been).
    // So the savings product test data doesn't adhere to business rules but all tests pass here and in others
    // tests.
    SavingsOfferingBO savingsOffering1 = TestObjectFactory.createSavingsProduct("SavingPrd1", "ased", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
    SavingsOfferingBO savingsOffering2 = TestObjectFactory.createSavingsProduct("SavingPrd2", "cvdf", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
    SavingsOfferingBO savingsOffering3 = TestObjectFactory.createSavingsProduct("SavingPrd3", "zxsd", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
    centerSavingsAccount = TestObjectFactory.createSavingsAccount("43244334", center, Short.valueOf("16"), startDate, savingsOffering1);
    groupSavingsAccount = TestObjectFactory.createSavingsAccount("43234434", group, Short.valueOf("16"), startDate, savingsOffering2);
    clientSavingsAccount = TestObjectFactory.createSavingsAccount("43245434", client, Short.valueOf("16"), startDate, savingsOffering3);
    CollectionSheetEntryDto bulkEntryParent = new CollectionSheetEntryDto(getCusomerView(center), null);
    SavingsAccountDto centerSavingsAccountView = getSavingsAccountView(centerSavingsAccount);
    centerSavingsAccountView.setDepositAmountEntered("100");
    centerSavingsAccountView.setWithDrawalAmountEntered("10");
    bulkEntryParent.addSavingsAccountDetail(centerSavingsAccountView);
    bulkEntryParent.setCustomerAccountDetails(getCustomerAccountView(center));
    CollectionSheetEntryDto bulkEntryChild = new CollectionSheetEntryDto(getCusomerView(group), null);
    LoanAccountDto groupLoanAccountView = getLoanAccountView(groupAccount);
    SavingsAccountDto groupSavingsAccountView = getSavingsAccountView(groupSavingsAccount);
    groupSavingsAccountView.setDepositAmountEntered("100");
    groupSavingsAccountView.setWithDrawalAmountEntered("10");
    bulkEntryChild.addLoanAccountDetails(groupLoanAccountView);
    bulkEntryChild.addSavingsAccountDetail(groupSavingsAccountView);
    bulkEntryChild.setCustomerAccountDetails(getCustomerAccountView(group));
    CollectionSheetEntryDto bulkEntrySubChild = new CollectionSheetEntryDto(getCusomerView(client), null);
    LoanAccountDto clientLoanAccountView = getLoanAccountView(clientAccount);
    clientLoanAccountView.setAmountPaidAtDisbursement(0.0);
    SavingsAccountDto clientSavingsAccountView = getSavingsAccountView(clientSavingsAccount);
    clientSavingsAccountView.setDepositAmountEntered("100");
    clientSavingsAccountView.setWithDrawalAmountEntered("10");
    bulkEntrySubChild.addLoanAccountDetails(clientLoanAccountView);
    bulkEntrySubChild.setAttendence(new Short("2"));
    bulkEntrySubChild.addSavingsAccountDetail(clientSavingsAccountView);
    bulkEntrySubChild.setCustomerAccountDetails(getCustomerAccountView(client));
    bulkEntryChild.addChildNode(bulkEntrySubChild);
    bulkEntryParent.addChildNode(bulkEntryChild);
    LoanAccountsProductDto childView = bulkEntryChild.getLoanAccountDetails().get(0);
    childView.setPrdOfferingId(groupLoanAccountView.getPrdOfferingId());
    childView.setEnteredAmount("100.0");
    LoanAccountsProductDto subchildView = bulkEntrySubChild.getLoanAccountDetails().get(0);
    subchildView.setDisBursementAmountEntered(clientAccount.getLoanAmount().toString());
    subchildView.setPrdOfferingId(clientLoanAccountView.getPrdOfferingId());
    ProductDto loanOfferingDto = new ProductDto(loanOffering1.getPrdOfferingId(), loanOffering1.getPrdOfferingShortName());
    ProductDto loanOfferingDto2 = new ProductDto(loanOffering2.getPrdOfferingId(), loanOffering2.getPrdOfferingShortName());
    List<ProductDto> loanProducts = Arrays.asList(loanOfferingDto, loanOfferingDto2);
    ProductDto savingsOfferingDto = new ProductDto(savingsOffering1.getPrdOfferingId(), savingsOffering1.getPrdOfferingShortName());
    ProductDto savingsOfferingDto2 = new ProductDto(savingsOffering2.getPrdOfferingId(), savingsOffering2.getPrdOfferingShortName());
    ProductDto savingsOfferingDto3 = new ProductDto(savingsOffering3.getPrdOfferingId(), savingsOffering3.getPrdOfferingShortName());
    List<ProductDto> savingsProducts = Arrays.asList(savingsOfferingDto, savingsOfferingDto2, savingsOfferingDto3);
    final PersonnelDto loanOfficer = getPersonnelView(center.getPersonnel());
    final OfficeDetailsDto officeDetailsDto = null;
    final List<CustomValueListElementDto> attendanceTypesList = new ArrayList<CustomValueListElementDto>();
    bulkEntryParent.setCountOfCustomers(3);
    final CollectionSheetEntryGridDto bulkEntry = new CollectionSheetEntryGridDto(bulkEntryParent, loanOfficer, officeDetailsDto, getPaymentTypeView(), startDate, "324343242", startDate, loanProducts, savingsProducts, attendanceTypesList);
    return bulkEntry;
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomValueListElementDto(org.mifos.application.master.business.CustomValueListElementDto) ArrayList(java.util.ArrayList) LoanAccountDto(org.mifos.accounts.loan.util.helpers.LoanAccountDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) Date(java.util.Date) LoanAccountsProductDto(org.mifos.accounts.loan.util.helpers.LoanAccountsProductDto) SavingsAccountDto(org.mifos.accounts.savings.util.helpers.SavingsAccountDto) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) CollectionSheetEntryDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryDto) LoanAccountsProductDto(org.mifos.accounts.loan.util.helpers.LoanAccountsProductDto) ProductDto(org.mifos.application.servicefacade.ProductDto) CollectionSheetEntryGridDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)

Example 15 with CollectionSheetEntryDto

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

the class SaveCollectionSheetFromLegacyAssembler method assembleCustomers.

private List<SaveCollectionSheetCustomerDto> assembleCustomers(List<CollectionSheetEntryDto> collectionSheetEntryDtos) {
    List<SaveCollectionSheetCustomerDto> saveCollectionSheetCustomers = new ArrayList<SaveCollectionSheetCustomerDto>();
    for (CollectionSheetEntryDto collectionSheetEntryDto : collectionSheetEntryDtos) {
        Short currencyId = null;
        if (collectionSheetEntryDto.getCurrency() != null) {
            currencyId = collectionSheetEntryDto.getCurrency().getCurrencyId();
        } else {
            currencyId = Money.getDefaultCurrency().getCurrencyId();
        }
        final Integer customerId = collectionSheetEntryDto.getCustomerDetail().getCustomerId();
        final Integer parentCustomerId = collectionSheetEntryDto.getCustomerDetail().getParentCustomerId();
        final Short attendanceId = collectionSheetEntryDto.getAttendence();
        final SaveCollectionSheetCustomerAccountDto SaveCollectionSheetCustomerAccount = assembleCustomerAccount(collectionSheetEntryDto.getCustomerAccountDetails(), currencyId);
        final List<SaveCollectionSheetCustomerLoanDto> saveCollectionSheetCustomerLoans = assembleCustomerLoans(collectionSheetEntryDto.getLoanAccountDetails(), currencyId);
        final List<SaveCollectionSheetCustomerSavingDto> saveCollectionSheetCustomerSavings = assembleCustomerSavings(collectionSheetEntryDto.getSavingsAccountDetails(), currencyId, false, collectionSheetEntryDto.getCustomerDetail().getCustomerLevelId());
        final List<SaveCollectionSheetCustomerSavingDto> saveCollectionSheetCustomerIndividualSavings = assembleCustomerSavings(collectionSheetEntryDto.getSavingsAccountDetails(), currencyId, true, collectionSheetEntryDto.getCustomerDetail().getCustomerLevelId());
        SaveCollectionSheetCustomerDto saveCollectionSheetCustomerDto = null;
        try {
            saveCollectionSheetCustomerDto = new SaveCollectionSheetCustomerDto(customerId, parentCustomerId, attendanceId, SaveCollectionSheetCustomerAccount, saveCollectionSheetCustomerLoans, saveCollectionSheetCustomerSavings, saveCollectionSheetCustomerIndividualSavings);
        } catch (SaveCollectionSheetException e) {
            throw new MifosRuntimeException(e.printInvalidSaveCollectionSheetReasons());
        }
        saveCollectionSheetCustomers.add(saveCollectionSheetCustomerDto);
    }
    return saveCollectionSheetCustomers;
}
Also used : ArrayList(java.util.ArrayList) CollectionSheetEntryDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

CollectionSheetEntryDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryDto)16 CollectionSheetEntryGridDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)6 ArrayList (java.util.ArrayList)5 SavingsAccountDto (org.mifos.accounts.savings.util.helpers.SavingsAccountDto)5 Money (org.mifos.framework.util.helpers.Money)5 Date (java.util.Date)4 LoanAccountDto (org.mifos.accounts.loan.util.helpers.LoanAccountDto)4 LoanAccountsProductDto (org.mifos.accounts.loan.util.helpers.LoanAccountsProductDto)4 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)4 PersonnelDto (org.mifos.dto.domain.PersonnelDto)4 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)3 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)3 CustomValueListElementDto (org.mifos.application.master.business.CustomValueListElementDto)3 MeetingBO (org.mifos.application.meeting.business.MeetingBO)3 ProductDto (org.mifos.application.servicefacade.ProductDto)3 MifosCurrency (org.mifos.application.master.business.MifosCurrency)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 CustomerAccountDto (org.mifos.customers.util.helpers.CustomerAccountDto)2 Date (java.sql.Date)1 Locale (java.util.Locale)1