Exemplo n.º 1
0
        /**
         *  Get InOut-Invoice Matches
         *	@param ctx context
         *	@param M_InOutLine_ID shipment
         *	@param C_InvoiceLine_ID invoice
         *	@param trxName transaction
         *	@return array of matches
         */
        public static MMatchInv[] Get(Ctx ctx, int M_InOutLine_ID, int C_InvoiceLine_ID, Trx trxName)
        {
            if (M_InOutLine_ID == 0 || C_InvoiceLine_ID == 0)
            {
                return new MMatchInv[] { }
            }
            ;
            //
            String           sql  = "SELECT * FROM M_MatchInv WHERE M_InOutLine_ID=" + M_InOutLine_ID + " AND C_InvoiceLine_ID=" + C_InvoiceLine_ID;
            List <MMatchInv> list = new List <MMatchInv>();
            DataSet          ds   = new DataSet();

            try
            {
                ds = DataBase.DB.ExecuteDataset(sql, null, trxName);

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = ds.Tables[0].Rows[i];
                    list.Add(new MMatchInv(ctx, dr, trxName));
                }
                ds = null;
            }
            catch (Exception e)
            {
                _log.Log(Level.SEVERE, sql, e);
            }
            MMatchInv[] retValue = new MMatchInv[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }
Exemplo n.º 2
0
 /**
  *  Get Match Inv
  *	@return matched invoices
  */
 public MMatchInv[] GetMatchInv()
 {
     if (_matchInv == null)
     {
         _matchInv = MMatchInv.Get(GetCtx(), GetM_InOutLine_ID(), Get_TrxName());
     }
     return(_matchInv);
 }
Exemplo n.º 3
0
 /**
  *  Is Match Inv posted
  *	@return true if posed
  */
 public bool IsMatchInvPosted()
 {
     MMatchInv[] inv = GetMatchInv();
     for (int i = 0; i < inv.Length; i++)
     {
         MMatchInv matchInv = inv[i];
         if (!matchInv.IsPosted())
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 4
0
        /**
         *  Get Match Inv Difference
         *	@return not matched qty (positive not - negative over)
         */
        public Decimal GetMatchInvDifference()
        {
            if (IsDescription())
            {
                return(Env.ZERO);
            }
            Decimal retValue = GetMovementQty();

            MMatchInv[] inv = GetMatchInv();
            for (int i = 0; i < inv.Length; i++)
            {
                MMatchInv matchInv = inv[i];
                //retValue = retValue.subtract(matchInv.getQty());
                retValue = Decimal.Subtract(retValue, matchInv.GetQty());
            }
            log.Finer("#" + retValue);
            return(retValue);
        }
Exemplo n.º 5
0
        /*  Get Inv Matches for Invoice
         *	@param ctx context
         *	@param C_Invoice_ID invoice
         *	@param trxName transaction
         *	@return array of matches
         */
        public static MMatchInv[] GetInvoice(Ctx ctx, int C_Invoice_ID, Trx trxName)
        {
            if (C_Invoice_ID == 0)
            {
                return new MMatchInv[] { }
            }
            ;
            //
            String sql = "SELECT * FROM M_MatchInv mi"
                         + " INNER JOIN C_InvoiceLine il ON (mi.C_InvoiceLine_ID=il.C_InvoiceLine_ID) "
                         + "WHERE il.C_Invoice_ID=" + C_Invoice_ID;
            List <MMatchInv> list = new List <MMatchInv>();
            DataTable        dt   = null;
            IDataReader      idr  = null;

            try
            {
                idr = DataBase.DB.ExecuteReader(sql, null, trxName);

                dt = new DataTable();
                dt.Load(idr);
                idr.Close();
                foreach (DataRow dr in dt.Rows)
                {
                    list.Add(new MMatchInv(ctx, dr, trxName));
                }
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, sql, e);
            }
            finally
            { dt = null; }

            MMatchInv[] retValue = new MMatchInv[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }