forked from GSDgit/PracticalAfas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFbSalesLines.php
201 lines (196 loc) · 7.63 KB
/
FbSalesLines.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php
/**
* This file is part of the PracticalAfas package.
*
* (c) Roderik Muit <[email protected]>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
namespace PracticalAfas\UpdateConnector;
/**
* An UpdateObject containing definitions / logic for FbSalesLines objects.
*/
class FbSalesLines extends UpdateObject
{
/**
* {@inheritdoc}
*/
protected function getDefaultPropertyDefinitions()
{
return [
'objects' => [
'FbOrderBatchLines' => [
'alias' => 'batch_line_items',
'multiple' => true,
],
'FbOrderSerialLines' => [
'alias' => 'serial_line_items',
'multiple' => true,
],
],
'fields' => [
// Type item (verwijzing naar: Tabelwaarde,Itemtype => AfasKnCodeTableValue)
// Values: 1:Werksoort 10:Productie-indicator 11:Deeg 14:Artikeldimensietotaal 2:Artikel 3:Tekst 4:Subtotaal 5:Toeslag 6:Kosten 7:Samenstelling 8:Cursus
'VaIt' => [
'alias' => 'item_type',
'type' => 'integer',
'default' => 2,
],
// Itemcode
'ItCd' => [
'alias' => 'item_code',
],
// Omschrijving
'Ds' => [
'alias' => 'description',
],
// Btw-tariefgroep (verwijzing naar: Btw-tariefgroep => AfasKnVatTarifGroup)
'VaRc' => [
'alias' => 'vat_type',
],
// Eenheid (verwijzing naar: Eenheid => AfasFbUnit)
'BiUn' => [
'alias' => 'unit_type',
],
// Aantal eenheden
'QuUn' => [
'alias' => 'quantity',
// This may be integer in some cases? Could this be set in
// validateFields()?
'type' => 'decimal',
],
// Lengte
'QuLe' => [
'alias' => 'length',
'type' => 'decimal',
],
// Breedte
'QuWi' => [
'alias' => 'width',
'type' => 'decimal',
],
// Hoogte
'QuHe' => [
'alias' => 'height',
'type' => 'decimal',
],
// Aantal besteld
'Qu' => [
'alias' => 'quantity_ordered',
'type' => 'decimal',
],
// Aantal te leveren
'QuDl' => [
'alias' => 'quantity_deliver',
'type' => 'decimal',
],
// Prijslijst (verwijzing naar: Prijslijst verkoop => AfasFbPriceListSale)
'PrLi' => [
'alias' => 'price_list',
],
// Magazijn (verwijzing naar: Magazijn => AfasFbWarehouse)
'War' => [
'alias' => 'warehouse',
],
// Dienstenberekening
'EUSe' => [
'type' => 'boolean',
],
// Gewichtseenheid (verwijzing naar: Tabelwaarde,Gewichtseenheid => AfasKnCodeTableValue)
// Values: 0:Geen gewicht 1:Microgram (µg) 2:Milligram (mg) 3:Gram (g) 4:Kilogram (kg) 5:Ton
'VaWt' => [
'alias' => 'weight_unit',
],
// Nettogewicht
'NeWe' => [
'alias' => 'weight_net',
'type' => 'decimal',
],
//
'GrWe' => [
'alias' => 'weight_gross',
'type' => 'decimal',
],
// Prijs per eenheid
'Upri' => [
'alias' => 'unit_price',
'type' => 'decimal',
],
// Kostprijs
'CoPr' => [
'alias' => 'cost_price',
'type' => 'decimal',
],
// Korting toestaan (verwijzing naar: Tabelwaarde,Toestaan korting => AfasKnCodeTableValue)
// Values: 0:Factuur- en regelkorting 1:Factuurkorting 2:Regelkorting 3:Geen factuur- en regelkorting
'VaAD' => [],
// % Regelkorting
'PRDc' => [
'alias' => 'discount_perc',
'type' => 'decimal',
],
// Bedrag regelkorting
'ARDc' => [
'type' => 'decimal',
],
// Handmatig bedrag regelkorting
'MaAD' => [
'type' => 'boolean',
],
// Opmerking
'Re' => [
'alias' => 'comment',
],
// GUID regel. (This is apparently not an 'ID property', which
// we'll assume a FbSalesLines object doesn't have then. Why not?
// what is the difference?)
'GuLi' => [
'alias' => 'guid',
'behavior' => 'afas_assigned_id',
],
// Artikeldimensiecode 1 (verwijzing naar: Artikeldimensiecodes => AfasFbStockDimLines)
'StL1' => [
'alias' => 'dimension_1',
],
// Artikeldimensiecode 2 (verwijzing naar: Artikeldimensiecodes => AfasFbStockDimLines)
'StL2' => [
'alias' => 'dimension_2',
],
// Direct leveren vanuit leverancier
'DiDe' => [
'alias' => 'direct_delivery',
'type' => 'boolean',
],
],
];
}
/**
* {@inheritdoc}
*/
protected function validateFields(array $element, $element_index, $change_behavior = self::DEFAULT_CHANGE, $validation_behavior = self::DEFAULT_VALIDATION)
{
// Unit Type and Quantity fields have default values only if item type
// is Article / Combination. (For other types, we don't know yet.)
if (isset($element['Fields']['VaIt'])) {
$is_article = in_array($element['Fields']['VaIt'], [2, 7]);
} else {
$is_article = isset($this->propertyDefinitions['fields']['VaIt']['default'])
&& in_array($this->propertyDefinitions['fields']['VaIt']['default'], [2, 7]);
}
if ($is_article) {
$this->propertyDefinitions['fields']['BiUn']['default'] = 'Stk';
$this->propertyDefinitions['fields']['QuUn']['default'] = 1;
} else {
unset($this->propertyDefinitions['fields']['BiUn']['default']);
unset($this->propertyDefinitions['fields']['QuUn']['default']);
}
// We're not sure if 'required' is true for some fields either, so set
// 'required' only for articles, for now.
$this->propertyDefinitions['fields']['ItCd']['required'] =
$this->propertyDefinitions['fields']['BiUn']['required'] =
$this->propertyDefinitions['fields']['QuUn']['required'] =
$this->propertyDefinitions['fields']['Upri']['required'] = $is_article;
return parent::validateFields($element, $element_index, $change_behavior, $validation_behavior);
}
}