public void UpdateTermsOfPaymentTest() { var description = $"{DateTime.Now}"; var request = new FortnoxApiRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret); var termsOfPayment = new TermsOfPayment { Code = "TEST", Description = description }; var updatedTermsOfPayment = TermsOfPaymentService.UpdateTermsOfPaymentAsync(request, termsOfPayment).GetAwaiter().GetResult(); Assert.AreEqual(description, updatedTermsOfPayment.Description); }
public async Task Test_TermsOfPayment_CRUD() { #region Arrange //Add code to create required resources #endregion Arrange var connector = FortnoxClient.TermsOfPaymentConnector; #region CREATE var newTermsOfPayment = new TermsOfPayment() { Code = TestUtils.RandomString(5), Description = "TestPaymentTerms" }; var createdTermsOfPayment = await connector.CreateAsync(newTermsOfPayment); Assert.AreEqual("TestPaymentTerms", createdTermsOfPayment.Description); #endregion CREATE #region UPDATE createdTermsOfPayment.Description = "UpdatedTestPaymentTerms"; var updatedTermsOfPayment = await connector.UpdateAsync(createdTermsOfPayment); Assert.AreEqual("UpdatedTestPaymentTerms", updatedTermsOfPayment.Description); #endregion UPDATE #region READ / GET var retrievedTermsOfPayment = await connector.GetAsync(createdTermsOfPayment.Code); Assert.AreEqual("UpdatedTestPaymentTerms", retrievedTermsOfPayment.Description); #endregion READ / GET #region DELETE await connector.DeleteAsync(createdTermsOfPayment.Code); await Assert.ThrowsExceptionAsync <FortnoxApiException>( async() => await connector.GetAsync(createdTermsOfPayment.Code), "Entity still exists after Delete!"); #endregion DELETE #region Delete arranged resources //Add code to delete temporary resources #endregion Delete arranged resources }
public void Test_TermsOfPayment_CRUD() { #region Arrange //Add code to create required resources #endregion Arrange ITermsOfPaymentConnector connector = new TermsOfPaymentConnector(); #region CREATE var newTermsOfPayment = new TermsOfPayment() { Code = TestUtils.RandomString(5), Description = "TestPaymentTerms" }; var createdTermsOfPayment = connector.Create(newTermsOfPayment); MyAssert.HasNoError(connector); Assert.AreEqual("TestPaymentTerms", createdTermsOfPayment.Description); #endregion CREATE #region UPDATE createdTermsOfPayment.Description = "UpdatedTestPaymentTerms"; var updatedTermsOfPayment = connector.Update(createdTermsOfPayment); MyAssert.HasNoError(connector); Assert.AreEqual("UpdatedTestPaymentTerms", updatedTermsOfPayment.Description); #endregion UPDATE #region READ / GET var retrievedTermsOfPayment = connector.Get(createdTermsOfPayment.Code); MyAssert.HasNoError(connector); Assert.AreEqual("UpdatedTestPaymentTerms", retrievedTermsOfPayment.Description); #endregion READ / GET #region DELETE connector.Delete(createdTermsOfPayment.Code); MyAssert.HasNoError(connector); retrievedTermsOfPayment = connector.Get(createdTermsOfPayment.Code); Assert.AreEqual(null, retrievedTermsOfPayment, "Entity still exists after Delete!"); #endregion DELETE #region Delete arranged resources //Add code to delete temporary resources #endregion Delete arranged resources }
public bool Get(long DocProformaInvoice_ID) { string Err = null; Clear(); string sql = @"select dpi.IssueDate, dpi.DocDuration, dpi.DocDurationType, dpi.TermsOfPayment_ID, dpi.MethodOfPayment_ID, mop.Atom_BankAccount_ID, top.Description as TermsOfPayment_Description, mop.PaymentType, aba.TRR, ao.Name, ao.Tax_ID, ao.Registration_ID from DocProformaInvoice dpi left join TermsOfPayment top on dpi.TermsOfPayment_ID = top.ID left join MethodOfPayment mop on dpi.MethodOfPayment_ID = mop.ID left join Atom_BankAccount aba on mop.Atom_BankAccount_ID = aba.ID left join Atom_Bank ab on aba.Atom_Bank_ID = ab.ID left join Atom_Organisation ao on ab.Atom_Organisation_ID = ao.ID where dpi.ID = " + DocProformaInvoice_ID.ToString(); DataTable dt = new DataTable(); if (DBSync.DBSync.ReadDataTable(ref dt, sql, ref Err)) { if (dt.Rows.Count > 0) { m_IssueDate = DocProformaInvoice_AddOn.IssueDate.Set(dt.Rows[0]["IssueDate"]); m_Duration = DocProformaInvoice_AddOn.Duration.Set(dt.Rows[0]["DocDuration"], dt.Rows[0]["DocDurationType"]); m_TermsOfPayment = DocProformaInvoice_AddOn.TermsOfPayment.Set(dt.Rows[0]["TermsOfPayment_ID"], dt.Rows[0]["TermsOfPayment_Description"]); m_MethodOfPayment = DocProformaInvoice_AddOn.MethodOfPayment.Set(dt.Rows[0]["MethodOfPayment_ID"], dt.Rows[0]["PaymentType"], dt.Rows[0]["Name"], dt.Rows[0]["Tax_ID"], dt.Rows[0]["Registration_ID"], dt.Rows[0]["TRR"], dt.Rows[0]["Atom_BankAccount_ID"]); } return true; } else { LogFile.Error.Show("ERROR:TangentaDB:DocProformaInvoice_AddOn:Get:sql=" + sql + "\r\nErr=" + Err); return false; } }
protected override OpResult _Store(TermsOfPayment _obj) { if (_obj == null) { return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "TermsOfPayment object cannot be created as it is null")); } if (Exists(_obj)) { ExecuteNonQuery(GetQuery_UpdateQuery(_obj)); return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj)); } ExecuteNonQuery(GetQuery_InsertQuery(_obj)); _obj.FromDb = true; return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj)); }
public void Test_Find() { ITermsOfPaymentConnector connector = new TermsOfPaymentConnector(); var newTermsOfPayment = new TermsOfPayment() { Description = "TestPaymentTerms" }; //Add entries for (var i = 0; i < 5; i++) { newTermsOfPayment.Code = TestUtils.RandomString(); connector.Create(newTermsOfPayment); MyAssert.HasNoError(connector); } //Filter not supported connector.Search.LastModified = DateTime.Now.AddMinutes(-5); var fullCollection = connector.Find(); MyAssert.HasNoError(connector); Assert.AreEqual(5, fullCollection.Entities.Count); Assert.AreEqual("TestPaymentTerms", fullCollection.Entities[0].Description); //Apply Limit connector.Search.Limit = 2; var limitedCollection = connector.Find(); MyAssert.HasNoError(connector); Assert.AreEqual(2, limitedCollection.Entities.Count); //Delete entries foreach (var entry in fullCollection.Entities) { connector.Delete(entry.Code); } }
public async Task Test_Find() { var connector = FortnoxClient.TermsOfPaymentConnector; var newTermsOfPayment = new TermsOfPayment() { Description = "TestPaymentTerms" }; //Add entries for (var i = 0; i < 5; i++) { newTermsOfPayment.Code = TestUtils.RandomString(); await connector.CreateAsync(newTermsOfPayment); } //Filter not supported var searchSettings = new TermsOfPaymentSearch(); searchSettings.LastModified = TestUtils.Recently; var fullCollection = await connector.FindAsync(searchSettings); Assert.AreEqual(5, fullCollection.Entities.Count); Assert.AreEqual("TestPaymentTerms", fullCollection.Entities[0].Description); //Apply Limit searchSettings.Limit = 2; var limitedCollection = await connector.FindAsync(searchSettings); Assert.AreEqual(2, limitedCollection.Entities.Count); //Delete entries foreach (var entry in fullCollection.Entities) { await connector.DeleteAsync(entry.Code); } }
private DbUpdateStatement GetQuery_UpdateQuery(TermsOfPayment _obj) { return(DbMgr.CreateUpdateClause("TermsOfPayment", GetFields(_obj), "TermsOfPaymentID", _obj.TermsOfPaymentID)); }
private DbInsertStatement GetQuery_InsertQuery(TermsOfPayment _obj) { Dictionary <string, DbFieldEntry> fields = GetFields(_obj); return(DbMgr.CreateInsertClause("TermsOfPayment", fields)); }
/// <summary> /// Create a new Terms of payment /// </summary> /// <param name="termsOfPayment">The terms of payment entity to create</param> /// <returns>The created terms of payment.</returns> public TermsOfPayment Create(TermsOfPayment termsOfPayment) { return(BaseCreate(termsOfPayment)); }
/// <summary> /// Updates a terms of payment /// </summary> /// <param name="termsOfPayment"></param> /// <returns></returns> public TermsOfPayment Update(TermsOfPayment termsOfPayment) { return(BaseUpdate(termsOfPayment, termsOfPayment.Code)); }
public static async Task <TermsOfPayment> UpdateTermsOfPaymentAsync(FortnoxApiRequest request, TermsOfPayment termsOfPayment) { var apiRequest = new FortnoxApiClientRequest <SingleResource <TermsOfPayment> >(HttpMethod.Put, request.AccessToken, request.ClientSecret, $"{ApiEndpoints.TermsOfPayments}/{termsOfPayment.Code}/") { Data = new SingleResource <TermsOfPayment> { Data = termsOfPayment } }; return((await FortnoxAPIClient.CallAsync(apiRequest)).Data); }
internal static TermsOfPayment Set(object oID, object oDescription) { if ((oID is long) && (oDescription is string)) { TermsOfPayment xTermsOfPayment = new TermsOfPayment(); xTermsOfPayment.ID = (long)oID; xTermsOfPayment.Description = (string)oDescription; return xTermsOfPayment; } else { return null; } }
private void Clear() { m_IssueDate = null; m_Duration = null; m_TermsOfPayment = null; m_MethodOfPayment = null; }
private void Clear() { m_IssueDate = null; m_TermsOfPayment = null; m_MethodOfPayment = null; m_PaymentDeadline = null; }