/*
 * 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.admin;

import com.arrebol.apc.model.ModelParameter;
import com.arrebol.apc.model.admin.constance.AdvanceCfg;
import com.arrebol.apc.model.admin.constance.BonusCfg;
import com.arrebol.apc.model.core.Office;
import com.arrebol.apc.model.enums.ActiveStatus;
import com.arrebol.apc.model.views.LoanRenovationDeliveryWeeklyView;
import com.arrebol.apc.model.views.constance.LoanRenovationDeliveryWeeklyViewCfg;
import com.arrebol.apc.repository.GenericEntityRepository;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 *
 * @author Oscar Armando Vargas Cardenas <oscar.vargas@arrebol.com.mx>
 */
public class LoanRenovationDeliveryWeeklyController implements Serializable {

    public List<LoanRenovationDeliveryWeeklyView> fillLoanRenovationDatatable() {
        logger.debug("fillLoanRenovationDatatable");
       
        return genericEntityRepository.xmlQueryAPCEntities(LoanRenovationDeliveryWeeklyView.class,LoanRenovationDeliveryWeeklyViewCfg.QUERY_FIND_LOAN_RENOVATION_DELIVERY_WEEKLY);
    }
    
    public Long getTotalRenovation(String renovation) {
        logger.debug("getTotalRenovation");
        List<ModelParameter> parameters = new ArrayList<>();
        parameters.add(new ModelParameter(LoanRenovationDeliveryWeeklyViewCfg.FIELD_RENOVATION, renovation));
        
        return (Long)  genericEntityRepository.xmlQueryAPCEntityUniqueResult(Long.class,LoanRenovationDeliveryWeeklyViewCfg.QUERY_FIND_LOAN_RENOVATION_TOTAL_RENOVATION,parameters);
    }
    
    public BigDecimal getTotalRenovationAmount(String renovation) {
        logger.debug("getTotalRenovation");
        List<ModelParameter> parameters = new ArrayList<>();
        parameters.add(new ModelParameter(LoanRenovationDeliveryWeeklyViewCfg.FIELD_RENOVATION, renovation));
        
        return (BigDecimal)  genericEntityRepository.xmlQueryAPCEntityUniqueResult(BigDecimal.class,LoanRenovationDeliveryWeeklyViewCfg.QUERY_FIND_LOAN_RENOVATION_TOTAL_RENOVATION_AMOUNT,parameters);
    }

    final Logger logger = LogManager.getLogger(LoanRenovationDeliveryWeeklyController.class);
    private final GenericEntityRepository genericEntityRepository;

    public LoanRenovationDeliveryWeeklyController() {
        this.genericEntityRepository = new GenericEntityRepository();
    }

}
