From 8ca735ba64fbcaa5896f7af7eb8fe007cfab5676 Mon Sep 17 00:00:00 2001 From: Jonas De Keukelaere Date: Mon, 3 May 2021 11:44:59 +0100 Subject: [PATCH 1/2] Generate invoice number when creating invoice without sending it --- Invoice/Invoice.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Invoice/Invoice.php b/Invoice/Invoice.php index 0b915de..b1152bb 100644 --- a/Invoice/Invoice.php +++ b/Invoice/Invoice.php @@ -61,6 +61,11 @@ class Invoice */ protected $discountDescription; + /** + * @var bool + */ + protected $prepareForSending = false; + /** * @param \SumoCoders\Factr\Client\Client $client */ @@ -394,6 +399,11 @@ public function setDiscountDescription($discountDescription) return $this; } + public function prepareForSending() + { + $this->prepareForSending = true; + } + /** * Initialize the object with raw data * @@ -482,6 +492,8 @@ public function toArray($forApi = false) foreach ($this->getHistory() as $history) { $data['history'][] = $history->toArray($forApi); } + } else { + $data['prepare_for_sending'] = $this->prepareForSending; } return $data; From 8f87a3643cace266bf354b76bb883284bcba4fdf Mon Sep 17 00:00:00 2001 From: Jonas De Keukelaere Date: Mon, 3 May 2021 11:45:46 +0100 Subject: [PATCH 2/2] Mark invoice as sent Use in conjunction with "prepare_for_sending" when creating the invoice. --- Factr.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Factr.php b/Factr.php index ba87a80..e0a80dd 100644 --- a/Factr.php +++ b/Factr.php @@ -715,6 +715,20 @@ public function invoiceSendByMail($id, $to = null, $cc = null, $bcc = null, $sub return Mail::initializeWithRawData($rawData); } + /** + * Marking invoice as sent by mail. + * + * @param string $id + * @param string $email + */ + public function invoiceMarkAsSentByMail($id, $email) + { + $parameters = array(); + $parameters['by'] = 'mail'; + $parameters['to'] = $email; + $this->doCall('invoices/' . (string) $id . '/sent', $parameters, 'POST'); + } + /** * Adding a payment to an invoice. *