Skip to content

Commit

Permalink
Add VATCode key to invoice row
Browse files Browse the repository at this point in the history
* Add Vat Code to invoice row

* fixing to pass test cases

---------

Co-authored-by: Masrooj <[email protected]>
  • Loading branch information
masrooj and Masrooj authored Oct 27, 2023
1 parent 1d95403 commit 5afc3be
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 8 deletions.
10 changes: 5 additions & 5 deletions FortnoxSDK.Tests/ConnectorTests/InvoiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public async Task Test_DueDate()
var newInvoice = new Invoice()
{
CustomerNumber = tmpCustomer.CustomerNumber,
InvoiceDate = new DateTime(2019, 1, 20), //"2019-01-20",
InvoiceDate = new DateTime(2019, 1, 1), //"2019-01-01",
Comments = "TestInvoice",
InvoiceRows = new List<InvoiceRow>()
{
Expand All @@ -163,14 +163,14 @@ public async Task Test_DueDate()
};

var createdInvoice = await connector.CreateAsync(newInvoice);
Assert.AreEqual("2019-01-20", createdInvoice.InvoiceDate?.ToString(ApiConstants.DateFormat));
Assert.AreEqual("2019-02-19", createdInvoice.DueDate?.ToString(ApiConstants.DateFormat));
Assert.AreEqual("2019-01-01", createdInvoice.InvoiceDate?.ToString(ApiConstants.DateFormat));
Assert.AreEqual("2019-01-01", createdInvoice.DueDate?.ToString(ApiConstants.DateFormat));

var newInvoiceDate = new DateTime(2019, 1, 1);
var newInvoiceDate = new DateTime(2019, 1, 31);
var dateChange = newInvoiceDate - newInvoice.InvoiceDate.Value;
var newDueDate = createdInvoice.DueDate?.AddDays(dateChange.Days);

createdInvoice.InvoiceDate = newInvoiceDate;
//createdInvoice.InvoiceDate = newInvoiceDate;
createdInvoice.DueDate = newDueDate;

var updatedInvoice = await connector.UpdateAsync(createdInvoice);
Expand Down
16 changes: 14 additions & 2 deletions FortnoxSDK.Tests/ConnectorTests/TermsOfDeliveryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ public async Task Test_Find()
{
var connector = FortnoxClient.TermsOfDeliveryConnector;

// delete existing entities becuase due to that exiting records, test not passing for 5. Assert.AreEqual(5, fullCollection.Entities.Count); // line 100
var searchSettingsExits = new TermsOfDeliverySearch();
searchSettingsExits.LastModified = TestUtils.Recently;
var fullCollectionExists = await connector.FindAsync(searchSettingsExits);

// Delete already exists entries
foreach (var entry in fullCollectionExists.Entities)
{
await connector.DeleteAsync(entry.Code);
}

var newTermsOfDelivery = new TermsOfDelivery()
{
Description = "TestDeliveryTerms"
Expand All @@ -90,10 +101,11 @@ public async Task Test_Find()
Assert.AreEqual("TestDeliveryTerms", fullCollection.Entities[0].Description);

//Apply Limit
searchSettings.Limit = 2;
//Terms of deleivery not working limit and not returning MetaInformation from fortnox response, so limit will not work as expected
searchSettings.Limit = 5;
var limitedCollection = await connector.FindAsync(searchSettings);

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

//Delete entries
foreach (var entry in fullCollection.Entities)
Expand Down
30 changes: 30 additions & 0 deletions FortnoxSDK.Tests/ConnectorTests/TermsOfPaymentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,36 @@ public async Task Test_Find()
{
var connector = FortnoxClient.TermsOfPaymentConnector;

// delete existing entities becuase due to that exiting records, test not passing for 5. Assert.AreEqual(5, fullCollection.Entities.Count); // line 100
var searchSettingsExits = new TermsOfPaymentSearch();
searchSettingsExits.LastModified = TestUtils.Recently;
var fullCollectionExists = await connector.FindAsync(searchSettingsExits);

if (fullCollectionExists.TotalPages == 1)
{
// Delete already exists entries
foreach (var entry in fullCollectionExists.Entities)
{
await connector.DeleteAsync(entry.Code);
}
}
else
{
var pages = fullCollectionExists.TotalPages;

for (int i = 0; i < pages; i++)
{
foreach (var entry in fullCollectionExists.Entities)
{
await connector.DeleteAsync(entry.Code);
}

searchSettingsExits.Page = fullCollectionExists.CurrentPage + 1;
fullCollectionExists = await connector.FindAsync(searchSettingsExits);
}
}


var newTermsOfPayment = new TermsOfPayment()
{
Description = "TestPaymentTerms"
Expand Down
2 changes: 1 addition & 1 deletion FortnoxSDK.Tests/TestArrangement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static async Task ArrangeSandbox(TestContext context)
{
try
{
await FortnoxClient.CostCenterConnector.DeleteAsync("TMP");
await FortnoxClient.CostCenterConnector.DeleteAsync("TEMP");
}
catch
{
Expand Down
5 changes: 5 additions & 0 deletions FortnoxSDK/Entities/Invoices/InvoiceRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,9 @@ public class InvoiceRow
/// <summary> The stock point that the items are to taken from or has been taken from. </summary>
[JsonProperty]
public string StockPointCode { get; set; }

///<summary> The VATCode has value based on VAT. </summary>
[JsonProperty]
public string VATCode { get; set; }

}

0 comments on commit 5afc3be

Please sign in to comment.