use of com.autentia.tnt.businessobject.AccountEntryGroup in project TNTConcept by autentia.
the class AccountEntryTypeBean method getGroups.
// Getters to list possible values of related entities
/**
* Get the list of all groups
* @return the list of all groups
*/
public List<SelectItem> getGroups() {
List<AccountEntryGroup> refs = AccountEntryGroupManager.getDefault().getAllEntities(null, new SortCriteria("name"));
ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
for (AccountEntryGroup ref : refs) {
ret.add(new SelectItem(ref, ref.getName()));
}
return ret;
}
use of com.autentia.tnt.businessobject.AccountEntryGroup 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"));
}
}
}
}
use of com.autentia.tnt.businessobject.AccountEntryGroup 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"));
}
}
}
}
Aggregations