/*
 ************************************************************************************
 * Copyright (C) 2013 Openbravo S.L.U.
 * Licensed under the Openbravo Commercial License version 1.0
 * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
 * or in the legal folder of this module distribution.
 ************************************************************************************
 */

package org.openbravo.retail.posterminal;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.log4j.Logger;
import org.openbravo.client.kernel.ComponentProvider.Qualifier;
import org.openbravo.mobile.core.model.HQLProperty;
import org.openbravo.mobile.core.model.HQLPropertyList;
import org.openbravo.mobile.core.model.ModelExtension;

/**
 * Defines hql properties for the PaidReceips Order header
 * 
 * @author alostale
 * 
 */

@Qualifier(PaidReceiptsHeader.PaidReceiptsHeaderPropertyExtension)
public class PaidReceiptsHeaderProperties extends ModelExtension {

  public static final Logger log = Logger.getLogger(PaidReceiptsHeaderProperties.class);

  @Override
  public List<HQLProperty> getHQLProperties(Object params) {
  // Calculate POS Precision
  String localstrIsLayaway = "";
  try {
    if (params != null) {
      @SuppressWarnings("unchecked")
      HashMap<String, Object> localParams = (HashMap<String, Object>) params;
      localstrIsLayaway = (String) localParams.get("strIsLayaway");
    }
  } catch (Exception e) {
    log.error("Error getting posPrecision: " + e.getMessage(), e);
  }
  final String strIsLayaway = localstrIsLayaway;
  
    ArrayList<HQLProperty> list = new ArrayList<HQLProperty>() {
      private static final long serialVersionUID = 1L;
      {
        add(new HQLProperty("ord.id", "id"));
        add(new HQLProperty("ord.orderDate", "orderDate"));
        add(new HQLProperty("ord.documentNo", "documentNo"));
        add(new HQLProperty("ord.businessPartner.name ", "businessPartner"));
        add(new HQLProperty("ord.grandTotalAmount", "totalamount"));
        add(new HQLProperty("ord.documentType.id", "documentTypeId"));
        add(new HQLProperty("'" + strIsLayaway + "'", "isLayaway"));
      }
    };

    return list;
  }
}
