예제 #1
0
        private void UpdateDisplayedLines()
        {
            DisplayedLines.Clear();

            using (var context = new ERPContext())
            {
                if (_selectedWarehouse.Name.Equals("All") && _selectedItem.Name.Equals("All"))
                {
                    DisplayAllItems(context);
                }

                else if (_selectedWarehouse.Name.Equals("All") && !_selectedItem.Name.Equals("All"))
                {
                    DisplaySelectedItemFromAllWarehouses(context);
                }

                else if (!_selectedWarehouse.Name.Equals("All") && _selectedItem.Name.Equals("All"))
                {
                    DisplayListedItemsFromSelectedWarehouse(context);
                }

                else
                {
                    DisplaySelectedItemFromSelectedWarehouse(context);
                }
            }

            UpdateUITotal();
        }
예제 #2
0
        private void ResetTransaction()
        {
            NewEntryVM.ResetEntryFields();
            NewEntryVM.NewEntryWarehouse = null;

            IsTransactionNotPaid             = true;
            NotEditMode                      = true;
            IsTransactionTaxCheckBoxSelected = false;

            Model = new PurchaseTransaction();
            TransactionSupplier = null;
            TransactionDOID     = null;
            TransactionTax      = 0;
            TransactionDiscount = 0;
            TransactionNote     = null;
            TransactionDate     = UtilityMethods.GetCurrentDate().Date;
            TransactionDueDate  = UtilityMethods.GetCurrentDate().Date;

            Warehouses.Clear();
            SupplierItems.Clear();
            DisplayedLines.Clear();
            UpdateSuppliers();

            OnPropertyChanged("TransactionGrossTotal");
            OnPropertyChanged("TransactionNetTotal");

            SetTransactionID();
        }
예제 #3
0
        private void SetEditMode(PurchaseTransaction transaction)
        {
            Model           = transaction;
            TransactionDOID = transaction.DOID;

            IsTransactionNotPaid             = transaction.Paid == 0;
            IsTransactionTaxCheckBoxSelected = Model.Tax > 0;

            UpdateSuppliers();
            _transactionSupplier = Suppliers.Single(supplier => supplier.ID.Equals(transaction.Supplier.ID));
            OnPropertyChanged("TransactionSupplier");

            TransactionDate    = transaction.Date;
            TransactionDueDate = transaction.DueDate;
            TransactionNote    = transaction.Note;

            DisplayedLines.Clear();
            foreach (var line in transaction.PurchaseTransactionLines.OrderBy(e => e.Item.Name).ThenBy(e => e.Warehouse.Name).ThenBy(e => e.PurchasePrice).ThenBy(e => e.Discount).ToList())
            {
                DisplayedLines.Add(new PurchaseTransactionLineVM {
                    Model = line
                });
            }

            OnPropertyChanged("TransactionGrossTotal"); // Updates transaction's net total too
            TransactionDiscount = transaction.Discount;
            TransactionTax      = transaction.Tax;
        }
예제 #4
0
        private void SetEditMode()
        {
            IsNotEditMode = false;
            NewEntryVM.ResetEntryFields();

            using (var context = new ERPContext())
            {
                var transactionFromDatabase = context.StockAdjustmentTransactions.Single(
                    transaction => transaction.StockAdjustmentTransactionID.Equals(_transactionID));
                TransactionDescription = transactionFromDatabase.Description;
                TransactionDate        = transactionFromDatabase.Date;

                var lines = context.StockAdjustmentTransactionLines
                            .Include("Item")
                            .Include("Warehouse")
                            .Where(line => line.StockAdjustmentTransactionID.Equals(_transactionID))
                            .OrderBy(line => line.Warehouse.Name)
                            .ThenBy(line => line.Item.Name);

                DisplayedLines.Clear();
                foreach (var line in lines)
                {
                    DisplayedLines.Add(new StockAdjustmentTransactionLineVM {
                        Model = line
                    });
                }
            }
        }
예제 #5
0
        private void UpdateDisplayedLines()
        {
            DisplayedLines.Clear();
            SetBeginningBalance();
            _endingBalance = _beginningBalance;
            using (var context = new ERPContext())
            {
                var lines = context.Ledger_Transaction_Lines
                            .Include("LedgerAccount")
                            .Include("LedgerTransaction")
                            .Where(line => line.LedgerAccount.Name.Equals("Cash") &&
                                   line.LedgerTransaction.Date.Equals(_date))
                            .ToList();

                var account = new LedgerAccount {
                    ID = -1, Name = "Sales Receipt", Class = "Asset"
                };
                var transaction = new LedgerTransaction {
                    ID = -1, Date = _date, Description = "Sales Receipt", Documentation = "Sales Receipt"
                };
                var salesreceiptLine = new LedgerTransactionLine {
                    LedgerTransaction = transaction, LedgerAccount = account, Seq = "Debit"
                };
                foreach (var line in lines)
                {
                    var lineVM = new LedgerTransactionLineVM {
                        Model = line
                    };
                    foreach (var oppositeLine in lineVM.OpposingLines)
                    {
                        if (!oppositeLine.Description.Equals("Sales Transaction Receipt"))
                        {
                            if (line.Seq == "Credit")
                            {
                                oppositeLine.Amount = -oppositeLine.Amount;
                            }
                            DisplayedLines.Add(new LedgerTransactionLineVM {
                                Model = oppositeLine.Model, Balance = _beginningBalance + oppositeLine.Amount
                            });
                        }

                        else
                        {
                            salesreceiptLine.Amount += oppositeLine.Amount;
                        }

                        _endingBalance      += oppositeLine.Amount;
                        oppositeLine.Balance = _endingBalance;
                    }
                }
                if (salesreceiptLine.Amount > 0)
                {
                    DisplayedLines.Add(new LedgerTransactionLineVM {
                        Model = salesreceiptLine, Balance = _endingBalance
                    });
                }
            }
            OnPropertyChanged("EndingBalance");
        }
예제 #6
0
        private void DisplaySelectedItemFromSelectedWarehouse(ERPContext context)
        {
            var line   = new InventoryReportLineVM(_selectedItem.Model);
            var stocks = context.Stocks.Where(stock => stock.ItemID.Equals(_selectedItem.ID) && stock.WarehouseID.Equals(_selectedWarehouse.ID));

            if (stocks.Any())
            {
                foreach (var stock in stocks)
                {
                    line.Quantity += stock.Pieces;
                }
            }
            DisplayedLines.Add(line);
        }
예제 #7
0
 private void ResetTransaction()
 {
     IsNotEditMode                = true;
     TransactionDescription       = null;
     TransactionDate              = UtilityMethods.GetCurrentDate();
     NewEntryVM.NewEntryWarehouse = null;
     NewEntryVM.ResetEntryFields();
     DisplayedLines.Clear();
     Model = new StockAdjustmentTransaction
     {
         AdjustStockTransactionLines = new ObservableCollection <StockAdjustmentTransactionLine>()
     };
     SetTransactionID();
     NewEntryVM.UpdateWarehouses();
 }
예제 #8
0
        private void DisplayAllItems(ERPContext context)
        {
            foreach (var item in ListedItems)
            {
                if (item.Name.Equals("All"))
                {
                    continue;
                }
                var line = new InventoryReportLineVM(item.Model);

                var stocks = context.Stocks.Where(stock => stock.ItemID.Equals(item.ID));
                if (stocks.Any())
                {
                    foreach (var stock in stocks)
                    {
                        line.Quantity += stock.Pieces;
                    }
                }

                DisplayedLines.Add(line);
            }
        }