Skip to content

Commit f6d79c3

Browse files
authored
Merge pull request #69 from zeauw/credit-invoice
Added duplicateToCreditInvoice
2 parents fe13fb9 + a98366a commit f6d79c3

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ var_dump($salesInvoice); // SalesInvoice object
8484
// *** Officially unsupported in the Moneybird API ***
8585
$pdfContents = $salesInvoice->download();
8686

87+
// Example: Create credit invoice based on existing invoice
88+
$creditInvoice = $salesInvoice->duplicateToCreditInvoice();
89+
var_dump($creditInvoice); // SalesInvoice object
90+
8791
// Example: Create a new contact
8892
$contact = $moneybird->contact();
8993

src/Picqer/Financials/Moneybird/Entities/SalesInvoice.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,18 @@ public function addNote(Note $note)
162162
$note->jsonWithNamespace()
163163
);
164164
}
165+
166+
/**
167+
* Create a credit invoice based on the current invoice.
168+
*
169+
* @return \Picqer\Financials\Moneybird\Entities\SalesInvoice
170+
*/
171+
public function duplicateToCreditInvoice()
172+
{
173+
$response = $this->connection()->patch($this->getEndpoint() . '/' . $this->id . '/duplicate_creditinvoice',
174+
json_encode([]) // No body needed for this call. The patch method however needs one.
175+
);
176+
177+
return $this->makeFromResponse($response);
178+
}
165179
}

0 commit comments

Comments
 (0)