コード例 #1
0
        public void Test_Book()
        {
            #region Arrange
            var tmpSupplier = new SupplierConnector().Create(new Supplier()
            {
                Name = "TmpSupplier"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", PurchasePrice = 100
            });
            #endregion Arrange

            ISupplierInvoiceConnector connector = new SupplierInvoiceConnector();

            var newSupplierInvoice = new SupplierInvoice()
            {
                SupplierNumber      = tmpSupplier.SupplierNumber,
                Comments            = "InvoiceComments",
                InvoiceDate         = new DateTime(2020, 1, 1),
                DueDate             = new DateTime(2020, 2, 1),
                SalesType           = SalesType.Stock,
                OCR                 = "123456789",
                Total               = 5000,
                SupplierInvoiceRows = new List <SupplierInvoiceRow>()
                {
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    }
                }
            };

            var createdSupplierInvoice = connector.Create(newSupplierInvoice);

            //Act
            connector.Bookkeep(createdSupplierInvoice.GivenNumber);
            var bookedInvoice = connector.Get(createdSupplierInvoice.GivenNumber);

            //Assert
            Assert.AreEqual(true, bookedInvoice.Booked);
            Assert.AreEqual(1, bookedInvoice.Vouchers.Count);
            Assert.AreEqual(ReferenceType.SupplierInvoice, bookedInvoice.Vouchers.First().ReferenceType);

            #region Delete arranged resources
            //Can not cancel booked invoice

/*            connector.Cancel(createdSupplierInvoice.GivenNumber);
 *          new SupplierConnector().Delete(tmpSupplier.SupplierNumber);
 *          new ArticleConnector().Delete(tmpArticle.ArticleNumber);*/
            #endregion Delete arranged resources
        }
コード例 #2
0
        public void Test_Issue96_fixed() // Origins from https://github.com/FortnoxAB/csharp-api-sdk/issues/96
        {
            #region Arrange
            var tmpSupplier = new SupplierConnector().Create(new Supplier()
            {
                Name = "TmpSupplier"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", PurchasePrice = 100
            });
            #endregion Arrange

            var connector = new SupplierInvoiceConnector();

            var createdInvoice = connector.Create(new SupplierInvoice()
            {
                SupplierNumber      = tmpSupplier.SupplierNumber,
                Comments            = "InvoiceComments",
                InvoiceDate         = new DateTime(2010, 1, 1),
                DueDate             = new DateTime(2010, 2, 1),
                SalesType           = SalesType.Stock,
                OCR                 = "123456789",
                Total               = 5000,
                SupplierInvoiceRows = new List <SupplierInvoiceRow>()
                {
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    }
                }
            });
            MyAssert.HasNoError(connector);
            Assert.AreEqual(false, createdInvoice.Cancelled);

            var retrievedInvoice = connector.Get(createdInvoice.GivenNumber);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(false, retrievedInvoice.Cancelled);

            connector.LastModified = DateTime.Today;
            var invoiceSubsets = connector.Find().Entities;
            MyAssert.HasNoError(connector);
            foreach (var supplierInvoiceSubset in invoiceSubsets)
            {
                Assert.IsNotNull(supplierInvoiceSubset.Cancelled);
            }

            #region Delete arranged resources
            new CustomerConnector().Delete(tmpSupplier.SupplierNumber);
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            #endregion Delete arranged resources
        }
コード例 #3
0
ファイル: Testv300.cs プロジェクト: Zwapgrid/fortnox-sdk
        public void TestSupplierInvoice()
        {
            var connector = new SupplierInvoiceConnector();

            connector.Authorization = new StaticTokenAuth(at, cs);

            var invoice = connector.Get("5");

            Assert.IsFalse(connector.HasError);
            Assert.IsTrue(invoice.AccountingMethod == "ACCRUAL");

            invoice.PaymentPending = "true";
            invoice.CostCenter     = "101";
            invoice.YourReference  = "ABC";
            invoice.OurReference   = "DEF";
            invoice = connector.Update(invoice);

            Assert.IsFalse(connector.HasError);
            Assert.IsTrue(invoice.PaymentPending == "true");
            Assert.IsTrue(invoice.CostCenter == "101");
            Assert.IsTrue(invoice.YourReference == "ABC");
            Assert.IsTrue(invoice.OurReference == "DEF");

            invoice.PaymentPending = "false";
            invoice.CostCenter     = "100";
            invoice.Project        = "2";
            invoice = connector.Update(invoice);

            Assert.IsFalse(connector.HasError);
            Assert.IsTrue(invoice.PaymentPending == "false");
            Assert.IsTrue(invoice.CostCenter == "100");
            Assert.IsTrue(invoice.Project == "2");


            connector.FromDate = "2017-01-01";
            connector.ToDate   = "2017-04-03";

            var invoices = connector.Find();

            Assert.IsFalse(connector.HasError);
            Assert.IsTrue(invoices.TotalResources == "3");
        }
コード例 #4
0
        public void TestSupplierInvoice()
        {
            var connector = new SupplierInvoiceConnector();

            connector.AccessToken  = at;
            connector.ClientSecret = cs;

            var invoice = connector.Get("5");

            Assert.IsFalse(connector.HasError);
            Assert.IsTrue(invoice.AccountingMethod == SupplierInvoiceConnector.AccountingMethod.ACCRUAL);

            invoice.PaymentPending = "true";
            invoice.CostCenter     = "101";
            invoice.YourReference  = "ABC";
            invoice.OurReference   = "DEF";
            invoice.Project        = "1";
            invoice = connector.Update(invoice);

            Assert.IsFalse(connector.HasError);
            Assert.IsTrue(invoice.PaymentPending == "true");
            Assert.IsTrue(invoice.CostCenter == "101");
            Assert.IsTrue(invoice.Project == "1");
            Assert.IsTrue(invoice.YourReference == "ABC");
            Assert.IsTrue(invoice.OurReference == "DEF");

            invoice.PaymentPending = "false";
            invoice.CostCenter     = "100";
            invoice.Project        = "2";
            invoice = connector.Update(invoice);

            Assert.IsFalse(connector.HasError);
            Assert.IsTrue(invoice.PaymentPending == "false");
            Assert.IsTrue(invoice.CostCenter == "100");
            Assert.IsTrue(invoice.Project == "2");
        }
コード例 #5
0
        public void Test_SupplierInvoice_CRUD()
        {
            #region Arrange
            var tmpSupplier = new SupplierConnector().Create(new Supplier()
            {
                Name = "TmpSupplier"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", PurchasePrice = 100
            });
            #endregion Arrange

            ISupplierInvoiceConnector connector = new SupplierInvoiceConnector();

            #region CREATE
            var newSupplierInvoice = new SupplierInvoice()
            {
                SupplierNumber      = tmpSupplier.SupplierNumber,
                Comments            = "InvoiceComments",
                InvoiceDate         = new DateTime(2010, 1, 1),
                DueDate             = new DateTime(2010, 2, 1),
                SalesType           = SalesType.Stock,
                OCR                 = "123456789",
                Total               = 5000,
                SupplierInvoiceRows = new List <SupplierInvoiceRow>()
                {
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    }
                }
            };

            var createdSupplierInvoice = connector.Create(newSupplierInvoice);
            Assert.AreEqual("InvoiceComments", createdSupplierInvoice.Comments);
            Assert.AreEqual("TmpSupplier", createdSupplierInvoice.SupplierName);
            Assert.AreEqual(3 + 1, createdSupplierInvoice.SupplierInvoiceRows.Count);
            //3 + 1 => A row "Leverant�rsskulder" is created by default

            #endregion CREATE

            #region UPDATE

            createdSupplierInvoice.Comments = "UpdatedInvoiceComments";

            var updatedSupplierInvoice = connector.Update(createdSupplierInvoice);
            Assert.AreEqual("UpdatedInvoiceComments", updatedSupplierInvoice.Comments);

            #endregion UPDATE

            #region READ / GET

            var retrievedSupplierInvoice = connector.Get(createdSupplierInvoice.GivenNumber);
            Assert.AreEqual("UpdatedInvoiceComments", retrievedSupplierInvoice.Comments);

            #endregion READ / GET

            #region DELETE
            //Not supported
            connector.Cancel(createdSupplierInvoice.GivenNumber);
            var cancelledInvoice = connector.Get(createdSupplierInvoice.GivenNumber);
            Assert.AreEqual(true, cancelledInvoice.Cancelled);
            #endregion DELETE

            #region Delete arranged resources
            new SupplierConnector().Delete(tmpSupplier.SupplierNumber);
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            #endregion Delete arranged resources
        }
コード例 #6
0
        public void Test_Find()
        {
            #region Arrange
            var tmpSupplier = new SupplierConnector().Create(new Supplier()
            {
                Name = "TmpSupplier"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", PurchasePrice = 100
            });
            #endregion Arrange

            ISupplierInvoiceConnector connector = new SupplierInvoiceConnector();
            var newSupplierInvoice = new SupplierInvoice()
            {
                SupplierNumber      = tmpSupplier.SupplierNumber,
                Comments            = "InvoiceComments",
                InvoiceDate         = new DateTime(2010, 1, 1),
                DueDate             = new DateTime(2010, 2, 1),
                SalesType           = SalesType.Stock,
                OCR                 = "123456789",
                Total               = 5000,
                SupplierInvoiceRows = new List <SupplierInvoiceRow>()
                {
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    }
                }
            };

            //Add entries
            for (var i = 0; i < 5; i++)
            {
                connector.Create(newSupplierInvoice);
            }

            //Apply base test filter
            var searchSettings = new SupplierInvoiceSearch();
            searchSettings.SupplierNumber = tmpSupplier.SupplierNumber;
            var fullCollection = connector.Find(searchSettings);

            Assert.AreEqual(5, fullCollection.TotalResources);
            Assert.AreEqual(5, fullCollection.Entities.Count);
            Assert.AreEqual(1, fullCollection.TotalPages);

            Assert.AreEqual(tmpSupplier.SupplierNumber, fullCollection.Entities.First().SupplierNumber);

            //Apply Limit
            searchSettings.Limit = 2;
            var limitedCollection = connector.Find(searchSettings);

            Assert.AreEqual(5, limitedCollection.TotalResources);
            Assert.AreEqual(2, limitedCollection.Entities.Count);
            Assert.AreEqual(3, limitedCollection.TotalPages);

            //Delete entries (DELETE not supported)
            foreach (var invoice in fullCollection.Entities)
            {
                connector.Cancel(invoice.GivenNumber);
            }

            #region Delete arranged resources
            new SupplierConnector().Delete(tmpSupplier.SupplierNumber);
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            #endregion Delete arranged resources
        }
コード例 #7
0
        public void Test_SupplierInvoicePayment_CRUD()
        {
            #region Arrange
            var tmpSupplier = new SupplierConnector().Create(new Supplier()
            {
                Name = "TmpSupplier"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", PurchasePrice = 100
            });
            var tmpSpplierInvoice = new SupplierInvoiceConnector().Create(new SupplierInvoice()
            {
                SupplierNumber      = tmpSupplier.SupplierNumber,
                Comments            = "InvoiceComments",
                InvoiceDate         = new DateTime(2020, 1, 1),
                DueDate             = new DateTime(2020, 2, 1),
                SalesType           = SalesType.Stock,
                OCR                 = "123456789",
                Total               = 5000,
                SupplierInvoiceRows = new List <SupplierInvoiceRow>()
                {
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    }
                }
            });
            var bookedInvoice = new SupplierInvoiceConnector().Bookkeep(tmpSpplierInvoice.GivenNumber);
            #endregion Arrange

            ISupplierInvoicePaymentConnector connector = new SupplierInvoicePaymentConnector();

            #region CREATE
            var newSupplierInvoicePayment = new SupplierInvoicePayment()
            {
                InvoiceNumber  = (int?)tmpSpplierInvoice.GivenNumber,
                Amount         = 1000,
                AmountCurrency = 1000,
                PaymentDate    = new DateTime(2020, 1, 20)
            };

            var createdSupplierInvoicePayment = connector.Create(newSupplierInvoicePayment);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(1000, createdSupplierInvoicePayment.Amount);

            #endregion CREATE

            #region UPDATE

            createdSupplierInvoicePayment.Amount = 2000;

            var updatedSupplierInvoicePayment = connector.Update(createdSupplierInvoicePayment);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(2000, updatedSupplierInvoicePayment.Amount);

            #endregion UPDATE

            #region READ / GET

            var retrievedSupplierInvoicePayment = connector.Get(createdSupplierInvoicePayment.Number);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(2000, retrievedSupplierInvoicePayment.Amount);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdSupplierInvoicePayment.Number);
            MyAssert.HasNoError(connector);

            retrievedSupplierInvoicePayment = connector.Get(createdSupplierInvoicePayment.Number);
            Assert.AreEqual(null, retrievedSupplierInvoicePayment, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            new SupplierConnector().Delete(tmpSupplier.SupplierNumber);
            #endregion Delete arranged resources
        }
コード例 #8
0
        public void Test_SupplierInvoice_CRUD()
        {
            //Arrange
            var tmpSupplier = new SupplierConnector().Create(new Supplier()
            {
                Name = "TmpSupplier", CountryCode = "SE", City = "Testopolis"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", Type = ArticleType.STOCK, PurchasePrice = 100
            });

            //Act
            var connector = new SupplierInvoiceConnector();

            #region CREATE
            var newInvoice = new SupplierInvoice()
            {
                SupplierNumber      = tmpSupplier.SupplierNumber,
                InvoiceDate         = new DateTime(2019, 1, 20).ToString(APIConstants.DateFormat), //"2019-01-20",
                DueDate             = new DateTime(2019, 2, 20).ToString(APIConstants.DateFormat), //"2019-02-20",
                SalesType           = SalesType.STOCK,
                OCR                 = "123456789",
                SupplierInvoiceRows = new List <SupplierInvoiceRow>()
                {
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 15
                    }
                }
            };

            var createdInvoice = connector.Create(newInvoice);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(createdInvoice.SupplierName, "TmpSupplier");
            Assert.AreEqual(3 + 1, createdInvoice.SupplierInvoiceRows.Count);
            //3 + 1 => A row "Leverantörsskulder" is created by default

            #endregion CREATE

            #region UPDATE

            createdInvoice.OCR = "987654321";
            var updatedInvoice = connector.Update(createdInvoice);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("987654321", updatedInvoice.OCR);

            #endregion UPDATE

            #region READ / GET

            var retrievedInvoice = connector.Get(createdInvoice.GivenNumber);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("987654321", retrievedInvoice.OCR);

            #endregion READ / GET

            #region DELETE
            //Invoice does not provide DELETE method, but can be canceled
            connector.Cancel(createdInvoice.GivenNumber);
            MyAssert.HasNoError(connector);

            retrievedInvoice = connector.Get(createdInvoice.GivenNumber);
            Assert.AreEqual(true, retrievedInvoice.Cancelled);

            #endregion DELETE

            //Clean
            new SupplierConnector().Delete(tmpSupplier.SupplierNumber);
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
        }
コード例 #9
0
        public void Test_SupplierInvoiceAccrual_CRUD()
        {
            #region Arrange
            var tmpSupplier = new SupplierConnector().Create(new Supplier()
            {
                Name = "TmpSupplier"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle"
            });
            var conn = new SupplierInvoiceConnector();
            var tmpSupplierInvoice = conn.Create(new SupplierInvoice()
            {
                SupplierNumber = tmpSupplier.SupplierNumber,
                Comments       = "InvoiceComments",
                InvoiceDate    = new DateTime(2020, 1, 20), //"2019-01-20",
                DueDate        = new DateTime(2020, 6, 20), //"2019-02-20",
                SalesType      = SalesType.Stock,
                //OCR = "123456789",
                Total = 6000,
                SupplierInvoiceRows = new List <SupplierInvoiceRow>()
                {
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 6, Price = 1000, Account = 5820
                    }
                }
            });
            MyAssert.HasNoError(conn);
            #endregion Arrange

            ISupplierInvoiceAccrualConnector connector = new SupplierInvoiceAccrualConnector();

            #region CREATE
            var newSupplierInvoiceAccrual = new SupplierInvoiceAccrual()
            {
                Description           = "TestSupplierInvoiceAccrual",
                SupplierInvoiceNumber = (int?)tmpSupplierInvoice.GivenNumber,
                Period                     = "MONTHLY",
                AccrualAccount             = 1790,
                CostAccount                = 5820,
                StartDate                  = new DateTime(2021, 1, 1),
                EndDate                    = new DateTime(2021, 3, 1),
                VATIncluded                = false,
                Total                      = 2000,
                SupplierInvoiceAccrualRows = new List <SupplierInvoiceAccrualRow>()
                {
                    new SupplierInvoiceAccrualRow()
                    {
                        Account = 5820, Credit = 0, Debit = 2000
                    },
                    new SupplierInvoiceAccrualRow()
                    {
                        Account = 1790, Credit = 2000, Debit = 0
                    }
                }
            };

            var createdSupplierInvoiceAccrual = connector.Create(newSupplierInvoiceAccrual);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("TestSupplierInvoiceAccrual", createdSupplierInvoiceAccrual.Description);

            #endregion CREATE

            #region UPDATE

            createdSupplierInvoiceAccrual.Description = "UpdatedTestSupplierInvoiceAccrual";

            var updatedSupplierInvoiceAccrual = connector.Update(createdSupplierInvoiceAccrual);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestSupplierInvoiceAccrual", updatedSupplierInvoiceAccrual.Description);

            #endregion UPDATE

            #region READ / GET

            var retrievedSupplierInvoiceAccrual = connector.Get(createdSupplierInvoiceAccrual.SupplierInvoiceNumber);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestSupplierInvoiceAccrual", retrievedSupplierInvoiceAccrual.Description);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdSupplierInvoiceAccrual.SupplierInvoiceNumber);
            MyAssert.HasNoError(connector);

            retrievedSupplierInvoiceAccrual = connector.Get(createdSupplierInvoiceAccrual.SupplierInvoiceNumber);
            Assert.AreEqual(null, retrievedSupplierInvoiceAccrual, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            new SupplierConnector().Delete(tmpSupplier.SupplierNumber);
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            #endregion Delete arranged resources
        }
        public void Test_SupplierInvoiceExternalURLConnection_CRUD()
        {
            #region Arrange
            var tmpSupplier = new SupplierConnector().Create(new Supplier()
            {
                Name = "TmpSupplier"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", PurchasePrice = 100
            });
            var tmpSpplierInvoice = new SupplierInvoiceConnector().Create(new SupplierInvoice()
            {
                SupplierNumber      = tmpSupplier.SupplierNumber,
                Comments            = "InvoiceComments",
                InvoiceDate         = new DateTime(2020, 1, 1),
                DueDate             = new DateTime(2020, 2, 1),
                SalesType           = SalesType.Stock,
                OCR                 = "123456789",
                Total               = 5000,
                SupplierInvoiceRows = new List <SupplierInvoiceRow>()
                {
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    }
                }
            });
            #endregion Arrange

            ISupplierInvoiceExternalURLConnectionConnector connector = new SupplierInvoiceExternalURLConnectionConnector();

            #region CREATE
            var newSupplierInvoiceExternalURLConnection = new SupplierInvoiceExternalURLConnection()
            {
                SupplierInvoiceNumber = (int?)tmpSpplierInvoice.GivenNumber,
                ExternalURLConnection = @"http://example.com/image.jpg"
            };

            var createdSupplierInvoiceExternalURLConnection = connector.Create(newSupplierInvoiceExternalURLConnection);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("http://example.com/image.jpg", createdSupplierInvoiceExternalURLConnection.ExternalURLConnection);

            #endregion CREATE

            #region UPDATE

            createdSupplierInvoiceExternalURLConnection.ExternalURLConnection = "http://example.com/image.png";

            var updatedSupplierInvoiceExternalURLConnection = connector.Update(createdSupplierInvoiceExternalURLConnection);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("http://example.com/image.png", updatedSupplierInvoiceExternalURLConnection.ExternalURLConnection);

            #endregion UPDATE

            #region READ / GET

            var retrievedSupplierInvoiceExternalURLConnection = connector.Get(createdSupplierInvoiceExternalURLConnection.Id);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("http://example.com/image.png", retrievedSupplierInvoiceExternalURLConnection.ExternalURLConnection);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdSupplierInvoiceExternalURLConnection.Id);
            MyAssert.HasNoError(connector);

            retrievedSupplierInvoiceExternalURLConnection = connector.Get(createdSupplierInvoiceExternalURLConnection.Id);
            Assert.AreEqual(null, retrievedSupplierInvoiceExternalURLConnection, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            new SupplierConnector().Delete(tmpSupplier.SupplierNumber);
            #endregion Delete arranged resources
        }
コード例 #11
0
        public void Test_SupplierInvoiceFileConnection_CRUD()
        {
            #region Arrange
            var tmpSupplier = new SupplierConnector().Create(new Supplier()
            {
                Name = "TmpSupplier"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", PurchasePrice = 100
            });
            var tmpSpplierInvoice = new SupplierInvoiceConnector().Create(new SupplierInvoice()
            {
                SupplierNumber      = tmpSupplier.SupplierNumber,
                Comments            = "InvoiceComments",
                InvoiceDate         = new DateTime(2020, 1, 1),
                DueDate             = new DateTime(2020, 2, 1),
                SalesType           = SalesType.Stock,
                OCR                 = "123456789",
                Total               = 5000,
                SupplierInvoiceRows = new List <SupplierInvoiceRow>()
                {
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    }
                }
            });
            var tmpFile = new InboxConnector().UploadFile("tmpImage.png", Resource.fortnox_image, StaticFolders.SupplierInvoices);
            #endregion Arrange

            ISupplierInvoiceFileConnectionConnector connector = new SupplierInvoiceFileConnectionConnector();

            #region CREATE
            var newSupplierInvoiceFileConnection = new SupplierInvoiceFileConnection()
            {
                SupplierInvoiceNumber = tmpSpplierInvoice.GivenNumber.ToString(),
                FileId = tmpFile.Id
            };

            var createdSupplierInvoiceFileConnection = connector.Create(newSupplierInvoiceFileConnection);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(tmpSupplier.Name, createdSupplierInvoiceFileConnection.SupplierName);

            #endregion CREATE

            #region UPDATE
            //Not supported
            #endregion UPDATE

            #region READ / GET

            var retrievedSupplierInvoiceFileConnection = connector.Get(createdSupplierInvoiceFileConnection.FileId);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(tmpSupplier.Name, retrievedSupplierInvoiceFileConnection.SupplierName);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdSupplierInvoiceFileConnection.FileId);
            MyAssert.HasNoError(connector);

            retrievedSupplierInvoiceFileConnection = connector.Get(createdSupplierInvoiceFileConnection.FileId);
            Assert.AreEqual(null, retrievedSupplierInvoiceFileConnection, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            new SupplierConnector().Delete(tmpSupplier.SupplierNumber);
            #endregion Delete arranged resources
        }