SalesEntry   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 60
c 1
b 0
f 0
dl 0
loc 72
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A addItem() 0 9 4
1
<?php
2
3
namespace Picqer\Financials\Exact;
4
5
/**
6
 * Class SalesEntry.
7
 *
8
 * @see https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=SalesEntrySalesEntries
9
 *
10
 * @property string $EntryID The unique ID of the entry. Via this ID all transaction lines of a single entry can be retrieved
11
 * @property float $AmountDC Amount in the default currency of the company. For the header lines (LineNumber = 0) of an entry this is the SUM(AmountDC) of all lines
12
 * @property float $AmountFC Amount in the currency of the transaction. For the header this is the sum of all lines, including VAT
13
 * @property int $BatchNumber The number of the batch of entries. Normally a batch consists of multiple entries. Batchnumbers are filled for invoices created by: - Fixed entries - Prolongation (only available with module hosting)
14
 * @property string $Created Creation date
15
 * @property string $Creator User ID of creator
16
 * @property string $CreatorFullName Name of creator
17
 * @property string $Currency Currency for the invoice. By default this is the currency of the administration
18
 * @property string $Customer Reference to customer (account)
19
 * @property string $CustomerName Name of customer
20
 * @property string $Description Description. Can be different for header and lines
21
 * @property int $Division Division code
22
 * @property string $Document Document that is manually linked to the invoice
23
 * @property int $DocumentNumber Number of the document
24
 * @property string $DocumentSubject Subject of the document
25
 * @property string $DueDate The due date for payments. This date is calculated based on the EntryDate and the Paymentcondition
26
 * @property string $EntryDate The date when the invoice is entered
27
 * @property int $EntryNumber Entry number
28
 * @property string $ExternalLinkDescription Description of ExternalLink
29
 * @property string $ExternalLinkReference Reference of ExternalLink
30
 * @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.
31
 * @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
32
 * @property bool $IsExtraDuty Indicates whether the invoice has extra duty
33
 * @property string $Journal The journal code. Every invoice should be linked to a sales journal
34
 * @property string $JournalDescription Description of Journal
35
 * @property string $Modified Last modified date
36
 * @property string $Modifier User ID of modifier
37
 * @property string $ModifierFullName Name of modifier
38
 * @property int $OrderNumber Number to indentify the invoice. Order numbers are not unique. Default the number is based on a setting for the first free number
39
 * @property string $PaymentCondition The payment condition used for due date and discount calculation
40
 * @property string $PaymentConditionDescription Description of PaymentCondition
41
 * @property string $PaymentReference The payment reference used for bank imports, VAT return and Tax reference
42
 * @property int $ProcessNumber
43
 * @property float $Rate Foreign currency rate
44
 * @property int $ReportingPeriod The period of the transaction lines. The period should exist in the period date table
45
 * @property int $ReportingYear The financial year to which the entry belongs. The financial year should exist in the period date table
46
 * @property bool $Reversal Indicates if amounts are reversed
47
 * @property salesentrylines $SalesEntryLines Collection of lines
48
 * @property int $Status Status: 20 = Open, 50 = Processed
49
 * @property string $StatusDescription Description of Status
50
 * @property int $Type Type: 20 = Sales entry, 21 = Sales credit note
51
 * @property string $TypeDescription Description of Type
52
 * @property float $VATAmountDC Vat amount in the default currency of the company
53
 * @property float $VATAmountFC Vat amount in the currency of the transaction
54
 * @property float $WithholdingTaxAmountDC Withholding tax amount
55
 * @property float $WithholdingTaxBaseAmount Withholding tax base amount to calculate withholding amount
56
 * @property float $WithholdingTaxPercentage Withholding tax percentage
57
 * @property string $YourRef The invoice number of the customer
58
 */
59
class SalesEntry extends Model
60
{
61
    use Query\Findable;
62
    use Persistance\Storable;
63
64
    protected $primaryKey = 'EntryID';
65
66
    protected $saleEntryLines = [];
67
68
    protected $fillable = [
69
        'EntryID',
70
        'AmountDC',
71
        'AmountFC',
72
        'BatchNumber',
73
        'Created',
74
        'Creator',
75
        'CreatorFullName',
76
        'Currency',
77
        'Customer',
78
        'CustomerName',
79
        'Description',
80
        'Division',
81
        'Document',
82
        'DocumentNumber',
83
        'DocumentSubject',
84
        'DueDate',
85
        'EntryDate',
86
        'EntryNumber',
87
        'ExternalLinkDescription',
88
        'ExternalLinkReference',
89
        'GAccountAmountFC',
90
        'InvoiceNumber',
91
        'IsExtraDuty',
92
        'Journal',
93
        'JournalDescription',
94
        'Modified',
95
        'Modifier',
96
        'ModifierFullName',
97
        'OrderNumber',
98
        'PaymentCondition',
99
        'PaymentConditionDescription',
100
        'PaymentReference',
101
        'ProcessNumber',
102
        'Rate',
103
        'ReportingPeriod',
104
        'ReportingYear',
105
        'Reversal',
106
        'SalesEntryLines',
107
        'Status',
108
        'StatusDescription',
109
        'Type',
110
        'TypeDescription',
111
        'VATAmountDC',
112
        'VATAmountFC',
113
        'WithholdingTaxAmountDC',
114
        'WithholdingTaxBaseAmount',
115
        'WithholdingTaxPercentage',
116
        'YourRef',
117
    ];
118
119
    public function addItem(array $array)
120
    {
121
        if (! isset($this->attributes['SalesEntryLines']) || $this->attributes['SalesEntryLines'] == null) {
122
            $this->attributes['SalesEntryLines'] = [];
123
        }
124
        if (! isset($array['LineNumber'])) {
125
            $array['LineNumber'] = count($this->attributes['SalesEntryLines']) + 1;
126
        }
127
        $this->attributes['SalesEntryLines'][] = $array;
128
    }
129
130
    protected $url = 'salesentry/SalesEntries';
131
}
132