public void UpdateSupplierInvoicePaymentTest() { var request = new FortnoxApiRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret); var supplierInvoicePayment = new SupplierInvoicePayment { Number = 2, Amount = 99, InvoiceNumber = "1", ModeOfPayment = "BG" }; var updatedSupplierInvoicePayment = SupplierInvoicePaymentService.UpdateSupplierInvoicePaymentAsync(request, supplierInvoicePayment).GetAwaiter().GetResult(); Assert.AreEqual(99, updatedSupplierInvoicePayment.Amount); }
public async Task Test_SupplierInvoicePayment_CRUD() { #region Arrange var tmpSupplier = await FortnoxClient.SupplierConnector.CreateAsync(new Supplier() { Name = "TmpSupplier" }); var tmpArticle = await FortnoxClient.ArticleConnector.CreateAsync(new Article() { Description = "TmpArticle", PurchasePrice = 100 }); var tmpSpplierInvoice = await FortnoxClient.SupplierInvoiceConnector.CreateAsync(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 = await FortnoxClient.SupplierInvoiceConnector.BookkeepAsync(tmpSpplierInvoice.GivenNumber); #endregion Arrange var connector = FortnoxClient.SupplierInvoicePaymentConnector; #region CREATE var newSupplierInvoicePayment = new SupplierInvoicePayment() { InvoiceNumber = (int?)tmpSpplierInvoice.GivenNumber, Amount = 1000, AmountCurrency = 1000, PaymentDate = new DateTime(2020, 1, 20) }; var createdSupplierInvoicePayment = await connector.CreateAsync(newSupplierInvoicePayment); Assert.AreEqual(1000, createdSupplierInvoicePayment.Amount); #endregion CREATE #region UPDATE createdSupplierInvoicePayment.Amount = 2000; var updatedSupplierInvoicePayment = await connector.UpdateAsync(createdSupplierInvoicePayment); Assert.AreEqual(2000, updatedSupplierInvoicePayment.Amount); #endregion UPDATE #region READ / GET var retrievedSupplierInvoicePayment = await connector.GetAsync(createdSupplierInvoicePayment.Number); Assert.AreEqual(2000, retrievedSupplierInvoicePayment.Amount); #endregion READ / GET #region DELETE await connector.DeleteAsync(createdSupplierInvoicePayment.Number); await Assert.ThrowsExceptionAsync <FortnoxApiException>( async() => await connector.GetAsync(createdSupplierInvoicePayment.Number), "Entity still exists after Delete!"); #endregion DELETE #region Delete arranged resources //Can't cancel invoice since it is booked //FortnoxClient.SupplierInvoiceConnector.Cancel(tmpSpplierInvoice.GivenNumber); //FortnoxClient.ArticleConnector.Delete(tmpArticle.ArticleNumber); //FortnoxClient.SupplierConnector.Delete(tmpSupplier.SupplierNumber); #endregion Delete arranged resources }
/// <summary> /// Creates a new supplierInvoicePayment /// </summary> /// <param name="supplierInvoicePayment">The supplierInvoicePayment to create</param> /// <returns>The created supplierInvoicePayment</returns> public SupplierInvoicePayment Create(SupplierInvoicePayment supplierInvoicePayment) { return(CreateAsync(supplierInvoicePayment).Result); }
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 }
public async Task <SupplierInvoicePayment> UpdateAsync(SupplierInvoicePayment supplierInvoicePayment) { return(await BaseUpdate(supplierInvoicePayment, supplierInvoicePayment.Number.ToString())); }
public async Task <SupplierInvoicePayment> CreateAsync(SupplierInvoicePayment supplierInvoicePayment) { return(await BaseCreate(supplierInvoicePayment)); }
public static async Task <SupplierInvoicePayment> UpdateSupplierInvoicePaymentAsync(FortnoxApiRequest request, SupplierInvoicePayment supplierInvoicePayment) { var apiRequest = new FortnoxApiClientRequest <SingleResource <SupplierInvoicePayment> >(HttpMethod.Put, request.AccessToken, request.ClientSecret, $"{ApiEndpoints.SupplierInvoicePayments}/{supplierInvoicePayment.Number}") { Data = new SingleResource <SupplierInvoicePayment> { Data = supplierInvoicePayment } }; return((await FortnoxAPIClient.CallAsync(apiRequest)).Data); }
/// <summary> /// Create a new supplier invoice payment /// </summary> /// <param name="supplierInvoicePayment">The supplier invoice payment to be created</param> /// <returns>The created supplier invoice payment</returns> public SupplierInvoicePayment Create(SupplierInvoicePayment supplierInvoicePayment) { return(BaseCreate(supplierInvoicePayment)); }
public async Task <SupplierInvoicePayment> CreateAsync(SupplierInvoicePayment supplierInvoicePayment) { return(await BaseCreate(supplierInvoicePayment).ConfigureAwait(false)); }