/*
 * Arrebol Consultancy copyright.
 * 
 * This code belongs to Arrebol Consultancy
 * its use, redistribution or modification are prohibited 
 * without written authorization from Arrebol Consultancy.
 */
package com.arrebol.apc.controller.mobile.controller.admin;

import com.arrebol.apc.controller.mobile.repository.admin.StableGeneralBoxRepository;
import com.arrebol.apc.model.ModelParameter;
import com.arrebol.apc.model.admin.constance.StableGeneralBoxCfg;
import com.arrebol.apc.model.core.Office;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 *
 * @author Carlos Janitzio Zavala Lopez <janitzio.zavala@arrebol.com.mx>
 */
public class StableGeneralBoxController implements Serializable {

    /**
     *
     * @param idOffice
     * @return
     * @throws Exception
     */
    public boolean existStableGeneralBoxByCreatedOn(String idOffice) throws Exception {
        try {
            StableGeneralBoxRepository repository = new StableGeneralBoxRepository();
            List<ModelParameter> parameters = new ArrayList<>();

            parameters.add(new ModelParameter(StableGeneralBoxCfg.FIELD_OFFICE, new Office(idOffice)));

            return new Long(1).compareTo(repository.countStableGeneralBoxByOfficeEqualsToCurrentDate(StableGeneralBoxCfg.QUERY_COUNT_STABLE_GENERAL_BOX_BY_OFFICE_EQUALS_TO_CURRENT_DATE, parameters)) == 0;
        } catch (Exception e) {
            logger.error("existStableSmallBoxByCreatedOn", e);
            throw e;
        }
    }
    final Logger logger = LogManager.getLogger(getClass());
}
