/// <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); }
/// <summary> /// Method to initiliase purchase item /// </summary> /// <param name="purchaseItem">Purchase item</param> /// <param name="oTreatyNo">Treaty number</param> /// <param name="sProductKey">Product key</param> /// <param name="dOriginalPrice">Original price</param> /// <param name="dQuantity">Orginal quantity</param> /// <param name="iRowNumberInSalesMainForm">Row number is sale line</param> /// <param name="invoiceId">Invoice Id</param> /// <param name="tillId">Till Id</param> /// <param name="stockcode">Stock code</param> /// <param name="taxInclPrice">Tax included price</param> /// <param name="isFuelItem">Is fuel item or not</param> /// <param name="noRtvp">RTVP or not</param> /// <returns>True or false</returns> public bool Init(ref tePurchaseItem purchaseItem, ref teTreatyNo oTreatyNo, ref string sProductKey, double dOriginalPrice, double dQuantity, short iRowNumberInSalesMainForm, int invoiceId, short tillId, ref string stockcode, double taxInclPrice, bool isFuelItem, bool noRtvp) { purchaseItem.InvoiceID = invoiceId; purchaseItem.TillID = tillId; if (!_teSystemManager.TeGetTaxFreePrice(ref mPrivateGlobals.theSystem, ref purchaseItem, sProductKey, (float)dOriginalPrice, false, stockcode, "", 0)) { return(false); } if (_policyManager.SITE_RTVAL && !noRtvp) // And Not NoRTVP condition { if (Variables.RTVPService == null) { Variables.RTVPService = new RTVP.POSService.Transaction(); // Writing this to solve the issue of products not getting added in DB in tax exempt sale due to cache loss } purchaseItem.LineItem = Convert.ToInt16(Variables.RTVPService.AddLineItem()); WriteToLogFile("Response is " + Convert.ToString(purchaseItem.LineItem) + " from AddLineItem sent with no parameters"); } purchaseItem.Quantity = (float)dQuantity; // if (isFuelItem) { purchaseItem.PsIsFuelItem = true; purchaseItem.PsGradeStockCode = stockcode; var psGradeId = purchaseItem.PsGradeIDpsTreatyNo; var psTierId = purchaseItem.PsTierID; var psLevelId = purchaseItem.PsLevelID; _teSystemManager.TeExtractFuelKey(ref mPrivateGlobals.theSystem, ref sProductKey, ref psGradeId, ref psTierId, ref psLevelId); purchaseItem.PsGradeIDpsTreatyNo = psGradeId; purchaseItem.PsTierID = psTierId; purchaseItem.PsLevelID = psLevelId; } else { purchaseItem.PsIsFuelItem = false; } purchaseItem.PsProductKey = sProductKey; purchaseItem.PdQuantity = (float)dQuantity; purchaseItem.PiRowInSalesMain = iRowNumberInSalesMainForm; purchaseItem.PetaxInclPrice = (float)dOriginalPrice; purchaseItem.PdOriginalPrice = (float)dOriginalPrice; purchaseItem.PiOverrideCode = -1; purchaseItem.PsOverrideFormNumber = (0).ToString(); purchaseItem.PsOverrideDetails = "Not Set"; purchaseItem.PetaxInclPrice = (float)taxInclPrice; purchaseItem.PsTreatyNo = oTreatyNo; purchaseItem.BIsInit = true; if (!_policyManager.SITE_RTVAL) { purchaseItem.PeIsLimitRequired = _teSystemManager.IsLimitRequired(ref mPrivateGlobals.theSystem, purchaseItem.ProdType); } return(true); }