Ejemplo n.º 1
0
        /// <summary>
        /// Method to load tax exempt for delete preapay
        /// </summary>
        /// <param name="taxExemptSale">Tax exempt sale</param>
        /// <param name="teType">Tax exempt type</param>
        /// <param name="till">Till</param>
        /// <param name="user">User</param>
        /// <param name="sn">Sale number</param>
        /// <param name="tillId">Till number</param>
        /// <param name="lineNum">Line number</param>
        /// <param name="newSaleNo">New sale number</param>
        /// <returns>True or false</returns>
        public bool LoadTaxExemptForDeletePrepay(ref TaxExemptSale taxExemptSale,
                                                 string teType, Till till, User user, int sn, byte tillId, short lineNum,
                                                 int newSaleNo)
        {
            var rsHead = GetRecords("select * from TaxExemptSaleHead " + " where SALE_NO=" + Convert.ToString(sn) + " AND TILL_NUM=" + Convert.ToString(tillId), DataSource.CSCTills);
            var rsLine = GetRecords("select * from TaxExemptSaleLine " + " where SALE_NO=" + Convert.ToString(sn) + " AND LINE_NUM=" + Convert.ToString(lineNum) + " AND TILL_NUM=" + Convert.ToString(tillId), DataSource.CSCTills);

            if (teType == "QITE")
            {
                if (rsHead.Rows.Count == 0)
                {
                    return(false);
                }
            }
            else //
            {
                if (rsHead.Rows.Count == 0 || rsLine.Rows.Count == 0)
                {
                    return(false);
                }
            }


            taxExemptSale = new TaxExemptSale
            {
                Sale_Num     = newSaleNo,
                TillNumber   = tillId,
                Shift        = Convert.ToInt16(till.Shift),
                UserCode     = Convert.ToString(user.Code),
                teCardholder =
                {
                    CardholderID = CommonUtility.GetStringValue(rsHead.Rows[0]["CardholderID"]),
                    Barcode      = CommonUtility.GetStringValue(rsHead.Rows[0]["Barcode"]),
                    CardNumber   = CommonUtility.GetStringValue(rsHead.Rows[0]["cardnumber"])
                }
            };


            //ShinyFeb26,2009- QITE development
            if (teType == "QITE")
            {
                var rsCardHolder = GetRecords("select * from CLIENT " + " where CL_CODE=\'" + taxExemptSale.teCardholder.CardholderID + "\'", DataSource.CSCMaster);
                if (rsCardHolder.Rows.Count != 0)
                {
                    taxExemptSale.teCardholder.Name        = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["Cl_Name"]);
                    taxExemptSale.teCardholder.Address     = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["CL_Add1"]);
                    taxExemptSale.teCardholder.City        = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["CL_City"]);
                    taxExemptSale.teCardholder.PlateNumber = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["PlateNumber"]);
                    taxExemptSale.teCardholder.PostalCode  = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["CL_Postal"]);
                }
                //
            }
            else // For AITE
            {
                var rsCardHolder = GetRecords("select * from TaxExemptCardRegistry " + " where CardholderID=\'" + taxExemptSale.teCardholder.CardholderID + "\'", DataSource.CSCMaster);
                if (rsCardHolder.Rows.Count != 0)
                {
                    taxExemptSale.teCardholder.Name         = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["Name"]);
                    taxExemptSale.teCardholder.GasQuota     = CommonUtility.GetFloatValue(rsCardHolder.Rows[0]["GasQuota"]);
                    taxExemptSale.teCardholder.PropaneQuota = CommonUtility.GetFloatValue(rsCardHolder.Rows[0]["PropaneQuota"]);
                    taxExemptSale.teCardholder.TobaccoQuota = CommonUtility.GetFloatValue(rsCardHolder.Rows[0]["TobaccoQuota"]);
                }
            }
            if (rsLine.Rows.Count != 0)
            {
                foreach (DataRow line in rsLine.Rows)
                {
                    var mTeLine = new TaxExemptSaleLine
                    {
                        Quantity      = CommonUtility.GetFloatValue(-1 * CommonUtility.GetIntergerValue(line["Quantity"])),
                        UnitsPerPkg   = CommonUtility.GetFloatValue(-1 * CommonUtility.GetIntergerValue(line["UnitQuantity"])),
                        EquvQuantity  = CommonUtility.GetFloatValue(-1 * CommonUtility.GetIntergerValue(line["EquvQuantity"])),
                        OriginalPrice = CommonUtility.GetFloatValue(line["OriginalPrice"]),
                        TaxFreePrice  = CommonUtility.GetFloatValue(line["price"]),
                        Line_Num      = 1,
                        StockCode     = CommonUtility.GetStringValue(line["Stock_Code"]),
                        TaxInclPrice  = CommonUtility.GetFloatValue(-1 * CommonUtility.GetIntergerValue(line["TaxIncludedAmount"])),
                        Amount        = CommonUtility.GetFloatValue(-1 * CommonUtility.GetIntergerValue(line["Amount"])),
                        ExemptedTax   = CommonUtility.GetFloatValue(-1 * CommonUtility.GetIntergerValue(line["ExemptedTax"])),
                        Description   = CommonUtility.GetStringValue(line["Description"]),
                        ProductCode   = CommonUtility.GetStringValue(line["ProductCode"])
                    };

                    mPrivateGlobals.teProductEnum productType;
                    Enum.TryParse(CommonUtility.GetStringValue(line["ProductType"]), out productType);

                    mTeLine.ProductType = productType;

                    mTeLine.TaxExemptRate = CommonUtility.GetFloatValue(line["TaxExemptRate"]);

                    bool tempCheckOverLimit = true;
                    var  tempCheckQuota     = true;
                    taxExemptSale.Add_a_Line(mTeLine, ref tempCheckOverLimit, ref tempCheckQuota);
                }
            }

            taxExemptSale.Amount = CommonUtility.GetFloatValue(-1 * CommonUtility.GetIntergerValue(rsHead.Rows[0]["SaleAmount"]));

            LoadGstExemptForDeletePrepay(ref taxExemptSale, sn, tillId, DataSource.CSCTills);
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method to load tax exempt
        /// </summary>
        /// <param name="teType">Tax exemption type</param>
        /// <param name="sn">Sale number</param>
        /// <param name="tillId">Till Number</param>
        /// <param name="db">Data base</param>
        /// <param name="checkQuota">Check Quota or not</param>
        /// <returns>Tax exempt sale</returns>
        public TaxExemptSale LoadTaxExempt(string teType, int sn, byte tillId, DataSource db,
                                           bool checkQuota = true)
        {
            var taxExemptSale = new TaxExemptSale();

            if (LoadGstExempt(ref taxExemptSale, sn, tillId, db))
            {
                taxExemptSale.Sale_Num   = sn;
                taxExemptSale.TillNumber = tillId;
            }

            var rsHead = GetRecords("select * from TaxExemptSaleHead " + " where SALE_NO=" + Convert.ToString(sn) + " AND TILL_NUM=" + Convert.ToString(tillId), db);
            var rsLine = GetRecords("select * from TaxExemptSaleLine " + " where SALE_NO=" + Convert.ToString(sn) + " AND TILL_NUM=" + Convert.ToString(tillId), db);

            if (teType == "QITE")
            {
                if (rsHead.Rows.Count == 0)
                {
                    return(null);
                }
            }
            else
            {
                if (rsHead.Rows.Count == 0 || rsLine.Rows.Count == 0)
                {
                    return(null);
                }
            }
            var rsHeadField = rsHead.Rows[0];

            taxExemptSale.Sale_Num   = sn;
            taxExemptSale.TillNumber = tillId;

            foreach (DataRow fields in rsLine.Rows)
            {
                var mTeLine = new TaxExemptSaleLine
                {
                    Quantity      = CommonUtility.GetFloatValue(fields["Quantity"]),
                    UnitsPerPkg   = CommonUtility.GetFloatValue(fields["UnitQuantity"]),
                    EquvQuantity  = CommonUtility.GetFloatValue(fields["EquvQuantity"]),
                    OriginalPrice = CommonUtility.GetFloatValue(fields["OriginalPrice"]),
                    TaxFreePrice  = CommonUtility.GetFloatValue(fields["price"]),
                    Line_Num      = CommonUtility.GetShortValue(fields["Line_Num"]),
                    StockCode     = CommonUtility.GetStringValue(fields["Stock_Code"]),
                    TaxInclPrice  = CommonUtility.GetFloatValue(fields["TaxIncludedAmount"]),
                    Amount        = CommonUtility.GetFloatValue(fields["Amount"]),
                    ExemptedTax   = CommonUtility.GetFloatValue(fields["ExemptedTax"]),
                    Description   = CommonUtility.GetStringValue(fields["Description"]),
                    ProductCode   = CommonUtility.GetStringValue(fields["ProductCode"])
                };
                mPrivateGlobals.teProductEnum productType;
                Enum.TryParse(CommonUtility.GetStringValue(fields["ProductType"]), out productType);
                mTeLine.ProductType  = productType;
                mTeLine.RunningQuota = CommonUtility.GetFloatValue(fields["RunningQuota"]);

                mTeLine.OverLimit = CommonUtility.GetBooleanValue(fields["OverLimit"]);

                mTeLine.TaxExemptRate = CommonUtility.GetFloatValue(fields["TaxExemptRate"]);
                var tempCheckOverLimit = false;
                taxExemptSale.Add_a_Line(mTeLine, ref tempCheckOverLimit, ref checkQuota);
                if (!mTeLine.OverLimit)
                {
                    continue;
                }
                switch (mTeLine.ProductType)
                {
                case mPrivateGlobals.teProductEnum.eCigarette:
                case mPrivateGlobals.teProductEnum.eCigar:
                case mPrivateGlobals.teProductEnum.eLooseTobacco:
                    taxExemptSale.TobaccoOverLimit = true;
                    break;

                case mPrivateGlobals.teProductEnum.eGasoline:
                case mPrivateGlobals.teProductEnum.eDiesel:
                case mPrivateGlobals.teProductEnum.emarkedGas:
                case mPrivateGlobals.teProductEnum.emarkedDiesel:

                    taxExemptSale.GasOverLimit = true;
                    break;

                case mPrivateGlobals.teProductEnum.ePropane:
                    taxExemptSale.PropaneOverLimit = true;
                    break;

                case mPrivateGlobals.teProductEnum.eNone:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            taxExemptSale.Amount              = CommonUtility.GetFloatValue(rsHeadField["SaleAmount"]);
            taxExemptSale.ShiftDate           = CommonUtility.GetDateTimeValue(rsHeadField["ShiftDate"]);
            taxExemptSale.Sale_Time           = CommonUtility.GetDateTimeValue(rsHeadField["SaleTime"]);
            taxExemptSale.GasReason           = CommonUtility.GetStringValue(rsHeadField["GasReason"]);
            taxExemptSale.GasReasonDesp       = CommonUtility.GetStringValue(rsHeadField["GasReasonDesp"]);
            taxExemptSale.GasReasonDetail     = CommonUtility.GetStringValue(rsHeadField["GasReasonDetail"]);
            taxExemptSale.PropaneReason       = CommonUtility.GetStringValue(rsHeadField["PropaneReason"]);
            taxExemptSale.PropaneReasonDesp   = CommonUtility.GetStringValue(rsHeadField["PropaneReasonDesp"]);
            taxExemptSale.PropaneReasonDetail = CommonUtility.GetStringValue(rsHeadField["PropaneReasonDetail"]);
            taxExemptSale.TobaccoReason       = CommonUtility.GetStringValue(rsHeadField["TobaccoReason"]);
            taxExemptSale.TobaccoReasonDesp   = CommonUtility.GetStringValue(rsHeadField["TobaccoReasonDesp"]);
            taxExemptSale.TobaccoReasonDetail = CommonUtility.GetStringValue(rsHeadField["TobaccoReasonDetail"]);
            taxExemptSale.Shift    = CommonUtility.GetShortValue(rsHeadField["Shift"]);
            taxExemptSale.UserCode = CommonUtility.GetStringValue(rsHeadField["User"]);
            taxExemptSale.teCardholder.CardholderID = CommonUtility.GetStringValue(rsHeadField["CardholderID"]);
            taxExemptSale.teCardholder.Barcode      = CommonUtility.GetStringValue(rsHeadField["Barcode"]);
            taxExemptSale.teCardholder.CardNumber   = CommonUtility.GetStringValue(rsHeadField["cardnumber"]);
            if (teType == "QITE")
            {
                var rsCardHolder = GetRecords("select * from CLIENT " + " where CL_CODE=\'" + taxExemptSale.teCardholder.CardholderID + "\'", DataSource.CSCMaster);
                if (rsCardHolder.Rows.Count > 0)
                {
                    taxExemptSale.teCardholder.Name        = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["Cl_Name"]);
                    taxExemptSale.teCardholder.Address     = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["CL_Add1"]);
                    taxExemptSale.teCardholder.City        = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["CL_City"]);
                    taxExemptSale.teCardholder.PlateNumber = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["PlateNumber"]);
                    taxExemptSale.teCardholder.PostalCode  = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["CL_Postal"]);
                }
            }
            else // For AITE
            {
                var rsCardHolder = GetRecords("select * from TaxExemptCardRegistry " + " where CardholderID=\'" + taxExemptSale.teCardholder.CardholderID + "\'", DataSource.CSCMaster);
                if (rsCardHolder.Rows.Count > 0)
                {
                    taxExemptSale.teCardholder.Name = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["Name"]);
                }
            }
            return(taxExemptSale);
        }