1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Picqer\Financials\Exact; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class SalesInvoice. |
7
|
|
|
* |
8
|
|
|
* @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=SalesInvoiceSalesInvoices |
9
|
|
|
* |
10
|
|
|
* @property string $InvoiceID Primary key |
11
|
|
|
* @property float $AmountDC For the header lines (LineNumber = 0) of an entry this is the SUM(AmountDC) of all lines |
12
|
|
|
* @property float $AmountDiscount Discount amount in the default currency of the company |
13
|
|
|
* @property float $AmountDiscountExclVat Discount amount exclude VAT in the default currency of the company |
14
|
|
|
* @property float $AmountFC For the header this is the sum of all lines, including VAT |
15
|
|
|
* @property float $AmountFCExclVat For the header this is the sum of all lines, excluding VAT |
16
|
|
|
* @property string $Created Creation date |
17
|
|
|
* @property string $Creator User ID of creator |
18
|
|
|
* @property string $CreatorFullName Name of creator |
19
|
|
|
* @property string $Currency Currency for the invoice. Default this is the currency of the administration |
20
|
|
|
* @property string $DeliverTo Delivery account for invoice |
21
|
|
|
* @property string $DeliverToAddress Address of delivery as per invoice delivery account |
22
|
|
|
* @property string $DeliverToContactPerson Delivery account person for invoice |
23
|
|
|
* @property string $DeliverToContactPersonFullName Name of delivery account's contact person as per invoice |
24
|
|
|
* @property string $DeliverToName Name of the delivery account's customer as per invoice |
25
|
|
|
* @property string $Description Description. Can be different for header and lines |
26
|
|
|
* @property float $Discount Discount percentage |
27
|
|
|
* @property int $DiscountType Leading field of total discount. 1=Discount percentage, 2=Discount amount excl. VAT, 3=Discount amount incl. VAT, 4=Total amount excl. VAT, 5=Total amount incl. VAT |
28
|
|
|
* @property int $Division Division code |
29
|
|
|
* @property string $Document Document that is manually linked to the invoice |
30
|
|
|
* @property int $DocumentNumber Number of the document |
31
|
|
|
* @property string $DocumentSubject Subject of the document |
32
|
|
|
* @property string $DueDate The due date for payments. This date is calculated based on the EntryDate and the Paymentcondition |
33
|
|
|
* @property float $ExtraDutyAmountFC Extra duty amount in the currency of the transaction. Both extra duty amount and VAT amount need to be specified in order to differ this property from automatically calculated. |
34
|
|
|
* @property float $GAccountAmountFC A positive value of the amount indicates that the amount is to be paid by the customer to your G bank account.In case of a credit invoice the amount should have negative value when retrieved or posted to Exact. |
35
|
|
|
* @property string $InvoiceDate Official date for the invoice. When the invoice is entered it's equal to the field 'EntryDate'. During the printing process the invoice date can be entered |
36
|
|
|
* @property int $InvoiceNumber Assigned at entry or at printing depending on setting. The number assigned is based on the freenumbers as defined for the Journal. When printing the field InvoiceNumber is copied to the fields EntryNumber and InvoiceNumber of the sales entry |
37
|
|
|
* @property string $InvoiceTo Reference to the Customer who will receive the invoice |
38
|
|
|
* @property string $InvoiceToContactPerson Reference to the Contact person of the customer who will receive the invoice |
39
|
|
|
* @property string $InvoiceToContactPersonFullName Name of the contact person of the customer who will receive the invoice |
40
|
|
|
* @property string $InvoiceToName Name of the customer who will receive the invoice |
41
|
|
|
* @property bool $IsExtraDuty Indicates whether the invoice has extra duty |
42
|
|
|
* @property string $Journal The journal code. Every invoice should be linked to a sales journal |
43
|
|
|
* @property string $JournalDescription Description of Journal |
44
|
|
|
* @property string $Modified Last modified date |
45
|
|
|
* @property string $Modifier User ID of modifier |
46
|
|
|
* @property string $ModifierFullName Name of modifier |
47
|
|
|
* @property string $OrderDate Order date |
48
|
|
|
* @property string $OrderedBy Customer who ordered the invoice |
49
|
|
|
* @property string $OrderedByContactPerson Contact person of customer who ordered the invoice |
50
|
|
|
* @property string $OrderedByContactPersonFullName Name of contact person of customer who ordered the invoice |
51
|
|
|
* @property string $OrderedByName Name of customer who ordered the invoice |
52
|
|
|
* @property int $OrderNumber Number to identify the order. By default the number is based on a setting for the first free number, but you can post your own number. |
53
|
|
|
* @property string $PaymentCondition The payment condition used for due date and discount calculation |
54
|
|
|
* @property string $PaymentConditionDescription Description of PaymentCondition |
55
|
|
|
* @property string $PaymentReference Payment reference for sales invoice |
56
|
|
|
* @property string $Remarks Extra remarks |
57
|
|
|
* @property salesinvoicelines $SalesInvoiceLines Collection of lines |
58
|
|
|
* @property string $Salesperson Sales representative |
59
|
|
|
* @property string $SalespersonFullName Name of sales representative |
60
|
|
|
* @property int $StarterSalesInvoiceStatus Starter Sales invoice status (for starter functionality) |
61
|
|
|
* @property string $StarterSalesInvoiceStatusDescription Description of StarterSalesInvoiceStatus |
62
|
|
|
* @property int $Status The status of the entry. 10 = draft. During the creation of an invoice draft records occur in the draft modus if during an invoice a new page with lines is triggered. If the user leaves the invoice in an abnormal way the draft invoices can be recovered. Draft invoices are not included in financial reports, balances etc. 20 = open. Open invoices can be changed. New invoices get the status open by default. 50 = processed. Processed invoices can't be changed anymore. Processing is done via printing. Processed invoices can't be reopened |
63
|
|
|
* @property string $StatusDescription Description of Status |
64
|
|
|
* @property string $TaxSchedule Obsolete |
65
|
|
|
* @property string $TaxScheduleCode Obsolete |
66
|
|
|
* @property string $TaxScheduleDescription Obsolete |
67
|
|
|
* @property int $Type Indicates the type of invoice Values: 8020 - Sales invoices, 8021 - Sales credit note, 8023 - Direct sales invoice, 8024 - Direct credit note |
68
|
|
|
* @property string $TypeDescription Description of the type |
69
|
|
|
* @property float $VATAmountDC Total VAT amount in the default currency of the company |
70
|
|
|
* @property float $VATAmountFC Total VAT amount in the currency of the transaction |
71
|
|
|
* @property string $Warehouse Mandatory for direct sales invoice/credit note, cannot be set for normal sales invoice/credit note. |
72
|
|
|
* @property float $WithholdingTaxAmountFC Withholding tax amount applied to sales invoice |
73
|
|
|
* @property float $WithholdingTaxBaseAmount Withholding tax base amount to calculate withholding amount |
74
|
|
|
* @property float $WithholdingTaxPercentage Withholding tax percentage applied to sales invoice |
75
|
|
|
* @property string $YourRef The invoice number of the customer |
76
|
|
|
*/ |
77
|
|
|
class SalesInvoice extends Model |
78
|
|
|
{ |
79
|
|
|
use Query\Findable; |
80
|
|
|
use Persistance\Storable; |
81
|
|
|
|
82
|
|
|
protected $primaryKey = 'InvoiceID'; |
83
|
|
|
|
84
|
|
|
protected $fillable = [ |
85
|
|
|
'InvoiceID', |
86
|
|
|
'AmountDC', |
87
|
|
|
'AmountDiscount', |
88
|
|
|
'AmountDiscountExclVat', |
89
|
|
|
'AmountFC', |
90
|
|
|
'AmountFCExclVat', |
91
|
|
|
'Created', |
92
|
|
|
'Creator', |
93
|
|
|
'CreatorFullName', |
94
|
|
|
'Currency', |
95
|
|
|
'DeliverTo', |
96
|
|
|
'DeliverToAddress', |
97
|
|
|
'DeliverToContactPerson', |
98
|
|
|
'DeliverToContactPersonFullName', |
99
|
|
|
'DeliverToName', |
100
|
|
|
'Description', |
101
|
|
|
'Discount', |
102
|
|
|
'DiscountType', |
103
|
|
|
'Division', |
104
|
|
|
'Document', |
105
|
|
|
'DocumentNumber', |
106
|
|
|
'DocumentSubject', |
107
|
|
|
'DueDate', |
108
|
|
|
'ExtraDutyAmountFC', |
109
|
|
|
'GAccountAmountFC', |
110
|
|
|
'InvoiceDate', |
111
|
|
|
'InvoiceNumber', |
112
|
|
|
'InvoiceTo', |
113
|
|
|
'InvoiceToContactPerson', |
114
|
|
|
'InvoiceToContactPersonFullName', |
115
|
|
|
'InvoiceToName', |
116
|
|
|
'IsExtraDuty', |
117
|
|
|
'Journal', |
118
|
|
|
'JournalDescription', |
119
|
|
|
'Modified', |
120
|
|
|
'Modifier', |
121
|
|
|
'ModifierFullName', |
122
|
|
|
'OrderDate', |
123
|
|
|
'OrderedBy', |
124
|
|
|
'OrderedByContactPerson', |
125
|
|
|
'OrderedByContactPersonFullName', |
126
|
|
|
'OrderedByName', |
127
|
|
|
'OrderNumber', |
128
|
|
|
'PaymentCondition', |
129
|
|
|
'PaymentConditionDescription', |
130
|
|
|
'PaymentReference', |
131
|
|
|
'Remarks', |
132
|
|
|
'SalesInvoiceLines', |
133
|
|
|
'Salesperson', |
134
|
|
|
'SalespersonFullName', |
135
|
|
|
'StarterSalesInvoiceStatus', |
136
|
|
|
'StarterSalesInvoiceStatusDescription', |
137
|
|
|
'Status', |
138
|
|
|
'StatusDescription', |
139
|
|
|
'TaxSchedule', |
140
|
|
|
'TaxScheduleCode', |
141
|
|
|
'TaxScheduleDescription', |
142
|
|
|
'Type', |
143
|
|
|
'TypeDescription', |
144
|
|
|
'VATAmountDC', |
145
|
|
|
'VATAmountFC', |
146
|
|
|
'Warehouse', |
147
|
|
|
'WithholdingTaxAmountFC', |
148
|
|
|
'WithholdingTaxBaseAmount', |
149
|
|
|
'WithholdingTaxPercentage', |
150
|
|
|
'YourRef', |
151
|
|
|
]; |
152
|
|
|
|
153
|
|
|
protected $url = 'salesinvoice/SalesInvoices'; |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Updates the SalesInvoiceLines collection on a SalesInvoice if it's been detected as a deferred collection. |
157
|
|
|
* Fetches results and stores them on this object. |
158
|
|
|
* |
159
|
|
|
* @return mixed |
160
|
|
|
*/ |
161
|
|
|
public function getSalesInvoiceLines() |
162
|
|
|
{ |
163
|
|
|
if (array_key_exists('__deferred', $this->attributes['SalesInvoiceLines'])) { |
164
|
|
|
$this->attributes['SalesInvoiceLines'] = (new SalesInvoiceLine($this->connection()))->filter("InvoiceID eq guid'{$this->InvoiceID}'"); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
return $this->attributes['SalesInvoiceLines']; |
168
|
|
|
} |
169
|
|
|
} |
170
|
|
|
|