Пример #1
0
        }       //	MTaxDeclarationLine

        /// <summary>
        /// Parent Constructor
        /// </summary>
        /// <param name="parent">parent</param>
        /// <param name="invoice">invoice</param>
        /// <param name="tLine">tax line</param>
        public MTaxDeclarationLine(MTaxDeclaration parent, MInvoice invoice, MInvoiceTax tLine) : this(parent.GetCtx(), 0, parent.Get_TrxName())
        {
            //this(parent.getCtx(), 0, parent.get_TrxName());
            SetClientOrg(invoice);
            SetC_TaxDeclaration_ID(parent.GetC_TaxDeclaration_ID());
            SetIsManual(false);
            //
            SetC_Invoice_ID(invoice.GetC_Invoice_ID());
            SetC_BPartner_ID(invoice.GetC_BPartner_ID());
            SetC_Currency_ID(invoice.GetC_Currency_ID());
            SetDateAcct(invoice.GetDateAcct());
            //
            SetC_Tax_ID(tLine.GetC_Tax_ID());
            SetTaxBaseAmt(tLine.GetTaxBaseAmt());
            SetTaxAmt(tLine.GetTaxAmt());
        } //	MTaxDeclarationLine
Пример #2
0
        /**
         *  Get Tax Line for Invoice Line
         *	@param line invoice line
         *	@param precision currency precision
         *	@param oldTax if true old tax is returned
         *	@param trxName transaction name
         *	@return existing or new tax
         */
        public static MInvoiceTax Get(MInvoiceLine line, int precision,
                                      Boolean oldTax, Trx trxName)
        {
            MInvoiceTax retValue = null;

            try
            {
                if (line == null || line.GetC_Invoice_ID() == 0 || line.IsDescription())
                {
                    return(null);
                }
                int C_Tax_ID = line.GetC_Tax_ID();
                if (oldTax && line.Is_ValueChanged("C_Tax_ID"))
                {
                    Object old = line.Get_ValueOld("C_Tax_ID");
                    if (old == null)
                    {
                        return(null);
                    }
                    C_Tax_ID = int.Parse(old.ToString());
                }
                if (C_Tax_ID == 0)
                {
                    _log.Warning("C_Tax_ID=0");
                    return(null);
                }

                String sql = "SELECT * FROM C_InvoiceTax WHERE C_Invoice_ID=" + line.GetC_Invoice_ID() + " AND C_Tax_ID=" + C_Tax_ID;
                try
                {
                    DataSet ds = DataBase.DB.ExecuteDataset(sql, null, trxName);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            retValue = new MInvoiceTax(line.GetCtx(), dr, trxName);
                        }
                    }
                }
                catch (Exception e)
                {
                    _log.Log(Level.SEVERE, sql, e);
                }

                if (retValue != null)
                {
                    retValue.Set_TrxName(trxName);
                    retValue.SetPrecision(precision);
                    _log.Fine("(old=" + oldTax + ") " + retValue);
                    return(retValue);
                }

                //	Create New
                retValue = new MInvoiceTax(line.GetCtx(), 0, trxName);
                retValue.Set_TrxName(trxName);
                retValue.SetClientOrg(line);
                retValue.SetC_Invoice_ID(line.GetC_Invoice_ID());
                retValue.SetC_Tax_ID(line.GetC_Tax_ID());
                retValue.SetPrecision(precision);
                retValue.SetIsTaxIncluded(line.IsTaxIncluded());
                _log.Fine("(new) " + retValue);
            }
            catch
            {
                // MessageBox.Show("MInvoiceTax--Get");
            }
            return(retValue);
        }
Пример #3
0
        /// <summary>
        /// Get Surcharge Tax Line for Invoice Line
        /// </summary>
        /// <param name="line">line</param>
        /// <param name="precision">currenct precision</param>
        /// <param name="oldTax">get old tax</param>
        /// <param name="trxName">transaction</param>
        /// <returns>existing or new tax</returns>
        public static MInvoiceTax GetSurcharge(MInvoiceLine line, int precision, bool oldTax, Trx trxName)
        {
            MInvoiceTax retValue = null;

            try
            {
                if (line == null || line.GetC_Invoice_ID() == 0 || line.IsDescription())
                {
                    return(null);
                }
                int C_Tax_ID = line.GetC_Tax_ID();
                if (oldTax && line.Is_ValueChanged("C_Tax_ID"))
                {
                    Object old = line.Get_ValueOld("C_Tax_ID");
                    if (old == null)
                    {
                        return(null);
                    }
                    C_Tax_ID = int.Parse(old.ToString());
                }

                // Get Surcharge Tax ID from Tax selected on Line
                C_Tax_ID = Util.GetValueOfInt(DB.ExecuteScalar("SELECT Surcharge_Tax_ID FROM C_Tax WHERE C_Tax_ID = " + C_Tax_ID, null, trxName));

                if (C_Tax_ID == 0)
                {
                    _log.Warning("C_Tax_ID=0");
                    return(null);
                }

                String sql = "SELECT * FROM C_InvoiceTax WHERE C_Invoice_ID=" + line.GetC_Invoice_ID() + " AND C_Tax_ID=" + C_Tax_ID;
                try
                {
                    DataSet ds = DataBase.DB.ExecuteDataset(sql, null, trxName);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            retValue = new MInvoiceTax(line.GetCtx(), dr, trxName);
                        }
                    }
                }
                catch (Exception e)
                {
                    _log.Log(Level.SEVERE, sql, e);
                }

                // Get IsTaxincluded from selected PriceList on header
                bool isTaxIncluded = Util.GetValueOfString(DB.ExecuteScalar("SELECT IsTaxIncluded FROM M_PriceList WHERE M_PriceList_ID = (SELECT M_PriceList_ID FROM C_Invoice WHERE C_Invoice_ID = "
                                                                            + line.GetC_Invoice_ID() + ")", null, trxName)) == "Y";

                if (retValue != null)
                {
                    retValue.Set_TrxName(trxName);
                    retValue.SetPrecision(precision);
                    retValue.SetIsTaxIncluded(isTaxIncluded);
                    _log.Fine("(old=" + oldTax + ") " + retValue);
                    return(retValue);
                }

                //	Create New
                retValue = new MInvoiceTax(line.GetCtx(), 0, trxName);
                retValue.Set_TrxName(trxName);
                retValue.SetClientOrg(line);
                retValue.SetC_Invoice_ID(line.GetC_Invoice_ID());
                retValue.SetC_Tax_ID(C_Tax_ID);
                retValue.SetPrecision(precision);
                retValue.SetIsTaxIncluded(isTaxIncluded);
                _log.Fine("(new) " + retValue);
            }
            catch
            {
                // MessageBox.Show("MInvoiceTax--Get");
            }
            return(retValue);
        }