/// <summary>
        /// Get/Create Entry for BPartner
        /// </summary>
        /// <param name="C_BPartner_ID">business partner</param>
        /// <param name="C_Currency_ID">currency</param>
        /// <param name="SalesRep_ID">sales rep</param>
        /// <returns>entry</returns>
        public MDunningRunEntry GetEntry(int C_BPartner_ID, int C_Currency_ID, int SalesRep_ID)
        {
            // TODO: Related BP
            int C_BPartnerRelated_ID = C_BPartner_ID;

            //
            GetEntries(false);
            for (int i = 0; i < _entries.Length; i++)
            {
                MDunningRunEntry entry = _entries[i];
                if (entry.GetC_BPartner_ID() == C_BPartnerRelated_ID)
                {
                    return(entry);
                }
            }
            //	New Entry
            MDunningRunEntry entry1 = new MDunningRunEntry(this);
            MBPartner        bp     = new MBPartner(GetCtx(), C_BPartnerRelated_ID, Get_TrxName());

            entry1.SetBPartner(bp, true);       //	AR hardcoded
            //
            //if (entry1.GetSalesRep_ID() == 0)
            // Change done bu mohit to set sales rep selected.- 1 May 2019.
            if (SalesRep_ID > 0)
            {
                entry1.SetSalesRep_ID(SalesRep_ID);
            }
            entry1.SetC_Currency_ID(C_Currency_ID);
            //
            _entries = null;
            return(entry1);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get/Create Entry for BPartner
        /// </summary>
        /// <param name="C_BPartner_ID">business partner</param>
        /// <param name="C_Currency_ID">currency</param>
        /// <param name="SalesRep_ID">sales rep</param>
        /// <returns>entry</returns>
        public MDunningRunEntry GetEntry(int C_BPartner_ID, int C_Currency_ID, int SalesRep_ID)
        {
            // TODO: Related BP
            int C_BPartnerRelated_ID = C_BPartner_ID;

            //
            GetEntries(false);
            for (int i = 0; i < _entries.Length; i++)
            {
                MDunningRunEntry entry = _entries[i];
                if (entry.GetC_BPartner_ID() == C_BPartnerRelated_ID)
                {
                    return(entry);
                }
            }
            //	New Entry
            MDunningRunEntry entry1 = new MDunningRunEntry(this);
            MBPartner        bp     = new MBPartner(GetCtx(), C_BPartnerRelated_ID, Get_TrxName());

            entry1.SetBPartner(bp, true);       //	AR hardcoded

            // Change by mohit -1st Priority given to the sales rep selected in process parameter and 2nd given to the sales rep on customer master..- 1 May 2019.
            if (SalesRep_ID > 0)
            {
                entry1.SetSalesRep_ID(SalesRep_ID);
            }
            entry1.SetC_Currency_ID(C_Currency_ID);
            //
            _entries = null;
            return(entry1);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Get Parent
 /// </summary>
 /// <returns>parent</returns>
 public MDunningRunEntry GetParent()
 {
     if (_parent == null)
     {
         _parent = new MDunningRunEntry(GetCtx(), GetC_DunningRunEntry_ID(), Get_TrxName());
     }
     return(_parent);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Parent Constructor
 /// </summary>
 /// <param name="parent">parent</param>
 public MDunningRunLine(MDunningRunEntry parent)
     : this(parent.GetCtx(), 0, parent.Get_TrxName())
 {
     SetClientOrg(parent);
     SetC_DunningRunEntry_ID(parent.GetC_DunningRunEntry_ID());
     //
     _parent          = parent;
     _C_CurrencyTo_ID = parent.GetC_Currency_ID();
 }
        /// <summary>
        /// Get Entries
        /// </summary>
        /// <param name="requery">requery requery</param>
        /// <param name="onlyInvoices">only invoices</param>
        /// <returns>entries</returns>
        public MDunningRunEntry[] GetEntries(bool requery, bool onlyInvoices)
        {
            if (_entries != null && !requery)
            {
                return(_entries);
            }

            String sql = "SELECT * FROM C_DunningRunEntry WHERE C_DunningRun_ID=" + GetC_DunningRun_ID();
            List <MDunningRunEntry> list = new List <MDunningRunEntry>();
            DataTable   dt  = null;
            IDataReader idr = null;

            try
            {
                idr = DataBase.DB.ExecuteReader(sql, null, Get_TrxName());
                dt  = new DataTable();
                dt.Load(idr);
                idr.Close();
                foreach (DataRow dr in dt.Rows)
                {
                    MDunningRunEntry thisEntry = new MDunningRunEntry(GetCtx(), dr, Get_TrxName());
                    if (!(onlyInvoices && thisEntry.HasInvoices()))
                    {
                        list.Add(new MDunningRunEntry(GetCtx(), dr, Get_TrxName()));
                    }
                }
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                log.Log(Level.SEVERE, sql, e);
            }
            finally
            {
                dt = null;
                if (idr != null)
                {
                    idr.Close();
                }
            }

            _entries = new MDunningRunEntry[list.Count];
            _entries = list.ToArray();
            return(_entries);
        }
        /// <summary>
        /// Delete all Entries
        /// </summary>
        /// <param name="force">delete also processed records</param>
        /// <returns>true if deleted</returns>
        public bool DeleteEntries(bool force)
        {
            GetEntries(true);
            for (int i = 0; i < _entries.Length; i++)
            {
                MDunningRunEntry entry = _entries[i];
                entry.Delete(force);
            }
            bool ok = GetEntries(true).Length == 0;

            if (ok)
            {
                _entries = null;
            }
            return(ok);
        }