softwerkab / fortnox-csharp-api-sdk

.NET SDK for Fortnox API.
MIT License
52 stars 64 forks source link

SupplierInvoiceNumber has wrong type in SupplierInvoiceFileConnectionSearch #189

Open bpaolo71 opened 3 years ago

bpaolo71 commented 3 years ago

SupplierInvoiceNumber in SupplierInvoiceFileConnectionSearch is of type string but want SupplierInvoice,GivenNumber which is a long? Just for the sake of clarity should not they be the same type ?

richardrandak commented 3 years ago

Yes, it make sense to make it a same type. This needs to be checked for all the search parameters to sync with the corresponding entity properties.

On the other hand, the search parameters could be understood as string patterns, not the actual values, since they are used as "LIKE" condition on server side.

richardrandak commented 3 years ago

Well.. actually, for the LIKE operator it seems there are only two special characters % and _ From the Fortnox documentation it seems, the parameter value is wrapped on server side and database query is build as "LIKE %{parametervalue}%".

Now I wonder... does it make sense to have something like %_123% ? Lets say we have these three values: 4123, 123, 441234 The %123% pattern would find matches with 4123, 123, 441234 The %_123% would find matches only with 4123, 441234.. the 123 is not a match, since it does not have any character before the '123' substring, corresponding to the single wild character represented by the _

Other example would be with using additional % Imagine full pattern as %12%3% vs %123% The first one would match value 1243 while the second pattern would not, due to "unexpected" 4 .

If there is a difference in results, the search parameters should support using the _ and % , therefore, should be strings.

richardrandak commented 3 years ago

The good question is then.. would Fortnox escape these characters? In that case, there would be no point of using them. I will have to test this :)

bpaolo71 commented 3 years ago

I understand your point of view but i was wondering if someone would like to find an invoice number which in its origin is a long type as partial string ? When i wrote my code i started by using the value in the proprety SupplierInvoive.InvoiceNumber that is a string and has the same name as the SupplierInvoiceFileConnectionSearch proprerty. But it didn't work. Så I realized that I should have used SupplierInvoice.GivenNumber but i find all that a litle confusing.