Exemplo n.º 1
0
 public override bool RecalcHeadReceipt(IdReceipt parReceipt)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         return(DB.ExecuteNonQuery <IdReceipt>(this.SqlRecalcHeadReceipt, parReceipt) > 0);
     }
 }
Exemplo n.º 2
0
        public async Task <LogRRO> PrintXYAsync(bool pIsX, IdReceipt pIdR)
        {
            string res;
            var    Res = new LogRRO(pIdR);

            Res.CodeReceipt = 0;
            HttpStatusCode Response;

            (res, Response) = await HttpAsync($"/innovate/{(pIsX?"x":"z")}report", "{\"cashierName\": \"" + OperatorName + "\"}");

            if (Response == HttpStatusCode.OK)
            {
                var xx = JsonConvert.DeserializeObject <pRroAnswerSG>(res);
                Res.TypeOperation   = pIsX ? eTypeOperation.XReport : eTypeOperation.ZReport;
                Res.NumberOperation = xx.receiptNumber;
                Res.TextReceipt     = xx.text;
                Res.SUM             = Convert.ToDecimal(xx.sum) / 100m;
                Res.JSON            = res; //JsonConvert.SerializeObject(xx, Formatting.Indented);
                SetStatus(eStatusRRO.OK);
            }
            else
            {
                Res.Error     = Response.ToString();
                Res.CodeError = -1;
            }
            return(Res);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Внесення/Винесення коштів коштів. pSum>0 - внесення
        /// </summary>
        /// <param name="pSum"></param>
        /// <returns></returns>
        override public async Task <LogRRO> MoveMoneyAsync(decimal pSum, IdReceipt pIdR)
        {
            ///innovate/servicein внесення /innovate/serviceout  --винесення
            var Res = new LogRRO(pIdR);

            return(Res);
        }
Exemplo n.º 4
0
 public virtual bool UpdateClient(IdReceipt parIdReceipt, int parCodeClient)
 {
     lock (GetObjectForLockByIdWorkplace(parIdReceipt.IdWorkplace))
     {
         return(this.db.ExecuteNonQuery <IdReceipt>(SqlUpdateClient, parIdReceipt) > 0);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Внесення/Винесення коштів коштів. pSum>0 - внесення
        /// </summary>
        /// <param name="pSum"></param>
        /// <returns></returns>
        override public async Task <LogRRO> MoveMoneyAsync(decimal pSum, IdReceipt pIdR)
        {
            ///innovate/servicein внесення /innovate/serviceout  --винесення
            var Res = new LogRRO(pIdR);

            Res.CodeReceipt = 0;

            var Body = JsonConvert.SerializeObject(new pRroRequestBaseSG()
            {
                docSubType = (pSum > 0?eTypeDoc.MoneyIn : eTypeDoc.MoneyOut), sum = pSum, cashierName = OperatorName
            });
            string         res;
            HttpStatusCode Response;

            (res, Response) = await HttpAsync("innovate/service" + (pSum > 0? "in" :"out"), Body);

            if (Response == HttpStatusCode.OK)
            {
                var xx = JsonConvert.DeserializeObject <pRroAnswerSG>(res);
                Res.TypeOperation   = pSum > 0 ? eTypeOperation.MoneyIn : eTypeOperation.MoneyOut;
                Res.TextReceipt     = xx.text;
                Res.SUM             = xx.sum;
                Res.NumberOperation = xx.receiptNumber;
                Res.JSON            = res;
                SetStatus(eStatusRRO.OK);
            }
            else
            {
                Res.Error = Response.ToString();
            }
            return(Res);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Cстворення повернення на основі чека.
        /// </summary>
        /// <param name="IdR">Чек на який робиться повернення</param>
        /// <returns></returns>
        public Receipt CreateRefund(IdReceipt IdR)
        {
            try
            {
                var NewR = GetNewIdReceipt(IdR.IdWorkplace);
                var R    = GetReceiptHead(IdR, true);
                R.Payment      = null;
                R.ReceiptEvent = null;
                R.TypeReceipt  = eTypeReceipt.Refund;
                R.RefundId     = new IdReceipt(R);
                R.SetIdReceipt(NewR);
                db.ReplaceReceipt(R);

                foreach (var el in R.Wares)
                {
                    el.MaxRefundQuantity = el.Quantity - el.RefundedQuantity;
                    el.Quantity          = 0;
                    db.AddWares(el);
                }
                curRecipt = R;
                return(R);
            }
            catch (Exception e)
            {
                FileLogger.WriteLogMessage($"BL.CreateRefund Exception =>( {IdR?.ToJSON() }) => (){Environment.NewLine}Message=>{e.Message}{Environment.NewLine}StackTrace=>{e.StackTrace}", eTypeLog.Error);
                return(null);
            }
        }
Exemplo n.º 7
0
 public override bool DeleteReceiptEvent(IdReceipt parIdReceipt)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         return(DB.ExecuteNonQuery <IdReceipt>(SqlDeleteReceiptEvent, parIdReceipt) > 0);
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Внесення/Винесення коштів коштів. pSum>0 - внесення
 /// </summary>
 /// <param name="pSum"></param>
 /// <returns></returns>
 override public async Task <LogRRO> MoveMoneyAsync(decimal pSum, IdReceipt pIdR = null)
 {
     return(new LogRRO(pIdR)
     {
         TypeOperation = eTypeOperation.MoneyIn, FiscalNumber = "V0001111", SUM = 1230m
     });
 }
Exemplo n.º 9
0
 override public async Task <LogRRO> PrintXAsync(IdReceipt pIdR)
 {
     return(new LogRRO(pIdR)
     {
         TypeOperation = eTypeOperation.XReport, FiscalNumber = "V0001111"
     });
 }
Exemplo n.º 10
0
 ///відкрити порт
 private bool FpOpenPort(IdReceipt pReceipt = null)
 {
     SetStatus(eStatusRRO.TryOpenPort);
     if (!string.IsNullOrEmpty(SerialPort) && BaudRate > 0)
     {
         FP.OpenPort(SerialPort, BaudRate);
     }
     else if (!string.IsNullOrEmpty(IP) && IpPort > 0)
     {
         FP.ConnectLan(IP, IpPort.ToString()); //"10.1.5.221", "9100"
     }
     else
     {
         CodeError = -999;
         StrError  = "Відсутні налаштування з'єднааня з Фіскальним апаратом";
     }
     if (!CheckResult())
     {
         SetStatus(eStatusRRO.Error, StrError, CodeError);
         FP.ClosePort();
         return(false);
     }
     SetStatus(eStatusRRO.OpenPort);
     return(true);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Внесення/Винесення коштів коштів.
 /// </summary>
 /// <param name="pSum"> pSum>0 - внесення</param>
 /// <returns></returns>
 override public async Task <LogRRO> MoveMoneyAsync(decimal pSum, IdReceipt pIdR = null)
 {
     SetError(M304.MoveCash((pSum > 0 ? 1 : 0), Convert.ToInt32(Math.Abs(pSum) * 100m)) != 1);
     return(new LogRRO(pIdR)
     {
         CodeError = CodeError, Error = StrError, SUM = pSum, TypeRRO = "Maria304", TypeOperation = pSum > 0?eTypeOperation.MoneyIn:eTypeOperation.MoneyOut
     });
 }
Exemplo n.º 12
0
 public override bool DeleteWaresReceiptPromotion(IdReceipt parIdReceipt)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         DB.ExecuteNonQuery <IdReceipt>(SqlDeleteWaresReceiptPromotion, parIdReceipt);
     }
     return(true);
 }
Exemplo n.º 13
0
        public Receipt GetLastReceipt(int pIdWorkplace = 0, int parCodePeriod = 0)
        {
            var idReceip = new IdReceipt()
            {
                IdWorkplace = (pIdWorkplace == 0 ? Global.IdWorkPlace : pIdWorkplace), CodePeriod = (parCodePeriod == 0 ? Global.GetCodePeriod() : parCodePeriod)
            };

            return(db.GetLastReceipt(idReceip));
        }
Exemplo n.º 14
0
        public bool MoveReceipt(IdReceipt pIdReceipt, IdReceipt pIdReceiptTo)
        {
            var param = new ParamMoveReceipt(pIdReceipt)
            {
                NewCodePeriod = pIdReceiptTo.CodePeriod, NewCodeReceipt = pIdReceiptTo.CodePeriod, NewIdWorkplace = pIdReceiptTo.IdWorkplace
            };

            return(db.MoveReceipt(param));
        }
Exemplo n.º 15
0
        public ReceiptViewModel GetReceiptViewModel(IdReceipt pReceipt, bool pIsDetail = false)
        {
            if (pReceipt == null)
            {
                return(null);
            }
            var receiptMID = Bl.GetReceiptHead(pReceipt, true);

            if (receiptMID == null)
            {
                return(null);
            }
            var receipt = new Receipt()
            {
                Id           = receiptMID.ReceiptId,
                FiscalNumber = receiptMID.NumberReceipt,
                Status       = (receiptMID.SumCash > 0 || receiptMID.SumCreditCard > 0
                    ? ReceiptStatusType.Paid
                    : ReceiptStatusType.Created),    //!!!TMP Треба врахувати повернення
                TerminalId  = receiptMID.TerminalId,
                Amount      = receiptMID.SumReceipt, //!!!TMP Сума чека.
                Discount    = receiptMID.SumDiscount,
                TotalAmount = receiptMID.SumReceipt - receiptMID.SumBonus - receiptMID.SumDiscount,
                CustomerId  = new Client(receiptMID.CodeClient).ClientId,
                CreatedAt   = receiptMID.DateCreate,
                UpdatedAt   = receiptMID.DateReceipt,

                //ReceiptItems=
                //Customer /// !!!TMP Модель клієнта
                //PaymentInfo
            };
            var listReceiptItem = GetReceiptItem(receiptMID.Wares, pIsDetail); //GetReceiptItem(pReceipt);
            var Res             = new ReceiptViewModel(receipt, listReceiptItem, null, null)
            {
                CustomId = receiptMID.NumberReceipt1C
            };

            if (receiptMID.Payment != null && receiptMID.Payment.Count() > 0)
            {
                Res.PaidAmount = receiptMID.Payment.Sum(r => receipt.Amount);
                var SumCash = receiptMID.Payment.Where(r => r.TypePay == eTypePay.Cash).Sum(r => receipt.Amount);
                var SumCard = receiptMID.Payment.Where(r => r.TypePay == eTypePay.Card).Sum(r => receipt.Amount);
                Res.PaymentType = (SumCash > 0 && SumCard > 0 ? PaymentType.Card | PaymentType.Card : (SumCash == 0 && SumCard == 0 ? PaymentType.None : (SumCash > 0 ? PaymentType.Cash : PaymentType.Card)));
                Res.PaymentInfo = PaymentToReceiptPayment(receiptMID.Payment.First());
            }

            if (receiptMID.ReceiptEvent != null && receiptMID.ReceiptEvent.Count() > 0)
            {
                Res.ReceiptEvents = receiptMID.ReceiptEvent.Select(r => GetReceiptEvent(r)).ToList();
            }
            if (pIsDetail)
            {
                Bl.GenQRAsync(receiptMID.Wares);
            }
            return(Res);
        }
Exemplo n.º 16
0
 override public async Task <LogRRO> PrintXAsync(IdReceipt pIdR)
 {
     Init();
     SetError(M304.XReportAsync() != 1);
     Done();
     return(new LogRRO(pIdR)
     {
         CodeError = CodeError, Error = StrError, SUM = 0, TypeRRO = "Maria304", TypeOperation = eTypeOperation.XReport
     });
 }
Exemplo n.º 17
0
        public virtual Receipt GetLastReceipt(IdReceipt parIdReceipt)
        {
            var r = this.db.Execute <IdReceipt, Receipt>(SqlGetLastReceipt, parIdReceipt);

            if (r != null && r.Count() == 1)
            {
                return(r.First());
            }
            return(null);
        }
Exemplo n.º 18
0
 public override bool UpdateClient(IdReceipt parIdReceipt, int parCodeClient)
 {
     using (var DB = new SQLite(ReceiptFile))
     {
         lock (GetObjectForLockByIdWorkplace(parIdReceipt.IdWorkplace))
         {
             return(DB.ExecuteNonQuery <IdReceipt>(SqlUpdateClient, parIdReceipt) > 0);
         }
     }
 }
Exemplo n.º 19
0
        public bool SendReceiptTo1C(IdReceipt parIdReceipt)
        {
            var ldb = new WDB_SQLite(parIdReceipt.DTPeriod);
            var r   = ldb.ViewReceipt(parIdReceipt, true);


#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            SendReceiptTo1CAsync(r, ldb);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            return(true);
        }
Exemplo n.º 20
0
        public IdReceipt GetNewIdReceipt(int pIdWorkplace = 0, int pCodePeriod = 0)
        {
            var idReceip = new IdReceipt()
            {
                IdWorkplace = (pIdWorkplace == 0 ? Global.IdWorkPlace : pIdWorkplace), CodePeriod = (pCodePeriod == 0 ? Global.GetCodePeriod() : pCodePeriod)
            };

            curRecipt = new Receipt(db.GetNewReceipt(idReceip));
            db.RecalcPriceAsync(new IdReceiptWares(curRecipt));
            return(curRecipt);
        }
Exemplo n.º 21
0
 /// <summary>
 /// Вертає код Чека в зазначеному періоді
 /// </summary>
 /// <param name="parCodePeriod">Код періоду (201401 - січень 2014)</param>
 /// <returns>
 ///Повертає код чека
 ///</returns>
 public virtual IdReceipt GetNewReceipt(IdReceipt parIdReceipt)
 {
     lock (GetObjectForLockByIdWorkplace(parIdReceipt.IdWorkplace))
     {
         if (parIdReceipt.CodePeriod == 0)
         {
             parIdReceipt.CodePeriod = Global.GetCodePeriod();
         }
         parIdReceipt.CodeReceipt = this.db.ExecuteScalar <IdReceipt, int>(SqlGetNewReceipt, parIdReceipt);
     }
     return(parIdReceipt);
 }
Exemplo n.º 22
0
        public Client GetClientByPhone(IdReceipt idReceipt, string parPhone)
        {
            var r = db.FindClient(null, parPhone);

            if (r.Count() == 1)
            {
                var client = r.First();
                UpdateClientInReceipt(idReceipt, client);
                return(client);
            }
            return(null);
        }
Exemplo n.º 23
0
        public bool SetStateReceipt(IdReceipt pIdReceipt, eStateReceipt pStateReceipt)
        {
            if (pIdReceipt == null)
            {
                pIdReceipt = curRecipt;
            }
            var receipt = new Receipt(pIdReceipt)
            {
                StateReceipt = pStateReceipt, DateReceipt = DateTime.Now, UserCreate = GetUserIdbyWorkPlace(pIdReceipt.IdWorkplace)
            };

            return(db.CloseReceipt(receipt));
        }
Exemplo n.º 24
0
        public Receipt GetReceiptHead(IdReceipt idReceipt, bool parWithDetail = false)
        {
            DateTime Ldc = idReceipt.DTPeriod;

            if (Ldc == DateTime.Now.Date)
            {
                return(db.ViewReceipt(idReceipt, parWithDetail));
            }

            var ldb = new WDB_SQLite(Ldc);

            return(ldb.ViewReceipt(idReceipt, parWithDetail));
        }
Exemplo n.º 25
0
        private void UpdateClientInReceipt(IdReceipt idReceipt, Client parClient)
        {
            var RH = GetReceiptHead(idReceipt);

            RH.CodeClient      = parClient.CodeClient;
            RH.PercentDiscount = parClient.PersentDiscount;
            db.ReplaceReceipt(RH);
            if (Global.RecalcPriceOnLine)
            {
                db.RecalcPriceAsync(new IdReceiptWares(idReceipt));
            }
            _ = ds.GetBonusAsync(parClient, idReceipt.IdWorkplace);
        }
Exemplo n.º 26
0
        public IEnumerable <ReceiptWares> GetProductsByName(IdReceipt parReceipt, string parName, int parOffSet = -1, int parLimit = 10, int parCodeFastGroup = 0)
        {
            if (parReceipt == null)
            {
                parReceipt = curRecipt;
            }

            parName = parName.Trim();
            // Якщо пошук по штрихкоду і назва похожа на штрихкод або артикул
            if (!string.IsNullOrEmpty(parName))
            {
                var Reg = new Regex(@"^[0-9]{4,13}$");
                if (Reg.IsMatch(parName))
                {
                    if (parName.Length >= 8)
                    {
                        var w = AddWaresBarCode(parReceipt, parName);
                        if (w != null)
                        {
                            return new List <ReceiptWares> {
                                       w
                            }
                        }
                        ;
                    }
                    else
                    {
                        var ww = db.FindWares(null, null, 0, 0, 0, Convert.ToInt32(parName));
                        if (ww.Count() > 0)
                        {
                            return(ww);
                        }
                    }
                }
            }
            else
            {
                parName = null;
            }

            var r = db.FindWares(null, parName, 0, 0, parCodeFastGroup, -1, parOffSet, parLimit);

            if (r.Count() > 0)
            {
                return(r);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 27
0
        ////////////////// RC

        /// <summary>
        ///
        /// </summary>
        /// <param name="parIdReceipt"></param>
        /// <returns></returns>
        public override IdReceipt GetNewReceipt(IdReceipt parIdReceipt)
        {
            using (var DB = new SQLite(ReceiptFile))
            {
                lock (GetObjectForLockByIdWorkplace(parIdReceipt.IdWorkplace))
                {
                    if (parIdReceipt.CodePeriod == 0)
                    {
                        parIdReceipt.CodePeriod = Global.GetCodePeriod();
                    }
                    parIdReceipt.CodeReceipt = DB.ExecuteScalar <IdReceipt, int>(SqlGetNewReceipt, parIdReceipt);
                }
            }
            return(parIdReceipt);
        }
Exemplo n.º 28
0
 // Допоміжні методи
 /// <summary>
 /// Clears the receipt by receipt identifier.
 /// </summary>
 /// <param name="idReceipt">The identifier receipt.</param>
 /// <returns></returns>
 public bool ClearReceiptByReceiptId(IdReceipt idReceipt)
 {
     if (Receipts != null)
     {
         foreach (var el in Receipts)
         {
             if (el.Value != null && el.Value.Equals(idReceipt))
             {
                 Receipts[el.Key] = null;
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 29
0
        public virtual Receipt ViewReceipt(IdReceipt parIdReceipt, bool parWithDetail = false)
        {
            var res = this.db.Execute <IdReceipt, Receipt>(SqlViewReceipt, parIdReceipt);

            if (res.Count() == 1)
            {
                var r = res.FirstOrDefault();
                if (parWithDetail)
                {
                    r.Wares        = ViewReceiptWares(parIdReceipt, true);
                    r.Payment      = GetPayment(parIdReceipt);
                    r.ReceiptEvent = GetReceiptEvent(parIdReceipt);
                }
                return(r);
            }
            return(null);
        }
Exemplo n.º 30
0
 /// <summary>
 /// Внесення/Винесення коштів коштів.
 /// </summary>
 /// <param name="pSum"> pSum>0 - внесення</param>
 /// <returns></returns>
 override public async Task <LogRRO> MoveMoneyAsync(decimal pSum, IdReceipt pIdR = null)
 {
     return(await Task.Run(() =>
     {
         if (FpOpenPort())
         {
             FP.InOut(Convert.ToDouble(pSum));
             CheckResult();
             FP.OpenDrawer();
             FpClosePort();
         }
         return new LogRRO(pIdR)
         {
             CodeError = CodeError, Error = StrError, SUM = pSum, TypeRRO = "Maria304", TypeOperation = pSum > 0 ? eTypeOperation.MoneyIn : eTypeOperation.MoneyOut
         };
     }));
 }