Search in sources :

Example 1 with GlBalancesBO

use of org.mifos.application.accounting.business.GlBalancesBO in project head by mifos.

the class OpenBalanceAction method loadOpenBalance.

public ActionForward loadOpenBalance(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    OpenBalanceActionForm actionForm = (OpenBalanceActionForm) form;
    GlBalancesBO balancesBO = accountingServiceFacade.loadExistedGlBalancesBO(new Integer(actionForm.getOfficeHierarchy()), actionForm.getOffice(), actionForm.getCoaName(), new Integer(actionForm.getFinancialYearId()));
    if (balancesBO != null) {
        BigDecimal openBalance = balancesBO.getOpeningBalance();
        if (openBalance.compareTo(new BigDecimal(0.0)) < 0)
            actionForm.setAmountAction("-");
        else
            actionForm.setAmountAction("+");
        actionForm.setOpenBalance(openBalance.abs().toString());
    }
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : OpenBalanceActionForm(org.mifos.accounting.struts.actionform.OpenBalanceActionForm) GlBalancesBO(org.mifos.application.accounting.business.GlBalancesBO) BigDecimal(java.math.BigDecimal)

Example 2 with GlBalancesBO

use of org.mifos.application.accounting.business.GlBalancesBO in project head by mifos.

the class OpenBalanceAction method submit.

public ActionForward submit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    OpenBalanceActionForm actionForm = (OpenBalanceActionForm) form;
    UserContext context = getUserContext(request);
    //
    GlBalancesBO glBalancesBO = new GlBalancesBO();
    String finacialYearId = (String) (actionForm.getFinancialYearId() == "" ? "0" : actionForm.getFinancialYearId());
    glBalancesBO.setFinancialYearBO(accountingServiceFacade.getFinancialYearBO(new Integer(finacialYearId)));
    glBalancesBO.setCreatedBy(context.getId());
    glBalancesBO.setCreatedDate(DateUtils.getCurrentDateWithoutTimeStamp());
    glBalancesBO.setOfficeLevel(new Integer(actionForm.getOfficeHierarchy()));
    glBalancesBO.setOfficeId(actionForm.getOffice());
    glBalancesBO.setGlCodeValue(actionForm.getCoaName());
    glBalancesBO.setOpeningBalance(new BigDecimal(actionForm.getAmountAction() + actionForm.getOpenBalance()));
    glBalancesBO.setClosingBalance(new BigDecimal(actionForm.getAmountAction() + actionForm.getOpenBalance()));
    glBalancesBO.setTransactionDebitSum(new BigDecimal(0.0));
    glBalancesBO.setTransactionCreditSum(new BigDecimal(0.0));
    accountingServiceFacade.savingOpeningBalances(glBalancesBO);
    return mapping.findForward("submit_success");
}
Also used : OpenBalanceActionForm(org.mifos.accounting.struts.actionform.OpenBalanceActionForm) UserContext(org.mifos.security.util.UserContext) GlBalancesBO(org.mifos.application.accounting.business.GlBalancesBO) BigDecimal(java.math.BigDecimal)

Example 3 with GlBalancesBO

use of org.mifos.application.accounting.business.GlBalancesBO in project head by mifos.

the class AccountingDaoHibernate method findExistedGlBalacesBOs.

public List<GlBalancesBO> findExistedGlBalacesBOs(Integer officeLevelId, String officeId, String glCodeValue, Integer financialYearId) {
    List<GlBalancesBO> balancesBOs = null;
    Query query = createdNamedQuery("getExistedGlBalancesBO");
    query.setInteger("OFFICE_LEVEL", officeLevelId);
    query.setString("OFFICE_ID", officeId);
    query.setString("GLCODEVALUE", glCodeValue);
    query.setInteger("FINANCIALYEARID", financialYearId);
    balancesBOs = query.list();
    return balancesBOs;
}
Also used : Query(org.hibernate.Query) GlBalancesBO(org.mifos.application.accounting.business.GlBalancesBO)

Example 4 with GlBalancesBO

use of org.mifos.application.accounting.business.GlBalancesBO in project head by mifos.

the class AccountingServiceFacadeWebTier method savingOpeningBalances.

@Override
public boolean savingOpeningBalances(GlBalancesBO bo) throws MifosRuntimeException {
    boolean flag = false;
    List<GlBalancesBO> balancesBOs = accountingDao.getResultantGlBalancesBO(bo);
    GlBalancesBO balancesBO = null;
    if (balancesBOs.size() > 0) {
        balancesBO = balancesBOs.get(0);
        balancesBO = getResultantGlBalancesBO(balancesBO, bo);
    } else {
        balancesBO = bo;
    }
    this.hibernateTransactionHelper.startTransaction();
    flag = accountingDao.savingOpenBalancesTransaction(balancesBO);
    this.hibernateTransactionHelper.flushSession();
    return flag;
}
Also used : GlBalancesBO(org.mifos.application.accounting.business.GlBalancesBO)

Example 5 with GlBalancesBO

use of org.mifos.application.accounting.business.GlBalancesBO in project head by mifos.

the class AccountingServiceFacadeWebTier method updateGlBalancesBO.

public boolean updateGlBalancesBO(String accountglCode, String action, GlMasterBO bo) {
    boolean flag = false;
    GlBalancesBO balancesBOTemp = new GlBalancesBO();
    balancesBOTemp.setOfficeId(bo.getFromOfficeId());
    balancesBOTemp.setOfficeLevel(bo.getFromOfficeLevel());
    balancesBOTemp.setCreatedBy(bo.getCreatedBy());
    balancesBOTemp.setCreatedDate(bo.getCreatedDate());
    FinancialYearBO financialYearBO = getFinancialYear();
    if (financialYearBO != null)
        balancesBOTemp.setFinancialYearBO(financialYearBO);
    else
        throw new MifosRuntimeException("no financial year defined");
    balancesBOTemp.setGlCodeValue(accountglCode);
    //
    GlBalancesBO balancesBO = null;
    List<GlBalancesBO> balancesBOs = accountingDao.getResultantGlBalancesBO(balancesBOTemp);
    if (balancesBOs.size() > 0) {
        // to check whether the row is existed or
        // not
        balancesBO = balancesBOs.get(0);
        balancesBO = getResultantGlBalancesBOForAccountingTransactions(balancesBO, bo.getTransactionAmount(), action);
    } else {
        balancesBO = balancesBOTemp;
        balancesBO = getResultantGlBalancesBOForAccountingTransactions(balancesBO, bo.getTransactionAmount(), action);
    }
    this.hibernateTransactionHelper.flushAndClearSession();
    flag = accountingDao.savingOpenBalancesTransaction(balancesBO);
    return flag;
}
Also used : GlBalancesBO(org.mifos.application.accounting.business.GlBalancesBO) FinancialYearBO(org.mifos.application.accounting.business.FinancialYearBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

GlBalancesBO (org.mifos.application.accounting.business.GlBalancesBO)7 BigDecimal (java.math.BigDecimal)2 OpenBalanceActionForm (org.mifos.accounting.struts.actionform.OpenBalanceActionForm)2 Query (org.hibernate.Query)1 FinancialYearBO (org.mifos.application.accounting.business.FinancialYearBO)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 UserContext (org.mifos.security.util.UserContext)1