Completed
Push — master ( 6e6443...323068 )
by Stephan
12s
created

PurchaseInvoice::getSalesInvoiceLines()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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