File tree Expand file tree Collapse file tree 5 files changed +81
-27
lines changed
src/Picqer/Financials/Moneybird Expand file tree Collapse file tree 5 files changed +81
-27
lines changed Original file line number Diff line number Diff line change 1+ <?php namespace Picqer \Financials \Moneybird \Entities \Generic ;
2+
3+ use Picqer \Financials \Moneybird \Model ;
4+
5+ /**
6+ * Class InvoicePayment
7+ * @package Picqer\Financials\Moneybird\Entities\Generic
8+ */
9+ abstract class InvoicePayment extends Model {
10+
11+ /**
12+ * @var array
13+ */
14+ protected $ fillable = [
15+ 'id ' ,
16+ 'invoice_type ' ,
17+ 'invoice_id ' ,
18+ 'financial_account_id ' ,
19+ 'user_id ' ,
20+ 'payment_transaction_id ' ,
21+ 'price ' ,
22+ 'price_base ' ,
23+ 'payment_date ' ,
24+ 'credit_invoice_id ' ,
25+ 'financial_mutation_id ' ,
26+ 'created_at ' ,
27+ 'updated_at ' ,
28+ ];
29+
30+ /**
31+ * @var string
32+ */
33+ protected $ namespace = 'payment ' ;
34+ }
Original file line number Diff line number Diff line change @@ -72,4 +72,26 @@ class PurchaseInvoice extends Model
7272 'type ' => self ::NESTING_TYPE_ARRAY_OF_OBJECTS ,
7373 ],
7474 ];
75+
76+ /**
77+ * Register a payment for the current purchase invoice
78+ *
79+ * @param PurchaseInvoicePayment $purchaseInvoicePayment (payment_date and price are required)
80+ * @throws ApiException
81+ */
82+ public function registerPayment (PurchaseInvoicePayment $ purchaseInvoicePayment )
83+ {
84+ if (! isset ($ purchaseInvoicePayment ->payment_date )) {
85+ throw new ApiException ('Required [payment_date] is missing ' );
86+ }
87+
88+ if (! isset ($ purchaseInvoicePayment ->price )) {
89+ throw new ApiException ('Required [price] is missing ' );
90+ }
91+
92+ $ this ->connection ()->patch ($ this ->endpoint . '/ ' . $ this ->id . '/register_payment ' ,
93+ $ purchaseInvoicePayment ->jsonWithNamespace ()
94+ );
95+ }
96+
7597}
Original file line number Diff line number Diff line change 1+ <?php namespace Picqer \Financials \Moneybird \Entities ;
2+
3+ use Picqer \Financials \Moneybird \Entities \Generic \InvoicePayment ;
4+
5+ /**
6+ * Class SalesInvoicePayment
7+ * @package Picqer\Financials\Moneybird\Entities
8+ */
9+ class PurchaseInvoicePayment extends InvoicePayment
10+ {
11+ }
Original file line number Diff line number Diff line change 11<?php namespace Picqer \Financials \Moneybird \Entities ;
22
3- use Picqer \Financials \Moneybird \Model ;
3+ use Picqer \Financials \Moneybird \Entities \ Generic \ InvoicePayment ;
44
55/**
66 * Class SalesInvoicePayment
77 * @package Picqer\Financials\Moneybird\Entities
88 */
9- class SalesInvoicePayment extends Model {
10-
11- /**
12- * @var array
13- */
14- protected $ fillable = [
15- 'id ' ,
16- 'invoice_type ' ,
17- 'invoice_id ' ,
18- 'financial_account_id ' ,
19- 'user_id ' ,
20- 'payment_transaction_id ' ,
21- 'price ' ,
22- 'price_base ' ,
23- 'payment_date ' ,
24- 'credit_invoice_id ' ,
25- 'financial_mutation_id ' ,
26- 'created_at ' ,
27- 'updated_at ' ,
28- ];
29-
30- /**
31- * @var string
32- */
33- protected $ namespace = 'payment ' ;
34- }
9+ class SalesInvoicePayment extends InvoicePayment
10+ {
11+ }
Original file line number Diff line number Diff line change 1717use Picqer \Financials \Moneybird \Entities \Product ;
1818use Picqer \Financials \Moneybird \Entities \PurchaseInvoice ;
1919use Picqer \Financials \Moneybird \Entities \PurchaseInvoiceDetail ;
20+ use Picqer \Financials \Moneybird \Entities \PurchaseInvoicePayment ;
2021use Picqer \Financials \Moneybird \Entities \Receipt ;
2122use Picqer \Financials \Moneybird \Entities \RecurringSalesInvoice ;
2223use Picqer \Financials \Moneybird \Entities \Note ;
@@ -224,6 +225,15 @@ public function purchaseInvoiceDetail($attributes = [])
224225 return new PurchaseInvoiceDetail ($ this ->connection , $ attributes );
225226 }
226227
228+ /**
229+ * @param array $attributes
230+ * @return PurchaseInvoicePayment
231+ */
232+ public function purchaseInvoicePayment ($ attributes = [])
233+ {
234+ return new PurchaseInvoicePayment ($ this ->connection , $ attributes );
235+ }
236+
227237 /**
228238 * @param array $attributes
229239 * @return Receipt
You can’t perform that action at this time.
0 commit comments