예제 #1
0
        }       //	invoiceDone

        /// <summary>
        ///	New Invoice
        /// </summary>
        /// <param name="request">request</param>
        private void InvoiceNew(MRequest request)
        {
            _m_invoice = new MInvoice(GetCtx(), 0, Get_TrxName());
            _m_invoice.SetC_DocTypeTarget_ID(MDocBaseType.DOCBASETYPE_ARINVOICE);
            MBPartner partner = new MBPartner(GetCtx(), request.GetC_BPartner_ID(), Get_TrxName());

            _m_invoice.SetBPartner(partner);
            _m_invoice.SetM_PriceList_ID(partner.GetM_PriceList_ID());
            int _CountVA009 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA009_'  AND IsActive = 'Y'"));

            if (_CountVA009 > 0)
            {
                _m_invoice.SetVA009_PaymentMethod_ID(partner.GetVA009_PaymentMethod_ID());
            }
            _m_invoice.Save();
            request.SetC_Invoice_ID(_m_invoice.GetC_Invoice_ID());
            request.Save();
            if (string.IsNullOrEmpty(_msg))
            {
                _msg = "Invoice-[ID:" + _m_invoice.Get_ID() + "] created";
            }
            else
            {
                _msg += ",Invoice-[ID: " + _m_invoice.Get_ID() + "] created";
            }
            //_m_linecount = 0;
        }       //	invoiceNew
예제 #2
0
        } //	invoiceDone

        /// <summary>
        ///	New Invoice
        /// </summary>
        /// <param name="request">request</param>
        private void InvoiceNew(MRequest request)
        {
            _m_invoice = new MInvoice(GetCtx(), 0, Get_TrxName());
            _m_invoice.SetC_DocTypeTarget_ID(MDocBaseType.DOCBASETYPE_ARINVOICE);
            MBPartner partner = new MBPartner(GetCtx(), request.GetC_BPartner_ID(), null);

            _m_invoice.SetBPartner(partner);

            _m_invoice.Save();
            if (string.IsNullOrEmpty(_msg))
            {
                _msg = "Invoice-[ID:" + _m_invoice.Get_ID() + "] created";
            }
            else
            {
                _msg += ",Invoice-[ID: " + _m_invoice.Get_ID() + "] created";
            }
            _m_linecount = 0;
        }       //	invoiceNew
예제 #3
0
        } //	prepare

        /// <summary>
        ///	Process
        /// </summary>
        /// <returns>info</returns>
        protected override String DoIt()
        {
            int lenth = 1;

            log.Info("R_RequestType_ID=" + _R_RequestType_ID + ", R_Group_ID=" + _R_Group_ID
                     + ", R_Category_ID=" + _R_Category_ID + ", C_BPartner_ID=" + _C_BPartner_ID
                     + ", _M_Product_ID=" + _M_Product_ID);

            MRequestType type = MRequestType.Get(GetCtx(), _R_RequestType_ID);

            if (type.Get_ID() == 0)
            {
                throw new Exception("@R_RequestType_ID@ @NotFound@ " + _R_RequestType_ID);
            }

            if (!type.IsInvoiced())
            {
                throw new Exception("@R_RequestType_ID@ <> @IsInvoiced@");
            }

            String sql = "SELECT * FROM R_Request r"
                         + " INNER JOIN R_Status s ON (r.R_Status_ID=s.R_Status_ID) "
                         + "WHERE s.IsClosed='Y'"
                         + " AND r.R_RequestType_ID=@Param1";

            if (_R_Group_ID != 0 && _R_Group_ID != -1)
            {
                sql  += " AND r.R_Group_ID=@Param2";
                lenth = lenth + 1;
            }
            if (_R_Category_ID != 0 && _R_Category_ID != -1)
            {
                sql  += " AND r.R_Category_ID=@Param3";
                lenth = lenth + 1;
            }
            if (_C_BPartner_ID != 0)
            {
                sql  += " AND r.C_BPartner_ID=@Param4";
                lenth = lenth + 1;
            }
            sql += " AND r.IsInvoiced='Y' "
                   + "ORDER BY C_BPartner_ID";
            SqlParameter[] Param = new SqlParameter[lenth];
            IDataReader    idr   = null;
            DataTable      dt    = null;

            try
            {
                int index = 0;
                Param[index] = new SqlParameter("@Param1", _R_RequestType_ID);
                if (_R_Group_ID != 0 && _R_Group_ID != -1)
                {
                    index++;
                    Param[index] = new SqlParameter("@Param2", _R_Group_ID);
                }
                if (_R_Category_ID != 0 && _R_Category_ID != -1)
                {
                    index++;
                    Param[index] = new SqlParameter("@Param3", _R_Category_ID);
                }
                if (_C_BPartner_ID != 0)
                {
                    index++;
                    Param[index] = new SqlParameter("@Param4", _C_BPartner_ID);
                }
                idr = DataBase.DB.ExecuteReader(sql, Param, Get_TrxName());
                dt  = new DataTable();
                dt.Load(idr);
                idr.Close();
                int oldC_BPartner_ID = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    MRequest request = new MRequest(GetCtx(), dr, Get_TrxName());
                    if (!request.IsInvoiced())
                    {
                        continue;
                    }
                    if (oldC_BPartner_ID != request.GetC_BPartner_ID())
                    {
                        InvoiceDone();
                    }
                    if (_m_invoice == null)
                    {
                        InvoiceNew(request);
                        oldC_BPartner_ID = request.GetC_BPartner_ID();
                    }
                    InvoiceLine(request);
                }
                InvoiceDone();
                //
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                log.Log(Level.SEVERE, sql, e);
            }
            finally
            {
                dt = null;
                if (idr != null)
                {
                    idr.Close();
                }
            }
            if (string.IsNullOrEmpty(_msg))
            {
                _msg = "No Invoice Generated";
            }
            //	R_Category_ID
            return(_msg);
        } //	doIt