softwerkab / fortnox-csharp-api-sdk

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

Remove ReadOnly attribute from Article.SalesPrice #154

Closed WilliamGanrot closed 3 years ago

WilliamGanrot commented 3 years ago

I don't see any reason for the attribute [ReadOnly] on property Article.SalesPrice since the field is accessable directly through the API.

If the Attribute has to stay on the property please explain.

If the pr is accepted I would appriciate if you could do a release as soon as possible :)

Thanks

richardrandak commented 3 years ago

Hello William! The reason for this is that it was marked as read-only in the old documentation.

I also tried to update the property just now in Postman and it really is read-only, giving BadRequest in case it is sent in JSON.

What is your motivation for removing it? :)

In the SDK, the attribute needs to be there so that the serializer will not add the value to the generated JSON when sent to the server. So, you are able to retrieve an entity, change some properties and sent it back to server, without triggering the bad request.

WilliamGanrot commented 3 years ago

Hi!

We are working on an integration to Fortnox and need to be able to create an article, where the SalesPrice is a pretty vital property :)

I'm asuming that it's a bug in the API and the field should actually be writable since it's writable according to the documentation? If my assumption is correct do you think that is something that could be fixed? It's kind of crucial for us to be able to write to the field.

Thank you!

richardrandak commented 3 years ago

In which documentation is the SalesPrice write-able? I don't think it is a bug.

To change a price of an article, you have to update Price entity. I am not very familiar with price lists, but i tried just now, in my case, the SalesPrice is equal to a price in price list "A" for that article. So, when I updated a price in price list A, the SalesPrice on article changed as well.

So, check the PriceConnector

WilliamGanrot commented 3 years ago

It looks like it's writable according to this documentation since they pass a SalesPrice in the CURL example for creating an article. But yes, you are correct, if I scroll down I can in fact see that the SalesPrice is ReadOnly.

I will look in to the PriceConnector. Thanks for the help!

richardrandak commented 3 years ago

In the CURL request they only specified ArticleNumber and Description. The SalesPrice is in response json :) Anyway, good luck, let me know if you run in any other issues.