picqer / moneybird-php-client Goto Github PK
View Code? Open in Web Editor NEWPHP Client for Moneybird V2
License: MIT License
PHP Client for Moneybird V2
License: MIT License
Like a SalesInvoice, a Contact is also searchable with the filter() method, so Contact can be extended with this functionality.
Regards,
Joep
Hello,
I have a question about the example code. I am trying to save a contact as in your example.
$contact = $moneybird->contact();
$contact->company_name = 'foo';
$contact->save();
But on this and other action I try I get a 404 error.
Picqer\Financials\Moneybird\Exceptions\ApiException : Error 404: {"error":"404 Not Found"}
I have checked the accesstoken etc. but they seem correct and work when I used the curl command. Any idea what i'm doing wrong?
Hi,
when I want to save a contact like this:
// Example: Create a new contact
$contact = $moneybird->contact();
$contact->firstname = 'Test';
$contact->lastname = 'Test';
$contact->email = '[email protected]';
$contact->save();
And I var_dump($contact);
, I see that the ID field is NULL...
Contact {#430 โผ
+"id": null
+"company_name": null
+"firstname": "Test"
+"lastname": "Test"
+"attention": null
+"address1": null
+"address2": null
+"zipcode": null
+"city": null
+"country": null
+"email": "[email protected]"
+"phone": null
+"delivery_method": null
+"customer_id": null
+"tax_number": null
+"chamber_of_commerce": null
+"bank_account": null
+"send_invoices_to_attention": null
+"send_invoices_to_email": null
+"send_estimates_to_attention": null
+"send_estimates_to_email": null
+"sepa_active": null
+"sepa_iban": null
+"sepa_iban_account_name": null
+"sepa_bic": null
+"sepa_mandate_id": null
+"sepa_mandate_date": null
+"sepa_sequence_type": null
+"credit_card_number": null
+"credit_card_reference": null
+"credit_card_type": null
+"tax_number_validated_at": null
+"created_at": null
+"updated_at": null
+"notes": null
+"custom_fields": null
+"version": null
}
I use this code:
$moneyBird = new Moneybird($this->connect());
$estimate = $moneyBird->estimate()->get();
this return :Exceptions\ApiException: Error 401: {"error":"No access to estimates"}
When a 429 error is spawned by MoneyBird the Picqer\Financials\Moneybird\Exceptions\ApiException
exception is thrown. I would except the $code
property to be 429. However it is empty! Therefore you need to parse the $message
yourself.
Do you agree? If so I can implement it this way.
Hi @stephangroen ,
it is unclear to me how to set the details of a (recurring sales) invoice. Unfortunately there is no example available for this. Can you tell me how to do this? I'd be more than happy to create an example afterwards, so others know how to do it.
Current code:
$this->_moneybird = new MoneybirdAPI\Moneybird($this->_connection);
$invoiceDetail = $this->_moneybird->salesInvoiceDetail();
$invoiceDetail->tax_rate_id = $this::TAX_HIGH; // ID of 21% tax in MoneyBird
$invoiceDetail->price = '5.00';
$invoiceDetail->description = 'Foo';
$invoiceDetail->period = 'prev_month';
$invoice = $this->_moneybird->recurringSalesInvoice();
$invoice->contact_id = $contactID; // Valid contact ID
$invoice->currency = 'EUR';
$invoice->prices_are_incl_tax = true;
$invoice->reference = 'Bar';
$invoice->invoice_date = date('Y-m-d', strtotime('first day of next month'));
$invoice->frequency_type = 'month';
$invoice->frequency = 1;
$invoice->details = [$invoiceDetail]; // This fails
$invoice->save();
The invoice is saved, but without any invoice lines. I've tried the following codes for setting the details:
$invoice->details = $invoiceDetail;
$invoice->details = [$invoiceDetail];
$invoice->details = [0 => $invoiceDetail];
$invoice->details = (object) [$invoiceDetail];
$invoice->details = (object) [0 => $invoiceDetail];
$invoice->__set('details', $invoiceDetail);
$invoice->__set('details', [$invoiceDetail]);
But none of them work :( Your help on this is much appreciated. Bedankt!
I'm trying to filter on company_names if they exist or not. I see it working with for example a sales invoice status (draft) but is it also possible to filter contacts? With code:
$contact = $moneybird->contact()->filter([
'company_name' => 'Tester'
]);
var_dump($contact);
I know this is on the ToDo-list, but having a dedicated issue makes it easier to reference from code ๐ค and might trigger someone to put effort in this / refer it from a Pull Request. Maybe I will have time to dive in to this after the summer.
Is there a way by fetching all salesinvoices if the late and reminded has a workflow pay in terms?
I use this function but i want to add the pay in terms.
/**
* find Late and Open SalesInvoices
* @return array|bool|string
*/
public function findLateRemindedInvoices()
{
if ($moneybird = $this->moneybirdClient()) {
try {
$late_invoices = $moneybird->salesInvoice()->filter([
'state' => 'late'
]);
$reminded_invoices = $moneybird->salesInvoice()->filter([
'state' => 'reminded'
]);
return array_merge($late_invoices, $reminded_invoices);
} catch (\Exception $e) {
return get_class($e) . ' : ' . $e->getMessage();
}
}
return false;
}
It would be helpful if you could pass options or set fetchAll to true in FindAll:get(), e.g.:
<?php namespace Picqer\Financials\Moneybird\Actions;
/**
* Class FindAll
* @package Picqer\Financials\Moneybird\Actions
*/
trait FindAll
{
/**
* @param $options array
* @param $fetchAll boolean
* @return mixed
*/
public function get($options = [], $fetchAll = false)
{
$result = $this->connection()->get($this->getEndpoint(), $options, $fetchAll);
return $this->collectionFromResult($result);
}
/**
* @return mixed
*/
public function getAll()
{
$result = $this->connection()->get($this->getEndpoint(), [], true);
return $this->collectionFromResult($result);
}
}
Would be nice if there would be pagination support out of the box. Any ideas how to implement it? If i have the time i can PR it.
I'm trying to add estimates and send them automatically after filling in a form. Adding the Estimate to Moneybird works, just not how it should. Details aren't added and besides that I am unable to send the estimate, only to save it as a draft.
In another issue I saw code that used $moneybird->salesInvoiceDetail()
, just as you would with adding an invoice. I tried using that, but the Details in the actual Estimate in Moneybird are not there. Using EstimateDetail()
or estimateDetail()
results in an error stating that those methods don't exist.
Using $moneybird->sendEstimate()
and $moneybird->send()
for trying to send the Estimate result in the same 'method does not exist' error.
I noticed that in SalesInvoice.php
the SalesInvoiceDetail
and sendInvoice()
mentioned specifically. Those for Estimates in Estimate.php
are missing (or at least not there). Is that the reason why adding details to my Estimate (and trying to send it) are failing?
As of October 13, recurring sales invoices can be filtered. It would be great if this was supported, i.e. $invoices = $connection->recurringSalesInvoice()->filter(['contact_id' => 1234567890]);
Is this as simple as adding use Filterable
to the RecurringSalesInvoice
class? If so I'd be happy to provide a PR.
I think you forgot to add a new tag on the repo, since these two files differ;
(the 'period' attribute is present in master, but not in v0.2.0)
I'd like to create an invoice, but I need to send data to the endpoint. Currently I can't find any method to do so except for the insert()
method (I'm assuming it makes a POST call to that endpoint). Is there a way this is possible or do I need to edit the code to add the functionality? Thanks
This is the code I have:
use \Picqer\Financials\Moneybird;
$client = new Moneybird\Connection();
$client->setClientId(CONFIG_API_ID);
$client->setAccessToken(CONFIG_API_TOKEN);
$invoice = new Moneybird\Moneybird($client);
$invoice->salesInvoice()->insert()
When working on #63 I noticed (again) that:
integer
in the API documentation, are of type string
in the model, for example:
DateTime
or DateTimeImmutable
objects, are of type string
in the model, for example:
I think the integers are incorrectly returned as a string by the API, I will contact Moneybird about that.
About the dates, should we consider detecting 'date' strings and assemble a DateTimeImmutable
for that?
Hey,
I want to do something like this, but it is not possible? Want to fetch a total number on estimates that are open / late
$offers = $moneybird
->estimate()
->listVersions()
->filter([
'period' => 'this_year',
'state' => 'open|late',
]);
without listVersions()
it works...
Currently it sometimes is 'difficult' to use the Entities as used by the API since it is not directly clear what properties are available / involved.
This can be improved by, for example:
/**
* @property string $state The state of this SalesInvoice, either 'x', 'y', or 'z'
* @property <type> <name> <description> XYZ
*/
class SalesInvoice {
//content
}
Now IDE's will detect the state
property, making it easier to use the Entities. More info here: https://phpdoc.org/docs/latest/references/phpdoc/tags/property.html
Currently there is no support for the custom_fields field for recurring invoices, although MoneyBird does support it. Can you add it to RecurringSalesInvoice.php?
<?php namespace Picqer\Financials\Moneybird\Entities;
use Picqer\Financials\Moneybird\Actions\Filterable;
use Picqer\Financials\Moneybird\Actions\FindAll;
use Picqer\Financials\Moneybird\Actions\FindOne;
use Picqer\Financials\Moneybird\Actions\Removable;
use Picqer\Financials\Moneybird\Actions\Storable;
use Picqer\Financials\Moneybird\Actions\Synchronizable;
use Picqer\Financials\Moneybird\Model;
/**
* Class RecurringSalesInvoice
* @package Picqer\Financials\Moneybird\Entities
*/
class RecurringSalesInvoice extends Model {
use FindAll, FindOne, Storable, Removable, Filterable, Synchronizable;
/**
* @var array
*/
protected $fillable = [
'id',
'contact_id',
'contact',
'workflow_id',
'state',
'start_date',
'invoice_date',
'last_date',
'payment_conditions',
'reference',
'language',
'currency',
'discount',
'first_due_interval',
'auto_send',
'mergeable',
'sending_scheduled_at',
'sending_scheduled_user_id',
'frequency_type',
'frequency',
'created_at',
'updated_at',
'details',
'notes',
'attachments',
'has_desired_count',
'desired_count',
'custom_fields',
];
/**
* @var string
*/
protected $endpoint = 'recurring_sales_invoices';
/**
* @var string
*/
protected $namespace = 'recurring_sales_invoice';
/**
* @var array
*/
protected $multipleNestedEntities = [
'details' => [
'entity' => 'RecurringSalesInvoiceDetail',
'type' => self::NESTING_TYPE_ARRAY_OF_OBJECTS,
],
];
}
Hello,
I installed your API with composer on my local computer. After moving to a server I get the following Fatal error: Call to undefined function GuzzleHttp\Handler\curl_reset()
Do I need to upgrade the server to PHP 5.5 ?
Or is this because I didn't install the API with composer again op the server?
I can't use composer on the server so I hope there is an other solution if this is the problem.
Thanks in advance,
Hello Stephan,
I try to use your moneybird V2 api but i'm a bit stuck.
I get the following error:
Fatal error: Uncaught exception 'Picqer\Financials\Moneybird\Exceptions\ApiException' with message 'cURL error 60: SSL certificate problem: self signed certificate in certificate chain (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in vendor\picqer\moneybird-php-client\src\Picqer\Financials\Moneybird\Connection.php on line 373
Can you please help me?
Thanks in advance.
SalesInvoice entity has a protected $url attribute to hold the endpoint location, but also get's a url for the public location of the invoice. The latter is never reachable by just requesting $salesInvoice->url
and is now only available via $salesInvoice->attributes()
.
Hi,
When i try to save a custom field for a contact, with the following example code. It's only saving the last entry. This occurs when creating a new contact.
$customField = $moneybird->contactCustomField();
$customField->id = 142467688176813880;
$customField->value = 'Field_0';
$customField_2 = $moneybird->contactCustomField();
$customField_2->id = 142467688176813881;
$customField_2->value = 'Field_1';
$customFields = [];
$customFields[] = $customField;
$customFields[] = $customField_2;
$contact->custom_fields = $customFields;
$contact->save();
When i dump the values of both fields. I see that the object is being created. But not saved to MoneyBird. I am using the latest release.
When using Moneybird, setting an access token is sufficient to perform authenticated requests (Picqer\Financials\Moneybird\Connection->setAccessToken()
). However, in Picqer\Financials\Moneybird\Connection->createRequest()
it is required to set the authorization code as it is checked upon with Picqer\Financials\Moneybird\Connection->needsAuthentication()
.
Fatal error: Uncaught exception 'Picqer\Financials\Moneybird\Exceptions\ApiException' with message 'Error 404: {"error":"404 Not Found"}
I get the fatal error when trying to delete:
// Create the Moneybird client
$connection = $this->connect($this->redirectUrl, $this->clientId, $this->clientSecret);
$connection->setAdministrationId($this->administrationId);
$moneybird = new \Picqer\Financials\Moneybird\Moneybird($connection);
$moneybird->contact()->delete();
I've used the example and added that line after making connection
Other functions work fine, awesome client ๐
Misschien kijk ik er overheen, maar ik kan niet vinden hoe ik een credit invoice aanmaak van een factuur (duplicate_creditinvoice)
Zit dit hier nog niet in?
The Picqer\Financials\Moneybird\Actions\FindOne::find()
is used to find e.g. a contact for a given id.
It does a request to moneybird, which has 3 possibly outcomes:
{"error":"record not found","symbolic":{"customer_id":"not_found"}}
is returned.Currently, Picqer\Financials\Moneybird\Actions\FindOne::find()
does not properly distinguish between cases 2 and 3.
In both cases:
GuzzleHttp\Exception\ClientException
, because the client is configured with 'http_errors' => true
. This still contains the complete response.Picqer\Financials\Moneybird\Connection::parseExceptionForErrorMessages()
converts this into an Picqer\Financials\Moneybird\Exceptions\ApiException
. This exception class is much less convenient, and also does not contain the parent exception.Picqer\Financials\Moneybird\Actions\FindOne::find()
does not care to catch any exceptions.This means a caller needs to parse the exception message to find out which of the cases 2. or 3. is happening.
E.g. I am having a case where I have a record in the local database referencing moneybird contact ids.
If the contact no longer exists in moneybird, I should delete the local record.
However, if the connection failed, it means that the contact might still exist in moneybird, and deleting the local record would be a grave mistake.
I see the following options.
Picqer\Financials\Moneybird\Actions\FindOne::find()
return NULL if the entity does not exist, and throw an exception if there are connection problems. This is a BC break.Picqer\Financials\Moneybird\Actions\FindOne::findOrNull()
with the described behavior, and leave the other method as it is. This is no BC break, but clutters the API.'http_errors' => true
parameter for the Guzzle client.Can you help me how to add an estimate?
setClientId('CLIENTID'); $connection->setClientSecret('CLIENTSECRET'); $connection->setAuthorizationCode('AUTHORIZATIONCODE'); $connection->setAccessToken('ACCESTOKEN'); $administrationId = 'ADMINISTRATION ID'; try { $connection->connect(); } catch (\Exception $e) { throw new Exception('Could not connect to Moneybird: ' . $e->getMessage()); } $connection->setAdministrationId($administrationId); $moneybird = new \Picqer\Financials\Moneybird\Moneybird($connection); $contacs= $con->query("SELECT \* FROM `contacts` WHERE id='$id'"); if( $contacs->num_rows>0 ) { while ( $contact= $contacs->fetch_object() ) { $email = $contact->email; } } $emails = $con->query("SELECT \* FROM `moneybirdContacten` WHERE email='$email'"); if( $emails->num_rows>0 ) { while ( $email = $emails->fetch_object() ) { $contactid = $email->moneybirdid; } } $workflow_id = 'WORKFLOWID'; $document_style_id = 'DOCUMENTSTYLEID'; $estimate = $moneybird->estimate(); $estimate->contact_id = $contactid; $estimate->workflow_id = $workflow_id; $estimate->document_style_id = $document_style_id; $estimate->save(); ?>I added Estimate to moneybird.php
I never worked with an composer, I dont know what to do. The previous version is easy to install. With a view lines in .php. But now i dont know what to do. Please help!
In Moneybird you can pick what type of Authentication you want. It's also possible to generate a token for one administration (and send this as a Bearer header). Does this library support this?
Hi @stephangroen,
I'm trying to add details to a recurringInvoice. This is what I've tried so far. It says:
Call to undefined method Picqer\Financials\Moneybird\Moneybird::recurringSalesInvoiceDetail()
.
The solution / PR that #14 suggested doesn't seem to work anymore. Am I overseeing something?
Thanks.
$invoiceDetail = $moneybird->recurringSalesInvoiceDetail();
$invoiceDetail->tax_rate_id = $taxrate;
$invoiceDetail->price = '5.00';
$invoiceDetail->description = 'Foo';
$invoice = $moneybird->recurringSalesInvoice();
$invoice->contact_id = $contact_id;
$invoice->prices_are_incl_tax = true;
$invoice->reference = 'Bar';
$invoice->frequency_type = 'year';
$invoice->frequency = 1;
$invoice->details = [$invoiceDetail];
I added the recurringSalesInvoiceDetail method but it doesn't seem to add anything. Adding the invoice works fine without the $invoice->details
part.
https://developer.moneybird.com/api/sales_invoices/#post_sales_invoices_id_attachments
See this commit for a possible solution
dannyvw@72ece22
As I'm switching over from the v1 of the API with the youngguns wrapper, I'm looking for a markAsSent equivalent. Right now the Invoices get marked as a concept because I'm sending the PDF's with a custom email, together with other attachments. I've tried to set the sent_at property but it doesn't have the required effect.
Any help would be greatly appreciated!
We use PHP-DI as dependency injection container which allows us to:
[
Picqer\Financials\Moneybird\Connection::class => object()->constructor()
->method('setClientId', 'X')
->method('setClientSecret', 'Y')
->method('setRedirectUrl', 'Z'),
Picqer\Financials\Moneybird\Moneybird::class => object()->constructor(get(Picqer\Financials\Moneybird\Connection::class)),
]
Then the Moneybird object can be injected like:
class Administration{
/**
* @Inject
*
* @var \Picqer\Financials\Moneybird\Moneybird
*/
private $apiClient;
public function execute(){
var_dump($this->apiClient->administration->get());
}
}
This works well. However, after determining the Administration, the Connection object needs to be updated with the administrationId
. However, we can not access the connection of the Moneybird object.
Any suggestion on how to do this? Maybe the $connection property should be made public / or be accessible using a getter function?
I get a 404 error while trying to save a contact. This is the code being used:
$connection = new \Picqer\Financials\Moneybird\Connection();
$connection->setRedirectUrl(site_url());
$connection->setClientId('clientid');
$connection->setClientSecret('secret');
// $connection->redirectForAuthorization();
$connection->setAuthorizationCode('authcode');
$connection->setAccessToken('accesstoken');
$connection->connect();
$moneybird = new \Picqer\Financials\Moneybird\Moneybird($connection);
// echo $connection->getAccessToken();
$contact = $moneybird->contact();
$contact->company_name = 'Picqer';
$contact->firstname = 'Stephan';
$contact->lastname = 'Groen';
$contact->save();
var_dump($contact);
Took the code from your .README file. Not sure where it is going wrong, this is the error message:
Fatal error: Uncaught exception 'Picqer\Financials\Moneybird\Exceptions\ApiException' with message 'Error 404: 404 Not Found' in /Applications/MAMP/htdocs/vlieglesdeal/wp-content/themes/vlieglesdeal/vendor/picqer/moneybird-php-client/src/Picqer/Financials/Moneybird/Connection.php:387 Stack trace: #0 /Applications/MAMP/htdocs/vlieglesdeal/wp-content/themes/vlieglesdeal/vendor/picqer/moneybird-php-client/src/Picqer/Financials/Moneybird/Connection.php(199): Picqer\Financials\Moneybird\Connection->parseExceptionForErrorMessages(Object(GuzzleHttp\Exception\ClientException)) #1 /Applications/MAMP/htdocs/vlieglesdeal/wp-content/themes/vlieglesdeal/vendor/picqer/moneybird-php-client/src/Picqer/Financials/Moneybird/Actions/Storable.php(28): Picqer\Financials\Moneybird\Connection->post('contacts', '{"contact":{"co...') #2 /Applications/MAMP/htdocs/vlieglesdeal/wp-content/themes/vlieglesdeal/vendor/picqer/moneybird-php-client/src/Picqer/Financials/Moneybird/Actions/Storable.php(19): Picqer\Financials\Moneybird\Entities\Contact->inse in /Applications/MAMP/htdocs/vlieglesdeal/wp-content/themes/vlieglesdeal/vendor/picqer/moneybird-php-client/src/Picqer/Financials/Moneybird/Connection.php on line 387
This are my required dependencies in composer.json:
"require": {
"guzzlehttp/guzzle": "^6.2",
"picqer/moneybird-php-client": "^0.7.2"
},
I was looking through the documentation and saw this:
https://developer.moneybird.com/api/sales_invoices/#patch_sales_invoices_id_register_payment
it is deprecated and replaced with https://developer.moneybird.com/api/sales_invoices/#post_sales_invoices_sales_invoice_id_payments
Since this is a global function, in my opinion this should also work when administrationId is set. I'm not sure about the best approach around this with $connection->formatUrl() here, since this always sets the id when it's available. I'm open to suggestions!
Could you update your composer package to have versions and a stable and dev line? (Might be based on git branches)
Especially a stable version.
When I call the ->delete()
function like so: (last foreach)
//Remove all salesInvoices
$salesInvoices = $moneybird->salesInvoice()->listVersions();
$i = 0;
$total = count($salesInvoices);
echo 'Got '.$total.' sales invoices.'.SYS_EOL;
foreach ($salesInvoices as $salesInvoice) {
$i++;
echo 'Removed sales invoice ID: '.$salesInvoices->id.' ('.$i.' of '.$total.').'.SYS_EOL;
if($salesInvoice->delete()){
echo 'Removed sales invoice ID: '.$salesInvoices->id.' ('.$i.' of '.$total.').'.SYS_EOL;
} else {
echo 'Could not removed sales invoice ID: '.$salesInvoices->id.' ('.$i.' of '.$total.').'.SYS_EOL;
}
}
//Remove all purchaseInvoices
$purchaseInvoices = $moneybird->purchaseInvoice()->get(); //listVersions is missing for whatever reason
$i= 0;
$total = count($purchaseInvoices);
echo 'Got '.$total.' purchase invoices.'.SYS_EOL;
foreach ($purchaseInvoices as $purchaseInvoice) {
$i++;
if($purchaseInvoice->delete()){
echo 'Removed purchase invoice ID: '.$purchaseInvoice->id.' ('.$i.' of '.$total.').'.SYS_EOL;
} else {
echo 'Could not removed purchase invoice ID: '.$purchaseInvoice->id.' ('.$i.' of '.$total.').'.SYS_EOL;
}
}
//Remove all contacts
$contacts = $moneybird->contact()->listVersions();
$i= 0;
$total = count($contacts);
echo 'Got '.$total.' contacts.'.SYS_EOL;
foreach ($contacts as $contact) {
$i++;
$result = $contact->delete();
var_dump($result); //returns full object instead of true or false.
if($result){
echo 'Removed contact ID: '.$contact->id.' ('.$i.' of '.$total.').'.SYS_EOL;
} else{
echo 'Could not remove contact ID: '.$contact->id.' ('.$i.' of '.$total.').'.SYS_EOL;
}
}
this is the output (sanitized for privacy)
===start=== wo 27 jul 2016 22:45:17 CEST
Cleaning moneybird.
Got 0 sales invoices.
Got 0 purchase invoices.
Got 4 contacts.
array(40) {
<snip/ full contact object>
["notes"]=>
array(0) {
}
["custom_fields"]=>
array(0) {
}
["events"]=>
array(1) {
[0]=>
array(8) {
<snip>
["action"]=>
string(15) "contact_created"
<snip>
}
}
}
Removed contact ID: <snip>(1 of 4).
array(40) {
<snip/ full contact object>
["notes"]=>
array(0) {
}
["custom_fields"]=>
array(0) {
}
["events"]=>
array(1) {
[0]=>
array(8) {
<snip>
["action"]=>
string(15) "contact_created"
<snip>
}
}
}
Removed contact ID: <snip>(2 of 4).
array(40) {
<snip/ full contact object>
["notes"]=>
array(0) {
}
["custom_fields"]=>
array(0) {
}
["events"]=>
array(1) {
[0]=>
array(8) {
<snip>
["action"]=>
string(15) "contact_created"
<snip>
}
}
}
Removed contact ID: <snip> (3 of 4).
array(40) {
<snip/ full contact object>
["notes"]=>
array(0) {
}
["custom_fields"]=>
array(0) {
}
["events"]=>
array(1) {
[0]=>
array(8) {
<snip>
["action"]=>
string(15) "contact_created"
<snip>
}
}
}
Removed contact ID: <snip>(4 of 4).
Done. Removed state file.
All these users are not getting removed. (There are purchaseInvoices that block them, even though those should be removed by the previous loop.)
But the return type confuses me, it's the result of the parseResponse method and the delete action returns the contact, the only difference seems to be the events parts. Any insight on how to properly detect removal? (Without an extra request)
Can you help me how to add rules ("Description")
Here is my code:
$estimate = $moneybird->estimate();
$estimate->contact_id = $contact_id;
$estimate->contact = $contact; <- This was by the way the error from previous issiue
$estimate->workflow_id = $workflow_id;
$estimate->document_style_id = $document_style_id;
$details = $moneybird->SalesInvoiceDetail();
$details->tax_rate_id = "134151041448937070";
$details->ledger_account_id = "134151041263339116";
$details->amount = "90.88 m2";
$details->description = "test";
$details->price = "36.75";
$details->row_order = 0;
And i would like to add another detail.
$estimate->details = $details;
$estimate->save();
SalesInvoice->due_date is available on the moneybird API, but not used in moneybird-php-client
Could you add support for retrieving a contact by customer ID?
This or similar should be added in Entities/Contact.php:
public function findByCustomerId($customerId) {
$result = $this->connection()->get($this->getUrl() . '/customer_id/' . urlencode($customerId));
return $this->makeFromResponse($result);
}
Thanks!
(Sorry, no time for pull request, but I hope you can implement it, as it is a quick fix)
Is there a way to get the link of the online invoice?
Or maybe the mollie ideal link?
PurchaseInvoiceDetail factory is missing in https://github.com/picqer/moneybird-php-client/blob/master/src/Picqer/Financials/Moneybird/Moneybird.php
I can succesfully auth with moneybird 2.0 website. I also save the tokens succesfully. But everye request I do gives me a
( ! ) Fatal error: Uncaught exception 'Picqer\Financials\Moneybird\Exceptions\ApiException' with message 'Error 404: {"error":"record not found"}' in /home/jochem/websites/websitename/pages/vendor/picqer/moneybird-php-client/src/Picqer/Financials/Moneybird/Connection.php on line 387
Currently the minimum required version is 5.5.0
, would it be an idea to bump this to either:
5.6.0
: allowing us to use return types7.1.0
: even better, allowing us to use all the new (typing) goodness
Note that some PHP 7.0 code is already used, for example the short array notation []
at:
I see that i have to give the workflow id when i make an estimates, is it possible that you can include the contact? That when I make a new contact that i can deccide wich workflow to use?
I ran into the problem that custom fields for contacts were not saved in Moneybird. The only way I could get it to work was to change 'custom_fields' to 'custom_fields_attributes' in Entities/Contact.php and then set them via $contact->custom_fields_attributes = array(0 => ['id' => CF_ID1, 'value' => 'Some value'], 1 => ['id' => CF_ID2, 'value' => 'Some other value']);
Similary, details were not added to invoices generated through the API until I changed 'details' to 'details_attributes' in Entities/SalesInvoice.php.
Lastly, to save the custom fields for contacts,I had to add JSON_FORCE_OBJECT
to json_encode(...)
in Model.php, public function jsonWithNamespace()
.
This may not be the best solution, but it works for me.
I was wondering if there was a specific reason to leave that out?
http://developer.moneybird.com/api/documents_purchase_invoices/ This page does specify the /synchronization
endpoint.
Hello,
I tried the lastest version but for some reason I can't connect.
It's giving me this error all the time
Fatal error: Class 'Picqer\Financials\Moneybird\Connection' not found in /......
Seems its hanging somewhere on:
`require DIR . '/autoload.php';
$connection = new \Picqer\Financials\Moneybird\Connection(); `
If i look in the folder, I see this:
Picqer/Financials/Moneybird/Connection.php (file, not folder Connection)
I have autoload.php listed in the same folder as my test file.
What do i do wrong?
Hope someone can help me out, trying for over 2 weeks now to get it working right.
Marco
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.