picqer / exact-php-client Goto Github PK
View Code? Open in Web Editor NEWPHP Client library for Exact Online
License: MIT License
PHP Client library for Exact Online
License: MIT License
Hi,
I've had my application running on my live environment. This worked perfectly fine.
Now I want to do some development locally (due to several reasons i can not use my live environment for this). However, when I transfered my application to my local environment and tested it I get the following error:
start.exactonline.nl redirected you too many times. Try clearing your cookies. ERR_TOO_MANY_REDIRECTS
Can anyone help me with figuring out what causes this? I can not find the problem.
I have of course changed the redirect urls to match with my local environment.
Kind regards
The SalesEntryLines end point is not correct.
Check this: https://start.exactonline.co.uk/docs/HlpRestAPIResourcesDetails.aspx?name=SalesEntrySalesEntryLines
protected $url = 'salesentry/SalesEntryLines';
instead of:
protected $url = 'salesinvoice/SalesInvoiceLines';
I'm having a list of account and want to get the contact info that belongs to it.
Currently I'm trying something like:
$contact = new Contact($connection);
$info = $contact->filter('Account eq \''.$account->ID.'\'');
But this is not working, I'm getting the error:
Error 400: Operator 'eq' incompatible with operand types 'System.Nullable`1[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' and 'System.String' at position 8.
When I output the results of $contact->get() it has a property Account
that contains the account ID. So I should be able to get the contact info by Account ID right?
Unfortunately to late or 3.0 I wanted to add another possibly breaking change. The biggest question is how to go about it.
We get this weird '/Data(microtime)/' string what should be a DateTime object when working with it and than again transformed back in the json body.
The problem is that we have no good indication of what elements to transform. We could check for '/Date(' on each property in Model->fill()
and perhaps fill another array so we don't have to look for DateTime objects in the Model->json()
method. Or we could add some Type info in the Entity declarations like ['StartDate' => 'DateTime'] or even a separate property type hints.
Also some suggestions on where to place timezone information is welcome. Connection is the only long lived object in the current model. Perhaps we can trigger the DateTime object replacement only when timezone is set for backward compatibility.
Please let me know what you think!
For anyone reading this and in need of a solution now:
function exactToDateTime($exact) {
$timestamp = substr($exact, 6, 10);
$date = new \DateTime();
$date->setTimestamp($timestamp);
return $date;
}
AmountFC is required by the Exact API for creating SalesEntryLines. However, in the $fillable property of the SalesEntryLine class it lists AmountDC instead of AmountFC.
The API docs for stockPosition (https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=ReadLogisticsStockPosition) states that the url to retrieve stock positions is like:
/api/v1/{division}/read/logistics/StockPosition?itemId=guid'00000000-0000-0000-0000-000000000000'
Currently this url is used:
/api/v1/{division}/read/logistics/StockPosition?%24filter=ItemId+eq+guid%2700000000-0000-0000-0000-000000000000%27
This results in a 400 error.
Probably exact-php-client/src/Picqer/Financials/Exact/Query/Findable.php should be edited on line 8-10 to account for this deviation, or StockPosition should not use the Findable mixin and define it's own method. (As StockPosition can also not be listed using get(), maybe this last method is best).
Currently I use:
$positions = $stock->filter([], '', '', ['itemId' => "guid'{$id}'"]);
$position = $positions[0];
which works.
I'm trying to show the PictureUrl from an item shown in https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=logisticsItems.
The image returns a 1x1 px white image to non loggedin users. How can I show the images to this users with your code?
Is it possible to authenticate an application on server side, without using the web interface to login?
As the title says, does this library also work for Exact Globe and not only Exact Online?
Thanks.
I don't know if it's dependant on my PHP version, but I noticed some issues with the update / delete function in the Storable trait.
When I'm done, I'll file a PR for this.
If you want to research this in the mean while. Please see if changing lines 25 and 30 of Storable.php to:
return $this->connection()->put($this->url . "(guid'{$this->{$this->primaryKey}}')", $this->json());
And
return $this->connection()->delete($this->url . "(guid'{$this->{$this->primaryKey}}')");
Thanks ;-).
Hi,
I run into an error while making an connection. I use the example to make a connection and I got the following issue :
Fatal error: Uncaught Exception: Could not connect to Exact: Client error:
POST https://start.exactonline.nl/api/oauth2/token` resulted in a 400 Bad Request
response: Bad Request in /var/www/html/oauth_call_connect.php:61 Stack trace: #0 {main} thrown in /var/www/html/oauth_call_connect.php on line 61`
Any help?
Im trying to send a request like:
$StockPosition = new apis\ExactOnline\Exact\StockPosition($connection, array('ItemId' => '3a6700ce-fb14-477d-8ea9-fd73a2f8d858'));
$result = $StockPosition->get();
But it is not working, first of all, the attributes are not included.
Changed this in Query\Findable.php:
public function get()
{
$result = $this->connection()->get($this->url);
return $this->collectionFromResult($result);
}
to this:
public function get()
{
$result = $this->connection()->get($this->url, $this->attributes);
return $this->collectionFromResult($result);
}
And after that, i changed in Picqer\Financials\Exact\StockPosition the url to: read/logistics/StockPosition
There's also no methods available to overwrite these values.
/**
* @var string
*/
private $apiUrl = 'https://start.exactonline.nl/api/v1';
/**
* @var string
*/
private $authUrl = 'https://start.exactonline.nl/api/oauth2/auth';
/**
* @var string
*/
private $tokenUrl = 'https://start.exactonline.nl/api/oauth2/token';
As you might know Exact also has an XML option. This option is very handy for importing transactions in one go (you don't have to create the General ledgers and journals automatically as the XML will do this for you). So for some cases this is very easy because you can make less requests.
I couldn't find this in this library since this is focussed on the REST API but I really liked the way for authentication. So I wrote a small gist that can POST and GET XML:
https://gist.github.com/alexjeen/6211c363c4efd4c3034cb3f81f7520bf
It may or may not be the best way to keep this in connection but as you see it isn't really hard to add. So it's up to the maintainer of this library if you want to copy this in or not.
Hi,
We're trying to add a "Boeking | Verkoopboek".
I tried adding a SalesEntry but I'm stuck with the error: "Ongeldige referentie: Journals"
Is SalesEntry
the correct model? And so, how can I fix the error above?
This is our current situation with the given error. Notice that I retrieve the journal id specifically to prevent any mismatch.
$journals = (new Journal($exact->connection()))->get();
$journal = array_filter($journals, function($journal) {
return $journal->Code == 70;
});
$journal = array_shift($journal);
\Log::info($journal->ID);
$accountingServiceEntry = new SalesEntry($exact->connection(), [
'Currency' => $invoice->valuta_id,
'Customer' => $invoice->klant->accounting_service_id,
'YourRef' => $invoice->nr,
'Journal' => $journal->ID,
'Description' => $description,
]);
$items = $invoice->getItems();
foreach($items as $invoiceItem) {
$accountingServiceEntry->addItem([
'Description' => $invoiceItem->omschr,
'Quantity' => (int) $invoiceItem->aantal,
'AmountFC' => $invoiceItem->bedrag,
'VATPercentage' => $invoiceItem->btw_perc,
]);
}
\Log::info($accountingServiceEntry->save());
Cheers
Hi there,
I'm completely new to Exact online. And I need to get all or search for clients in a application I'm making commissioned by my boss. Before downloading this and trying to make that work I want to ask if that is possible in the first place with this composer package? I can't seem to find anything like that in the examples.
I'm working with Laravel so this package would be ideal.
Thanks!
How can use the OrderBy ODATA function in a filter() request?
Edit: Stupid me!
The following code (found here):
/**
* @return mixed
*/
private function getCurrentDivisionNumber()
{
if (empty($this->division)) {
$me = new Me($this);
$this->division = $me->find()->CurrentDivision;
}
return $this->division;
}
causes the URL that is created through formatUrl()
(found here) to default to the CurrentDivision of the user that provided access to the API. When a user has access to multiple Divisions, and switches Divisions within the Exact Online webapp, the URL changes accordingly.
Wouldn't it be better to throw an Exception when $this->division
is not explicitly set, to prevent accidental communication with the wrong Division?
It's not possible to register webhook, i recivee this error,
Error 500: A problem has occurred. The cause of this issue will be investigated as soon as possible.
I try to fix that, changing in trait Storable.php
return $this->connection()->post($this->url, $this->json(0 TRUE));
into
return $this->connection()->post($this->url, $this->json(JSON_UNESCAPED_SLASHES, TRUE));
but still without result. Doeas anyoun try to register webhook thrue this library ?
SalesItemPrice is missing from the API
https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=LogisticsSalesItemPrices
Will this be implemented?
Hey, great work so far, works as expected and it is easy to handle.
However, I have a question which I can't answer myself.
I'm using your code like this:
$item = new \Picqer\Financials\Exact\SalesInvoice($connection);
$items = $item->filter("InvoiceToName eq 'Some name'");
And I get a response, however, do you offer something to parse it? Because it is returned as one long string and I can't access it via
$items["attributes"]
or something like this.
Does the new version number mean there are incompatibilities with the 2.* version? I could not find any information in the release notes in why a new major version number was chosen, does that mean that the changes are actually not that major?
We successfully integrated the package in our application for quite a while now. Each user can use their own exact environment to log invoices, products, customers etc.
This was all working fine until recently, a specific user with a clean/newly created Exact environment get's a Forbidden response when we're trying to insert an invoice into their Exact environment. The OAuth procedure was succesful, we can even insert products and retrieve journals to work with.
I think it's probably a specific setting in Exact. Did anyone ever encounter the same issue?
Small stack trace:
Hi, I am getting this error message when using your example file... Can you help?
Exception [ Error ]:
Could not connect to Exact: Client error response [status code] 400 [reason phrase] Bad Request [url] https://start.exactonline.nl/api/oauth2/token
When adding a SalesEntry with addItem array item added I get an error Undefined index: ID
When trying to save a SalesEntryLine I need an EntryID
When trying to save a SalesEntry without items I get "No sales entry lines. Sales entry lines must be supplied to create a new sales entry."
How do I solve this chicken-egg conundrum?
Is there a reason for that classes does not have @Property in class dockblock header for __get variables?
If not, i can prepare patch.
Hey Stephan,
Misschien had je 'm al gezien. In SalesEntryLine staat 2x AmountDC
Groeten!
Michael
never mind ;-)
I want to add SalesOrders to Exact Online. Will this be supported in the future?
I already tried adding SalesOrder.php and SalesOrderLine.php, based on the code from the SalesEntry files, but I can't get it to work yet. Adding a SalesOrder without SalesOrderLines returns an error telling me I need to add SalesOrderLines (so that's a good sign, ExactOnline seems to understand what I'm trying to do), but when I do add a SalesOrderLine before saving the SalesOrder it returns a 400 error.
Anybody have any suggestions on how to fix this?
Suddenly today the connection with exact stopped working and I am getting these errors:
Error - Could not connect to Exact: Client error: `POST https://start.exactonline.nl/api/oauth2/token` resulted in a `400 Bad Request`
and sometimes
Error - Could not connect to Exact: Could not acquire tokens, json decode failed.
I think this line is producing the error:
I get a login screen from exact, this will redirect me to my own webpage with a code parameter and then it barfs the error...
I tried creating a new api key etc but the errors are the same... I cannot debug why this is not working, I don't know if this library is the problem or the Exact API... Hopefully you can help me
I have used this library for some months now. Since 2 days, I am getting errors when connecting to Exact.
The first is:
Fatal error: Uncaught exception 'Exception' with message 'Could not connect to Exact: Client error: 'POST https://start.exactonline.nl/api/oauth2/token' resulted in a '400 Bad Request' response: 'Bad Request' in /vagrant/valvomo/include/application/class.Exact.php:901 Stack trace: #0 /vagrant/valvomo/include/application/class.Exact.php(40): Exact->connect(Array) #1 /vagrant/mijn/index.php(1040): Exact->index('10', Array) #2 {main} thrown in /vagrant/valvomo/include/application/class.Exact.php on line 901
After some debugging, I found:
Catchable fatal error: Object of class GuzzleHttp\Client could not be converted to string in /vagrant/vendor/picqer/exact-php-client/src/Picqer/Financials/Exact/Connection.php on line 114
But I have no clue how to fix it, going deeper is going into the src code of Guzzlehttp. Do you have a fix?
I have created a new class 'ReportingBalance.php' using the code below. However, creating an instance of this class does not work.
Im trying to create the new instance using:
$RepBal = new \Picqer\Financials\Exact\ReportingBalance($connection);
And I have created the new class using:
<?php namespace Picqer\Financials\Exact;
class ReportingBalance extends Model
{
use Query\Findable;
use Persistance\Storable;
protected $fillable = [
'ID',
'Amount',
'AmountCredit',
'AmountDebit',
'BalanceType',
'CostCentercode',
'CostCenterDescription',
'CostUnitCode',
'CostUnitDescription',
'Count',
'Division',
'GLAccount',
'GLAccountCode',
'GLAccountDescription',
'ReportingPeriod',
'ReportingYear',
'Status',
'Type'
];
protected $url = 'financial/ReportingBalance';
}
Am I missing something in the creation of the class?
So after cache fail, a new one popped up for my clients. This time, I got no clue what is causing this, I tried reinstalling everything through composer, I restarted the services, checked my ssl cerificate. Nothing seems to have changed, anyone has this problem and a solution to it?
Fatal error: Uncaught exception 'Picqer\Financials\Exact\ApiException' with message 'cURL error 56: SSL read: error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac, errno 0 (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in /vagrant/vendor/picqer/exact-php-client/src/Picqer/Financials/Exact/Connection.php:526 Stack trace: #0 /vagrant/vendor/picqer/exact-php-client/src/Picqer/Financials/Exact/Connection.php(192): Picqer\Financials\Exact\Connection->parseExceptionForErrorMessages(Object(GuzzleHttp\Exception\RequestException)) #1 /vagrant/vendor/picqer/exact-php-client/src/Picqer/Financials/Exact/Query/Findable.php(52): Picqer\Financials\Exact\Connection->get('crm/Accounts') #2 /vagrant/valvomo/include/application/class.Exact.php(891): Picqer\Financials\Exact\Account->get() #3 /vagrant/valvomo/include/application/class.Exact.php(718): Exact->checkCustomer(Object(Picqer\Financials\Exact\Connection), Array) #4 /vagrant/mijn/index.php(1067): Exact->postToExact() #5 {main} thrown in /vagrant/vendor/picqer/exact-php-client/src/Picqer/Financials/Exact/Connection.php on line 526
I get the following error when i try to create the class SalesItemPrice and use the get()
function:
exception 'Picqer\Financials\Exact\ApiException' with message 'Error 400: Please add a $select or a $top=1 statement to the query string.'
This is the code for the class SalesItemPrice:
<?php namespace Picqer\Financials\Exact;
/**
* Class SalesItemPrice
*
* @package Picqer\Financials\Exact
* @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=LogisticsSalesItemPrices
*
* @property Guid $ID Primary key
* @property Guid $Account ID of the customer
* @property String $AccountName Name of the customer account
* @property DateTime $Created Creation date
* @property Guid $Creator User ID of creator
* @property String $CreatorFullName Name of creator
* @property String $Currency The currency of the price
* @property String $DefaultItemUnit The default unit of the item
* @property String $DefaultItemUnitDescription The description of the default item unit
* @property Int32 $Division Division code
* @property DateTime $EndDate Together with StartDate this determines if the item is active
* @property Guid $Item Item ID
* @property String $ItemCode Code of Item
* @property String $ItemDescription Description of Item
* @property DateTime $Modified Last modified date
* @property Guid $Modifier User ID of modifier
* @property String $ModifierFullName Name of modifier
* @property Double $NumberOfItemsPerUnit This is the multiplication factor when going from default item unit to the unit of this price.For example if the default item unit is 'gram' and the price unit is 'kilogram' then the value of this property is 1000.
* @property Double $Price The actual price of this sales item
* @property Double $Quantity Minimum quantity to which the price is applicable
* @property DateTime $StartDate Together with StartDate this determines if the item is active
* @property String $Unit The unit code of the price
* @property String $UnitDescription Description of the price unit
*/
class SalesItemPrice extends Model
{
use Query\Findable;
use Persistance\Storable;
protected $fillable = [
'ID',
'Account',
'AccountName',
'Created',
'Creator',
'CreatorFullName',
'Currency',
'DefaultItemUnit',
'DefaultItemUnitDescription',
'Division',
'EndDate',
'Item',
'ItemCode',
'ItemDescription',
'Modified',
'Modifier',
'ModifierFullName',
'NumberOfItemsPerUnit',
'Price',
'Quantity',
'StartDate',
'Unit',
'UnitDescription'
];
protected $url = 'logistics/SalesItemPrices';
}
Hi,
I'm trying to fetch more than 60 results from the Exact API. I saw that you can limit the results using $top
but how can I fetch a different "part" of the results.
Can't find anything in their documentation about pagination...
(Tried $bottom
but that won't work obviously ^^)
Thanks.
Todo mentions:
However switching division already works as expected:
$connection = \app\models\Exact::connect(\app\models\Credential::findOne(1));
$connection->setDivision(123456);
$account = new \Picqer\Financials\Exact\Account($connection);
$account->Name = 'Alex';
$account->Status = 'C';
var_dump($account->save());
Hello,
i have an application on symfony 2.8 and want to connect to your api. The authorization success and i get the authorizationCode but when i want to get the Journals i am getting this error:
Could not connect to Exact: Client error: POST https://start.exactonline.de/api/oauth2/token resulted in a '400 Bad Request' response: Bad Request
My connect function:
public function connect() {
$em = $this->em;
//getting exact tokens from DB
$clientConfig = $this->getConfig();
$connection = new Connection();
$connection->setRedirectUrl($this->exactCallbackUrl);
$connection->setExactClientId($this->exactClientId);
$connection->setExactClientSecret($this->exactClientSecret);
$connection->setBaseUrl('https://start.exactonline.de');
if ($clientConfig->getAuthorizationcode()) {
$connection->setAuthorizationCode($clientConfig->getAuthorizationcode());
} // Retrieves authorizationcode from database
if (null !== $clientConfig->getAccesstoken()) {
$connection->setAccessToken(unserialize($clientConfig->getAccesstoken()));
}// Retrieves accesstoken from database
if (null !== $clientConfig->getRefreshtoken()) {
$connection->setRefreshToken($clientConfig->getRefreshtoken());
}// Retrieves refreshtoken from database
if (null !== $clientConfig->getExpiresIn()) { // Retrieves expires timestamp from database
$connection->setTokenExpires($clientConfig->getExpiresIn());
}
// Make the client connect and exchange tokens
try {
$connection->connect();
} catch (\Exception $e) {
throw new Exception('Could not connect to Exact: ' . $e->getMessage());
}
// Save the new tokens for next connections
$clientConfig->setAccesstoken(serialize($connection->getAccessToken()));
$clientConfig->setRefreshtoken($connection->getRefreshToken());
$clientConfig->setExpiresIn($connection->getTokenExpires());
$clientConfig->setUpdateDate(new \DateTime());
$em->persist($clientConfig);
$em->flush();
return $connection;
}
An auhtorizationCode from the DB:
eTWA!IAAAAHCcr0YXhas8XRzqtKBc0xBCZGYUyNUVhcSj1jiX0W0vAQEAAAEyItD_eVi1LRgnj0O0aLN9E2L18zBYgYxZo5nBs4oG6k5aBtSjsP5sP0C-E8SEWVzlr7k_XS_xHHPe7S2Z9v285nYxHI3vhoUWM1wUeHJpCxNYLmmvhhOmZQ8TPFHT3bFr9jaTz45j88tx_tPDBcHJ3mxZt3L3VWZvWL3sBY4RBp09-AqIIgzwpGMJrdcE8CCN-LcXZBxOyc2t6cRSuVSOJZ8q9Ku7RJXjR2tPMSLWbL9qJ_IZr1rHBvXFcS0CAxHtH0xB1vaFCXBPapVsza2p86Ew2bpFas5sdDtbtMw_iOjvbw8_iVLhol-rcsKFZuqJ2hRzBk9H8YQWBC7kAp48
What i am doing wrong?
I have looked in almost every file to find a possible solution to get the Stock Location, anyone has a solution yet?
The __call
method of class Model
(added in 8f4e812) prevents calling private method isFillable
.
Code example:
$account = new Account($connection);
if ($account->isFillable('Description') )
{
$account->Description = $sDescription;
}
Is there a reason why isFillable
shouldn't be accessible on an instance?
Possible solutions to make the code example work again:
isFillable
in a public function, so it's call isn't handled by __call
.__call
test if $name
doesn't refer to a method, before handling it as a property.What's your opinion?
In short; great library, definitely the way to go for us to integrate with Exact.
Over the upcoming weeks we wil start implementing this, and the way we'd like to do this is by creating a bridge bundle to integrate this library with Symfony. The thing we're planning on:
Connection
configurable via DIClogger
into Connection
and Guzzle
client (I'd like to propose to go for Monolog)OptionResolver
on the most important required fields of Connection
Connection
to make it a DataCollectingConnection
that adds information to the profiler
via a custom data collector.stopwatch
component to benchmark requests in the profiler performance metrics panel.Would love to hear your feedback on this.
Question, how do we get transaction lines again?
//(where getTransactions is a wrapper to new Transactions($connection)
$transactions = $this->exactClient->getTransactions()->filter('','','EntryNumber, ClosingBalanceFC, Description, Date, TransactionLines');
foreach ($transactions as $transaction) {
var_dump($transaction->TransactionLines);
}
array(1) {
["__deferred"]=>
array(1) {
["uri"]=>
string(136) "https://start.exactonline.de/api/v1/31816/financialtransaction/Transactions(guid'2081821f-337f-45a1-ab62-fca677467846')/TransactionLines"
}
}
that URI leads me to an XML doc... (if i used $connection->get($the_above_url) , I get a '
Hallo Stephan,
Bedankt voor deze code, het heeft mij een heel stuk op weg geholpen. Ik loop alleen tegen een ding aan bij het updaten en verwijderen van een record.
De wijzigingen worden wel doorgevoerd binnen Exact, maar na het verwerken van mijn opdracht krijg ik deze foutmelding.
ApiException in Connection.php line 498: array_key_exists() expects parameter 2 to be array, null given
Heb jij enig idee wat hier het probleem zou kunnen zijn?
Vriendelijke groet,
Michael
Hi,
I'm using your library for a while now and i really like it. But i have a question about the output of a save action.
If i make a save action i get output that is protected so i can't really use it.
Is there a way to just get the json output from exact so i can use that for more actions?
regards,
Egbert
Ps, i wrote this in english but i am dutch, so if its more convenient to answer in dutch thats possible ;)
The results from the function getDateTimeFromExpires of the Connection class (/src/Picqer/Financials/Exact/Connection.php:455) returns a time based on the current time, instead of using the parameter given.
Hi,
I've made a class named SalesItemPrice which I use to retrieve the sales price for an item, but the price returned is an old price. The price returned is 65 and the price in Exact is 95.
The code for the class i've made:
<?php namespace Picqer\Financials\Exact;
/**
* Class SalesItemPrice
*
* @package Picqer\Financials\Exact
* @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=LogisticsSalesItemPrices
*
* @property Guid $ID Primary key
* @property Guid $Account ID of the customer
* @property String $AccountName Name of the customer account
* @property DateTime $Created Creation date
* @property Guid $Creator User ID of creator
* @property String $CreatorFullName Name of creator
* @property String $Currency The currency of the price
* @property String $DefaultItemUnit The default unit of the item
* @property String $DefaultItemUnitDescription The description of the default item unit
* @property Int32 $Division Division code
* @property DateTime $EndDate Together with StartDate this determines if the item is active
* @property Guid $Item Item ID
* @property String $ItemCode Code of Item
* @property String $ItemDescription Description of Item
* @property DateTime $Modified Last modified date
* @property Guid $Modifier User ID of modifier
* @property String $ModifierFullName Name of modifier
* @property Double $NumberOfItemsPerUnit This is the multiplication factor when going from default item unit to the unit of this price.For example if the default item unit is 'gram' and the price unit is 'kilogram' then the value of this property is 1000.
* @property Double $Price The actual price of this sales item
* @property Double $Quantity Minimum quantity to which the price is applicable
* @property DateTime $StartDate Together with StartDate this determines if the item is active
* @property String $Unit The unit code of the price
* @property String $UnitDescription Description of the price unit
*/
class SalesItemPrice extends Model
{
use Query\Findable;
use Persistance\Storable;
protected $fillable = [
'ID',
'Account',
'AccountName',
'Created',
'Creator',
'CreatorFullName',
'Currency',
'DefaultItemUnit',
'DefaultItemUnitDescription',
'Division',
'EndDate',
'Item',
'ItemCode',
'ItemDescription',
'Modified',
'Modifier',
'ModifierFullName',
'NumberOfItemsPerUnit',
'Price',
'Quantity',
'StartDate',
'Unit',
'UnitDescription'
];
protected $url = 'logistics/SalesItemPrices';
}
and here is the code that I use to retrieve the items:
$salesItemPrice = new \Picqer\Financials\Exact\SalesItemPrice($connection); $salesItemPrices = $salesItemPrice->filter('', '', 'Price, ItemCode');
Does anybody have any idea why it would return the old price and not the new one?
After save or add object exactonline api do not return info about codeid, and other data.
I fix this by changing in Connection.php headers from
$headers = array_merge($headers, [
'Accept' => 'application/json',
'Content-Type' => 'application/json'
]);
into
$headers = array_merge($headers, [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Prefer' => 'return=representation'
]);
When I want to update a purchaseEntry with a newly uploaded document, I get this following error:
Error 400: Please add a $select or a $top=1 statement to the query string.
I'm using this lines to fetch the right purchaseEntry.
$purchaseInvoice = new \Picqer\Financials\Exact\PurchaseEntry($connection);
$purchaseInvoice = $purchaseInvoice->find($purchaseInvoiceID);
$purchaseInvoice->Document = $documentID;
$purchaseInvoice->update();
When I change the find() function in Findable.php like this:
public function find($id, $select = '')
{
$result = $this->connection()->get($this->url, [
'$filter' => $this->primaryKey . " eq guid'$id'",
'$select' => $select
]);
return new self($this->connection(), $result);
}
Using this, it seems to work.
$purchaseInvoice = new \Picqer\Financials\Exact\PurchaseEntry($connection);
$purchaseInvoice = $purchaseInvoice->find($purchaseInvoiceID, 'EntryID, Document');
$purchaseInvoice->Document = $documentID;
$purchaseInvoice->update();
Hi,
I've been tryin to add a salesinvoice in the same way you are doing it in the example, only by hardcoded ID's and stuff. Did you manage to get an invoice added?
The exception i get is :
{ "error": { "code": "", "message": { "lang": "", "value": "Verplicht: Factuur voor\r\nVerplicht: Besteld door" } } }
This is the code i used. $items is an array just like the way you showed in your example.
$salesinvoice = new \Picqer\Financials\Exact\SalesInvoice($connection);
$salesinvoide->InvoiceTo = '8578a5d2-d4cf-48f2-a299-03ab75edcc74';
$salesinvoice->OrderedBy = '8578a5d2-d4cf-48f2-a299-03ab75edcc74';
$salesinvoice->YourRef = '50098';
$salesinvoice->Description = 'Beschrijving';
$salesinvoice->SalesInvoiceLines = $items;
$salesinvoice->save();
I've also reached out to exact online with this error, will update if i get it working with the solution they maybe provide.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.