Exemple #1
0
        public void CalculateGrossAmount_CorrectVat_CorrectGrossAmount()
        {
            //Arrange
            var invoiceItem = new InvoiceItem();

            invoiceItem.AmountNet = 100;
            invoiceItem.SetVatRate(23);

            //Act
            invoiceItem.CalculateGrossAmount();

            //Assert
            Assert.AreEqual(invoiceItem.AmountGross, 123);
        }
        private void btnSaveInvoice_Click(object sender, RoutedEventArgs e)
        {
            //  MessageBox.Show("Plik nie istnieje", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error);

            Invoice invoice = new Invoice();

            invoice.SellerData = tbSellerData.Text;
            invoice.BuyerData  = tbBuyerData.Text;
            invoice.IssueDate  = tbIssueDate.SelectedDate;

            InvoiceFileService.SaveInvoiceFile(invoice);

            DBService.InsertInvoice(invoice);

            if (!string.IsNullOrEmpty(tbProductName1.Text))
            {
                InvoiceItem invoiceItem = new InvoiceItem()
                {
                    Name      = tbProductName1.Text,
                    AmountNet = Convert.ToDouble(tbAmount1.Text)
                };

                invoiceItem.SetAmountNet(Convert.ToDouble(tbNettoPrice1.Text));
                invoiceItem.SetVatRate(Convert.ToInt32(tbVat1.Text));
                invoiceItem.CalculateGrossAmount();
            }
            if (!string.IsNullOrEmpty(tbProductName2.Text))
            {
                InvoiceItem invoiceItem = new InvoiceItem()
                {
                    Name      = tbProductName2.Text,
                    AmountNet = Convert.ToDouble(tbAmount2.Text)
                };

                invoiceItem.SetAmountNet(Convert.ToDouble(tbNettoPrice2.Text));
                invoiceItem.SetVatRate(Convert.ToInt32(tbVat2.Text));
                invoiceItem.CalculateGrossAmount();
            }
        }
Exemple #3
0
        public void CalculateTotalGrossAmount_CorrectValuesFiveItems_CorrectTotalGrossAmount()
        {
            //Arrange
            var invoice = new Invoice();

            for (int i = 0; i < 5; i++)
            {
                var invoiceItem = new InvoiceItem()
                {
                    AmountNet = 100,
                    Amount    = 1
                };
                invoiceItem.SetVatRate(23);
                invoiceItem.CalculateGrossAmount();

                invoice.items.Add(invoiceItem);
            }

            //Act
            invoice.CalculateTotalGrossAmount();

            //Assert
            Assert.Equal(615, invoice.TotalGrossAmount);
        }