Search in sources :

Example 1 with AccountEntryType

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

the class PeriodicalAccountEntryBean method getTypes.

/**
 * Get the list of all types
 * @return the list of all types
 */
public List<SelectItem> getTypes() {
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    List<AccountEntryType> refs = AccountEntryTypeManager.getDefault().getAllEntities(null, new SortCriteria("name"));
    for (AccountEntryType ref : refs) {
        ret.add(new SelectItem(ref, ref.getName()));
    }
    ret.add(0, new SelectItem(""));
    return ret;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList) AccountEntryType(com.autentia.tnt.businessobject.AccountEntryType)

Example 2 with AccountEntryType

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

the class AccountEntryValidator method validate.

/**
 */
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
    log.info("validate - value = " + value);
    if (value != null) {
        // Check if value is a BigDecimal
        if (!(value instanceof BigDecimal)) {
            log.info("validate - value is not a BigDecimal (" + value.getClass().getName() + ")");
            throw new ValidatorException(new FacesMessage("Las cantidades monetarias deben ser de tipo BigDecimal"));
        }
        // Check if it has no more than 2 decimal digits
        BigDecimal bd = (BigDecimal) value;
        if (bd.scale() > 2) {
            log.info("validate - value has more than 2 decimals (" + value + ")");
            throw new ValidatorException(new FacesMessage("Las cantidades monetarias no pueden tener mas de dos decimales"));
        }
        AccountEntryBean bean = (AccountEntryBean) FacesUtils.getBean("accountEntryBean");
        AccountEntryType type = bean.getType();
        AccountEntryGroup group = type.getGroup();
        if (group.getId() == ConfigurationUtil.getDefault().getCostId()) {
            if (bd.signum() != -1) {
                log.info("validate - value cost is negative (" + value + ")");
                throw new ValidatorException(new FacesMessage("La cantidad debe ser negativa"));
            }
        }
        if (group.getId() == ConfigurationUtil.getDefault().getIncomeId()) {
            if (bd.signum() != 1) {
                log.info("validate - value incom is positive (" + value + ")");
                throw new ValidatorException(new FacesMessage("La cantidad debe ser positiva"));
            }
        }
    }
}
Also used : AccountEntryBean(com.autentia.tnt.bean.account.AccountEntryBean) AccountEntryType(com.autentia.tnt.businessobject.AccountEntryType) AccountEntryGroup(com.autentia.tnt.businessobject.AccountEntryGroup)

Example 3 with AccountEntryType

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

the class PeriodicalAccountEntryValidator method validate.

/**
 */
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
    log.info("validate - value = " + value);
    if (value != null) {
        // Check if value is a BigDecimal
        if (!(value instanceof BigDecimal)) {
            log.info("validate - value is not a BigDecimal (" + value.getClass().getName() + ")");
            throw new ValidatorException(new FacesMessage("Las cantidades monetarias deben ser de tipo BigDecimal"));
        }
        // Check if it has no more than 2 decimal digits
        BigDecimal bd = (BigDecimal) value;
        if (bd.scale() > 2) {
            log.info("validate - value has more than 2 decimals (" + value + ")");
            throw new ValidatorException(new FacesMessage("Las cantidades monetarias no pueden tener mas de dos decimales"));
        }
        PeriodicalAccountEntryBean bean = (PeriodicalAccountEntryBean) FacesUtils.getBean("periodicalAccountEntryBean");
        AccountEntryType type = bean.getType();
        AccountEntryGroup group = type.getGroup();
        if (group.getId() == ConfigurationUtil.getDefault().getCostId()) {
            if (bd.signum() != -1) {
                log.info("validate - value cost is negative (" + value + ")");
                throw new ValidatorException(new FacesMessage("La cantidad debe ser negativa"));
            }
        }
        if (group.getId() == ConfigurationUtil.getDefault().getIncomeId()) {
            if (bd.signum() != 1) {
                log.info("validate - value incom is positive (" + value + ")");
                throw new ValidatorException(new FacesMessage("La cantidad debe ser positiva"));
            }
        }
    }
}
Also used : PeriodicalAccountEntryBean(com.autentia.tnt.bean.account.PeriodicalAccountEntryBean) AccountEntryType(com.autentia.tnt.businessobject.AccountEntryType) AccountEntryGroup(com.autentia.tnt.businessobject.AccountEntryGroup)

Example 4 with AccountEntryType

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

the class AccountEntryBean method getTypes.

/**
 * Get the list of all types
 *
 * @return the list of all types
 */
public List<SelectItem> getTypes() {
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    List<AccountEntryType> refs = AccountEntryTypeManager.getDefault().getAllEntities(null, new SortCriteria("name"));
    for (AccountEntryType ref : refs) {
        ret.add(new SelectItem(ref, ref.getName()));
    }
    ret.add(0, new SelectItem(""));
    return ret;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList) AccountEntryType(com.autentia.tnt.businessobject.AccountEntryType)

Example 5 with AccountEntryType

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

the class AccountEntryTypeBean method getParentsWithNull.

public List<SelectItem> getParentsWithNull() {
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    if (accountEntryType != null) {
        if (this.getId() != null) {
            search.setDifferentId(this.getId());
        }
    }
    search.setParent(null);
    List<AccountEntryType> refs = manager.getAllEntities(search, new SortCriteria("name"));
    for (AccountEntryType ref : refs) {
        ret.add(new SelectItem(ref, ref.getName()));
    }
    ret.add(0, new SelectItem(FacesUtils.getMessage("select.noneValue")));
    search.unsetDifferentId();
    search.unsetParent();
    return ret;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList) AccountEntryType(com.autentia.tnt.businessobject.AccountEntryType)

Aggregations

AccountEntryType (com.autentia.tnt.businessobject.AccountEntryType)5 SortCriteria (com.autentia.tnt.dao.SortCriteria)3 ArrayList (java.util.ArrayList)3 SelectItem (javax.faces.model.SelectItem)3 AccountEntryGroup (com.autentia.tnt.businessobject.AccountEntryGroup)2 AccountEntryBean (com.autentia.tnt.bean.account.AccountEntryBean)1 PeriodicalAccountEntryBean (com.autentia.tnt.bean.account.PeriodicalAccountEntryBean)1