1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Picqer\Financials\Exact; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class PurchaseInvoice. |
7
|
|
|
* |
8
|
|
|
* @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=PurchasePurchaseInvoices |
9
|
|
|
* |
10
|
|
|
* @property string $ID A guid that is the unique identifier of the purchase invoice. |
11
|
|
|
* @property float $Amount The amount including VAT in the currency of the invoice. |
12
|
|
|
* @property string $ContactPerson Guid identifying the contact person of the supplier. |
13
|
|
|
* @property string $Currency The code of the currency of the invoiced amount. |
14
|
|
|
* @property string $Description The description of the invoice. |
15
|
|
|
* @property string $Document Guid identifying a document that is attached to the invoice. |
16
|
|
|
* @property string $DueDate The date before which the invoice has to be paid. |
17
|
|
|
* @property int $EntryNumber The unique number of the purchase invoice. The entry number is based on a setting in the purchase journal and incremented for each new purchase invoice. |
18
|
|
|
* @property float $ExchangeRate The exchange rate between the invoice currency and the default currency of the division. |
19
|
|
|
* @property int $FinancialPeriod The financial period in which the invoice is entered. |
20
|
|
|
* @property int $FinancialYear The financial year in which the invoice is entered. |
21
|
|
|
* @property string $InvoiceDate The date on which the supplier entered the invoice. |
22
|
|
|
* @property string $Journal The code of the purchase journal in which the invoice is entered. |
23
|
|
|
* @property string $Modified The date and time the invoice was last modified. |
24
|
|
|
* @property string $PaymentCondition The code of the payment condition that is used to calculate the due date and discount. |
25
|
|
|
* @property string $PaymentReference Unique reference to match payments and invoices. |
26
|
|
|
* @property purchaseinvoicelines $PurchaseInvoiceLines The collection of lines that belong to the purchase invoice. |
27
|
|
|
* @property string $Remarks The user can enter remarks related to the invoice here. |
28
|
|
|
* @property int $Source Indicates the origin of the invoice. 1 Manual entry, 3 Purchase invoice, 4 Purchase order, 5 Web service. |
29
|
|
|
* @property int $Status The status of the invoice. 10 Draft, 20 Open, 50 Processed. |
30
|
|
|
* @property string $Supplier Guid that identifies the supplier. |
31
|
|
|
* @property int $Type Indicates the type of the purchase invoice. 8030 Direct purchase invoice, 8031 Direct purchase invoice (Credit), 8033 Purchase invoice, 8034 Purchase invoice (Credit) |
32
|
|
|
* @property float $VATAmount The total VAT amount of the purchase invoice. |
33
|
|
|
* @property string $Warehouse Guid that identifies the warehouse that will receive the purchased goods. This is mandatory for creating a direct purchase invoice. |
34
|
|
|
* @property string $YourRef The invoice number provided by the supplier. |
35
|
|
|
*/ |
36
|
|
|
class PurchaseInvoice extends Model |
37
|
|
|
{ |
38
|
|
|
use Query\Findable; |
39
|
|
|
use Persistance\Storable; |
40
|
|
|
|
41
|
|
|
protected $fillable = [ |
42
|
|
|
'ID', |
43
|
|
|
'Amount', |
44
|
|
|
'ContactPerson', |
45
|
|
|
'Currency', |
46
|
|
|
'Description', |
47
|
|
|
'Document', |
48
|
|
|
'DueDate', |
49
|
|
|
'EntryNumber', |
50
|
|
|
'ExchangeRate', |
51
|
|
|
'FinancialPeriod', |
52
|
|
|
'FinancialYear', |
53
|
|
|
'InvoiceDate', |
54
|
|
|
'Journal', |
55
|
|
|
'Modified', |
56
|
|
|
'PaymentCondition', |
57
|
|
|
'PaymentReference', |
58
|
|
|
'PurchaseInvoiceLines', |
59
|
|
|
'Remarks', |
60
|
|
|
'Source', |
61
|
|
|
'Status', |
62
|
|
|
'Supplier', |
63
|
|
|
'Type', |
64
|
|
|
'VATAmount', |
65
|
|
|
'Warehouse', |
66
|
|
|
'YourRef', |
67
|
|
|
]; |
68
|
|
|
|
69
|
|
|
protected $url = 'purchase/PurchaseInvoices'; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Updates the PurchaseInvoiceLines collection on a PurchaseInvoice if it's been detected as a deferred collection. |
73
|
|
|
* Fetches results and stores them on this object. |
74
|
|
|
* |
75
|
|
|
* @return mixed |
76
|
|
|
*/ |
77
|
|
|
public function getPurchaseInvoiceLines($statement = '') |
78
|
|
|
{ |
79
|
|
|
if (array_key_exists('__deferred', $this->attributes['PurchaseInvoiceLines'])) { |
80
|
|
|
$this->attributes['PurchaseInvoiceLines'] = (new PurchaseInvoiceLine($this->connection()))->filter("InvoiceID eq guid'{$this->ID}'", '', '', $statement); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return $this->attributes['PurchaseInvoiceLines']; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @deprecated This function got renamed, still here for backward compatibility. To be removed in next major version. |
88
|
|
|
*/ |
89
|
|
|
public function getSalesInvoiceLines($statement = '') |
90
|
|
|
{ |
91
|
|
|
return $this->getPurchaseInvoiceLines($statement); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|