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;
}
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);
}
}
}
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;
}
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;
}
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));
}
Aggregations