/// <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);
        }
示例#2
0
        /// <summary>
        /// Add Item to Purchase List
        /// </summary>
        /// <param name="purchaseList">Purchase list</param>
        /// <param name="sale">Sale</param>
        /// <param name="peTreatyNo">Treaty number</param>
        /// <param name="sProductKey">Product key</param>
        /// <param name="dQuantity">Quantity</param>
        /// <param name="dOriginalPrice">Original price</param>
        /// <param name="iRowNumberInSalesMainForm">Row number</param>
        /// <param name="stockcode">Stock code</param>
        /// <param name="taxInclPrice">Tax included price</param>
        /// <param name="isFuelItem">Is fuel item or not</param>
        /// <returns>True or false</returns>
        public bool AddItem(ref tePurchaseList purchaseList, ref Sale sale,
                            ref teTreatyNo peTreatyNo, ref string sProductKey, ref double dQuantity,
                            ref double dOriginalPrice, ref short iRowNumberInSalesMainForm,
                            ref string stockcode, ref double taxInclPrice, ref bool isFuelItem)
        {
            double quota              = 0;
            var    productType        = default(mPrivateGlobals.teProductEnum);
            var    limitMaxType       = default(mPrivateGlobals.teLimitEnum);
            var    limitThresholdType = default(mPrivateGlobals.teLimitEnum);
            double limitMax           = 0;
            double limitThreshold     = 0;
            short  ret;
            string formatString  = "";
            double runningQuotaF = 0;
            short  runningQuotaT = 0;

            var oItem = new tePurchaseItem {
                BIsInit = true
            };

            //initialize item then add to purchase list
            if (!_purchaseItemManager.Init(ref oItem, ref peTreatyNo, ref sProductKey, dOriginalPrice, dQuantity, iRowNumberInSalesMainForm, sale.Sale_Num, sale.TillNumber, ref stockcode, taxInclPrice, isFuelItem, purchaseList.NoRTVP))
            {
                purchaseList.SetLastError(mPrivateGlobals.theSystem.teGetLastError());//"Failed to Add Item: " & oDb.GetLastError()
                return(false);
            }

            oItem.GetProductType(ref productType);

            // Validation
            if (_policyManager.SITE_RTVAL && !purchaseList.NoRTVP) // And Not Me.NoRTVP
            {
                if (productType == mPrivateGlobals.teProductEnum.eCigarette | productType == mPrivateGlobals.teProductEnum.eCigar | productType == mPrivateGlobals.teProductEnum.eLooseTobacco)
                {
                    ret = Convert.ToInt16(Variables.RTVPService.SetItemUPC(oItem.LineItem, sProductKey, (int)productType));
                    WriteToLogFile("Response is " + Convert.ToString(ret) + " from SetItemUPC sent with parameters " + Convert.ToString(oItem.LineItem) + "," + sProductKey + "," + Convert.ToString(productType));
                    formatString = "0.00";
                }
                else
                {
                    SetStockCode(ref oItem, stockcode);
                    ret = Convert.ToInt16(Variables.RTVPService.SetItemUPC(oItem.LineItem, oItem.ItemUPC, (int)productType));
                    WriteToLogFile("Response is " + Convert.ToString(ret) + " from SetItemUPC sent with parameters " + Convert.ToString(oItem.LineItem) + "," + oItem.ItemUPC + "," + Convert.ToString(productType));
                    formatString = "0.000";
                }
                if (ret != 0)
                {
                    purchaseList.RTVPCommand  = "SetItemUPC";
                    purchaseList.RTVPError    = true;
                    purchaseList.RTVPResponse = ret;
                    return(false);
                }
                purchaseList.RTVPError = false;

                ret = Convert.ToInt16(Variables.RTVPService.SetItemTotal(oItem.LineItem,
                                                                         double.Parse((dQuantity * oItem.GetTaxFreePrice()).ToString(formatString))));
                WriteToLogFile("Response is " + Convert.ToString(ret) + " from SetItemTotal sent with parameters " + Convert.ToString(oItem.LineItem) + "," +
                               (dQuantity * oItem.GetTaxFreePrice()).ToString(formatString));
                if (ret != 0)
                {
                    purchaseList.RTVPCommand  = "SetItemTotal";
                    purchaseList.RTVPError    = true;
                    purchaseList.RTVPResponse = ret;
                    return(false);
                }
                purchaseList.RTVPError = false;
            }
            //   end

            var unitsPerPkg = oItem.UnitsPerPkg;
            var quantity    = dQuantity * unitsPerPkg;

            // validation
            if (_policyManager.SITE_RTVAL && !purchaseList.NoRTVP) // And Not Me.NoRTVP
            {
                // based on email from SITE all products need SetItemEquivalence including fuel
                // for fuel we decided to set Equivalence to 1, meaning send the quantity
                double dblEquivalent;
                if (productType == mPrivateGlobals.teProductEnum.eCigarette | productType == mPrivateGlobals.teProductEnum.eCigar | productType == mPrivateGlobals.teProductEnum.eLooseTobacco)
                {
                    dblEquivalent = _teSystemManager.GetCigaretteEquivalentUnits((mPrivateGlobals.teTobaccoEnum)Convert.ToInt16(productType));
                }
                else
                {
                    dblEquivalent = 1;
                }
                oItem.Quantity        = (float)dQuantity;     //
                oItem.ItemEquivalence = (float)dblEquivalent; //
                oItem.UnitsPerPkg     = unitsPerPkg;

                ret = Convert.ToInt16(Variables.RTVPService.SetItemEquivalence(oItem.LineItem, double.Parse((quantity * dblEquivalent).ToString(formatString))));
                WriteToLogFile("Response is " + Convert.ToString(ret) + " from SetItemEquivalence sent with parameters " + Convert.ToString(oItem.LineItem) + "," +
                               (quantity * dblEquivalent).ToString(formatString));
                if (ret != 0)
                {
                    purchaseList.RTVPCommand  = "SetItemEquivalence";
                    purchaseList.RTVPError    = true;
                    purchaseList.RTVPResponse = ret;
                    return(false);
                }
                purchaseList.RTVPError = false;
            }
            else
            {
                _treatyManager.GetQuota(ref peTreatyNo, ref productType, ref quota);
            }

            //   added the If condition; real time validation for SITE doesn't require next code
            if (!_policyManager.SITE_RTVAL)
            {
                GetLimitType(productType, ref limitMaxType, ref limitThresholdType);
                _teSystemManager.TeGetLimit(limitMaxType, ref limitMax);
                _teSystemManager.TeGetLimit(limitThresholdType, ref limitThreshold);

                if (productType == mPrivateGlobals.teProductEnum.eGasoline | productType == mPrivateGlobals.teProductEnum.eDiesel | productType == mPrivateGlobals.teProductEnum.ePropane | productType == mPrivateGlobals.teProductEnum.emarkedGas | productType == mPrivateGlobals.teProductEnum.emarkedDiesel) // hen
                {
                    runningQuotaF = (float)(runningQuotaF + quantity + quota);

                    //   added next two lines, for FNGTR Gasoline Single Transaction Limit is the only validation required
                    if (_policyManager.TAX_EXEMPT_FNGTR)
                    {
                        if (runningQuotaF > limitMax)
                        {
                            purchaseList.IsFuelOverLimit = true;
                        }
                        else
                        {
                            purchaseList.IsTobaccoOverLimit = false;
                        }
                        purchaseList.IsTobaccoOverLimit = false;
                    }
                    else
                    {
                        if (runningQuotaF > limitThreshold)
                        {
                            purchaseList.IsFuelOverLimit = true;
                        }
                        else if (quantity > limitMax)
                        {
                            purchaseList.IsFuelOverLimit = true;
                        }
                        else
                        {
                            purchaseList.IsFuelOverLimit = false;
                        }
                    }
                    if (!_teSystemManager.IsLimitRequired(ref mPrivateGlobals.theSystem, productType))
                    {
                        purchaseList.IsFuelOverLimit = false;
                    }
                }
                else if (productType == mPrivateGlobals.teProductEnum.eCigarette | productType == mPrivateGlobals.teProductEnum.eCigar | productType == mPrivateGlobals.teProductEnum.eLooseTobacco)
                {
                    runningQuotaT = (short)(runningQuotaT + quantity + quota);

                    if (runningQuotaT > limitThreshold)
                    {
                        purchaseList.IsTobaccoOverLimit = true;
                    }
                    else if (runningQuotaT > limitMax)
                    {
                        purchaseList.IsTobaccoOverLimit = true;
                    }
                    else
                    {
                        purchaseList.IsTobaccoOverLimit = false;
                    }



                    if (!_teSystemManager.IsLimitRequired(ref mPrivateGlobals.theSystem, productType))
                    {
                        purchaseList.IsTobaccoOverLimit = false;
                    }
                }
            }
            // real time validation end if '

            purchaseList.AddItemInCollection(oItem); //save the item in purchase list



            purchaseList.PeQuantity   = quantity;
            purchaseList.PsProductKey = sProductKey;
            return(true);
        }