Ejemplo n.º 1
0
 protected bool Equals(Invoice other)
 {
     return base.Equals(other) &&
         PaymentPeriod == other.PaymentPeriod &&
         PaymentMethod == other.PaymentMethod &&
         IssueDate.Equals(other.IssueDate);
 }
Ejemplo n.º 2
0
        public InvoiceViewModel(IUnitOfWork context, 
                                IMessageBoxService messageBoxService,
                                IFrameNavigationService navigationService)
            : base(context, messageBoxService,navigationService)
        {
            IssueDate = DateTime.Now;
            InvoiceModel = new Invoice();
            PaymentPeriod = 1;
            PaymentMethodValues = new Dictionary<PaymentMethod, string>
            {
                {PaymentMethod.Cash,"Gotówka"},
                {PaymentMethod.Transfer,"Przelew"}
            };
            SelectedPaymentMethod = PaymentMethod.Transfer;
            HandleNavigationParameter(navigationService.Parameter);

            RegisterMessages();
            ConfigureValidationRules();

            #region DesignMode
            if (IsInDesignMode)
            {
                BuyerList = new Collection<Buyer>
                {
                    new Buyer
                    {
                        FirstName = "Michał",
                        LastName = "Pełcik",
                        CompanyName = "sdfsf"
                    }
                };
                SaleDate = new DateTime(2015, 05, 05);
                PaymentDetailList = new ItemsChangeObservableCollection<PaymentDetail>
                {
                    new PaymentDetail
                    {
                        Description = "sdfsdf",
                        MeasureUnit = "szt.",
                        PricePerUnit = 234,
                        Quantity = 3,
                        Amount = 702
                    }
                };
            }
            #endregion
        }
Ejemplo n.º 3
0
        public void FindInvoice_Returns_Invoice_From_Data_Store()
        {
            //Arrange
            const string invoiceNumber = "1/2015";
            int sellerId;
            using (var bc = new UnitOfWork())
            {
                var seller = bc.DataContext.People.OfType<Seller>().First();
                sellerId = seller.ID;
                var newInvoice = new Invoice
                {
                    IssueDate = new DateTime(2015, 5, 6),
                    Number = invoiceNumber,
                    PaymentMethod = PaymentMethod.Transfer,
                    SaleDate = new DateTime(2015, 5, 6),
                    PaymentDetails = new List<PaymentDetail>
                    {
                        new PaymentDetail
                        {
                            Description = "Czynsz za lokal ul. Marsa 3 maj",
                            MeasureUnit = "szt.",
                            PricePerUnit = 5300,
                            Quantity = 1
                        }
                    },

                    Buyer = bc.DataContext.People.OfType<Buyer>().First(),
                    Seller = bc.DataContext.People.OfType<Seller>().First(),
                };

                //Act
                bc.Payments.Add(newInvoice);
                bc.Complete();
            }

            using (var bc = new UnitOfWork())
            {
                var invoice = bc.Payments.FindInvoice(i=>i.Number==invoiceNumber && i.Seller.ID==sellerId);
                //Verify
                Assert.IsNotNull(invoice);
            }
        }
Ejemplo n.º 4
0
        public void Add_Invoice_To_Data_Store()
        {
            //Arrange

            using (var bc = new UnitOfWork())
            {
                var newInvoice = new Invoice
                {
                    IssueDate = new DateTime(2015, 5, 6),
                    Number = "1/2015",
                    PaymentMethod = PaymentMethod.Transfer,
                    SaleDate = new DateTime(2015, 5, 6),
                    PaymentDetails = new List<PaymentDetail>
                    {
                        new PaymentDetail
                        {
                            Description = "Czynsz za lokal ul. Marsa 3 maj",
                            MeasureUnit = "szt.",
                            PricePerUnit = 5300,
                            Quantity = 1
                        }
                    },

                    Buyer = bc.DataContext.People.OfType<Buyer>().First(),
                    Seller = bc.DataContext.People.OfType<Seller>().First(),
                };

                //Act
                bc.Payments.Add(newInvoice);
                bc.Complete();
            }

            using (var bc = new UnitOfWork())
            {
                bool exists = bc.DataContext.Payments.Any();
                //Verify
                Assert.IsTrue(exists);
            }
        }
Ejemplo n.º 5
0
        public void Returns_True_When_Invoices_Are_Equal()
        {
            var anewInvoice = new Invoice
            {
                IssueDate = new DateTime(2015, 5, 6),
                Number = "3/2015",
                PaymentMethod = PaymentMethod.Transfer,
                SaleDate = new DateTime(2015, 5, 6),
                PaymentPeriod = 3,
                PaymentDetails = new List<PaymentDetail>
                         {
                            new PaymentDetail
                            {
                                Description = "Czynsz za lokal ul. Marsa 3 maj",
                                MeasureUnit = "szt.",
                                PricePerUnit = 5300,
                                Quantity = 1
                            },
                            new PaymentDetail
                            {
                                Description = "Czynsz za lokal ul. wris 3 lipiec",
                                MeasureUnit = "szt.",
                                PricePerUnit = 3500,
                                Quantity = 1
                            }

                         },
            };

            var bnewInvoice = new Invoice
            {
                IssueDate = new DateTime(2015, 5, 6),
                Number = "3/2015",
                PaymentMethod = PaymentMethod.Transfer,
                SaleDate = new DateTime(2015, 5, 6),
                PaymentPeriod = 3,
                PaymentDetails = new List<PaymentDetail>
                         {
                            new PaymentDetail
                            {
                                Description = "Czynsz za lokal ul. Marsa 3 maj",
                                MeasureUnit = "szt.",
                                PricePerUnit = 5300,
                                Quantity = 1
                            },
                            new PaymentDetail
                            {
                                Description = "Czynsz za lokal ul. wris 3 lipiec",
                                MeasureUnit = "szt.",
                                PricePerUnit = 3500,
                                Quantity = 1
                            }

                         },
            };

            Assert.IsTrue(anewInvoice.Equals(bnewInvoice));
        }
Ejemplo n.º 6
0
        public void GetBasicInvoicesData_Returns_Invoices_From_Data_Store()
        {
            //Arrange
            int sellerId;
            using (var bc = new UnitOfWork())
            {
                var seller = bc.DataContext.People.OfType<Seller>().First();
                sellerId = seller.ID;
                var newInvoice = new Invoice
                {
                    IssueDate = new DateTime(2015, 5, 6),
                    Number = "1/2015",
                    PaymentMethod = PaymentMethod.Transfer,
                    SaleDate = new DateTime(2015, 5, 6),
                    PaymentDetails = new List<PaymentDetail>
                    {
                        new PaymentDetail
                        {
                            Description = "Czynsz za lokal ul. Marsa 3 maj",
                            MeasureUnit = "szt.",
                            PricePerUnit = 5300,
                            Quantity = 1
                        }
                    },

                    Buyer = bc.DataContext.People.OfType<Buyer>().First(),
                    Seller = seller
                };

                //Act
                bc.Payments.Add(newInvoice);
                bc.Complete();
            }

            using (var bc = new UnitOfWork())
            {

                var listOfInvoices = bc.Payments.GetBasicInvoicesData(sellerId);
                //Verify
                Assert.IsTrue(listOfInvoices.Count()==1);
            }
        }
Ejemplo n.º 7
0
 public MessageService(Invoice invoice, EntityState entityState)
 {
     Invoice = invoice;
     EntityState = entityState;
 }
Ejemplo n.º 8
0
 private void ReplaceInvoice(Invoice invoiceToReplace)
 {
     try
     {
         Context.Payments.Remove(invoiceToReplace);
         Context.Payments.Add(InvoiceModel);
         Context.Complete();
     }
     catch
     {
         throw new Exception("Nie udało się zastąpić faktury");
     }
     StatusSetter.SetStatus("Faktura zastąpiona");
 }
Ejemplo n.º 9
0
        private void LoadInvoice(Invoice invoice)
        {
            SelectedBuyer = invoice.Buyer;

            InvoiceModel = invoice;
            ReadFromModel(invoice);
        }
Ejemplo n.º 10
0
 protected override void ExecuteClearPayment()
 {
     base.ExecuteClearPayment();
     InvoiceModel = new Invoice();
     IssueDate = DateTime.Today;
 }
Ejemplo n.º 11
0
        private Invoice CreateInvoice()
        {
            var buyer = new Buyer
            {
                ID = 2,
                FirstName = "Tomasz",
                LastName = "Pakul",
                CompanyName = "Tymbol",
                NIP = "5455914065",
                Address = new Address
                {
                    City = "Kraków",
                    StreetAddress = "ul. Kolorowe 3",
                    ZipCode = "30-710"
                }
            };

            _selectedSeller = new Seller
            {
                ID = 1,
                FirstName = "Michał",
                LastName = "Rakel",
                BankName = "mBank",
                BankAccountNumber = "32 3245 5456 5435 3242 5456 1296 ",
                NIP = "3234326576",
                Address = new Address
                {
                    City = "Kraków",
                    StreetAddress = "ul. Kredki 5/8a",
                    ZipCode = "31-063"
                }
            };
            var myInvoice = new Invoice
            {
                ID = 1,
                IssueDate = new DateTime(2015, 5, 6),
                Number = "3/2015",
                PaymentMethod = PaymentMethod.Transfer,
                SaleDate = new DateTime(2015, 5, 6),
                PaymentDetails = new List<PaymentDetail>
                         {
                            new PaymentDetail
                            {
                                Description = "Czynsz za lokal ul. Marsa 3 maj",
                                MeasureUnit = "szt.",
                                PricePerUnit = 5300,
                                Quantity = 1
                            },
                            new PaymentDetail
                            {
                                Description = "Czynsz za lokal ul. wris 3 lipiec",
                                MeasureUnit = "szt.",
                                PricePerUnit = 3500,
                                Quantity = 1
                            }

                         },

                Buyer = buyer,
                Seller = _selectedSeller,
            };

            return myInvoice;
        }
Ejemplo n.º 12
0
        public void When_ReplaceInvoice_Executed_Send_Message_To_Update_Status_Bar()
        {
            //Arrange
            var invoice = new Invoice();
            _contextMock.Setup(m => m.Payments.FindInvoice(It.IsAny<Expression<Func<Invoice, bool>>>()))
                .Returns(invoice);
            _messageBoxMock.Setup(m => m.ShowDialogBox(It.IsAny<string>())).Returns(true);

            const string expectedStatus = "Faktura zastąpiona";

            string receivedStatus = null;

            Messenger.Default.Register<StatusMessage>(this, MessengerToken.MainWindowVm, msg =>
            {
                receivedStatus = msg.NewStatus;

            });

            _invoiceViewModel = new InvoiceViewModel(_contextMock.Object, _messageBoxMock.Object, _navigationServiceMock.Object)
            {
                Mode = Mode.Add,
                IssueDate = new DateTime(2015, 5, 6),
                Number = "2/2015",
                SelectedPaymentMethod = PaymentMethod.Cash,
                SaleDate = new DateTime(2015, 5, 6),
                SelectedBuyer = _buyers.First(),
                SelectedSeller = _selectedSeller,
                PaymentPeriod = 30,
                PaymentDetailList = new ItemsChangeObservableCollection<PaymentDetail>
                    {
                        new PaymentDetail
                        {
                            Description = "Czynsz za lokal ul. Marsa 3 maj",
                            MeasureUnit = "szt.",
                            PricePerUnit = 34400,
                            Quantity = 1
                        }
                    }

            };

            //Act
            _invoiceViewModel.AddEditInvoiceCommand.Execute(null);

            //Verify
            Assert.IsTrue(expectedStatus.Equals(receivedStatus));
        }
Ejemplo n.º 13
0
        public void When_MessageBoxService_ShowDialogBox_Returns_True_Invoke_Remove_With_Returned_Invoice()
        {
            //Arrange
            var invoice = new Invoice();
            _contextMock.Setup(m => m.Payments.FindInvoice(It.IsAny<Expression<Func<Invoice, bool>>>()))
                .Returns(invoice);
            _messageBoxMock.Setup(m => m.ShowDialogBox(It.IsAny<string>())).Returns(true);

            _invoiceViewModel = new InvoiceViewModel(_contextMock.Object, _messageBoxMock.Object, _navigationServiceMock.Object)
            {
                Mode = Mode.Add,
                IssueDate = new DateTime(2015, 5, 6),
                Number = "2/2015",
                SelectedPaymentMethod = PaymentMethod.Cash,
                SaleDate = new DateTime(2015, 5, 6),
                SelectedBuyer = _buyers.First(),
                SelectedSeller = _selectedSeller,
                PaymentPeriod = 30,
                PaymentDetailList = new ItemsChangeObservableCollection<PaymentDetail>
                    {
                        new PaymentDetail
                        {
                            Description = "Czynsz za lokal ul. Marsa 3 maj",
                            MeasureUnit = "szt.",
                            PricePerUnit = 34400,
                            Quantity = 1
                        }
                    }

            };

            //Act
            _invoiceViewModel.AddEditInvoiceCommand.Execute(null);

            //Verify
            _contextMock.Verify(m=>m.Payments.Remove(invoice),Times.Once);
        }