-
Notifications
You must be signed in to change notification settings - Fork 79
Description
The API docs say:
This endpoint provides two options: sending the invoice and scheduling sending in the future. When sending now, you can provide a send method, email address and message. If you don't provide any arguments, the defaults from the contact and workflow will be used.
So, if you don't provide a delivery method, the default method of the Moneybird contact is used. For example, some of my clients use Peppol as delivery method. But that preference is stored only in Moneybird, not in any external system.
The way \Picqer\Financials\Moneybird\Entities\SalesInvoice::sendInvoice acts right now, doesn't support using an empty delivery method:
moneybird-php-client/src/Picqer/Financials/Moneybird/Entities/SalesInvoice.php
Lines 146 to 169 in b9fb016
| public function sendInvoice($deliveryMethodOrOptions = SendInvoiceOptions::METHOD_EMAIL) | |
| { | |
| if (is_string($deliveryMethodOrOptions)) { | |
| $options = new SendInvoiceOptions($deliveryMethodOrOptions); | |
| } else { | |
| $options = $deliveryMethodOrOptions; | |
| } | |
| unset($deliveryMethodOrOptions); | |
| if (! $options instanceof SendInvoiceOptions) { | |
| $options = is_object($options) ? get_class($options) : gettype($options); | |
| throw new InvalidArgumentException("Expected string or options instance. Received: '$options'"); | |
| } | |
| $response = $this->connection->patch($this->endpoint . '/' . $this->id . '/send_invoice', json_encode([ | |
| 'sales_invoice_sending' => $options->jsonSerialize(), | |
| ])); | |
| if (is_array($response)) { | |
| $this->selfFromResponse($response); | |
| } | |
| return $this; | |
| } |
moneybird-php-client/src/Picqer/Financials/Moneybird/Entities/SalesInvoice/SendInvoiceOptions.php
Lines 108 to 118 in b9fb016
| public function setMethod($method) | |
| { | |
| $validMethods = self::getValidMethods(); | |
| if (! in_array($method, $validMethods)) { | |
| $method = is_object($method) ? get_class($method) : $method; | |
| $validMethodNames = implode(',', $validMethods); | |
| throw new InvalidArgumentException("Invalid method: '$method'. Expected one of: '$validMethodNames'"); | |
| } | |
| $this->method = $method; | |
| } |
I'll solve it and create a pull request later tonight.