picqer / exact-php-client

PHP Client library for Exact Online
MIT License
165 stars 202 forks source link

Set StandardSalesPrice #648

Closed redbinky closed 2 weeks ago

redbinky commented 1 month ago

I can create succesful a new Item, but to set the StandardSalesPrice this has to be done via a seperate API call: SalesItemPrice.
However i did not get it working. After adding a item it returns a item GUID. I am using this ID to add a Standard Sales Price for a item. With this code:

$SalesItemPrice = new \Picqer\Financials\Exact\SalesItemPrice($connection); $SalesItemPrice->Item = '86822063-273e-4192-922c-a646cb079d8e'; //GUID of Item $SalesItemPrice->Price = 47.45; $SalesItemPrice->save();

But if i use this code i get 500 internal server error.

If i extract the GUID from the edit button in Exact under price managent and use the code as follows it works fine.

$SalesItemPrice = new \Picqer\Financials\Exact\SalesItemPrice($connection); $SalesItemPrice->ID = '3afc418e-f439-426c-bb7f-db69670aac46'; //GUID of price management $SalesItemPrice->Price = 47.45; $SalesItemPrice->save();

Can anyone explain me how to apply a standardSalesPrice for a Item.

DannyvdSluijs commented 1 month ago

I would recommend adding request response logging and see if there are any tips in the response body.

https://github.com/picqer/exact-php-client/wiki/Exact-php-client-tips#log-api-request-and-response

Besides that this is a community driven api client for actual support questions you might be best of asking Exact.

remkobrenters commented 1 month ago

Your explanation isn't entirely clear regarding the steps taken and the data submitted. However, as I understand it, you created an Item, used its ID to try to POST a SalesItemPrice, and encountered a 500 error. Then, you retrieved an ID from the Exact Online UI for a SalesItemPrice, and using that ID to update the price worked.

Could it be that when you created the product through the API, you provided the StandardSalesPrice, which likely created a SalesItemPrice in the background? Then, you might have tried to create a new record for the same product with the same price. Remember, the SalesItemPrice needs to be unique for the article, currency, unit, amount, and start date.

If this does not solves your question please provide more detailed information about the steps and data submitted and where possible and of added value some logs as @DannyvdSluijs suggested.