コード例 #1
0
        public ModelMID.Receipt ReceiptViewModelToReceipt(Guid pTerminalId, ReceiptViewModel pReceiptRVM)
        {
            if (pReceiptRVM == null)
            {
                return(null);
            }
            RefundReceiptViewModel RefundRVM = null;

            if (pReceiptRVM is RefundReceiptViewModel)
            {
                RefundRVM = (RefundReceiptViewModel)pReceiptRVM;
            }


            var receipt = new ModelMID.Receipt(RefundRVM == null ? new IdReceipt(pReceiptRVM.Id) : Bl.GetNewIdReceipt(Global.GetIdWorkplaceByTerminalId(pTerminalId)))
            {
                //ReceiptId  = pReceiptRVM.Id,
                StateReceipt  = (string.IsNullOrEmpty(pReceiptRVM.FiscalNumber) ? (pReceiptRVM.PaymentInfo != null ? eStateReceipt.Pay : eStateReceipt.Prepare) : eStateReceipt.Print),
                TypeReceipt   = (RefundRVM == null ? eTypeReceipt.Sale : eTypeReceipt.Refund),
                NumberReceipt = pReceiptRVM.FiscalNumber,

                /* Status = (pReceiptRVM.SumCash > 0 || pReceiptRVM.SumCreditCard > 0
                 *   ? ReceiptStatusType.Paid
                 *   : ReceiptStatusType.Created), //!!!TMP Треба врахувати повернення*/
                TerminalId  = pReceiptRVM.TerminalId,
                SumReceipt  = pReceiptRVM.Amount, //!!!TMP Сума чека.
                SumDiscount = pReceiptRVM.Discount,
                //!!TMP TotalAmount = pReceiptRVM.SumReceipt - pReceiptRVM.SumBonus,
                ///CustomerId = new Client(pReceiptRVM.CodeClient).ClientId,
                DateCreate  = pReceiptRVM.CreatedAt,
                DateReceipt = (pReceiptRVM.UpdatedAt == default(DateTime) ? DateTime.Now : pReceiptRVM.UpdatedAt)
                              //ReceiptItems=
                              //Customer /// !!!TMP Модель клієнта
                              //PaymentInfo
            };

            if (RefundRVM != null)
            {
                receipt.RefundId = (RefundRVM.IdPrimary == null ? null : new IdReceipt(RefundRVM.IdPrimary));
            }

            if (pReceiptRVM.PaymentInfo != null)
            {
                receipt.Payment = new Payment[] { ReceiptPaymentToPayment(receipt, pReceiptRVM.PaymentInfo) }
            }
            ;

            if (pReceiptRVM.ReceiptItems != null)
            {
                receipt.Wares = pReceiptRVM.ReceiptItems.Select(r => GetReceiptWaresFromReceiptItem(receipt, r));
            }

            //if(pReceiptRVM.ReceiptEvents!=null)
            //    receipt.ReceiptEvent= pReceiptRVM.ReceiptEvent


            return(receipt);
        }
コード例 #2
0
 /// <summary>
 /// Gets the current receipt by terminal identifier.
 /// </summary>
 /// <param name="pTerminalId">The par terminal identifier.</param>
 /// <returns></returns>
 public ModelMID.IdReceipt GetCurrentReceiptByTerminalId(Guid pTerminalId)
 {
     if (!Receipts.ContainsKey(pTerminalId) || Receipts[pTerminalId] == null)
     {
         var idReceipt = Bl.GetNewIdReceipt(Global.GetIdWorkplaceByTerminalId(pTerminalId));
         Receipts[pTerminalId] = new ModelMID.Receipt(idReceipt);
         //Bl.AddReceipt(Receipts[pTerminalId]);
     }
     return(Receipts[pTerminalId]);
 }
コード例 #3
0
ファイル: ApiPSU.cs プロジェクト: OlehR/UniCS.TM
        public override bool MoveSessionToAnotherTerminal(Guid firstTerminalId, Guid secondTerminalId)
        {
            //Якщо чек незакрито на терміналі куди переносити тоді помилка.
            if (Receipts.ContainsKey(secondTerminalId) && Receipts[secondTerminalId] != null)
            {
                return(false);
            }
            var idReceipt = Bl.GetNewIdReceipt(Global.GetIdWorkplaceByTerminalId(secondTerminalId));

            if (Bl.MoveReceipt(GetCurrentReceiptByTerminalId(firstTerminalId), idReceipt))
            {
                Receipts[secondTerminalId] = new ModelMID.Receipt(idReceipt);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
ファイル: ApiPSU.cs プロジェクト: OlehR/UniCS.TM
        public override ReceiptViewModel GetNoFinishReceipt(Guid pTerminalId)
        {
            ReceiptViewModel Res = null;

            try
            {
                var receipt = Bl.GetLastReceipt(Global.GetIdWorkplaceByTerminalId(pTerminalId));
                if (receipt != null && receipt.StateReceipt == eStateReceipt.Prepare)
                {
                    Receipts[pTerminalId] = new ModelMID.Receipt(receipt);
                    Res = GetReceiptViewModel(receipt);
                }
                FileLogger.WriteLogMessage($"ApiPSU.GetNoFinishReceipt =>( pTerminalId=>{pTerminalId}) => ({Res?.ToJSON()})", eTypeLog.Full);
            }
            catch (Exception e)
            {
                FileLogger.WriteLogMessage($"ApiPSU.GetNoFinishReceipt Exception =>( pTerminalId=>{pTerminalId}) => (){Environment.NewLine}Message=>{e.Message}{Environment.NewLine}StackTrace=>{e.StackTrace}", eTypeLog.Error);
                throw new Exception("ApiPSU.GetNoFinishReceipt", e);
            }
            return(Res);
        }