Ejemplo n.º 1
0
 private void ButtonSaveChanges_Click(object sender, RoutedEventArgs e)
 {
     using (var repo = new TransactionRepo())
     {
         repo.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Updates Transaction View
 /// </summary>
 private void UpdateView()
 {
     using (var repo = new TransactionRepo())
     {
         transactionViewSource.Source = repo.GetAll();
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Event handler for the 'Add transaction' button
        /// </summary>
        /// <remarks>
        /// Fills a transaction and inserts it in the database </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ButtonAddTransaction_Click(object sender, RoutedEventArgs e)
        {
            if (!Utils.IsValid(TransactionGrid))
            {
                MessageBox.Show("Transaction is not valid");
                return;
            }

            // Get selected account
            Account selectedAccount;

            using (var repo = new AccountRepo())
            {
                selectedAccount = repo.GetAccountByConcept((String)AccountComboBox.SelectedItem);
            }

            // Creates transaction
            // TODO: this should use the Transaction created in the constructor
            Transaction transaction = new EF.Transaction()
            {
                Date = DatePicker.DisplayDate, Value = Convert.ToDecimal(textValue.Text), Concept = textConcept.Text, Account = selectedAccount
            };

            using (var repo = new TransactionRepo())
            {
                repo.Add(transaction);
            }

            this.Close();
        }
Ejemplo n.º 4
0
        public IActionResult TransactionDetails(int transactionID)
        {
            TransactionDetailsVM transaction = new TransactionRepo(db).GetTransactionDetails(transactionID, um.GetUserId(HttpContext.User));


            return(View(transaction));
        }
Ejemplo n.º 5
0
        public ActionResult TransactionSuccessful(string trxref, string reference)
        {
            Transaction Transaction      = new Transaction();
            string      UserId           = LoggedInUser.Id.ToString();
            List <Cart> CartTransactions = CartRepo.GetAll(x => x.CustomerId == UserId).ToList();

            foreach (var item in CartTransactions)
            {
                TransactionRepo.Add(new Transaction()
                {
                    AuctioneeId       = UserId,
                    BatchId           = item.Auction.BatchId,
                    BulkPurchase      = false,
                    DateOfTransaction = DateTime.Now,
                    Quantity          = item.Quantity,
                    TransactionType   = TransactionType.Auction,
                    TotalCost         = item.Auction.AuctionPrice * item.Quantity,
                });

                Batch batch = BatchRepo.Get(x => x.Id == item.Auction.BatchId);
                batch.QuantityAuctioned += item.Quantity;
                BatchRepo.Update(batch);
            }

            Guid[] ids = CartTransactions.Select(x => x.Id).ToArray();

            foreach (var item in ids)
            {
                CartRepo.Delete(item);
            }



            return(View());
        }
Ejemplo n.º 6
0
        private static Account GetTestSubject(TransactionRepo transactionRepo)
        {
            var mockConsole = new Mock <IConsole>();
            var subject     = new Account(transactionRepo, mockConsole.Object);

            return(subject);
        }
        private void initTransaction()
        {
            var transaction = TransactionRepo.retrieveTransactionToday(DateTime.Now.ToString("d"));

            if (transaction.Count > 0)
            {
                for (int i = 0; i < transaction.Count; i++)
                {
                    ListViewItem listViewItem = new ListViewItem(transaction[i].TransactionId.ToString());
                    listViewItem.SubItems.Add(transaction[i].TransactionAmountReceived.ToString());
                    listViewItem.SubItems.Add(transaction[i].TransactionAmountReturned.ToString());
                    listViewItem.SubItems.Add(transaction[i].TransactionNewAmountReturned.ToString());
                    listViewItem.SubItems.Add(transaction[i].TransactionSubTotal.ToString());
                    listViewItem.SubItems.Add(transaction[i].TransactionDate);
                    listViewItem.SubItems.Add(transaction[i].TransactionTime);
                    listViewItem.SubItems.Add(transaction[i].Transaction_Status);
                    listViewItem.SubItems.Add(transaction[i].Transaction_Remarks);
                    listViewItem.SubItems.Add(transaction[i].TransactionCustomer);
                    listViewItem.SubItems.Add(transaction[i].TransactionCashier);
                    listViewItem.SubItems.Add(transaction[i].TransactionDateModified);
                    listViewItem.SubItems.Add(transaction[i].TransactionTimeModified);

                    lvTransaction.Items.Add(listViewItem);
                }
            }
        }
Ejemplo n.º 8
0
        public void GetStatementTransactions_ThreeTransactions_TransactionsShowInResult()
        {
            var amount1         = 1000;
            var amount2         = 2000;
            var amount3         = 500;
            var closingBalance1 = 1000;
            var closingBalance2 = 3000;
            var closingBalance3 = 2500;


            var mockDateProvider = GetMockDateProviderWithDatesForAcceptanceTestScenario(out var transactionDate1, out var transactionDate2, out var transactionDate3);
            var transactionRepo  = new TransactionRepo(mockDateProvider.Object);

            var subject = GetTestSubject(transactionRepo);

            subject.Deposit(amount1);
            subject.Deposit(amount2);
            subject.Withdraw(amount3);

            var transactions = transactionRepo.GetStatementTransactions();

            Assert.AreEqual(3, transactions.Count);

            Assert.AreEqual(amount1, transactions[0].Amount);
            Assert.AreEqual(transactionDate1, transactions[0].Date);
            Assert.AreEqual(closingBalance1, transactions[0].ClosingBalance);

            Assert.AreEqual(amount2, transactions[1].Amount);
            Assert.AreEqual(transactionDate2, transactions[1].Date);
            Assert.AreEqual(closingBalance2, transactions[1].ClosingBalance);

            Assert.AreEqual(amount3, transactions[2].Amount);
            Assert.AreEqual(transactionDate3, transactions[2].Date);
            Assert.AreEqual(closingBalance3, transactions[2].ClosingBalance);
        }
Ejemplo n.º 9
0
        private void submitBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //dictionary to map an item to its quantity in this transaction
                Dictionary <Item, int> itemToQuantity = new Dictionary <Item, int>();
                foreach (TillDataRow tdr in ItemDisplayDatGrd.Items)
                {
                    itemToQuantity.Add(tdr.Item, tdr.Quantity);
                }

                using (var tRepo = new TransactionRepo(new InventoryContext()))
                {
                    tRepo.AddNewTransaction(itemToQuantity);
                    tRepo.Complete();
                }

                //it worked
                MessageBox.Show("Transaction added");
                ClearAll();
            }
            catch (Exception)
            {
                MessageBox.Show("An error occured. Try again");
            }
        }
Ejemplo n.º 10
0
        public ProfitsForProduct GetProfitForProduct(Guid productId, Expression <Func <Transaction, bool> > TransactionPredicate = null)
        {
            Product           Product       = ProductRepo.Get(x => x.Id == productId);
            ProfitsForProduct ProfitRecords = new ProfitsForProduct();

            ProfitRecords.Product = Product;

            Transaction[] TransactionsForProduct = TransactionPredicate == null?
                                                   TransactionRepo.GetAll(x => x.Batch.ProductId == productId).OrderBy(x => x.DateOfTransaction).ToArray() :
                                                       TransactionRepo.GetAll(x => x.Batch.ProductId == productId).Where(TransactionPredicate).OrderBy(x => x.DateOfTransaction).ToArray();

            Dictionary <int, Dictionary <Month, double> > ProfitsPerYear = new Dictionary <int, Dictionary <Month, double> >();

            ProfitsPerYear = GroupProfitsPerYear(TransactionsForProduct);

            foreach (var item in ProfitsPerYear)
            {
                int Year = item.Key;
                Dictionary <Month, double> ProfitsPerMonth = item.Value;
                ProfitRecords.ProfitsForProductInYear.Add(new ProfitsForProductInYear()
                {
                    Year            = Year,
                    ProfitsPerMonth = ProfitsPerMonth,
                });
            }


            return(ProfitRecords);
        }
        public TransactionsForProduct GetTransactionsForProduct(Guid productId, out Dictionary <int, Dictionary <Month, double> > TurnoverPerYear, Expression <Func <Transaction, bool> > TransactionPredicate = null)
        {
            Product Product = ProductRepo.Get(x => x.Id == productId);

            TransactionsForProduct TransactionsRecords = new TransactionsForProduct();

            Batch[] ProductInStoreRecords = BatchRepo.GetAll(x => x.ProductId == productId).ToArray();
            Guid[]  ProductInStoreIds     = ProductInStoreRecords.Select(x => x.Id).ToArray();

            Transaction[] TransactionsForProduct = TransactionPredicate == null?TransactionRepo.GetAll(x => x.Batch.ProductId == productId).OrderBy(x => x.DateOfTransaction).ToArray() : TransactionRepo.GetAll(x => x.Batch.ProductId == productId).Where(TransactionPredicate).OrderBy(x => x.DateOfTransaction).ToArray();

            Dictionary <int, Dictionary <Month, double> > TransactionsPerYear = new Dictionary <int, Dictionary <Month, double> >();

            TransactionsPerYear = GroupTransactionsPerYear(TransactionsForProduct, out TurnoverPerYear);

            if (TransactionsPerYear != null)
            {
                foreach (var item in TransactionsPerYear)
                {
                    int Year = item.Key;
                    Dictionary <Month, double> TransactionsPerMonth = item.Value;
                    TransactionsRecords.TransactionsForProductInYear.Add(new TransactionsForProductInYear()
                    {
                        Year = Year, TransactionsPerMonth = TransactionsPerMonth
                    });
                }
                TransactionsRecords.Product = Product;

                return(TransactionsRecords);
            }

            return(null);
        }
 public void SetUp()
 {
     _paymentProvider = Substitute.For <IPaymentProvider>();
     _emailGateway    = Substitute.For <IEmailGateway>();
     _transactionRepo = Substitute.For <TransactionRepo>();
     _paymentService  = new PaymentService(_paymentProvider, _emailGateway, _transactionRepo);
     _customerId      = "Cust-2345";
 }
Ejemplo n.º 13
0
 public void Setup()
 {
     _console         = Substitute.For <Printer>();
     _statement       = Substitute.For <Statement>(_console);
     _transactionRepo = Substitute.For <TransactionRepo>(_statement);
     _printingVisitor = Substitute.For <StatementPrinter>();
     _account         = new BankAccount(_transactionRepo, _printingVisitor);
 }
Ejemplo n.º 14
0
 public void GivenAClientMakesADepositOfOn(decimal amount, string date)
 {
     _console         = Substitute.For <Printer>();
     _printingVisitor = new StatementPrinter();
     _transactionRepo = new TransactionRepo(new Statement(_console));
     _account         = new BankAccount(_transactionRepo, _printingVisitor);
     _account.Deposit(amount, date);
 }
Ejemplo n.º 15
0
        public IActionResult HandleTransaction(TransactionVM transVM)
        {
            TransactionRepo transRepo = new TransactionRepo(_context);

            transVM.amount_of_users = transVM.receivers.Count();
            transRepo.CreateTransaction(transVM);

            return(RedirectToAction("Profile"));
        }
Ejemplo n.º 16
0
 public ActionResult SaveTransaction(TransactionViewModel mdl)
 {
     if (TransactionRepo.SimpanTransaksi(mdl))
     {
         return(Json(new { hasil = "Berhasil" }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(new { hasil = "Gagal" }, JsonRequestBehavior.AllowGet));
     }
 }
        public ActionResult Index()
        {
            ViewBag.profits      = ProfitLogic.GetProfitForProducts(x => x.StoreId == LoggedInUser.StoreId).Sum(x => x.ProfitsForProductInYear.Sum(y => y.ProfitsPerMonth.Sum(z => z.Value)));
            ViewBag.sales        = SalesL.GetSalesForProducts(x => x.StoreId == LoggedInUser.StoreId).Sum(x => x.TransactionsForProductInYear.Sum(y => y.TransactionsPerMonth.Sum(z => z.Value)));
            ViewBag.transactions = TransactionRepo.GetAll(x => x.Batch.Product.StoreId == LoggedInUser.StoreId).Count();
            ViewBag.products     = ProductRepo.GetAll(x => x.StoreId == LoggedInUser.StoreId).Count();

            ProfitLogic.GetProfitForProducts(x => x.StoreId == LoggedInUser.StoreId);

            return(View());
        }
Ejemplo n.º 18
0
        public static void CheckOut(int userID, int paymentTypeID)
        {
            List <Cart> cartlist      = CartRepo.getListCartByID(userID);
            int         transactionID = TransactionRepo.insertHeaderTransaction(userID, paymentTypeID);

            foreach (Cart cart in cartlist)
            {
                TransactionRepo.insertDetailTransaction(transactionID, cart.ProductID, cart.Quantity);
            }
            CartRepo.deleteAllCart(userID);
        }
 public ActionResult SaveTransaction(TransactionViewModel mdl)
 {
     if (TransactionRepo.SimpanTransaksi(mdl))
     {
         return(Json(new { hasil = "Berhasil" }, JsonRequestBehavior.AllowGet)); //return json digunakan untuk memunculkan alert
     }
     else
     {
         return(Json(new { hasil = "Gagal" }, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 20
0
        public ViewTransactionsPageVM()
        {
            //assigns default values to display
            using (var TRepo = new TransactionRepo(new InventoryContext()))
            {
                Transactions = TRepo.AllTransactionsIncludeItemTransaction();
                TRepo.Complete();
            }

            //Default values from first transaction from db
            SelectionChanged(Transactions[0]);
        }
Ejemplo n.º 21
0
 public StoreSupServiceImpl(AdjustmentVoucherRepo avrepo, EmployeeRepo erepo, PurchaseRequestRepo purreqrepo,
                            PurchaseOrderRepo porepo, SupplierRepo srepo, CollectionPointRepo crepo, IMailer mailservice, PurchaseOrderDetailRepo podrepo, TransactionRepo trepo)
 {
     this.avrepo      = avrepo;
     this.erepo       = erepo;
     this.purreqrepo  = purreqrepo;
     this.porepo      = porepo;
     this.srepo       = srepo;
     this.crepo       = crepo;
     this.mailservice = mailservice;
     this.podrepo     = podrepo;
     this.trepo       = trepo;
 }
Ejemplo n.º 22
0
        public static Boolean isPaymentTypeReferenced(int PaymentID)
        {
            HeaderTransaction ht = TransactionRepo.getHeaderTransactionByPaymentID(PaymentID);

            if (ht == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        public List <Transaction> FetchCompletedAuctionTransactionsForBatch(Guid productInStoreId)
        {
            IEnumerable <Transaction> AllRecords            = TransactionRepo.GetAll(x => x.BatchId == productInStoreId && x.TransactionType == TransactionType.Auction);
            List <Transaction>        CompletedTransactions = new List <Transaction>();

            foreach (var item in AllRecords)
            {
                AuctionTransactionStatus StateRecord = AuctionTransactionStatusRepo.Get(x => x.TransactionId == item.Id);
                if (StateRecord.Status == AuctionState.Compleete)
                {
                    CompletedTransactions.Add(item);
                }
            }
            return(CompletedTransactions);
        }
Ejemplo n.º 24
0
        public static void insertTransaction(List <Cart> carts, int paymentTypeID, int UserID)
        {
            TransactionRepo.addHeaderTransaction(TransactionFactory.createHeaderTransaction(UserID, paymentTypeID));
            int transactionId = TransactionRepo.getLastTransactionID();

            for (int i = 0; i < carts.Count; i++)
            {
                Product product = ProductHandler.get(carts[i].ProductID);
                if (carts[i].Quantity <= product.Stock)
                {
                    ProductHandler.updateProductStock(carts[i].ProductID, carts[i].Quantity);
                    TransactionRepo.addDetailTransaction(TransactionFactory.createDetailTransaction(transactionId, carts[i].ProductID, carts[i].Quantity));
                }
            }
        }
Ejemplo n.º 25
0
        public void AcceptanceTest_PrintsStatement()
        {
            var mockConsole      = new Mock <IConsole>();
            var mockDateProvider = TransactionRepoTests.GetMockDateProviderWithDatesForAcceptanceTestScenario(out var transactionDate1, out var transactionDate2, out var transactionDate3);
            var transactionRepo  = new TransactionRepo(mockDateProvider.Object);
            var account          = new Account(transactionRepo, mockConsole.Object);

            account.Deposit(1000);
            account.Deposit(2000);
            account.Withdraw(500);
            account.PrintStatement();
            mockConsole.Verify(m => m.WriteLine("Date       || Amount || Balance"), Times.Once);
            mockConsole.Verify(m => m.WriteLine("14/01/2012 || -500 || 2500"), Times.Once);
            mockConsole.Verify(m => m.WriteLine("13/01/2012 || 2000 || 3000"), Times.Once);
            mockConsole.Verify(m => m.WriteLine("10/01/2012 || 1000 || 1000"), Times.Once);
        }
Ejemplo n.º 26
0
        public AllRepos(string ConnectionString)
        {
            AddressRepo.SetInstance(ConnectionString);
            TraderRepo.SetInstance(ConnectionString);
            Repos.ItemRepo.SetInstance(ConnectionString);
            TagAssocRepo.SetInstance(ConnectionString);
            TagRepo.SetInstance(ConnectionString);
            TransactionRepo.SetInstance(ConnectionString);


            Address      = AddressRepo.GetInstance();
            Traders      = TraderRepo.GetInstance();
            Items        = Repos.ItemRepo.GetInstance();
            TagAssoc     = TagAssocRepo.GetInstance();
            Tags         = TagRepo.GetInstance();
            Transactions = TransactionRepo.GetInstance();
        }
Ejemplo n.º 27
0
        private void TransactionsDisplay_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //update dataContext w/ new transaction

            //datagrid display transactionID = 1 in index = 0; therefor + 1
            int selectedTransactionID = TransactionsDisplay.SelectedIndex + 1;

            Transaction selectedTransaction;

            using (var TRepo = new TransactionRepo(new InventoryContext()))
            {
                selectedTransaction = TRepo.GetByID(selectedTransactionID, "ItemTransactions");
                TRepo.Complete();
            }

            dataContext.SelectionChanged(selectedTransaction);
            UpdateAll();
        }
Ejemplo n.º 28
0
        public void InsertTransactionHistory()
        {
            var transactionRepo = new TransactionRepo();

            var log = new TransactionLog
            {
                Type        = TransactionType.SuccessfulPurchase,
                PlayerName  = "Lionel Messi",
                SearchPrice = 150000,
                //SellPrice = 175000,
                TransactionDate = DateTime.Now,
                UserName        = "******"
            };

            transactionRepo.InsertTransactionLog(log);

            Assert.IsTrue(log.TransactionId.Length > 0);
        }
Ejemplo n.º 29
0
        static void Main(string[] args)
        {
            var itemTransactionDisplays = new List <ItemTransactionDisplay>();

            using (var tRepo = new TransactionRepo(new InventoryContext()))
            {
                Transaction transction = tRepo.AllTransactionsIncludeItemTransaction().ToList()[24];

                itemTransactionDisplays = ItemTransactionDisplay.GetRange(transction.ItemTransactions);
            }

            itemTransactionDisplays.ForEach(itd => Console.WriteLine(string.Format("Barcode: {0}, Description: {1}, RRP: {2}, Quantity: {3}"
                                                                                   , itd.Barcode
                                                                                   , itd.Description
                                                                                   , itd.RRP
                                                                                   , itd.Quantity)));

            NoF5Needed();
        }
Ejemplo n.º 30
0
        public IActionResult Profile()
        {
            //get current users total balance
            string          userId       = User.getUserId();
            TransactionRepo TransRepo    = new TransactionRepo(_context);
            decimal         totalBalance = TransRepo.GetTotalBalance(userId);
            //get all other roommates
            RoomieRepo             roomieRepo = new RoomieRepo(_context);
            IEnumerable <Roommate> roommates  = roomieRepo
                                                .GetAllOtherRoommates(userId);
            //create and fill VMs
            //get current user name
            Roommate         currentSignedInUser = roomieRepo.GetRoommate(userId);
            RoomieAndBalance currentUser         = new RoomieAndBalance()
            {
                Balance  = totalBalance,
                Roommate = currentSignedInUser
            };
            ProfilePageVM ppvm = new ProfilePageVM()
            {
                CurrentUser          = currentUser,
                RoomiesRelationships = new List <RoomieAndBalance>(),
            };

            //get all other balances with roomies, put them into a VM,
            //which then goes into another bigger VM
            if (roommates != null)
            {
                foreach (var roomie in roommates)
                {
                    decimal relationshipBalance =
                        TransRepo.GetIndividualRelationshipBalance(userId, roomie.RoommateId);
                    RoomieAndBalance roomieAndBalance = new RoomieAndBalance()
                    {
                        Roommate = roomie,
                        Balance  = relationshipBalance
                    };
                    ppvm.RoomiesRelationships.Add(roomieAndBalance);
                }
            }
            return(View(ppvm));
        }