diff --git a/src/Picqer/Financials/Moneybird/Entities/Generic/InvoicePayment.php b/src/Picqer/Financials/Moneybird/Entities/Generic/InvoicePayment.php new file mode 100644 index 0000000..71d1a9a --- /dev/null +++ b/src/Picqer/Financials/Moneybird/Entities/Generic/InvoicePayment.php @@ -0,0 +1,34 @@ + self::NESTING_TYPE_ARRAY_OF_OBJECTS, ], ]; + + /** + * Register a payment for the current purchase invoice + * + * @param PurchaseInvoicePayment $purchaseInvoicePayment (payment_date and price are required) + * @throws ApiException + */ + public function registerPayment(PurchaseInvoicePayment $purchaseInvoicePayment) + { + if (! isset($purchaseInvoicePayment->payment_date)) { + throw new ApiException('Required [payment_date] is missing'); + } + + if (! isset($purchaseInvoicePayment->price)) { + throw new ApiException('Required [price] is missing'); + } + + $this->connection()->patch($this->endpoint . '/' . $this->id . '/register_payment', + $purchaseInvoicePayment->jsonWithNamespace() + ); + } + } diff --git a/src/Picqer/Financials/Moneybird/Entities/PurchaseInvoicePayment.php b/src/Picqer/Financials/Moneybird/Entities/PurchaseInvoicePayment.php new file mode 100644 index 0000000..b6fd25c --- /dev/null +++ b/src/Picqer/Financials/Moneybird/Entities/PurchaseInvoicePayment.php @@ -0,0 +1,11 @@ +connection, $attributes); } + /** + * @param array $attributes + * @return PurchaseInvoicePayment + */ + public function purchaseInvoicePayment($attributes = []) + { + return new PurchaseInvoicePayment($this->connection, $attributes); + } + /** * @param array $attributes * @return Receipt