public static Decimal GetProductQty(Ctx ctx, int M_Product_ID, X_Ref_Quantity_Type qtyType, Trx trx) { String sql = "SELECT COALESCE(SUM(QTY),0) FROM M_STORAGE " + " WHERE M_Product_ID=" + M_Product_ID + " AND QtyType='" + qtyType.GetValue() + "'"; Decimal qty = Decimal.Zero; IDataReader idr = null; try { idr = DB.ExecuteReader(sql, null, trx); if (idr.Read()) { qty = Util.GetValueOfDecimal(idr[0]); } } catch (Exception ex) { _log.Log(Level.SEVERE, sql, ex); } finally { if (idr != null) { idr.Close(); idr = null; } } return(qty); }
public static Decimal GetForUpdate(Ctx ctx, int M_Warehouse_ID, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int reservationAttributeSetInstance_ID, X_Ref_Quantity_Type type, Trx trx) { return(Decimal.Zero); }
public Record(List <MStorage> storageDetails) { foreach (MStorage storage in storageDetails) { storageMap[X_Ref_Quantity_Type.GetEnum(storage.GetQtyType())] = storage; refDetail = storage; } }
/// <summary> /// Get all Storages for Product /// </summary> /// <param name="ctx"></param> /// <param name="M_Product_ID"></param> /// <param name="M_Locator_ID"></param> /// <param name="qtyType"></param> /// <param name="isFIFO"></param> /// <param name="withASI"></param> /// <param name="trx"></param> /// <returns></returns> public static List <MStorageDetail> GetAll(Ctx ctx, int M_Product_ID, int M_Locator_ID, X_Ref_Quantity_Type qtyType, Boolean isFIFO, Boolean withASI, Trx trx) { List <MStorageDetail> list = new List <MStorageDetail>(); String sql = "select s.* " + "from M_STORAGEDETAIL s INNER JOIN M_STORAGEDETAIL t " + "on ( s.AD_CLIENT_ID = t.AD_CLIENT_ID " + "and s.AD_ORG_ID = t.AD_ORG_ID " + "and s.M_PRODUCT_ID = t.M_PRODUCT_ID " + "and s.M_LOCATOR_ID = t.M_LOCATOR_ID) " + "where s.QTYTYPE ='" + qtyType.GetValue() + "' " + "and s.M_PRODUCT_ID =" + M_Product_ID + "and s.M_LOCATOR_ID =" + M_Locator_ID + " and t.QTYTYPE = 'H' "; if (withASI) { sql += "and t.QTY > 0 " + "and s.M_ATTRIBUTESETINSTANCE_ID > 0 "; } else { sql += "and t.QTY <> 0 "; } sql += " order by s.M_ATTRIBUTESETINSTANCE_ID "; if (!isFIFO) { sql += " DESC"; } IDataReader idr = null; try { idr = DB.ExecuteReader(sql, null, trx); DataTable dt = new DataTable(); dt.Load(idr); idr.Close(); foreach (DataRow dr in dt.Rows) { list.Add(new MStorageDetail(ctx, dr, trx)); } } catch (Exception ex) { s_log.Log(Level.SEVERE, sql, ex); } finally { if (idr != null) { idr.Close(); idr = null; } } return(list); }
public MStorageDetail(Ctx ctx, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, X_Ref_Quantity_Type type, Trx trx) : this(ctx, 0, trx) { SetM_Locator_ID(M_Locator_ID); SetM_Product_ID(M_Product_ID); SetM_AttributeSetInstance_ID(M_AttributeSetInstance_ID); SetQtyType(type.GetValue()); SetQty(Env.ZERO); }
/// <summary> /// Create storage for qty types that don't exist and return specified qty type /// </summary> /// <param name="ctx"></param> /// <param name="M_Locator_ID"></param> /// <param name="M_Product_ID"></param> /// <param name="M_AttributeSetInstance_ID"></param> /// <param name="trx"></param> /// <returns></returns> public static Storage.Record GetCreateRecord(Ctx ctx, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, Trx trx) { List <MStorage> details = new List <MStorage>(); // create storage for all qty types foreach (var qtyType in X_Ref_Quantity_Type.Get()) { MStorage detail = MStorage.GetCreate(ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, trx);//M_AttributeSetInstance_ID, qtyType, trx); detail.Save(trx); details.Add(detail); } return(new Storage.Record(details)); }
public Record(Ctx ctx, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, List <String> types, Trx trx) { if ((types == null) || types.Count < 1) { throw new Exception("Quantity types must not be null or empty"); } List <MStorage> storages = MStorage.GetMultipleForUpdate(ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, types, trx); foreach (MStorage storage in storages) { //storageMap.put(X_Ref_Quantity_Type.getEnum(storage.getQtyType()), storage); storageMap[X_Ref_Quantity_Type.GetEnum(storage.GetQtyType())] = storage; refDetail = storage; } }
/* public static Map<X_Ref_Quantity_Type, MStorageDetail> getAllForUpdate( * Ctx ctx, int M_Locator_ID, int M_Product_ID, * int M_AttributeSetInstance_ID, * Set<X_Ref_Quantity_Type> updateQtyTypes, Trx trx) { * Map<X_Ref_Quantity_Type, MStorageDetail> storageDetails = new HashMap<X_Ref_Quantity_Type, MStorageDetail>(); * for (X_Ref_Quantity_Type qtyType : X_Ref_Quantity_Type.values()) { * MStorageDetail store = MStorageDetail.Get(ctx, M_Locator_ID, * M_Product_ID, M_AttributeSetInstance_ID, qtyType, * (updateQtyTypes == null ? false : updateQtyTypes * .contains(qtyType)), trx); * storageDetails.put(qtyType, store); * } * return storageDetails; * }*/ public static Dictionary <String, MStorageDetail> GetAllForUpdate(Ctx ctx, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, List <String> updateQtyTypes, Trx trx) { Dictionary <String, MStorageDetail> storageDetails = new Dictionary <String, MStorageDetail>(); //Array qtyType = Enum.GetValues(typeof(X_Ref_Quantity_Type.X_Ref_Quantity_TypeEnum)); Array qtyType = X_Ref_Quantity_Type.Get().ToArray(); for (int i = 0; i < qtyType.Length; i++) { MStorageDetail store = MStorageDetail.Get(ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, qtyType.GetValue(i).ToString(), (updateQtyTypes == null ? false : updateQtyTypes.Contains(qtyType.GetValue(i).ToString())), trx); //storageDetails.put(qtyType, store); storageDetails[qtyType.GetValue(i).ToString()] = store; } return(storageDetails); }
/// <summary> /// Create storage for qty types that don't exist and return specified qty type /// </summary> /// <param name="ctx"></param> /// <param name="M_Locator_ID"></param> /// <param name="M_Product_ID"></param> /// <param name="M_AttributeSetInstance_ID"></param> /// <param name="qtyTypeToGet"></param> /// <param name="trx"></param> /// <returns></returns> public static MStorage GetCreateDetails(Ctx ctx, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, String qtyTypeToGet, Trx trx) { MStorage detailToGet = null; // create storage for all qty types foreach (var qtyType in X_Ref_Quantity_Type.Get()) { MStorage detail = MStorage.GetCreate(ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, trx);// M_AttributeSetInstance_ID, qtyType, trx); detail.Save(trx); if (qtyType == qtyTypeToGet) { detailToGet = detail; } } return(detailToGet); }
public static String GetEnum(String value) { foreach (var v in X_Ref_Quantity_Type.Get()) { if (v.ToString().Equals(value)) { return(v); } } return(null); /* * Array values = Enum.GetValues(typeof(X_Ref_Quantity_Type)); * for (int i = 0; i < values.Length; i++) * { * if (values.GetValue(i).ToString() == test) * { * return X_Ref_Quantity_TypeEnum; * } * } * return null; */ }
public static Boolean IsValid(String test) { foreach (var v in X_Ref_Quantity_Type.Get()) { if (v.ToString().Equals(test)) { return(true); } } return(false); /* * Array values = Enum.GetValues(typeof(X_Ref_Quantity_Type)); * for (int i = 0; i < values.Length; i++) * { * if (values.GetValue(i).ToString() == test) * { * return true; * } * } * return false; */ }