Search in sources :

Example 1 with AccountEntry

use of com.autentia.tnt.businessobject.AccountEntry in project TNTConcept by autentia.

the class AccountEntryBean method getAll.

/**
 * List accountEntrys. Order depends on Faces parameter sort.
 *
 * @return the list of all accountEntrys sorted by requested criterion
 */
public List<AccountEntry> getAll() {
    if (year == ALL_YEARS) {
        search.unsetYear();
    } else {
        search.setYear(year);
    }
    search.setHideInitialEntry(hideInitialEntry);
    if (accountSelected != ALL_ACCOUNTS) {
        search.setAccount(AccountManager.getDefault().getEntityById(accountSelected));
    } else {
        search.unsetAccount();
    }
    List<AccountEntry> res = manager.getAllEntities(search, new SortCriteria(sortColumn, sortAscending));
    calcTotals(res);
    return res;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) AccountEntry(com.autentia.tnt.businessobject.AccountEntry)

Example 2 with AccountEntry

use of com.autentia.tnt.businessobject.AccountEntry in project TNTConcept by autentia.

the class BillManager method calculateBillIsPaid.

public void calculateBillIsPaid(final Bill bill) {
    if (bill.getState() != BillState.PAID) {
        BigDecimal accountEntryTotal = new BigDecimal(0);
        for (AccountEntry accountEntry : bill.getEntries()) {
            accountEntryTotal = accountEntryTotal.add(accountEntry.getAmount());
        }
        if (accountEntryTotal.abs().compareTo(bill.getTotal()) >= 0) {
            bill.setState(BillState.PAID);
            updateEntity(bill);
        }
    }
}
Also used : AccountEntry(com.autentia.tnt.businessobject.AccountEntry) BigDecimal(java.math.BigDecimal)

Example 3 with AccountEntry

use of com.autentia.tnt.businessobject.AccountEntry in project TNTConcept by autentia.

the class PeriodicalAccountEntryManager method copy.

public PeriodicalAccountEntry copy(int id) {
    PeriodicalAccountEntry periodicalAccountEntry = new PeriodicalAccountEntry();
    AccountEntryDAO accountEntryDAO = new AccountEntryDAO();
    AccountEntry copyAccountEntry = accountEntryDAO.loadById(id);
    /*
		 	periodicalAccountEntry.setConcept(copyAccountEntry.getConcept());
		   	periodicalAccountEntry.setAccount(copyAccountEntry.getAccount());
		   	periodicalAccountEntry.setDate(copyAccountEntry.getDate());
		   	periodicalAccountEntry.setObservations(copyAccountEntry.getObservations());
			periodicalAccountEntry.setType(copyAccountEntry.getType());
			periodicalAccountEntry.setAmount(copyAccountEntry.getAmount());
*/
    BeanUtils.copyTransferObject(copyAccountEntry, periodicalAccountEntry);
    return periodicalAccountEntry;
}
Also used : PeriodicalAccountEntry(com.autentia.tnt.businessobject.PeriodicalAccountEntry) PeriodicalAccountEntry(com.autentia.tnt.businessobject.PeriodicalAccountEntry) AccountEntry(com.autentia.tnt.businessobject.AccountEntry) AccountEntryDAO(com.autentia.tnt.dao.hibernate.AccountEntryDAO) PeriodicalAccountEntryDAO(com.autentia.tnt.dao.hibernate.PeriodicalAccountEntryDAO)

Example 4 with AccountEntry

use of com.autentia.tnt.businessobject.AccountEntry in project TNTConcept by autentia.

the class AccountEntryBean method create.

// Getters to list possible values of enum fields
// Methods to create/remove instances of one-to-many entities (slave
// entities)
/**
 * Go to create page
 *
 * @return forward to CREATE page
 */
public String create() {
    accountEntry = new AccountEntry();
    accountEntry.setDate(new Date());
    accountEntry.setAmountDate(new Date());
    return NavigationResults.CREATE;
}
Also used : AccountEntry(com.autentia.tnt.businessobject.AccountEntry) Date(java.util.Date)

Example 5 with AccountEntry

use of com.autentia.tnt.businessobject.AccountEntry in project TNTConcept by autentia.

the class AccountEntryBean method calcTotals.

private void calcTotals(List<AccountEntry> res) {
    costs = new BigDecimal(0);
    incomes = new BigDecimal(0);
    costsType = new BigDecimal(0);
    incomesType = new BigDecimal(0);
    Hashtable mapaCajaTotales = new Hashtable();
    for (AccountEntry elem : res) {
        Integer accountAct = elem.getAccount().getId();
        BigDecimal accountValueAct = null;
        if (!mapaCajaTotales.containsKey(accountAct)) {
            mapaCajaTotales.put(accountAct, new BigDecimal(0));
        }
        accountValueAct = (BigDecimal) mapaCajaTotales.get(accountAct);
        BigDecimal actual = elem.getAmount();
        BigDecimal resul = accountValueAct.add(actual);
        elem.setAmountAccountNow(resul);
        mapaCajaTotales.remove(accountAct);
        mapaCajaTotales.put(accountAct, resul);
        if (actual.signum() >= 0) {
            setIncomes(incomes.add(actual));
        } else {
            setCosts(costs.add(actual));
        }
        if (elem.getType().getGroup().getId() == ConfigurationUtil.getDefault().getCostId()) {
            setCostsType(costsType.add(actual));
        } else {
            setIncomesType(incomesType.add(actual));
        }
    }
    setTotal(incomes.add(costs));
    setTotalType(incomesType.add(costsType));
}
Also used : Hashtable(java.util.Hashtable) AccountEntry(com.autentia.tnt.businessobject.AccountEntry) BigDecimal(java.math.BigDecimal)

Aggregations

AccountEntry (com.autentia.tnt.businessobject.AccountEntry)5 BigDecimal (java.math.BigDecimal)2 PeriodicalAccountEntry (com.autentia.tnt.businessobject.PeriodicalAccountEntry)1 SortCriteria (com.autentia.tnt.dao.SortCriteria)1 AccountEntryDAO (com.autentia.tnt.dao.hibernate.AccountEntryDAO)1 PeriodicalAccountEntryDAO (com.autentia.tnt.dao.hibernate.PeriodicalAccountEntryDAO)1 Date (java.util.Date)1 Hashtable (java.util.Hashtable)1