1 |
|
use Test::More tests => 15;
|
|
1 |
use Test::More tests => 28;
|
2 |
2 |
|
3 |
3 |
use strict;
|
4 |
4 |
|
... | ... | |
117 |
117 |
ordnumber => '1234',
|
118 |
118 |
orderitems => [ create_order_item(part => $parts[0], qty => 3, sellprice => 70),
|
119 |
119 |
create_order_item(part => $parts[1], qty => 10, sellprice => 50),
|
120 |
|
create_order_item(part => $parts[2], qty => 8, sellprice => 80)
|
|
120 |
create_order_item(part => $parts[2], qty => 8, sellprice => 80),
|
|
121 |
create_order_item(part => $parts[2], qty => 11, sellprice => 80)
|
121 |
122 |
]
|
122 |
123 |
)
|
123 |
124 |
);
|
... | ... | |
131 |
132 |
OrderItem;TestPart2;10
|
132 |
133 |
OrderItem;TestPart3;7
|
133 |
134 |
OrderItem;TestPart3;1
|
|
135 |
OrderItem;TestPart3;11
|
134 |
136 |
EOL
|
135 |
137 |
|
|
138 |
1; # make emacs happy
|
|
139 |
|
|
140 |
# should be:
|
|
141 |
# delivery oder pos/qty <- order pos/qty
|
|
142 |
# 1/5 <- -
|
|
143 |
# 2/10 <- 2/10
|
|
144 |
# 3/7 <- 3/7
|
|
145 |
# 4/1 <- 3/1
|
|
146 |
# 5/11 <- 4/11
|
|
147 |
|
136 |
148 |
$entries = do_import($file);
|
|
149 |
$orders[0]->load; # reload order to get correct delivered status
|
137 |
150 |
|
138 |
151 |
$entry = $entries->[0];
|
139 |
|
|
140 |
152 |
is $entry->{object}->ordnumber, '1234', 'with source order: ordnumber';
|
141 |
153 |
|
142 |
154 |
my $linked = $orders[0]->linked_records(to => 'DeliveryOrder');
|
... | ... | |
159 |
171 |
|
160 |
172 |
$entry = $entries->[3];
|
161 |
173 |
$linked = $entry->{object}->linked_records(from => 'OrderItem');
|
162 |
|
ok(scalar @$linked == 0, 'with source order: delivered qty < ordered qty: delivery order item not linked');
|
|
174 |
ok(scalar @$linked == 1, 'with source order: delivered qty < ordered qty: delivery order item linked (fill up)');
|
|
175 |
ok($linked->[0]->position == 3, 'with source order: delivered qty < ordered qty: order position ok (fill up)');
|
|
176 |
|
|
177 |
$entry = $entries->[4];
|
|
178 |
$linked = $entry->{object}->linked_records(from => 'OrderItem');
|
|
179 |
ok(scalar @$linked == 1, 'with source order: delivered qty < ordered qty: delivery order item linked (fill up) 2');
|
|
180 |
ok($linked->[0]->position == 3, 'with source order: delivered qty < ordered qty: order position ok (fill up) 2');
|
|
181 |
|
|
182 |
$entry = $entries->[5];
|
|
183 |
$linked = $entry->{object}->linked_records(from => 'OrderItem');
|
|
184 |
ok(scalar @$linked == 1, 'with source order: delivered qty == ordered qty: found exact match after fill up');
|
|
185 |
ok($linked->[0]->position == 4, 'with source order: delivered qty == ordered qty: order position ok after fill up');
|
|
186 |
|
|
187 |
ok(!$orders[0]->delivered, 'with source order: order not completely delivered');
|
|
188 |
|
|
189 |
$entries = undef;
|
|
190 |
clear_up;
|
163 |
191 |
|
164 |
192 |
#####
|
|
193 |
@customers = (new_customer(name => 'TestCustomer1', discount => 0)->save);
|
|
194 |
@parts = (
|
|
195 |
new_part(description => 'TestPart1', ean => '')->save,
|
|
196 |
new_part(description => 'TestPart2', ean => '')->save,
|
|
197 |
new_part(description => 'TestPart3', ean => '')->save
|
|
198 |
);
|
|
199 |
@orders = (
|
|
200 |
create_sales_order(
|
|
201 |
save => 1,
|
|
202 |
customer => $customers[0],
|
|
203 |
ordnumber => '1234',
|
|
204 |
orderitems => [ create_order_item(part => $parts[0], qty => 3, sellprice => 70),
|
|
205 |
create_order_item(part => $parts[1], qty => 10, sellprice => 50),
|
|
206 |
create_order_item(part => $parts[2], qty => 8, sellprice => 80),
|
|
207 |
create_order_item(part => $parts[2], qty => 11, sellprice => 80)
|
|
208 |
]
|
|
209 |
)
|
|
210 |
);
|
|
211 |
|
|
212 |
$file = \<<EOL;
|
|
213 |
datatype;customer;ordnumber
|
|
214 |
datatype;description;qty
|
|
215 |
datatype
|
|
216 |
DeliveryOrder;TestCustomer1;1234
|
|
217 |
OrderItem;TestPart1;1
|
|
218 |
OrderItem;TestPart2;10
|
|
219 |
OrderItem;TestPart1;2
|
|
220 |
OrderItem;TestPart3;7
|
|
221 |
OrderItem;TestPart3;11
|
|
222 |
OrderItem;TestPart3;1
|
|
223 |
|
|
224 |
EOL
|
|
225 |
|
|
226 |
1; # make emacs happy
|
|
227 |
|
|
228 |
# should be:
|
|
229 |
# delivery oder pos/qty <- order pos/qty
|
|
230 |
# 1/1 <- 1/1
|
|
231 |
# 2/10 <- 2/10
|
|
232 |
# 3/2 <- 1/2
|
|
233 |
# 4/7 <- 3/7
|
|
234 |
# 5/11 <- 4/11
|
|
235 |
# 6/1 <- 3/1
|
|
236 |
|
|
237 |
$entries = do_import($file);
|
|
238 |
$orders[0]->load; # reload order to get correct delivered status
|
|
239 |
|
|
240 |
$entry = $entries->[1];
|
|
241 |
$linked = $entry->{object}->linked_records(from => 'OrderItem');
|
|
242 |
ok($linked->[0]->position == 1, 'with source order: mixed qtys and fill up: order position ok 1');
|
|
243 |
|
|
244 |
$entry = $entries->[2];
|
|
245 |
$linked = $entry->{object}->linked_records(from => 'OrderItem');
|
|
246 |
ok($linked->[0]->position == 2, 'with source order: mixed qtys and fill up: order position ok 2');
|
|
247 |
|
|
248 |
$entry = $entries->[3];
|
|
249 |
$linked = $entry->{object}->linked_records(from => 'OrderItem');
|
|
250 |
ok($linked->[0]->position == 1, 'with source order: mixed qtys and fill up: order position ok 3');
|
|
251 |
|
|
252 |
$entry = $entries->[4];
|
|
253 |
$linked = $entry->{object}->linked_records(from => 'OrderItem');
|
|
254 |
ok($linked->[0]->position == 3, 'with source order: mixed qtys and fill up: order position ok 4');
|
|
255 |
|
|
256 |
$entry = $entries->[5];
|
|
257 |
$linked = $entry->{object}->linked_records(from => 'OrderItem');
|
|
258 |
ok($linked->[0]->position == 4, 'with source order: mixed qtys and fill up: order position ok 5');
|
|
259 |
|
|
260 |
$entry = $entries->[6];
|
|
261 |
$linked = $entry->{object}->linked_records(from => 'OrderItem');
|
|
262 |
ok($linked->[0]->position == 3, 'with source order: mixed qtys and fill up: order position ok 6');
|
|
263 |
|
|
264 |
ok(!!$orders[0]->delivered, 'with source order: mixed qtys and fill up: order completely delivered');
|
|
265 |
|
|
266 |
#####
|
|
267 |
$entries = undef;
|
165 |
268 |
clear_up;
|
166 |
269 |
|
|
270 |
#####
|
|
271 |
|
167 |
272 |
$::myconfig{numberformat} = $old_numberformat;
|
168 |
273 |
$::locale = $old_locale;
|
169 |
274 |
|
CsvImport Lieferscheine: Zusammenfassen von Lieferpositionen
Wenn in mehreren Positionen Teilmengen einer Position eines Auftrags
geliefert werden, dann diese Zusammenfassen.