Ejemplo n.º 1
0
        /// <summary>
        /// Method to writeoff a sale
        /// </summary>
        /// <param name="userCode">User code</param>
        /// <param name="saleNumber">Sale number</param>
        /// <param name="tillNumber">TillNumber</param>
        /// <param name="writeOffReason"></param>
        /// <param name="errorMessage">Error message</param>
        /// <param name="registerNumber">Register number</param>
        /// <returns>New sale</returns>
        public Report WriteOff(string userCode, int saleNumber, int tillNumber, string writeOffReason,
                               out ErrorMessage errorMessage, out int registerNumber)
        {
            errorMessage = new ErrorMessage();
            var sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, 0, userCode, out errorMessage);

            registerNumber = 0;
            if (!string.IsNullOrEmpty(errorMessage.MessageStyle.Message))
            {
                return(null);
            }
            var offSet = _policyManager.LoadStoreInfo().OffSet;

            //crash recovery- if there is partial/ full payment donot allow write off
            if (sale.Payment)
            {
                errorMessage.MessageStyle = _resourceManager.CreateMessage(offSet, 12, 86, null, MessageType.OkOnly);
                return(null);
            }
            registerNumber = sale.Register;
            sale.Sale_Type = Convert.ToString(sale.Sale_Type == "MARKDOWN" ? "SALE" : "MARKDOWN");
            if (sale.Sale_Type == "MARKDOWN")
            {
                var reasonType = 'M';
                sale.Return_Reason = _reasonService.GetReturnReason(writeOffReason, reasonType);
                if (sale.Return_Reason == null)
                {
                    errorMessage.MessageStyle = new MessageStyle
                    {
                        Message = "Invalid reason"
                    };
                    errorMessage.StatusCode = HttpStatusCode.NotFound;
                    return(null);
                }
                sale.Customer.Name = _resourceManager.GetResString(offSet, 159);
                sale.Customer.Code = _resourceManager.GetResString(offSet, 1252);

                _saleManager.ApplyTaxes(ref sale, false);   // Added, don't calculate taxes for MARKDOWN sales
                _saleManager.ApplyCharges(ref sale, false); // Added, don't calculate taxes for MARKDOWN sales
                var    user = CacheManager.GetUser(userCode);
                Stream signature;
                var    fileName = string.Empty;
                if (_policyManager.PRINT_REC)
                {
                    return(_paymentManager.ExactChange_Receipt(sale, user, tillNumber, out errorMessage, out signature, ref fileName));
                }
                return(_paymentManager.ExactChange_Receipt(sale, user, tillNumber, out errorMessage, out signature, ref fileName));
            }
            errorMessage.MessageStyle = new MessageStyle
            {
                Message = "Could not write off"
            };
            errorMessage.StatusCode = HttpStatusCode.NoContent;
            return(null);
        }
        /// <summary>
        /// Method to load tax exempt prepay
        /// </summary>
        /// <param name="saleNo">Sale number</param>
        /// <param name="sl">Sale line</param>
        /// <param name="lineNo">Line number</param>
        /// <param name="sale">Sale</param>
        /// <param name="oPurchaseList">Purchase list</param>
        /// <param name="oTreatyNo">Treaty number</param>
        /// <returns>True or false</returns>
        public bool LoadTaxExemptPrepay(int saleNo, Sale_Line sl, short lineNo, ref
                                        Sale sale, ref tePurchaseList oPurchaseList, ref teTreatyNo oTreatyNo)
        {
            var returnValue = false;

            if (!_policyManager.TAX_EXEMPT)
            {
                return(false);
            }
            var user = CacheManager.GetUser(UserCode);

            if (_policyManager.TE_Type == "SITE")
            {
                var teItem = _taxExemptSaleService.GetPurchaseItem(saleNo, lineNo);
                if (teItem != null)
                {
                    _treatyManager.Init(ref oTreatyNo, teItem.TreatyNo, false);
                    oPurchaseList.Init(oTreatyNo, sale.Sale_Num, sale.TillNumber);

                    var    tempSProductKey  = mPrivateGlobals.theSystem.teMakeFuelKey(sl.GradeID, teItem.PsTierID, teItem.PsLevelID);
                    var    tempIsFuelItem   = true;
                    var    stockCode        = string.Empty;
                    short  iRowNumberinSale = 0;
                    double tempQuantity     = 0f;
                    double org           = teItem.PdOriginalPrice;
                    double taxIncldPrice = teItem.petaxInclPrice;
                    _purchaseListManager.AddItem(ref oPurchaseList,
                                                 ref sale, ref oTreatyNo, ref tempSProductKey, ref tempQuantity, ref org, ref iRowNumberinSale, ref stockCode, ref taxIncldPrice, ref tempIsFuelItem);
                    sl.Stock_Code = stockCode;
                }
            }
            else
            {
                var oTeSale = new TaxExemptSale();

                if (_taxExemptSaleService.LoadTaxExemptForDeletePrepay(ref oTeSale,
                                                                       _policyManager.TE_Type, _tillService.GetTill(sale.TillNumber),
                                                                       user, saleNo, sale.TillNumber, lineNo, sale.Sale_Num))
                {
                    returnValue = true;
                }
                else if (_taxExemptSaleService.LoadGstExemptForDeletePrepay(ref oTeSale,
                                                                            saleNo, sale.TillNumber, DataSource.CSCTills))
                {
                    oTeSale.teCardholder.GstExempt = true;
                }
            }
            return(returnValue);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the user by user code in cache
        /// </summary>
        /// <param name="userCode">User code</param>
        /// <returns>User</returns>
        public User GetExistingUser(string userCode)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,LoginManager,GetExistingUser,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");
            if (string.IsNullOrEmpty(userCode))
            {
                return(null);
            }
            var user = CacheManager.GetUser(userCode);

            if (user != null)
            {
                return(user);
            }
            user = GetUser(userCode);
            Performancelog.Debug($"End,LoginManager,GetExistingUser,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            CacheManager.AddUser(userCode, user);
            return(user);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Checks User ID
        /// </summary>
        /// <param name="userName">Username</param>
        /// <param name="password">Password</param>
        /// <param name="posId">POS Id</param>
        /// <param name="unauthorizedAccess">Unauthorized access</param>
        /// <param name="message">Error</param>
        /// <returns>True or false</returns>
        private bool CheckUserId(string userName, string password, int posId,
                                 bool unauthorizedAccess, out ErrorMessage message)
        {
            var returnValue = true;

            message = new ErrorMessage();
            //var user = _userService.GetUser(userName);
            var user = CacheManager.GetUser(userName) ?? _userService.GetUser(userName);

            var encryptionManager = new EncryptionManager();

            if (user != null)
            {
                //Add user in Cache
                CacheManager.AddUser(userName, user);
                var offSet = _policyManager.LoadStoreInfo().OffSet;
                if (_policyManager.LogUnlimit == false)
                {
                    //User cannot log on to more than one register unless it is a Trainer
                    if (user.User_Group.Code != "Trainer" && !unauthorizedAccess)
                    {
                        var result = _loginService.CheckLoggedinUserPos(userName, posId);

                        if (result)
                        {
                            message = new ErrorMessage
                            {
                                MessageStyle = _resourceManager.CreateMessage(offSet, 30, 95, null, CriticalOkMessageType)
                            };
                            return(false);
                        }
                    }
                }
                if (!Convert.ToBoolean(_policyManager.GetPol("U_SELL", user)))
                {
                    //TIMsgbox "You are not authorized to sell products", _
                    //vbCritical + vbOKOnly, "No Authorization"
                    message = new ErrorMessage
                    {
                        MessageStyle = _resourceManager.CreateMessage(offSet, 30, 92, null, CriticalOkMessageType)
                    };
                }
                //End - SV

                if (!Convert.ToBoolean(_policyManager.GetPol("U_REQ_PW", user)))
                {
                    return(true);
                }
                if (password != encryptionManager.DecryptText(user.epw) || string.IsNullOrEmpty(password))
                {
                    message = new ErrorMessage
                    {
                        MessageStyle = _resourceManager.CreateMessage(offSet, 30, 91, null, CriticalOkMessageType)
                    };
                    returnValue = false;
                }
            }
            else
            {
                //TIMsgbox "UserID " & txtUserid.Text & " does not exist.", vbCritical + vbOKOnly, "No Such User", Me
                var offSet = _policyManager.LoadStoreInfo().OffSet;
                message = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 30, 93, userName, CriticalOkMessageType)
                };
                returnValue = false;
            }
            return(returnValue);
        }