Search in sources :

Example 1 with CoaNamesDto

use of org.mifos.dto.domain.CoaNamesDto in project head by mifos.

the class MultipleGeneralLedgerAction method getGlDetailBOList.

List<GlDetailBO> getGlDetailBOList(MultipleGeneralLedgerActionForm actionForm, List<String> amountActionList) {
    List<GlDetailBO> glDetailBOList = new ArrayList<GlDetailBO>();
    String[] amounts = actionForm.getAmount1();
    String[] trannotes = actionForm.getNotes1();
    String[] accountHeads = actionForm.getAccountHead1();
    List<GLCodeDto> gLCodeDtolist = new ArrayList<GLCodeDto>();
    for (int i = 0; i < amounts.length; i++) {
        GLCodeDto gLCodeDto = new GLCodeDto();
        gLCodeDto.setAmounts(amounts[i]);
        gLCodeDto.setTrannotes(trannotes[i]);
        if (amounts.length <= accountHeads.length) {
            gLCodeDto.setAccountHead(accountHeads[i]);
        }
        gLCodeDtolist.add(gLCodeDto);
    }
    for (GLCodeDto glCodeDto : gLCodeDtolist) {
        if (glCodeDto.getAccountHead() != null) {
            List<CoaNamesDto> subaccounthead = accountingServiceFacade.loadCoaNamesWithGlcodeValues(glCodeDto.getAccountHead());
            for (CoaNamesDto subaccount : subaccounthead) {
                double amount = Double.parseDouble(glCodeDto.getAmounts());
                String Accounthead = glCodeDto.getAccountHead();
                if (amount > 0) {
                    glDetailBOList.add(new GlDetailBO(subaccount.getGlcodeValue(), new BigDecimal(glCodeDto.getAmounts()), amountActionList.get(1), actionForm.getChequeNo(), DateUtils.getDate(actionForm.getChequeDate()), actionForm.getBankName(), actionForm.getBankBranch(), glCodeDto.getTrannotes()));
                }
            }
        }
    }
    return glDetailBOList;
}
Also used : CoaNamesDto(org.mifos.dto.domain.CoaNamesDto) GLCodeDto(org.mifos.dto.domain.GLCodeDto) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) GlDetailBO(org.mifos.application.accounting.business.GlDetailBO)

Example 2 with CoaNamesDto

use of org.mifos.dto.domain.CoaNamesDto in project head by mifos.

the class VoucherBranchMappingActionForm method mandatoryCheck.

private ActionErrors mandatoryCheck(UserContext userContext) {
    Locale locale = userContext.getPreferredLocale();
    ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
    ActionErrors errors = new ActionErrors();
    String branchname = resources.getString(SimpleAccountingConstants.BRANCH_NAME);
    String Amount = resources.getString(SimpleAccountingConstants.AMOUNT);
    String trxn_Type = resources.getString(SimpleAccountingConstants.TRXNTYPE);
    String main_Account = resources.getString(SimpleAccountingConstants.MAIN_ACCOUNT);
    String Notes = resources.getString(SimpleAccountingConstants.TRXN_NOTES);
    String trxn_Date = resources.getString(SimpleAccountingConstants.TRXNDATE);
    String[] amts = getAmount();
    String[] trannotes = getTransactionnotes();
    // String[] canames=getCoaname();
    List<CoaNamesDto> coaNamesDtolist = new ArrayList<CoaNamesDto>();
    if (amts.length < 0 || "".equals(amts)) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, Amount));
    }
    for (int i = 0; i < amts.length; i++) {
        if (amts[i].equalsIgnoreCase("0")) {
            errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, Amount));
        }
    }
    if (trannotes == null || "".equals(trannotes)) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, Notes));
    }
    {
        for (int i = 0; i < getAmount().length; i++) {
            CoaNamesDto coanamesob = new CoaNamesDto();
            coanamesob.setAmount(amts[i]);
            coanamesob.setTrxnnotes(trannotes[i]);
            // coanamesob.setCoaName(canames[i]);
            coaNamesDtolist.add(coanamesob);
        }
    }
    java.sql.Date currentDate = null;
    try {
        currentDate = DateUtils.getLocaleDate(userContext.getPreferredLocale(), DateUtils.getCurrentDate(userContext.getPreferredLocale()));
    } catch (InvalidDateException ide) {
        errors.add(SimpleAccountingConstants.INVALIDDATE, new ActionMessage(SimpleAccountingConstants.INVALIDDATE));
    }
    java.sql.Date trxnDate = null;
    if (getTransactiondate() == null || "".equals(getTransactiondate())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, trxn_Date));
    } else if (getTransactiondate() != null && !getTransactiondate().equals("") && !DateUtils.isValidDate(getTransactiondate())) {
        errors = trxnDateValidate(errors, locale);
    } else if (DateUtils.isValidDate(getTransactiondate())) {
        try {
            trxnDate = DateUtils.getDateAsSentFromBrowser(getTransactiondate());
        } catch (InvalidDateException ide) {
            errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.INVALID_TRXN_DATE, trxn_Date));
        }
        if (trxnDate.compareTo(currentDate) > 0) {
            errors.add(SimpleAccountingConstants.INVALID_FUTURE, new ActionMessage(SimpleAccountingConstants.INVALID_FUTURE, trxn_Date));
        }
    }
    if (getBranch() == null || "".equals(getBranch())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, branchname));
    }
    if (transactiontype == null || "".equals(transactiontype.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, trxn_Type));
    }
    if (mainAccount == null || "".equals(mainAccount.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, main_Account));
    }
    return errors;
}
Also used : Locale(java.util.Locale) ArrayList(java.util.ArrayList) ActionErrors(org.apache.struts.action.ActionErrors) CoaNamesDto(org.mifos.dto.domain.CoaNamesDto) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ActionMessage(org.apache.struts.action.ActionMessage) ResourceBundle(java.util.ResourceBundle)

Example 3 with CoaNamesDto

use of org.mifos.dto.domain.CoaNamesDto in project head by mifos.

the class VoucherBranchMappingAction method getGlDetailBOList.

List<GlDetailBO> getGlDetailBOList(VoucherBranchMappingActionForm actionForm, List<String> amountActionList) {
    List<GlDetailBO> glDetailBOList = new ArrayList<GlDetailBO>();
    String[] amounts = actionForm.getAmount();
    String[] transactionnotes = actionForm.getTransactionnotes();
    String[] coanames = actionForm.getCoaname();
    List<CoaNamesDto> coaNamesDtolist = new ArrayList<CoaNamesDto>();
    for (int i = 0; i < actionForm.getAmount().length; i++) {
        CoaNamesDto coanamesob = new CoaNamesDto();
        coanamesob.setAmount(amounts[i]);
        coanamesob.setTrxnnotes(transactionnotes[i]);
        coanamesob.setCoaName(coanames[i]);
        coaNamesDtolist.add(coanamesob);
    }
    for (CoaNamesDto namesdto : coaNamesDtolist) {
        List<CoaNamesDto> subaccounthead = accountingServiceFacade.loadCoaNamesWithGlcodeValues(namesdto.getCoaName());
        for (CoaNamesDto subaccount : subaccounthead) {
            double amount = Double.parseDouble(namesdto.getAmount());
            if (amount > 0) {
                glDetailBOList.add(new GlDetailBO(subaccount.getGlcodeValue(), new BigDecimal(namesdto.getAmount()), amountActionList.get(1), actionForm.getChequeNo(), DateUtils.getDate(actionForm.getChequeDate()), actionForm.getBankName(), actionForm.getBankBranch(), namesdto.getTrxnnotes()));
            }
        }
    }
    return glDetailBOList;
}
Also used : CoaNamesDto(org.mifos.dto.domain.CoaNamesDto) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) GlDetailBO(org.mifos.application.accounting.business.GlDetailBO)

Aggregations

ArrayList (java.util.ArrayList)3 CoaNamesDto (org.mifos.dto.domain.CoaNamesDto)3 BigDecimal (java.math.BigDecimal)2 GlDetailBO (org.mifos.application.accounting.business.GlDetailBO)2 Locale (java.util.Locale)1 ResourceBundle (java.util.ResourceBundle)1 ActionErrors (org.apache.struts.action.ActionErrors)1 ActionMessage (org.apache.struts.action.ActionMessage)1 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)1 GLCodeDto (org.mifos.dto.domain.GLCodeDto)1