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 }
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"); }
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 }