Ejemplo n.º 1
0
        private IList <ICategory> GetAllCategoriesToBon(IReceipt bon)
        {
            string            sql    = "SELECT kat.Kategorie, kat.ID FROM [BonKategorien] zuordnung join[Kategorien] kat on zuordnung.ID_Kategorie = kat.ID WHERE zuordnung.ID_Bon = " + bon.ID.ToString();
            IList <ICategory> retval = new List <ICategory>();
            SqlDataReader     reader;

            try
            {
                var cmd = new SqlCommand(sql, con);
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    var    b    = reader["Kategorie"];
                    string name = b as string;

                    var id       = reader["ID"];
                    int idAlsInt = (int)id;

                    retval.Add(_categories.Where(x => x.ID.Equals(idAlsInt)).FirstOrDefault());
                }

                reader.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("Fail", ex);
            }
            retval = retval.OrderBy(x => x.Name).ToList();
            return(retval);
        }
Ejemplo n.º 2
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                IReceipt receiptItem = item.As <IReceipt>();

                if (((receiptItem != null) &&
                     this._parent.Receipts.Remove(receiptItem)))
                {
                    return(true);
                }
                if ((this._parent.Vendor == item))
                {
                    this._parent.Vendor = null;
                    return(true);
                }
                ITransaction transactionItem = item.As <ITransaction>();

                if (((transactionItem != null) &&
                     this._parent.Transactions.Remove(transactionItem)))
                {
                    return(true);
                }
                if ((this._parent.MerchantAccount == item))
                {
                    this._parent.MerchantAccount = null;
                    return(true);
                }
                return(false);
            }
Ejemplo n.º 3
0
 public void GenerateRecipt()
 {
     recipt  = ReciptFactory.ReciptFact(ReciptType.duplicate.ToString());
     payment = PaymentFactory.PaymentFact("agent");
     Console.WriteLine(recipt.GenerateRecipt());
     Console.WriteLine(payment.GenerateComission());
 }
Ejemplo n.º 4
0
        private void SaveCategoriesToBon(IReceipt bon)
        {
            // Delete:
            string delCat = "DELETE FROM BonKategorien WHERE ID_Bon = " + bon.ID.ToString();

            // SqlDataReader reader;
            try
            {
                SqlCommand cmd = new SqlCommand(delCat, con);
                cmd.ExecuteNonQuery();
            }
            catch
            {
                throw new Exception("Fehler beim LÖschen der Kategorien zu Bon Nr. " + bon.ID.ToString());
            }

            // Insert:
            string insertSQL;

            foreach (ICategory cat in bon.Categories)
            {
                insertSQL = "INSERT INTO BonKategorien ([ID_Bon] ,[ID_Kategorie]) Values (" + bon.ID.ToString() + ", " + cat.ID.ToString() + ")";

                try
                {
                    var cmd = new SqlCommand(insertSQL, con);

                    cmd.ExecuteNonQuery();
                }
                catch
                {
                    throw new Exception("Fehler beim Hinzufügen der Kategorien zu Bon Nr. " + bon.ID.ToString());
                }
            }
        }
Ejemplo n.º 5
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IReceipt receiptsCasted = item.As <IReceipt>();

                if ((receiptsCasted != null))
                {
                    this._parent.Receipts.Add(receiptsCasted);
                }
                if ((this._parent.Vendor == null))
                {
                    IVendor vendorCasted = item.As <IVendor>();
                    if ((vendorCasted != null))
                    {
                        this._parent.Vendor = vendorCasted;
                        return;
                    }
                }
                ITransaction transactionsCasted = item.As <ITransaction>();

                if ((transactionsCasted != null))
                {
                    this._parent.Transactions.Add(transactionsCasted);
                }
                if ((this._parent.MerchantAccount == null))
                {
                    IMerchantAccount merchantAccountCasted = item.As <IMerchantAccount>();
                    if ((merchantAccountCasted != null))
                    {
                        this._parent.MerchantAccount = merchantAccountCasted;
                        return;
                    }
                }
            }
Ejemplo n.º 6
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                if ((this._parent.Cashier == null))
                {
                    ICashier cashierCasted = item.As <ICashier>();
                    if ((cashierCasted != null))
                    {
                        this._parent.Cashier = cashierCasted;
                        return;
                    }
                }
                if ((this._parent.PointOfSale == null))
                {
                    IPointOfSale pointOfSaleCasted = item.As <IPointOfSale>();
                    if ((pointOfSaleCasted != null))
                    {
                        this._parent.PointOfSale = pointOfSaleCasted;
                        return;
                    }
                }
                IReceipt receiptsCasted = item.As <IReceipt>();

                if ((receiptsCasted != null))
                {
                    this._parent.Receipts.Add(receiptsCasted);
                }
                ITransaction transactionsCasted = item.As <ITransaction>();

                if ((transactionsCasted != null))
                {
                    this._parent.Transactions.Add(transactionsCasted);
                }
            }
Ejemplo n.º 7
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                if ((this._parent.Cashier == item))
                {
                    this._parent.Cashier = null;
                    return(true);
                }
                if ((this._parent.PointOfSale == item))
                {
                    this._parent.PointOfSale = null;
                    return(true);
                }
                IReceipt receiptItem = item.As <IReceipt>();

                if (((receiptItem != null) &&
                     this._parent.Receipts.Remove(receiptItem)))
                {
                    return(true);
                }
                ITransaction transactionItem = item.As <ITransaction>();

                if (((transactionItem != null) &&
                     this._parent.Transactions.Remove(transactionItem)))
                {
                    return(true);
                }
                return(false);
            }
Ejemplo n.º 8
0
        public void ManyYieldsSingleReceiveDelete()
        {
            IQueue q = _queue;

            List <Message> sm = new List <Message>();

            for (int i = 0; i < ManyYeildCount; i++)
            {
                sm.AddRange(YieldMessages());
            }

            sm.ForEach((m) => q.Send(m));

            List <Message> rm = new List <Message>();

            for (int i = 0; i < sm.Count * 2; i++)
            {
                IReceipt rt = q.Receive();

                if (rt != null)
                {
                    rm.Add(rt.GetMessage <Message>());
                    rt.Delete();
                }
            }

            AssertSentReceivedMessages(
                sm,
                rm);
        }
Ejemplo n.º 9
0
        public void SetOSAgainstReceiptItem(IReceipt pyi)
        {
            double qtyAmount = pyi.GET_AMOUNT;

            if (qtyAmount <= 0)
            {
                return;
            }
            if (AGAINST_RECEIPT_STATUS == AgainstStatus.Close)
            {
                throw new Exception("Invoice Item Allready Close :" + this.INVOICE_NO);
            }
            if (qtyAmount > OUTSTANDING_AMOUNT)
            {
                throw new Exception("Receipt Item Amount exceed SIJ Outstanding Item Amount :" + this.INVOICE_NO);
            }
            OUTSTANDING_AMOUNT = OUTSTANDING_AMOUNT - qtyAmount;
            RECEIPT_AMOUNT     = RECEIPT_AMOUNT + qtyAmount;
            if (isValidToClose())
            {
                AGAINST_RECEIPT_STATUS = AgainstStatus.Close;
            }
            else
            {
                AGAINST_RECEIPT_STATUS = AgainstStatus.Outstanding;
            }
            ((CustomerInvoiceJournal)EVENT_JOURNAL).UpdateAgainstReceiptStatusSIJ();
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Receipt == null))
     {
         IReceipt receiptCasted = item.As <IReceipt>();
         if ((receiptCasted != null))
         {
             this._parent.Receipt = receiptCasted;
             return;
         }
     }
     if ((this._parent.Cheque == null))
     {
         ICheque chequeCasted = item.As <ICheque>();
         if ((chequeCasted != null))
         {
             this._parent.Cheque = chequeCasted;
             return;
         }
     }
     if ((this._parent.Card == null))
     {
         ICard cardCasted = item.As <ICard>();
         if ((cardCasted != null))
         {
             this._parent.Card = cardCasted;
             return;
         }
     }
 }
Ejemplo n.º 11
0
 public static T GetMessage <T>(this IReceipt receipt) where T : IDictionary <string, string>, new()
 {
     using (XmlReader reader = XmlReader.Create(new StringReader(receipt.Message)))
     {
         return(reader.ReadMessage <T>());
     }
 }
Ejemplo n.º 12
0
        public BonViewModel(IReceipt bon, DBConnector dbConnection)
        {
            _DBConnection    = dbConnection;
            _bon             = bon;
            _user            = _bon.User;
            _payDate         = _bon.PayDate;
            _details         = _bon.Details;
            _amount          = bon.Amount;
            _settlementDate  = _bon.SettlementDate;
            _id              = _bon.ID;
            _settled         = _bon.Settled;
            _paymentType     = _bon.PaymentType;
            _payments        = _bon.Payments;
            _categoryAdapter = new CategoryAdapter(bon.Categories, dbConnection);

            Balance = false;
            LoadPaymentViewModels();

            NewPaymentCommand    = new ActionCommand(NewPayment, null);
            SaveBonCommand       = new ActionCommand(SaveBon, CanSaveBon);
            EditBonCommand       = new ActionCommand(EditBon, CanEditBon);
            LiftPayDateCommand   = new ActionCommand(LiftPayDate, null);
            ReducePayDateCommand = new ActionCommand(ReducePayDate, null);
            CanBeEdited          = false;
        }
Ejemplo n.º 13
0
        private void SaveCurrentBon()
        {
            //CurrentBon.Save();
            IReceipt bon = CurrentBon.Bon;

            int id = _DBConnection.SaveBon(bon);
            // CurrentBon = null;
        }
Ejemplo n.º 14
0
        public IReceipt Buy()
        {
            NotifyObservers();
            IReceipt receipt = _payStationFactory.CreateReceipt(_minutes);

            Reset();
            return(receipt);
        }
Ejemplo n.º 15
0
        private static IReceipt ToCancelReceipt(IReceipt existingReceipt, CancelReceipt request)
        {
            var receipt = ((Receipt.Repository.OrmLite.Receipt)existingReceipt).CreateCopy();

            receipt.Status = (int)ReceiptStatusConstant.Cancelled;
            receipt.Note   = request.Note;
            return(receipt);
        }
Ejemplo n.º 16
0
        private IReceipt ToPayReceipt(IReceipt existingReceipt, PayReceipt request)
        {
            var receipt = ((Repository.Receipt)existingReceipt).CreateCopy();

            receipt.Status = (int)ReceiptStatusConstant.Paid;
            receipt.Note   = request.Note;
            return(receipt);
        }
Ejemplo n.º 17
0
 public string BuildHtmlReceipt(IReceipt receipt)///(IHeader header, IList<IBody> body, IFooter footer)
 {
     return(_builder.Init()
            .BuildHeader(receipt.Header)
            .BuildBody(receipt.Groceries)
            .BuildFooter(receipt.Footer)
            .BuildTemplate()
            .GetResult());
 }
Ejemplo n.º 18
0
 public IReceiptBuilder Init()
 {
     _receipt   = new Receipt();
     _groceries = new List <IBody>();
     _header    = new StringBuilder();
     _body      = new StringBuilder();
     _footer    = new StringBuilder();
     return(this);
 }
Ejemplo n.º 19
0
        public ReceiptCalculatorTests()
        {
            _container = Bootstrapper.Bootstrap();
            var shoppingCartsRepository = _container.GetService <IShoppingCartsRepository>();
            var shoppingCart            = shoppingCartsRepository.GetShoppingCart(Ids.ShoppingCartId);
            var receiptCalculator       = _container.GetService <IReceiptCalculator>();

            _receipt = receiptCalculator.CalculateReceipt(shoppingCart);
        }
        public void ShouldResetDisplayWhenBuying()
        {
            _ps.AddPayment(25);
            Assert.That(_ps.ReadDisplay(), Is.EqualTo(1010));
            IReceipt receipt = _ps.Buy();

            Assert.That(_ps.ReadDisplay(), Is.EqualTo(1000));
            Assert.That(receipt.Value(), Is.EqualTo(10));
        }
Ejemplo n.º 21
0
 public BusinessLogic(ILogger logger, IReceipt receipt, IDataAccess dataAccess, IShoppingCart shoppingCart)
 {
     if (logger == null || receipt == null || dataAccess == null || shoppingCart == null)
     {
         throw new ArgumentNullException();
     }
     _logger       = logger;
     _receipt      = receipt;
     _dataAccess   = dataAccess;
     _shoppingCart = shoppingCart;
 }
        public void ShouldProduceValidReceiptWhenBuying(int[] coins, int minutes)
        {
            foreach (var coin in coins)
            {
                _ps.AddPayment(coin);
            }
            IReceipt receipt = _ps.Buy();

            Assert.That(receipt, Is.Not.Null);
            Assert.That(receipt.Value(), Is.EqualTo(minutes));
        }
Ejemplo n.º 23
0
        public void UnSetOSAgainstReceiptItem(IReceipt grni)
        {
            double qtyAmount = grni.GET_AMOUNT;

            if (qtyAmount > this.AMOUNT || OUTSTANDING_AMOUNT + qtyAmount > this.AMOUNT)
            {
                throw new Exception("Receipt Item revise Amount exceed SIJ Item Amount :" + this.INVOICE_NO);
            }
            OUTSTANDING_AMOUNT = OUTSTANDING_AMOUNT + qtyAmount;
            RECEIPT_AMOUNT     = RECEIPT_AMOUNT - qtyAmount;
            if (OUTSTANDING_AMOUNT > 0)
            {
                AGAINST_RECEIPT_STATUS = AgainstStatus.Outstanding;
            }
            ((CustomerInvoiceJournal)EVENT_JOURNAL).UpdateAgainstReceiptStatusSIJ();
        }
Ejemplo n.º 24
0
        private void CalculateTotals(IReceipt receipt)
        {
            var productTotal = 0m;
            var taxTotal     = 0m;

            foreach (var item in receipt.ShoppingCart.Items)
            {
                productTotal += item.Product.Price * item.Quantity;
                foreach (var tax in item.Taxes)
                {
                    taxTotal += tax.Value;
                }
            }
            receipt.Total    = productTotal + taxTotal;
            receipt.TaxTotal = receipt.Total - productTotal;
        }
Ejemplo n.º 25
0
        public ChatWindow(IInputManager inputManager, IGuiFrame chatFrame)
        {
            if (inputManager == null)
            {
                throw new ArgumentNullException("inputManager");
            }

            SetupSlashCommands();

            mChatFrame = chatFrame;

            mChatEntryBox = mChatFrame.SelectSingleElement <Textbox>("ChatEntryTextbox");

            //mChatLogFrame = (mChatFrame.SelectSingleElement<TabButton>("BottomLeftTabView/ButtonsFrame/ChatLogTab")).Frame;
            //mLocalChatPrototype = mChatLogFrame.SelectSingleElement<Textbox>("**/MyMessages");

            //mChatLogFrame.RemoveChildWidget(mLocalChatPrototype);

            Hangout.Shared.Action chatSend = delegate()
            {
                // Get chat from text entry box, and clear it
                String chatText = mChatEntryBox.Text;
                mChatEntryBox.Text = "";

                Hangout.Shared.Action slashCommand;
                if (mSlashCommands.TryGetValue(chatText, out slashCommand))
                {
                    slashCommand();
                }
                else
                {
                    // Filter out empty string
                    if (chatText != "")
                    {
                        // Dispatch chat event.  This will get picked up by SendChatCommand
                        object[] args = { chatText };
                        GameFacade.Instance.SendNotification(GameFacade.SEND_CHAT, args);
                    }
                }
            };

            mInputReceiptReturn = inputManager.RegisterForButtonDown(KeyCode.Return, chatSend);
            // If numlock is down, some laptops send this event instead
            mInputReceiptEnter = inputManager.RegisterForButtonDown(KeyCode.KeypadEnter, chatSend);
        }
Ejemplo n.º 26
0
        // Make an immediate call to Javascript that bypasses our list of allowed functions
        // and will never be deferred until later.  Use this only if the call needs to
        // occur before mAllowedCalls is populated.
        private IReceipt MakeForcedJSCall(string func, List <object> argList, Action <string> callbackFunc)
        {
            bool forcedKey = false;

            if (!mAllowedCalls.ContainsKey(func))
            {
                forcedKey = true;
                mAllowedCalls.Add(func, true);
            }

            IReceipt rec = MakeJSCall(func, argList, callbackFunc);

            if (forcedKey)
            {
                mAllowedCalls.Remove(func);
            }

            return(rec);
        }
Ejemplo n.º 27
0
        public void StartListeningForInput()
        {
            if (!mInputStarted)
            {
                mInputStarted = true;
                mInputManager.StartInput();

                mRegisterForMouseDownReceipt     = mInputManager.RegisterForButtonDown(KeyCode.Mouse0, MouseDown);
                mRegisterForMouseUpReceipt       = mInputManager.RegisterForButtonUp(KeyCode.Mouse0, MouseUp);
                mRegisterForMousePositionReceipt = mInputManager.RegisterForMousePosition(MousePosition);

                if (Application.isEditor)
                {
                    mInputManager.RegisterForButtonDown(KeyCode.Semicolon, delegate()
                    {
                        GameFacade.Instance.RetrieveMediator <FashionLevel>().ReloadStationPositions();
                    });
                }
            }
        }
Ejemplo n.º 28
0
        public Motor(LocalAvatarEntity localAvatarEntity)
        {
            mLocalAvatarEntity = localAvatarEntity;
            GameObject gameObjectToMotorize = localAvatarEntity.UnityGameObject;

            if (gameObjectToMotorize == null)
            {
                throw new ArgumentNullException("gameObjectToMotorize");
            }

            mRigidBody = gameObjectToMotorize.GetComponent(typeof(Rigidbody)) as Rigidbody;
            if (mRigidBody == null)
            {
                mRigidBody = gameObjectToMotorize.AddComponent(typeof(Rigidbody)) as Rigidbody;
            }

            mScheduler = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler;

            mCollisionReceipt = CollisionUtility.ListenForCollisions(mRigidBody, StopMovingWhenHitGround);
        }
        /// <summary>
        /// Schliesst die Zahlung ab, sofern genug Geld eingeworfen wurde.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _btnFertig_Click(object sender, RoutedEventArgs e)
        {
            GasPump selectedGasPump = (GasPump)GasPumpComboBox.SelectedItem;

            int[] outputCoins = new int[1];
            try
            {
                outputCoins = Context.FinishInput(selectedGasPump);
                if (outputCoins[0] == -1)
                {
                    _tbxAnzeige.Text += $"\r\nEs wurde noch zu wenig Geld eingeworfen. Es fehlen noch {selectedGasPump.ToPayValue - decimal.Parse(Context.GetValueInput().ToString()) / 100} Franken.";
                }
                else
                {
                    _tbxAnzeige.Text += "\r\nAusgabe:\r\n";
                    RenderNumberOfCoins(outputCoins);
                    DisableButtons();

                    IReceipt receipt = Context.CreateReceipt(selectedGasPump);
                    selectedGasPump.ToPayValue = 0;
                    ReceiptDisplay receiptDisplay = new ReceiptDisplay();
                    receiptDisplay.Context = receipt;
                    receiptDisplay.Show();
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.StartsWith("Es kann leider kein Rückgeld gegeben werden."))
                {
                    MessageService.AddWarningMessage("Fehler", $"{ex.Message}\r\n{ex.Source}\r\n{ex.StackTrace}");
                }
                else
                {
                    MessageService.AddErrorMessage("Fehler", ex.Message);
                }
                return;
            }
        }
Ejemplo n.º 30
0
        private IList <IPayment> GetAllPaymentsToBon(IReceipt bon)
        {
            string           strSQL = "SELECT z.* from Zahlungen z join Bon b on b.ID = z.idBon WHERE z.idBon = " + bon.ID.ToString();
            IList <IPayment> retval = new List <IPayment>();
            SqlDataReader    reader;

            try
            {
                var cmd = new SqlCommand(strSQL, con);
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    var id       = reader["ID"];
                    int idAlsInt = (int)id;

                    var    c           = reader["Zahlungstyp"];
                    string paymentType = c as string;

                    double amount  = Convert.ToDouble(reader["Betrag"]);
                    string details = reader["Details"] as string;

                    IPayment payment = new Payment(idAlsInt, amount, details, paymentType);
                    retval.Add(payment);
                }

                reader.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("Fail", ex);
            }

            foreach (IPayment payment in retval)
            {
                payment.Categories = GetAllCategoriesToPayment(payment);
            }
            return(retval);
        }