Пример #1
0
        private bool SetTaxFreeInventoryPrice(string sProductKey, mPrivateGlobals.teProductEnum eProductCategory, double dNewPrice, string sEmpId, double dUnitsPerPackage, string sUpcCode)
        {
            bool returnValue = false;

            returnValue = false;
            return(returnValue);
        }
Пример #2
0
        /// <summary>
        /// Get Quota
        /// </summary>
        /// <param name="treatyNo">Treaty number</param>
        /// <param name="eProdType">Product type</param>
        /// <param name="dOutQuota">Quota</param>
        /// <returns>True or false</returns>
        public bool GetQuota(ref teTreatyNo treatyNo, ref mPrivateGlobals.teProductEnum eProdType,
                             ref double dOutQuota)
        {
            treatyNo.CheckInit();

            //   for real time validation SITE and Jan 12, 2015 for FNGTR validation this validation not required
            //   moved in processing sale to display the remaining qty
            if (_policyManager.SITE_RTVAL || _policyManager.TAX_EXEMPT_FNGTR)
            {
                return(true);
            }
            //   end

            var sFieldName = GetQuotaField(eProdType);

            dOutQuota = _treatyService.GetQuota(sFieldName, treatyNo.TreatyNumber);


            if (_policyManager.TE_Type != "SITE")
            {
                return(true);
            }
            if (eProdType == mPrivateGlobals.teProductEnum.eCigar | eProdType == mPrivateGlobals.teProductEnum.eLooseTobacco)
            {
                dOutQuota = dOutQuota * _teSystemManager.GetCigaretteEquivalentUnits((mPrivateGlobals.teTobaccoEnum)System.Convert.ToInt16(eProdType));
            }
            return(true);
        }
Пример #3
0
        /// <summary>
        /// Method to get category
        /// </summary>
        /// <param name="sProductKey">Product key</param>
        /// <param name="eOutCategory">Tax exempt category</param>
        /// <returns>True or false</returns>
        public bool TeGetCategory(string sProductKey, ref mPrivateGlobals.teProductEnum eOutCategory)
        {
            eOutCategory = mPrivateGlobals.teProductEnum.eNone;

            var oRecs = _stockService.GetProductTaxExempt(sProductKey);

            //eCategory is already set.
            if (oRecs != null)
            {
                if (Information.IsDBNull(oRecs.CategoryFK))
                {
                    return(false);
                }
                if (oRecs.CategoryFK != null)
                {
                    eOutCategory = (mPrivateGlobals.teProductEnum)oRecs.CategoryFK;
                }
            }
            else
            {
                return(false);
            }

            //There was no error, so set to true whether a taxfree price was found or not
            return(true);
        }
Пример #4
0
        public bool SetTaxFreeFuelPrice(ref string sProductKey, mPrivateGlobals.teProductEnum eProductCategory, double dNewCashPrice, double dNewCreditPrice, string sEmpId)
        {
            bool returnValue = false;

            returnValue = false;

            return(returnValue);
        }
Пример #5
0
        //Name: AddToQuota
        //Description: Adds the given quantity to the purchaser's current quota.  This
        // function will take care of cigarette equivalency math, the caller only
        // needs to enter the quantity sold.  For example, if a 30g pouch of tobacco
        // is sold, this function will look up the cigarette equivalency and do the
        // appropriate conversion internally.
        //Inputs: eProdType, the product type that was sold.
        //   dQuantity: The amount sold, grams for tobacco, number of cigarettes, number
        //      of cigars or number of liters of fuel.
        //Outputs: Returns True if function worked ok.  If False, check GetLastError()
        //Postconditions: On success, the appropriate amount will be added to the person's
        //   quota.  Note, all cigartte equivalency conversions are done internally.
        /// <summary>
        /// Method to add to quota
        /// </summary>
        /// <param name="treatyNo">Treaty umber</param>
        /// <param name="eProdType">Product type</param>
        /// <param name="dQuantity">Quantity</param>
        /// <returns>True or false</returns>
        public bool AddToQuota(teTreatyNo treatyNo, ref mPrivateGlobals.teProductEnum eProdType, double dQuantity)
        {
            treatyNo.CheckInit();
            if (string.IsNullOrEmpty(treatyNo.GetTreatyNo()))
            {
                return(false);
            }

            var dConvertedQuantity = dQuantity;

            if (eProdType == mPrivateGlobals.teProductEnum.eCigar | eProdType == mPrivateGlobals.teProductEnum.eLooseTobacco)
            {
                dConvertedQuantity = dConvertedQuantity * mPrivateGlobals.theSystem.teGetCigaretteEquivalentUnits((mPrivateGlobals.teTobaccoEnum)System.Convert.ToInt16(eProdType));
            }

            //Check if an entry in TreatyNo exists for this person.
            var sSql = "SELECT * FROM TreatyNo WHERE TreatyNo=\'" + treatyNo.GetTreatyNo() + "\'";

            var oRecs = _treatyService.GetTreatyNumbers(sSql);

            var sField = GetQuotaField(eProdType);

            if (oRecs.Count == 0)
            {
                //Record does not exist, so insert a new one
                //  New info - Treaty name

                //      "VALUES ('" & psTreatyNo & "', " & dConvertedQuantity & ")"
                sSql = "INSERT INTO TreatyNo ( TreatyNo, " + sField + ",TreatyName ) " + "VALUES (\'" + treatyNo.GetTreatyNo() + "\', " + System.Convert.ToString(dConvertedQuantity) + ", \'" + treatyNo.Name + "\')";
                //shiny end
            }
            else
            {
                foreach (var treaty in oRecs)
                {
                    if (treaty.TreatyNumber != treatyNo.GetTreatyNo())
                    {
                        continue;
                    }


                    double quantity = sField == "TobaccoQuota" ? treaty.TobaccoQuota : treaty.GasQuota;
                    dConvertedQuantity = System.Convert.ToDouble(dConvertedQuantity + quantity);

                    goto resumeOutofLoop;
                }

resumeOutofLoop:
                //Record exists, so update the current quota with the new value
                //  Update Treaty name

                sSql = "UPDATE TreatyNo " + "SET " + sField + "=" + (dConvertedQuantity) + " " + " , TreatyName =\'" + treatyNo.Name + "\'  WHERE TreatyNo=\'" + treatyNo.GetTreatyNo() + "\'";
            }
            _treatyService.UpdateTreatyNumber(sSql);

            return(true);
        }
Пример #6
0
        /// <summary>
        /// Method to test if limit is required
        /// </summary>
        /// <param name="oTeSystem">Tax exempt system</param>
        /// <param name="productType">Product type</param>
        /// <returns>True or false</returns>
        public bool IsLimitRequired(ref teSystem oTeSystem, mPrivateGlobals.teProductEnum productType)
        {
            bool isError;

            bool returnValue = _teSystemService.IsLimitRequired((int)productType, out isError);

            if (!isError)
            {
                return(returnValue);
            }
            oTeSystem.SLastError = "Error: No Category records found.";
            return(false);
        }
Пример #7
0
        public bool GetProductType(ref mPrivateGlobals.teProductEnum iType)
        {
            bool returnValue = false;

            CheckInit();

            returnValue = false;

            iType = peProdType;

            returnValue = true;

            return(returnValue);
        }
Пример #8
0
        /// <summary>
        /// Method to get tax free price
        /// </summary>
        /// <param name="blForFuel">For fule price or not</param>
        /// <param name="sProductKey">Product key</param>
        /// <param name="stockcode">Stock code</param>
        /// <param name="quantityPerPkg">Quantity per kg</param>
        /// <param name="baseUnitQty">Base unit quantity</param>
        /// <param name="taxExemptTaxCode">tax code</param>
        /// <param name="productCode">Product code</param>
        /// <param name="eOutCategory">Category</param>
        /// <param name="dOutUnitsPerPkg">Units per kg</param>
        /// <param name="sOutUpcCode">Out up code</param>
        /// <param name="isError">Is error or not</param>
        /// <returns>True or false</returns>
        public bool TeGetTaxFreePriceByRate(bool blForFuel, ref string sProductKey, string stockcode,
                                            ref short quantityPerPkg, ref short baseUnitQty,
                                            ref short taxExemptTaxCode, ref string productCode,
                                            ref mPrivateGlobals.teProductEnum eOutCategory,
                                            ref float dOutUnitsPerPkg, ref string sOutUpcCode,
                                            out bool isError)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,TaxService,TeGetTaxFreePriceByRate,{string.Empty},{dateStart:hh.mm.ss.ffffff}");

            DataTable oRecs;

            if (blForFuel)
            {
                oRecs = GetRecords("SELECT CategoryFK,ProductCode,TAX_CODE,  QuantityPerPkg, BaseUnitQty,  1 As UnitsPerPkg, \'\' As UpcCode  from ProductTaxExempt Where ProductKey =\'" + stockcode + "\' ", DataSource.CSCMaster);
            }
            else
            {
                oRecs = GetRecords("SELECT CategoryFK, ProductCode,UnitsPerPkg, TAX_CODE, QuantityPerPkg, BaseUnitQty, UpcCode FROM ProductTaxExempt Where ProductKey=\'" + sProductKey + "\'", DataSource.CSCMaster);
            }
            if (oRecs.Rows.Count == 0)
            {
                isError = false;
                return(false);
            }

            taxExemptTaxCode = CommonUtility.GetShortValue(oRecs.Rows[0]["Tax_Code"]);
            productCode      = CommonUtility.GetStringValue(oRecs.Rows[0]["ProductCode"]);
            if (CommonUtility.GetBooleanValue(oRecs.Rows[0]["CategoryFK"]))
            {
                eOutCategory = (mPrivateGlobals.teProductEnum)CommonUtility.GetIntergerValue(oRecs.Rows[0]["CategoryFK"]);
            }
            else
            {
                isError = true;
                return(true);
            }
            isError         = false;
            dOutUnitsPerPkg = CommonUtility.GetFloatValue(oRecs.Rows[0]["UnitsPerPkg"]);
            sOutUpcCode     = CommonUtility.GetStringValue(oRecs.Rows[0]["UpcCode"]);
            quantityPerPkg  = CommonUtility.GetShortValue(oRecs.Rows[0]["QuantityPerPkg"]);
            baseUnitQty     = CommonUtility.GetShortValue(oRecs.Rows[0]["BaseUnitQty"]);
            _performancelog.Debug($"End,TaxService,TeGetTaxFreePriceByRate,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(true);
        }
Пример #9
0
        /// <summary>
        /// Method to get tax exempt tax free price by price
        /// </summary>
        /// <param name="sSql">Query</param>
        /// <param name="dOutPrice">Price</param>
        /// <param name="originalPrice">Original Price</param>
        /// <param name="eOutCategory">Category</param>
        /// <param name="dOutUnitsPerPkg">Units per kg</param>
        /// <param name="sOutUpcCode">UPC code</param>
        /// <param name="bFound">Found or not</param>
        /// <param name="isError">Error or not</param>
        /// <returns>True or false</returns>
        public bool TeGetTaxFreePriceByPrice(string sSql, ref float dOutPrice, double originalPrice,
                                             ref mPrivateGlobals.teProductEnum eOutCategory, ref float dOutUnitsPerPkg,
                                             ref string sOutUpcCode, out bool bFound,
                                             out bool isError)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,TaxService,TeGetTaxFreePriceByPrice,{string.Empty},{dateStart:hh.mm.ss.ffffff}");

            var oRecs = GetRecords(sSql, DataSource.CSCPump);

            //eCategory and bFound are already set.
            if (oRecs.Rows.Count > 0)
            {
                if (CommonUtility.GetIntergerValue(oRecs.Rows[0]["TaxFreePrice"]) != 0)
                {
                    dOutPrice = CommonUtility.GetFloatValue(oRecs.Rows[0]["TaxFreePrice"]);
                }
                else
                {
                    dOutPrice = (float)originalPrice;
                }
                if (CommonUtility.GetBooleanValue(oRecs.Rows[0]["CategoryFK"]))
                {
                    eOutCategory = (mPrivateGlobals.teProductEnum)CommonUtility.GetIntergerValue(oRecs.Rows[0]["CategoryFK"]);
                }
                else
                {
                    isError = true;
                    bFound  = false;
                    return(false);
                }

                dOutUnitsPerPkg = CommonUtility.GetFloatValue(oRecs.Rows[0]["UnitsPerPkg"]);
                sOutUpcCode     = CommonUtility.GetStringValue(oRecs.Rows[0]["UpcCode"]);
                bFound          = true;
                isError         = false;
                return(true);
            }
            bFound  = false;
            isError = false;
            _performancelog.Debug($"End,TaxService,TeGetTaxFreePriceByPrice,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(false);
        }
Пример #10
0
        /// <summary>
        /// Method to set tax free fuel price
        /// </summary>
        /// <param name="sProductKey">Product key</param>
        /// <param name="eProductCategory">Product category</param>
        /// <param name="dNewCashPrice">New cash price</param>
        /// <param name="dNewCreditPrice">New credit price</param>
        /// <param name="sEmpId">Emp id</param>
        /// <returns>True or false</returns>
        public bool SetTaxFreeFuelPrice(ref string sProductKey, mPrivateGlobals.teProductEnum eProductCategory, double dNewCashPrice, double dNewCreditPrice, string sEmpId)
        {
            //Check if a record exists....
            //if it does, then update the record
            //if it does not then insert a new record.
            short iTier  = 0;
            short iGrade = 0;
            short iLevel = 0;

            if (!TeExtractFuelKey(ref sProductKey, ref iGrade, ref iTier, ref iLevel))
            {
                return(false);
            }

            var oRecs = _fuelPumpService.GetFuelPrice(iGrade, iTier, iLevel);

            if (oRecs == null)
            {
                //Insert a record into the table for this fuel product.
                _fuelPumpService.set_FuelPrice(ref Variables.gPumps, (byte)iGrade, (byte)iTier, (byte)iLevel, new CFuelPrice
                {
                    teCashPrice   = CommonUtility.GetFloatValue(dNewCashPrice),
                    teCreditPrice = CommonUtility.GetFloatValue(dNewCreditPrice),
                    EmplID        = "\'" + sEmpId + "\'",
                    Date_Time     = (int)(CommonUtility.GetDateTimeValue(IsoFormat(DateAndTime.Today, DateAndTime.TimeOfDay)).ToOADate())
                });
            }
            else
            {
                //Update the existing record with the new price.
                var sSql = "UPDATE FuelPrice " + "SET TaxFreePrice=" + System.Convert.ToString(dNewCashPrice) + ", TaxFreeCreditPrice=" + System.Convert.ToString(dNewCreditPrice) + ", EmplID=\'" + sEmpId + "\', Date_Time=\'" + IsoFormat(DateAndTime.Today, DateAndTime.TimeOfDay) + "\'   WHERE GradeID=" + (iGrade).ToString() + " AND TierID=" + (iTier).ToString() + " AND LevelID=" + (iLevel).ToString();
                _fuelPumpService.set_FuelPrice(ref Variables.gPumps, (byte)iGrade, (byte)iTier, (byte)iLevel, new CFuelPrice
                {
                    teCashPrice   = CommonUtility.GetFloatValue(dNewCashPrice),
                    teCreditPrice = CommonUtility.GetFloatValue(dNewCreditPrice),
                    EmplID        = "\'" + sEmpId + "\'",
                    Date_Time     = (int)(CommonUtility.GetDateTimeValue(IsoFormat(DateAndTime.Today, DateAndTime.TimeOfDay)).ToOADate()),
                    CashPrice     = CommonUtility.GetFloatValue(oRecs.CashPrice),
                    CreditPrice   = CommonUtility.GetFloatValue(oRecs.CreditPrice)
                });
            }

            return(true);
        }
Пример #11
0
        /// <summary>
        /// Method to get limit type
        /// </summary>
        /// <param name="productType">Product type</param>
        /// <param name="limitMax">Maximum limit</param>
        /// <param name="limitThreshold">Threshold limit</param>
        /// <returns>Limit type</returns>
        private void GetLimitType(mPrivateGlobals.teProductEnum productType, ref mPrivateGlobals.teLimitEnum limitMax, ref mPrivateGlobals.teLimitEnum limitThreshold)
        {
            switch (productType)
            {
            case mPrivateGlobals.teProductEnum.eCigarette:
                limitMax       = mPrivateGlobals.teLimitEnum.eCigLimit;
                limitThreshold = mPrivateGlobals.teLimitEnum.eCigMaxThreshhold;
                return;

            case mPrivateGlobals.teProductEnum.eCigar:
                limitMax       = mPrivateGlobals.teLimitEnum.eCigarLimit;
                limitThreshold = mPrivateGlobals.teLimitEnum.eCigarMaxThreshhold;
                return;

            case mPrivateGlobals.teProductEnum.eLooseTobacco:
                limitMax       = mPrivateGlobals.teLimitEnum.eTobaccoLimit;
                limitThreshold = mPrivateGlobals.teLimitEnum.eTobaccoMaxThreshhold;
                return;

            case mPrivateGlobals.teProductEnum.eGasoline:
            case mPrivateGlobals.teProductEnum.emarkedGas:
                limitMax       = mPrivateGlobals.teLimitEnum.eGasTransactionLimit; //
                limitThreshold = mPrivateGlobals.teLimitEnum.eGasLimit;
                return;

            case mPrivateGlobals.teProductEnum.eDiesel:
            case mPrivateGlobals.teProductEnum.emarkedDiesel:
                limitMax       = mPrivateGlobals.teLimitEnum.eDieselTransactionLimit; //
                limitThreshold = mPrivateGlobals.teLimitEnum.eDieselLimit;
                return;

            case mPrivateGlobals.teProductEnum.ePropane:
                limitMax       = mPrivateGlobals.teLimitEnum.ePropaneTransactionLimit;
                limitThreshold = mPrivateGlobals.teLimitEnum.ePropaneLimit;
                return;

            case mPrivateGlobals.teProductEnum.eNone:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(productType), productType, null);
            }
        }
Пример #12
0
        public bool teSetTaxFreePrice(ref string sProductKey, ref mPrivateGlobals.teProductEnum eProductCategory, ref double dNewPrice, ref string sEmpId, ref double dUnitsPerPackage, ref string sUpcCode)
        {
            bool returnValue = false;

            returnValue = false;

            string sSql;

            if (teIsFuelKey(sProductKey))
            {
                returnValue = SetTaxFreeFuelPrice(ref sProductKey, eProductCategory, dNewPrice, 0, sEmpId);
            }
            else
            {
                returnValue = SetTaxFreeInventoryPrice(sProductKey, eProductCategory, dNewPrice, sEmpId, dUnitsPerPackage, sUpcCode);
            }

            return(returnValue);
        }
Пример #13
0
        /// <summary>
        /// Get Quota fields
        /// </summary>
        /// <param name="eProdType">Product type</param>
        /// <returns>Quota field</returns>
        private string GetQuotaField(mPrivateGlobals.teProductEnum eProdType)
        {
            string sResult = "";

            //REVISIT: Raise an error if input is eNone
            if ((eProdType == mPrivateGlobals.teProductEnum.eCigarette) || (eProdType == mPrivateGlobals.teProductEnum.eLooseTobacco) || (eProdType == mPrivateGlobals.teProductEnum.eCigar))
            {
                sResult = "TobaccoQuota";
            } // hen
            else if ((eProdType == mPrivateGlobals.teProductEnum.eGasoline) || (eProdType == mPrivateGlobals.teProductEnum.eDiesel) || (eProdType == mPrivateGlobals.teProductEnum.emarkedGas) || (eProdType == mPrivateGlobals.teProductEnum.emarkedDiesel))
            {
                sResult = "GasQuota";
            }
            else if (eProdType == mPrivateGlobals.teProductEnum.ePropane)
            {
                if (_policyManager.TE_Type == "AITE")
                {
                    sResult = "PropaneQuota";
                }
                else
                {
                    sResult = "GasQuota";
                }
            }
            else if (eProdType == mPrivateGlobals.teProductEnum.eNone)
            {
                Information.Err().Raise(mPrivateGlobals.kNoQuotaForNoneCategoryNum, mPrivateGlobals.kNoQuotaForNoneCategoryDesc);
            }
            else
            {
                //REVISIT: Raise an error here too maybe
                Information.Err().Raise(mPrivateGlobals.kNoQuotaForUnknownProductNum, mPrivateGlobals.kNoQuotaForUnknownProductDesc);
            }

            return(sResult);
        }
Пример #14
0
        /// <summary>
        /// Method to get tax free price by price
        /// </summary>
        /// <param name="oTeSystem">Tax exempt system</param>
        /// <param name="sProductKey">Product key</param>
        /// <param name="originalPrice">Original price</param>
        /// <param name="dOutPrice">Price</param>
        /// <param name="dOutUnitsPerPkg">Units per kg</param>
        /// <param name="eOutCategory">Category</param>
        /// <param name="sOutUpcCode">UPC code</param>
        /// <param name="bFound">Value found</param>
        /// <param name="stockcode">Stock code</param>
        /// <returns>True or false</returns>
        private bool TeGetTaxFreePriceByPrice(ref teSystem oTeSystem, ref string sProductKey, double originalPrice
                                              , ref float dOutPrice, ref float dOutUnitsPerPkg, ref mPrivateGlobals.teProductEnum eOutCategory,
                                              ref string sOutUpcCode, ref bool bFound, string stockcode)
        {
            bFound          = false;
            eOutCategory    = mPrivateGlobals.teProductEnum.eNone;
            sOutUpcCode     = "";
            dOutUnitsPerPkg = 0;

            string sSql;

            short iTier  = 0;
            short iGrade = 0;
            short iLevel = 0;

            if (TeIsFuelKey(sProductKey))
            {
                if (!TeExtractFuelKey(ref oTeSystem, ref sProductKey, ref iGrade, ref iTier, ref iLevel))
                {
                    return(false);
                }

                sSql = "SELECT TaxFreePrice, " + "(SELECT CategoryFK From CSCMaster.dbo.ProductTaxExempt Where" + " ProductKey =\'" + stockcode + "\') As CategoryFK," + "1 As UnitsPerPkg, " + "\'\' As UpcCode  FROM FuelPrice  WHERE GradeID=" + iGrade + " AND TierID=" + iTier + " AND LevelID=" + iLevel;
            }
            else
            {
                sSql = "SELECT TaxFreePrice, CategoryFK, UnitsPerPkg, UpcCode FROM CSCMaster.dbo.ProductTaxExempt  WHERE ProductKey=\'" + sProductKey + "\'";
            }

            bool isError;
            var  success = _taxService.TeGetTaxFreePriceByPrice(sSql, ref dOutPrice, originalPrice, ref eOutCategory,
                                                                ref dOutUnitsPerPkg, ref sOutUpcCode, out bFound, out isError);

            if (!isError)
            {
                return(success);
            }
            oTeSystem.SLastError = "2";
            return(false);
        }
Пример #15
0
        private bool teGetTaxFreePriceByRate(ref string sProductKey, float OriginalPrice, ref float dOutPrice, ref float dOutUnitsPerPkg, ref mPrivateGlobals.teProductEnum eOutCategory, ref string sOutUpcCode, ref bool bFound, ref float OutTaxExemptRate, string stockcode, ref string ProductCode)
        {
            bool returnValue = false;


            return(returnValue);
        }
Пример #16
0
        /// <summary>
        /// Method to get tax free price by rate
        /// </summary>
        /// <param name="sProductKey">Product key</param>
        /// <param name="originalPrice">Original price</param>
        /// <param name="dOutPrice">Price</param>
        /// <param name="dOutUnitsPerPkg">Units per kg</param>
        /// <param name="eOutCategory">Category</param>
        /// <param name="sOutUpcCode">UPC code</param>
        /// <param name="bFound">Value found</param>
        /// <param name="outTaxExemptRate">Tax exempt rate</param>
        /// <param name="stockcode">Stock code</param>
        /// <param name="productCode">Product code</param>
        /// <returns>True or false</returns>
        private bool TeGetTaxFreePriceByRate(ref string sProductKey, float originalPrice, ref float dOutPrice,
                                             ref float dOutUnitsPerPkg, ref mPrivateGlobals.teProductEnum eOutCategory, ref string sOutUpcCode, ref bool bFound, ref float outTaxExemptRate, string stockcode, ref string productCode)
        {
            //Nancy added for calculating tax for cigar

            bFound          = false;
            eOutCategory    = mPrivateGlobals.teProductEnum.eNone;
            sOutUpcCode     = "";
            dOutUnitsPerPkg = 0;

            var regPrice = originalPrice;


            var   blForFuel      = TeIsFuelKey(sProductKey);
            short quantityPerPkg = 1;
            short baseUnitQty    = 1;
            bool  isError;
            short taxExemptTaxCode = 0;

            _taxService.TeGetTaxFreePriceByRate(blForFuel, ref sProductKey, stockcode, ref quantityPerPkg, ref baseUnitQty,
                                                ref taxExemptTaxCode, ref productCode, ref eOutCategory, ref dOutUnitsPerPkg, ref sOutUpcCode, out isError);

            if (isError)
            {
                return(false);
            }

            if (quantityPerPkg == 0)
            {
                quantityPerPkg = 1;
            }
            if (baseUnitQty == 0)
            {
                baseUnitQty = 1;
            }

            float  taxRate;
            string rateType;

            var issuccess = _taxService.GetTaxExemptRate(Convert.ToString(taxExemptTaxCode), out taxRate, out rateType);

            if (!issuccess)
            {
                dOutPrice = regPrice;
            }
            else
            {
                if (rateType == "$")
                {
                    outTaxExemptRate = taxRate;

                    if (eOutCategory == mPrivateGlobals.teProductEnum.eCigar)
                    {
                        taxRate          = RoundToHighCent(quantityPerPkg * taxRate * baseUnitQty);
                        dOutPrice        = regPrice - taxRate;
                        outTaxExemptRate = taxRate;
                    }
                    else
                    {
                        dOutPrice = regPrice - taxRate;
                    }
                }
                else if (rateType == "%")
                {
                    if (eOutCategory == mPrivateGlobals.teProductEnum.eCigar)
                    {
                        taxRate          = RoundToHighCent(regPrice / quantityPerPkg / baseUnitQty * (taxRate / 100));
                        outTaxExemptRate = float.Parse((taxRate * quantityPerPkg * baseUnitQty).ToString("#0.00"));
                        dOutPrice        = regPrice - outTaxExemptRate;
                    }
                    else
                    {
                        outTaxExemptRate = RoundToHighCent(regPrice * (taxRate / 100));
                        dOutPrice        = regPrice - outTaxExemptRate;
                    }
                }
                else
                {
                    dOutPrice        = regPrice;
                    outTaxExemptRate = 0;
                }
                if (blForFuel)
                {
                    dOutPrice = float.Parse(dOutPrice.ToString("#0.000"));
                }
                else
                {
                    var noDecimals = (short)((dOutPrice - Conversion.Int((short)dOutPrice)).ToString(CultureInfo.InvariantCulture).Length - 2);
                    if (noDecimals > 4)
                    {
                        noDecimals = 4;
                    }
                    if (noDecimals < 0)
                    {
                        noDecimals = 0;
                    }
                    dOutPrice = float.Parse(dOutPrice.ToString("#0." + new string('0', noDecimals)));
                }
            }

            bFound = true;
            return(true);
        }
Пример #17
0
        //Name: teGetTaxFreePrice
        //Description: Returns the tax free unit price of a given product.
        //To get the TaxFree price of a gas or diesel item, set sProductKey to the
        // result of teSystem.teMakeFuelKey()
        //Inputs: sProductKey, a string containing a product key.  Either a StockCode,
        //   or a compound fuel key. (eg: "Fuel:G:1,T:2,L:3").
        //Outputs: dOutPrice: The taxexempt price, or 0 if no price was found.
        //         eOutCategory, the product category (or eNone if none was found).
        //         bFound: True if a tax exempt price was found, false otherwise.
        //Returns: False if there was an error, True if function ran ok.

        public bool teGetTaxFreePrice(string sProductKey, float OriginalPrice, float dOutPrice, float dOutUnitsPerPkg, mPrivateGlobals.teProductEnum eOutCategory, string sOutUpcCode, bool bFound, string stockcode, string ProductCode, float OutTaxExemptRate)
        {
            bool returnValue = false;

            return(returnValue);
        }