Revision 0fbbccdf
Von Tamino Steinert vor etwa 2 Jahren hinzugefügt
t/Support/TestRoutines.pm | ||
---|---|---|
1 |
package Support::TestRoutines; |
|
2 |
|
|
3 |
use Test::More; |
|
4 |
use List::MoreUtils qw(any); |
|
5 |
|
|
6 |
require Exporter; |
|
7 |
our @ISA = qw(Exporter); |
|
8 |
|
|
9 |
our @EXPORT = qw(test_deeply); |
|
10 |
|
|
11 |
sub test_deeply { |
|
12 |
my ($first, $second, $description, @ignore_keys) = @_; |
|
13 |
|
|
14 |
my @first_keys = keys %{$first}; |
|
15 |
my @second_keys = keys %{$second}; |
|
16 |
foreach my $key (@first_keys) { |
|
17 |
if (!any { $_ eq $key } @ignore_keys) { |
|
18 |
if (!any { $_ eq $key } @second_keys) { |
|
19 |
ok(0, $description . ": " . $key); |
|
20 |
} |
|
21 |
} |
|
22 |
} |
|
23 |
foreach my $key (@second_keys) { |
|
24 |
if (!any { $_ eq $key } @ignore_keys) { |
|
25 |
if (!any { $_ eq $key } @first_keys) { |
|
26 |
ok(0, $description . ": " . $key); |
|
27 |
} else { |
|
28 |
is($first->{$key}, $second->{$key}, $description . ": " . $key); |
|
29 |
} |
|
30 |
} |
|
31 |
} |
|
32 |
} |
|
33 |
|
t/workflow/delivery_order_reclamation.t | ||
---|---|---|
7 | 7 |
|
8 | 8 |
use Carp; |
9 | 9 |
use Data::Dumper; |
10 |
use Data::Compare; |
|
11 | 10 |
use Support::TestSetup; |
11 |
use Support::TestRoutines qw(test_deeply); |
|
12 | 12 |
use Test::Exception; |
13 |
use List::Util qw(zip);
|
|
13 |
use List::MoreUtils qw(pairwise);
|
|
14 | 14 |
|
15 | 15 |
use SL::DB::DeliveryOrder; |
16 | 16 |
use SL::DB::Reclamation; |
... | ... | |
197 | 197 |
|
198 | 198 |
|
199 | 199 |
#get items before strip |
200 |
my @purchase_reclamation_items = $purchase_reclamation->items_sorted;
|
|
201 |
my @sales_reclamation_items = $sales_reclamation->items_sorted;
|
|
202 |
my @converted_purchase_reclamation_items = $converted_purchase_reclamation->items_sorted;
|
|
203 |
my @converted_sales_reclamation_items = $converted_sales_reclamation->items_sorted;
|
|
204 |
my @purchase_delivery_order_items = $purchase_delivery_order->items_sorted;
|
|
205 |
my @sales_delivery_order_items = $sales_delivery_order->items_sorted;
|
|
206 |
my @converted_purchase_delivery_order_items = $converted_purchase_delivery_order->items_sorted;
|
|
207 |
my @converted_sales_delivery_order_items = $converted_sales_delivery_order->items_sorted;
|
|
200 |
my @purchase_reclamation_items = @{$purchase_reclamation->items_sorted};
|
|
201 |
my @sales_reclamation_items = @{$sales_reclamation->items_sorted};
|
|
202 |
my @converted_purchase_reclamation_items = @{$converted_purchase_reclamation->items_sorted};
|
|
203 |
my @converted_sales_reclamation_items = @{$converted_sales_reclamation->items_sorted};
|
|
204 |
my @purchase_delivery_order_items = @{$purchase_delivery_order->items_sorted};
|
|
205 |
my @sales_delivery_order_items = @{$sales_delivery_order->items_sorted};
|
|
206 |
my @converted_purchase_delivery_order_items = @{$converted_purchase_delivery_order->items_sorted};
|
|
207 |
my @converted_sales_delivery_order_items = @{$converted_sales_delivery_order->items_sorted};
|
|
208 | 208 |
|
209 | 209 |
|
210 | 210 |
### TESTS ##################################################################### |
... | ... | |
223 | 223 |
$sales_reclamation_tmp->$_(undef); |
224 | 224 |
$purchase_reclamation_tmp->$_(undef); |
225 | 225 |
} |
226 |
foreach my $pair (zip(@purchase_reclamation_items, @sales_reclamation_items)) { |
|
227 |
my ($first, $second) = @{$pair}; |
|
228 |
my $first_tmp = clone($first); |
|
229 |
my $second_tmp = clone($second); |
|
226 |
pairwise { my $first_tmp = clone($a); my $second_tmp = clone($b); |
|
230 | 227 |
foreach (qw( |
231 | 228 |
id reclamation_id |
232 | 229 |
itime mtime |
... | ... | |
235 | 232 |
$second_tmp->$_(undef); |
236 | 233 |
} |
237 | 234 |
is_deeply($first_tmp->strip->as_tree, $second_tmp->strip->as_tree); |
238 |
} |
|
235 |
} @purchase_reclamation_items, @sales_reclamation_items;
|
|
239 | 236 |
is_deeply($purchase_reclamation_tmp->strip->as_tree, $sales_reclamation_tmp->strip->as_tree); |
240 | 237 |
|
241 | 238 |
## created sales und purchase delivery_order should be nearly the same |
... | ... | |
252 | 249 |
$sales_delivery_order_tmp->$_(undef); |
253 | 250 |
$purchase_delivery_order_tmp->$_(undef); |
254 | 251 |
} |
255 |
foreach my $pair (zip(@purchase_delivery_order_items, @sales_delivery_order_items)) { |
|
256 |
my ($first, $second) = @{$pair}; |
|
257 |
my $first_tmp = clone($first); |
|
258 |
my $second_tmp = clone($second); |
|
252 |
pairwise { my $first_tmp = clone($a); my $second_tmp = clone($b); |
|
259 | 253 |
foreach (qw( |
260 | 254 |
id delivery_order_id |
261 | 255 |
itime mtime |
... | ... | |
264 | 258 |
$second_tmp->$_(undef); |
265 | 259 |
} |
266 | 260 |
is_deeply($first_tmp->strip->as_tree, $second_tmp->strip->as_tree); |
267 |
} |
|
261 |
} @purchase_delivery_order_items, @sales_delivery_order_items;
|
|
268 | 262 |
is_deeply($purchase_delivery_order_tmp->strip->as_tree, $sales_delivery_order_tmp->strip->as_tree); |
269 | 263 |
|
270 | 264 |
|
... | ... | |
284 | 278 |
|
285 | 279 |
## converted should be nealy the same |
286 | 280 |
# sales |
287 |
foreach my $pair (zip(@sales_delivery_order_items, @converted_sales_reclamation_items)) { |
|
288 |
my ($first, $second) = @{$pair}; |
|
289 |
ok Compare($first->strip->as_tree, $second->strip->as_tree, {ignore_hash_keys => [qw( |
|
290 |
id delivery_order_id reclamation_id itime mtime |
|
291 |
cusordnumber marge_price_factor ordnumber transdate |
|
292 |
description reason_description_ext reason_description_int reason_id |
|
293 |
)]}); |
|
294 |
} |
|
295 |
ok Compare($sales_delivery_order->strip->as_tree, $converted_sales_reclamation->strip->as_tree, {ignore_hash_keys => [qw( |
|
296 |
id employee_id itime mtime reqdate |
|
297 |
is_sales order_type ordnumber oreqnumber |
|
298 |
amount exchangerate netamount |
|
299 |
cp_id contact_id |
|
300 |
cusordnumber cv_record_number |
|
301 |
donumber record_number |
|
302 |
)]}); |
|
303 |
|
|
304 |
foreach my $pair (zip(@sales_reclamation_items, @converted_sales_delivery_order_items)) { |
|
305 |
my ($first, $second) = @{$pair}; |
|
306 |
ok Compare($first->strip->as_tree, $second->strip->as_tree, {ignore_hash_keys => [qw( |
|
307 |
id delivery_order_id reclamation_id itime mtime |
|
308 |
cusordnumber marge_price_factor ordnumber transdate |
|
309 |
description reason_description_ext reason_description_int reason_id |
|
310 |
)]}); |
|
311 |
} |
|
312 |
ok Compare($sales_reclamation->strip->as_tree, $converted_sales_delivery_order->strip->as_tree, {ignore_hash_keys => [qw( |
|
313 |
id employee_id itime mtime delivered reqdate |
|
314 |
is_sales order_type ordnumber oreqnumber |
|
315 |
amount exchangerate netamount |
|
316 |
cp_id contact_id |
|
317 |
cusordnumber cv_record_number |
|
318 |
donumber record_number |
|
319 |
)]}); |
|
281 |
pairwise { |
|
282 |
test_deeply($a->strip->as_tree, $b->strip->as_tree, |
|
283 |
"sales_delivery_order_items to sales_reclamation_items", |
|
284 |
qw( |
|
285 |
id delivery_order_id reclamation_id itime mtime |
|
286 |
cusordnumber marge_price_factor ordnumber transdate |
|
287 |
description reason_description_ext reason_description_int reason_id |
|
288 |
)); |
|
289 |
} @sales_delivery_order_items, @converted_sales_reclamation_items; |
|
290 |
test_deeply($sales_delivery_order->strip->as_tree, $converted_sales_reclamation->strip->as_tree, |
|
291 |
"sales_delivery_order to sales_reclamation", |
|
292 |
qw( |
|
293 |
id employee_id itime mtime reqdate |
|
294 |
is_sales order_type ordnumber oreqnumber |
|
295 |
amount exchangerate netamount |
|
296 |
cp_id contact_id |
|
297 |
cusordnumber cv_record_number |
|
298 |
donumber record_number |
|
299 |
)); |
|
300 |
|
|
301 |
pairwise { |
|
302 |
test_deeply($a->strip->as_tree, $b->strip->as_tree, |
|
303 |
"sales_reclamation_items to sales_delivery_order_items", |
|
304 |
qw( |
|
305 |
id delivery_order_id reclamation_id itime mtime |
|
306 |
cusordnumber marge_price_factor ordnumber transdate |
|
307 |
description reason_description_ext reason_description_int reason_id |
|
308 |
)); |
|
309 |
} @sales_reclamation_items, @converted_sales_delivery_order_items; |
|
310 |
test_deeply($sales_reclamation->strip->as_tree, $converted_sales_delivery_order->strip->as_tree, |
|
311 |
"sales_reclamation to sales_delivery_order", |
|
312 |
qw( |
|
313 |
id employee_id itime mtime delivered reqdate |
|
314 |
is_sales order_type ordnumber oreqnumber |
|
315 |
amount exchangerate netamount |
|
316 |
cp_id contact_id |
|
317 |
cusordnumber cv_record_number |
|
318 |
donumber record_number |
|
319 |
)); |
|
320 | 320 |
|
321 | 321 |
|
322 | 322 |
# purchase |
323 |
foreach my $pair (zip(@purchase_delivery_order_items, @converted_purchase_reclamation_items)) { |
|
324 |
my ($first, $second) = @{$pair}; |
|
325 |
ok Compare($first->strip->as_tree, $second->strip->as_tree, {ignore_hash_keys => [qw( |
|
326 |
id delivery_order_id reclamation_id itime mtime |
|
327 |
cusordnumber marge_price_factor ordnumber transdate |
|
328 |
description reason_description_ext reason_description_int reason_id |
|
329 |
)]}); |
|
330 |
} |
|
331 |
ok Compare($purchase_delivery_order->strip->as_tree, $converted_purchase_reclamation->strip->as_tree, {ignore_hash_keys => [qw( |
|
332 |
id employee_id itime mtime reqdate |
|
333 |
is_sales order_type ordnumber oreqnumber |
|
334 |
amount exchangerate netamount |
|
335 |
cp_id contact_id |
|
336 |
cusordnumber cv_record_number |
|
337 |
donumber record_number |
|
338 |
)]}); |
|
339 |
|
|
340 |
foreach my $pair (zip(@purchase_reclamation_items, @converted_purchase_delivery_order_items)) { |
|
341 |
my ($first, $second) = @{$pair}; |
|
342 |
ok Compare($first->strip->as_tree, $second->strip->as_tree, {ignore_hash_keys => [qw( |
|
343 |
id delivery_order_id reclamation_id itime mtime |
|
344 |
cusordnumber marge_price_factor ordnumber transdate |
|
345 |
description reason_description_ext reason_description_int reason_id |
|
346 |
)]}); |
|
347 |
} |
|
348 |
ok Compare($purchase_reclamation->strip->as_tree, $converted_purchase_delivery_order->strip->as_tree, {ignore_hash_keys => [qw( |
|
349 |
id employee_id itime mtime delivered reqdate |
|
350 |
is_sales order_type ordnumber oreqnumber |
|
351 |
amount exchangerate netamount |
|
352 |
cp_id contact_id |
|
353 |
cusordnumber cv_record_number |
|
354 |
donumber record_number |
|
355 |
)]}); |
|
323 |
pairwise { |
|
324 |
test_deeply($a->strip->as_tree, $b->strip->as_tree, |
|
325 |
"purchase_delivery_order_items to purchase_reclamation_items", |
|
326 |
qw( |
|
327 |
id delivery_order_id reclamation_id itime mtime |
|
328 |
cusordnumber marge_price_factor ordnumber transdate |
|
329 |
description reason_description_ext reason_description_int reason_id |
|
330 |
)); |
|
331 |
} @purchase_delivery_order_items, @converted_purchase_reclamation_items; |
|
332 |
test_deeply($purchase_delivery_order->strip->as_tree, $converted_purchase_reclamation->strip->as_tree, |
|
333 |
"purchase_delivery_order to purchase_reclamation", |
|
334 |
qw( |
|
335 |
id employee_id itime mtime reqdate |
|
336 |
is_sales order_type ordnumber oreqnumber |
|
337 |
amount exchangerate netamount |
|
338 |
cp_id contact_id |
|
339 |
cusordnumber cv_record_number |
|
340 |
donumber record_number |
|
341 |
)); |
|
342 |
|
|
343 |
pairwise { |
|
344 |
test_deeply($a->strip->as_tree, $b->strip->as_tree, |
|
345 |
"purchase_reclamation_items to purchase_delivery_order_items", |
|
346 |
qw( |
|
347 |
id delivery_order_id reclamation_id itime mtime |
|
348 |
cusordnumber marge_price_factor ordnumber transdate |
|
349 |
description reason_description_ext reason_description_int reason_id |
|
350 |
)); |
|
351 |
} @purchase_reclamation_items, @converted_purchase_delivery_order_items; |
|
352 |
test_deeply($purchase_reclamation->strip->as_tree, $converted_purchase_delivery_order->strip->as_tree, |
|
353 |
"purchase_reclamation to purchase_delivery_order", |
|
354 |
qw( |
|
355 |
id employee_id itime mtime delivered reqdate |
|
356 |
is_sales order_type ordnumber oreqnumber |
|
357 |
amount exchangerate netamount |
|
358 |
cp_id contact_id |
|
359 |
cusordnumber cv_record_number |
|
360 |
donumber record_number |
|
361 |
)); |
|
356 | 362 |
|
357 | 363 |
|
358 | 364 |
|
t/workflow/invoice_to_reclamation.t | ||
---|---|---|
7 | 7 |
|
8 | 8 |
use Carp; |
9 | 9 |
use Data::Dumper; |
10 |
use Data::Compare; |
|
11 | 10 |
use Support::TestSetup; |
11 |
use Support::TestRoutines qw(test_deeply); |
|
12 | 12 |
use Test::Exception; |
13 |
use List::Util qw(zip);
|
|
13 |
use List::MoreUtils qw(pairwise);
|
|
14 | 14 |
|
15 | 15 |
use SL::DB::Order; |
16 | 16 |
use SL::DB::Reclamation; |
... | ... | |
190 | 190 |
$converted_purchase_reclamation->save->load; |
191 | 191 |
|
192 | 192 |
#get items before strip |
193 |
my @purchase_reclamation_items = $purchase_reclamation->items_sorted;
|
|
194 |
my @sales_reclamation_items = $sales_reclamation->items_sorted;
|
|
195 |
my @converted_purchase_reclamation_items = $converted_purchase_reclamation->items_sorted;
|
|
196 |
my @converted_sales_reclamation_items = $converted_sales_reclamation->items_sorted;
|
|
197 |
my @purchase_invoice_items = $purchase_invoice->items_sorted;
|
|
198 |
my @sales_invoice_items = $sales_invoice->items_sorted;
|
|
193 |
my @purchase_reclamation_items = @{$purchase_reclamation->items_sorted};
|
|
194 |
my @sales_reclamation_items = @{$sales_reclamation->items_sorted};
|
|
195 |
my @converted_purchase_reclamation_items = @{$converted_purchase_reclamation->items_sorted};
|
|
196 |
my @converted_sales_reclamation_items = @{$converted_sales_reclamation->items_sorted};
|
|
197 |
my @purchase_invoice_items = @{$purchase_invoice->items_sorted};
|
|
198 |
my @sales_invoice_items = @{$sales_invoice->items_sorted};
|
|
199 | 199 |
|
200 | 200 |
|
201 | 201 |
### TESTS ##################################################################### |
... | ... | |
214 | 214 |
$sales_reclamation_tmp->$_(undef); |
215 | 215 |
$purchase_reclamation_tmp->$_(undef); |
216 | 216 |
} |
217 |
foreach my $pair (zip(@purchase_reclamation_items, @sales_reclamation_items)) { |
|
218 |
my ($first, $second) = @{$pair}; |
|
219 |
my $first_tmp = clone($first); |
|
220 |
my $second_tmp = clone($second); |
|
217 |
pairwise { my $first_tmp = clone($a); my $second_tmp = clone($b); |
|
221 | 218 |
foreach (qw( |
222 | 219 |
id reclamation_id |
223 | 220 |
itime mtime |
... | ... | |
226 | 223 |
$second_tmp->$_(undef); |
227 | 224 |
} |
228 | 225 |
is_deeply($first_tmp->strip->as_tree, $second_tmp->strip->as_tree); |
229 |
} |
|
226 |
} @purchase_reclamation_items, @sales_reclamation_items;
|
|
230 | 227 |
is_deeply($purchase_reclamation_tmp->strip->as_tree, $sales_reclamation_tmp->strip->as_tree); |
231 | 228 |
|
232 | 229 |
## converted have to be linked to parent |
... | ... | |
237 | 234 |
|
238 | 235 |
|
239 | 236 |
## converted should be nealy the same |
240 |
foreach my $pair (zip(@sales_invoice_items, @converted_sales_reclamation_items)) { |
|
241 |
my ($first, $second) = @{$pair}; |
|
242 |
ok Compare($first->strip->as_tree, $second->strip->as_tree, {ignore_hash_keys => [qw( |
|
243 |
id trans_id reclamation_id itime mtime |
|
244 |
allocated assemblyitem cusordnumber deliverydate donumber fxsellprice marge_percent marge_price_factor marge_total optional ordnumber subtotal transdate |
|
245 |
reason_description_ext reason_description_int reason_id reqdate |
|
246 |
)]}); |
|
247 |
} |
|
248 |
ok Compare($sales_invoice->strip->as_tree, $converted_sales_reclamation->strip->as_tree, {ignore_hash_keys => [qw( |
|
249 |
id employee_id itime mtime transdate |
|
250 |
datepaid delivery_customer_id delivery_vendor_id deliverydate direct_debit donumber duedate dunning_config_id gldate invnumber_for_credit_note invoice marge_percent marge_total orddate ordnumber paid qr_reference qr_unstructured_message qrbill_without_amount quodate quonumber storno storno_id type |
|
251 |
delivered closed exchangerate reqdate vendor_id |
|
252 |
cp_id contact_id |
|
253 |
cusordnumber cv_record_number |
|
254 |
invnumber record_number |
|
255 |
)]}); |
|
256 |
|
|
257 |
foreach my $pair (zip(@purchase_invoice_items, @converted_purchase_reclamation_items)) { |
|
258 |
my ($first, $second) = @{$pair}; |
|
259 |
ok Compare($first->strip->as_tree, $second->strip->as_tree, {ignore_hash_keys => [qw( |
|
260 |
id trans_id reclamation_id itime mtime |
|
261 |
allocated assemblyitem cusordnumber deliverydate donumber fxsellprice marge_percent marge_price_factor marge_total optional ordnumber subtotal transdate |
|
262 |
reason_description_ext reason_description_int reason_id reqdate |
|
263 |
)]}); |
|
264 |
} |
|
265 |
ok Compare($purchase_invoice->strip->as_tree, $converted_purchase_reclamation->strip->as_tree, {ignore_hash_keys => [qw( |
|
266 |
id employee_id itime mtime transdate |
|
267 |
datepaid deliverydate direct_debit duedate gldate invoice orddate ordnumber paid quodate quonumber storno storno_id type |
|
268 |
billing_address_id customer_id cv_record_number delivered closed exchangerate reqdate salesman_id shippingpoint shipto_id |
|
269 |
cp_id contact_id |
|
270 |
invnumber record_number |
|
271 |
)]}); |
|
237 |
pairwise { |
|
238 |
test_deeply($a->strip->as_tree, $b->strip->as_tree, |
|
239 |
"sales_invoice_items to sales_reclamation_items", |
|
240 |
qw( |
|
241 |
id trans_id reclamation_id itime mtime |
|
242 |
allocated assemblyitem cusordnumber deliverydate donumber fxsellprice marge_percent marge_price_factor marge_total optional ordnumber subtotal transdate |
|
243 |
reason_description_ext reason_description_int reason_id reqdate |
|
244 |
)); |
|
245 |
} @sales_invoice_items, @converted_sales_reclamation_items; |
|
246 |
test_deeply($sales_invoice->strip->as_tree, $converted_sales_reclamation->strip->as_tree, |
|
247 |
"sales_invoice to sales_reclamation", |
|
248 |
qw( |
|
249 |
id employee_id itime mtime transdate |
|
250 |
datepaid delivery_customer_id delivery_vendor_id deliverydate direct_debit donumber duedate dunning_config_id gldate invnumber_for_credit_note invoice marge_percent marge_total orddate ordnumber paid qr_reference qr_unstructured_message qrbill_without_amount quodate quonumber storno storno_id type |
|
251 |
delivered closed exchangerate reqdate vendor_id |
|
252 |
cp_id contact_id |
|
253 |
cusordnumber cv_record_number |
|
254 |
invnumber record_number |
|
255 |
)); |
|
256 |
|
|
257 |
pairwise { |
|
258 |
test_deeply($a->strip->as_tree, $b->strip->as_tree, |
|
259 |
"purchase_invoice_items to purchase_reclamation_items", |
|
260 |
qw( |
|
261 |
id trans_id reclamation_id itime mtime |
|
262 |
allocated assemblyitem cusordnumber deliverydate donumber fxsellprice marge_percent marge_price_factor marge_total optional ordnumber subtotal transdate |
|
263 |
reason_description_ext reason_description_int reason_id reqdate |
|
264 |
)); |
|
265 |
} @purchase_invoice_items, @converted_purchase_reclamation_items; |
|
266 |
test_deeply($purchase_invoice->strip->as_tree, $converted_purchase_reclamation->strip->as_tree, |
|
267 |
"purchase_invoice to purchase_reclamation", |
|
268 |
qw( |
|
269 |
id employee_id itime mtime transdate |
|
270 |
datepaid deliverydate direct_debit duedate gldate invoice orddate ordnumber paid quodate quonumber storno storno_id type is_sepa_blocked |
|
271 |
billing_address_id customer_id cv_record_number delivered closed exchangerate reqdate salesman_id shippingpoint shipto_id |
|
272 |
cp_id contact_id |
|
273 |
invnumber record_number |
|
274 |
)); |
|
272 | 275 |
|
273 | 276 |
# diag Dumper($sales_invoice->strip->as_tree); |
274 | 277 |
# diag Dumper($converted_sales_reclamation->strip->as_tree); |
t/workflow/order_reclamation.t | ||
---|---|---|
7 | 7 |
|
8 | 8 |
use Carp; |
9 | 9 |
use Data::Dumper; |
10 |
use Data::Compare; |
|
11 | 10 |
use Support::TestSetup; |
11 |
use Support::TestRoutines qw(test_deeply); |
|
12 | 12 |
use Test::Exception; |
13 |
use List::Util qw(zip);
|
|
13 |
use List::MoreUtils qw(pairwise);
|
|
14 | 14 |
|
15 | 15 |
use SL::DB::Order; |
16 | 16 |
use SL::DB::Reclamation; |
... | ... | |
195 | 195 |
|
196 | 196 |
|
197 | 197 |
#get items before strip |
198 |
my @purchase_reclamation_items = $purchase_reclamation->items_sorted;
|
|
199 |
my @sales_reclamation_items = $sales_reclamation->items_sorted;
|
|
200 |
my @converted_purchase_reclamation_items = $converted_purchase_reclamation->items_sorted;
|
|
201 |
my @converted_sales_reclamation_items = $converted_sales_reclamation->items_sorted;
|
|
202 |
my @purchase_order_items = $purchase_order->items_sorted;
|
|
203 |
my @sales_order_items = $sales_order->items_sorted;
|
|
204 |
my @converted_purchase_order_items = $converted_purchase_order->items_sorted;
|
|
205 |
my @converted_sales_order_items = $converted_sales_order->items_sorted;
|
|
198 |
my @purchase_reclamation_items = @{$purchase_reclamation->items_sorted};
|
|
199 |
my @sales_reclamation_items = @{$sales_reclamation->items_sorted};
|
|
200 |
my @converted_purchase_reclamation_items = @{$converted_purchase_reclamation->items_sorted};
|
|
201 |
my @converted_sales_reclamation_items = @{$converted_sales_reclamation->items_sorted};
|
|
202 |
my @purchase_order_items = @{$purchase_order->items_sorted};
|
|
203 |
my @sales_order_items = @{$sales_order->items_sorted};
|
|
204 |
my @converted_purchase_order_items = @{$converted_purchase_order->items_sorted};
|
|
205 |
my @converted_sales_order_items = @{$converted_sales_order->items_sorted};
|
|
206 | 206 |
|
207 | 207 |
|
208 | 208 |
### TESTS ##################################################################### |
... | ... | |
221 | 221 |
$sales_reclamation_tmp->$_(undef); |
222 | 222 |
$purchase_reclamation_tmp->$_(undef); |
223 | 223 |
} |
224 |
foreach my $pair (zip(@purchase_reclamation_items, @sales_reclamation_items)) { |
|
225 |
my ($first, $second) = @{$pair}; |
|
226 |
my $first_tmp = clone($first); |
|
227 |
my $second_tmp = clone($second); |
|
224 |
|
|
225 |
pairwise { my $first_tmp = clone($a); my $second_tmp = clone($b); |
|
228 | 226 |
foreach (qw( |
229 | 227 |
id reclamation_id |
230 | 228 |
itime mtime |
... | ... | |
233 | 231 |
$second_tmp->$_(undef); |
234 | 232 |
} |
235 | 233 |
is_deeply($first_tmp->strip->as_tree, $second_tmp->strip->as_tree); |
236 |
} |
|
234 |
} @purchase_reclamation_items, @sales_reclamation_items;
|
|
237 | 235 |
is_deeply($purchase_reclamation_tmp->strip->as_tree, $sales_reclamation_tmp->strip->as_tree); |
238 | 236 |
|
239 | 237 |
## created sales und purchase order should be nearly the same |
... | ... | |
250 | 248 |
$sales_order_tmp->$_(undef); |
251 | 249 |
$purchase_order_tmp->$_(undef); |
252 | 250 |
} |
253 |
foreach my $pair (zip(@purchase_order_items, @sales_order_items)) { |
|
254 |
my ($first, $second) = @{$pair}; |
|
255 |
my $first_tmp = clone($first); |
|
256 |
my $second_tmp = clone($second); |
|
251 |
pairwise { my $first_tmp = clone($a); my $second_tmp = clone($b); |
|
257 | 252 |
foreach (qw( |
258 | 253 |
id trans_id |
259 | 254 |
itime mtime |
... | ... | |
262 | 257 |
$second_tmp->$_(undef); |
263 | 258 |
} |
264 | 259 |
is_deeply($first_tmp->strip->as_tree, $second_tmp->strip->as_tree); |
265 |
} |
|
260 |
} @purchase_order_items, @sales_order_items;
|
|
266 | 261 |
is_deeply($purchase_order_tmp->strip->as_tree, $sales_order_tmp->strip->as_tree); |
267 | 262 |
|
268 | 263 |
|
... | ... | |
282 | 277 |
|
283 | 278 |
## converted should be nealy the same |
284 | 279 |
# sales |
285 |
foreach my $pair (zip(@sales_order_items, @converted_sales_reclamation_items)) { |
|
286 |
my ($first, $second) = @{$pair}; |
|
287 |
ok Compare($first->strip->as_tree, $second->strip->as_tree, {ignore_hash_keys => [qw( |
|
288 |
id trans_id reclamation_id itime mtime |
|
289 |
cusordnumber marge_percent marge_price_factor marge_total optional ordnumber ship subtotal transdate |
|
290 |
reason_description_ext reason_description_int reason_id |
|
291 |
)]}); |
|
292 |
} |
|
293 |
ok Compare($sales_order->strip->as_tree, $converted_sales_reclamation->strip->as_tree, {ignore_hash_keys => [qw( |
|
294 |
id employee_id itime mtime reqdate transdate |
|
295 |
delivery_customer_id delivery_vendor_id expected_billing_date marge_percent marge_total order_probability order_status_id proforma quonumber quotation |
|
296 |
cp_id contact_id |
|
297 |
cusordnumber cv_record_number |
|
298 |
ordnumber record_number |
|
299 |
)]}); |
|
300 |
|
|
301 |
foreach my $pair (zip(@sales_reclamation_items, @converted_sales_order_items)) { |
|
302 |
my ($first, $second) = @{$pair}; |
|
303 |
ok Compare($first->strip->as_tree, $second->strip->as_tree, {ignore_hash_keys => [qw( |
|
304 |
id trans_id reclamation_id itime mtime |
|
305 |
cusordnumber marge_percent marge_price_factor marge_total optional ordnumber ship subtotal transdate |
|
306 |
reason_description_ext reason_description_int reason_id |
|
307 |
)]}); |
|
308 |
} |
|
309 |
ok Compare($sales_reclamation->strip->as_tree, $converted_sales_order->strip->as_tree, {ignore_hash_keys => [qw( |
|
310 |
id employee_id itime mtime reqdate transdate |
|
311 |
delivery_customer_id delivery_vendor_id expected_billing_date marge_percent marge_total order_probability order_status_id proforma quonumber quotation |
|
312 |
cp_id contact_id |
|
313 |
cusordnumber cv_record_number |
|
314 |
ordnumber record_number |
|
315 |
)]}); |
|
280 |
pairwise { |
|
281 |
test_deeply( $a->strip->as_tree, $b->strip->as_tree, |
|
282 |
"sales_order_items to sales_reclamation_items", |
|
283 |
qw( |
|
284 |
id trans_id reclamation_id itime mtime |
|
285 |
cusordnumber marge_percent marge_price_factor marge_total optional ordnumber ship subtotal transdate |
|
286 |
reason_description_ext reason_description_int reason_id |
|
287 |
)); |
|
288 |
} @sales_order_items, @converted_sales_reclamation_items; |
|
289 |
test_deeply( $sales_order->strip->as_tree, $converted_sales_reclamation->strip->as_tree, |
|
290 |
"sales_order to sales_reclamation", |
|
291 |
qw( |
|
292 |
id employee_id itime mtime reqdate transdate |
|
293 |
delivery_customer_id delivery_vendor_id expected_billing_date marge_percent marge_total order_probability order_status_id proforma quonumber quotation |
|
294 |
cp_id contact_id |
|
295 |
cusordnumber cv_record_number |
|
296 |
ordnumber record_number |
|
297 |
)); |
|
298 |
|
|
299 |
pairwise { |
|
300 |
test_deeply( $a->strip->as_tree, $b->strip->as_tree, |
|
301 |
"sales_reclamation_items to sales_order_items", |
|
302 |
qw( |
|
303 |
id trans_id reclamation_id itime mtime |
|
304 |
cusordnumber marge_percent marge_price_factor marge_total optional ordnumber ship subtotal transdate |
|
305 |
reason_description_ext reason_description_int reason_id |
|
306 |
)); |
|
307 |
} @sales_reclamation_items, @converted_sales_order_items; |
|
308 |
test_deeply($sales_reclamation->strip->as_tree, $converted_sales_order->strip->as_tree, |
|
309 |
"sales_reclamation to sales_order", |
|
310 |
qw( |
|
311 |
id employee_id itime mtime reqdate transdate |
|
312 |
delivery_customer_id delivery_vendor_id expected_billing_date marge_percent marge_total order_probability order_status_id proforma quonumber quotation |
|
313 |
cp_id contact_id |
|
314 |
cusordnumber cv_record_number |
|
315 |
ordnumber record_number |
|
316 |
)); |
|
316 | 317 |
|
317 | 318 |
# purchase |
318 |
foreach my $pair (zip(@purchase_order_items, @converted_purchase_reclamation_items)) { |
|
319 |
my ($first, $second) = @{$pair}; |
|
320 |
ok Compare($first->strip->as_tree, $second->strip->as_tree, {ignore_hash_keys => [qw( |
|
321 |
id trans_id reclamation_id itime mtime |
|
322 |
cusordnumber marge_percent marge_price_factor marge_total optional ordnumber ship subtotal transdate |
|
323 |
reason_description_ext reason_description_int reason_id |
|
324 |
)]}); |
|
325 |
} |
|
326 |
ok Compare($purchase_order->strip->as_tree, $converted_purchase_reclamation->strip->as_tree, {ignore_hash_keys => [qw( |
|
327 |
id employee_id itime mtime reqdate transdate |
|
328 |
delivery_customer_id delivery_vendor_id expected_billing_date marge_percent marge_total order_probability order_status_id proforma quonumber quotation |
|
329 |
cp_id contact_id |
|
330 |
cusordnumber cv_record_number |
|
331 |
ordnumber record_number |
|
332 |
)]}); |
|
333 |
|
|
334 |
foreach my $pair (zip(@purchase_reclamation_items, @converted_purchase_order_items)) { |
|
335 |
my ($first, $second) = @{$pair}; |
|
336 |
ok Compare($first->strip->as_tree, $second->strip->as_tree, {ignore_hash_keys => [qw( |
|
337 |
id trans_id reclamation_id itime mtime |
|
338 |
cusordnumber marge_percent marge_price_factor marge_total optional ordnumber ship subtotal transdate |
|
339 |
reason_description_ext reason_description_int reason_id |
|
340 |
)]}); |
|
341 |
} |
|
342 |
ok Compare($purchase_reclamation->strip->as_tree, $converted_purchase_order->strip->as_tree, {ignore_hash_keys => [qw( |
|
343 |
id employee_id itime mtime reqdate transdate |
|
344 |
delivery_customer_id delivery_vendor_id expected_billing_date marge_percent marge_total order_probability order_status_id proforma quonumber quotation |
|
345 |
cp_id contact_id |
|
346 |
cusordnumber cv_record_number |
|
347 |
ordnumber record_number |
|
348 |
)]}); |
|
319 |
pairwise { |
|
320 |
test_deeply($a->strip->as_tree, $b->strip->as_tree, |
|
321 |
"purchase_order_items to purchase_reclamation_items", |
|
322 |
qw( |
|
323 |
id trans_id reclamation_id itime mtime |
|
324 |
cusordnumber marge_percent marge_price_factor marge_total optional ordnumber ship subtotal transdate |
|
325 |
reason_description_ext reason_description_int reason_id |
|
326 |
)); |
|
327 |
} @purchase_order_items, @converted_purchase_reclamation_items; |
|
328 |
test_deeply($purchase_order->strip->as_tree, $converted_purchase_reclamation->strip->as_tree, |
|
329 |
"purchase_order to purchase_reclamation", |
|
330 |
qw( |
|
331 |
id employee_id itime mtime reqdate transdate |
|
332 |
delivery_customer_id delivery_vendor_id expected_billing_date marge_percent marge_total order_probability order_status_id proforma quonumber quotation |
|
333 |
cp_id contact_id |
|
334 |
cusordnumber cv_record_number |
|
335 |
ordnumber record_number |
|
336 |
)); |
|
337 |
|
|
338 |
pairwise { |
|
339 |
test_deeply($a->strip->as_tree, $b->strip->as_tree, |
|
340 |
"purchase_reclamation_items to purchase_order_items", |
|
341 |
qw( |
|
342 |
id trans_id reclamation_id itime mtime |
|
343 |
cusordnumber marge_percent marge_price_factor marge_total optional ordnumber ship subtotal transdate |
|
344 |
reason_description_ext reason_description_int reason_id |
|
345 |
)); |
|
346 |
} @purchase_reclamation_items, @converted_purchase_order_items; |
|
347 |
test_deeply($purchase_reclamation->strip->as_tree, $converted_purchase_order->strip->as_tree, |
|
348 |
"purchase_reclamation to purchase_order", |
|
349 |
qw( |
|
350 |
id employee_id itime mtime reqdate transdate |
|
351 |
delivery_customer_id delivery_vendor_id expected_billing_date marge_percent marge_total order_probability order_status_id proforma quonumber quotation |
|
352 |
cp_id contact_id |
|
353 |
cusordnumber cv_record_number |
|
354 |
ordnumber record_number |
|
355 |
)); |
|
349 | 356 |
|
350 | 357 |
# diag Dumper($sales_order->strip->as_tree); |
351 | 358 |
# diag Dumper($converted_sales_reclamation->strip->as_tree); |
t/workflow/reclamation_reclamation.t | ||
---|---|---|
9 | 9 |
use Data::Dumper; |
10 | 10 |
use Support::TestSetup; |
11 | 11 |
use Test::Exception; |
12 |
use List::Util qw(zip);
|
|
12 |
use List::MoreUtils qw(pairwise);
|
|
13 | 13 |
|
14 | 14 |
use SL::DB::Reclamation; |
15 | 15 |
use SL::DB::ReclamationReason; |
... | ... | |
162 | 162 |
$converted_sales_reclamation->save->load; |
163 | 163 |
|
164 | 164 |
#get items before strip |
165 |
my @purchase_reclamation_items = $purchase_reclamation->items_sorted;
|
|
166 |
my @sales_reclamation_items = $sales_reclamation->items_sorted;
|
|
167 |
my @new_purchase_reclamation_items = $new_purchase_reclamation->items_sorted;
|
|
168 |
my @new_sales_reclamation_items = $new_sales_reclamation->items_sorted;
|
|
169 |
my @converted_purchase_reclamation_items = $converted_purchase_reclamation->items_sorted;
|
|
170 |
my @converted_sales_reclamation_items = $converted_sales_reclamation->items_sorted;
|
|
165 |
my @purchase_reclamation_items = @{$purchase_reclamation->items_sorted};
|
|
166 |
my @sales_reclamation_items = @{$sales_reclamation->items_sorted};
|
|
167 |
my @new_purchase_reclamation_items = @{$new_purchase_reclamation->items_sorted};
|
|
168 |
my @new_sales_reclamation_items = @{$new_sales_reclamation->items_sorted};
|
|
169 |
my @converted_purchase_reclamation_items = @{$converted_purchase_reclamation->items_sorted};
|
|
170 |
my @converted_sales_reclamation_items = @{$converted_sales_reclamation->items_sorted};
|
|
171 | 171 |
|
172 | 172 |
|
173 | 173 |
### TESTS ##################################################################### |
... | ... | |
185 | 185 |
$purchase_tmp->$_(undef); |
186 | 186 |
} |
187 | 187 |
|
188 |
foreach my $pair (zip(@purchase_reclamation_items, @sales_reclamation_items)) { |
|
189 |
my ($first, $second) = @{$pair}; |
|
190 |
my $first_tmp = clone($first); |
|
191 |
my $second_tmp = clone($second); |
|
188 |
pairwise { my $first_tmp = clone($a); my $second_tmp = clone($b); |
|
192 | 189 |
foreach (qw( |
193 | 190 |
id reclamation_id |
194 | 191 |
itime mtime |
... | ... | |
197 | 194 |
$second_tmp->$_(undef); |
198 | 195 |
} |
199 | 196 |
is_deeply($first_tmp->strip->as_tree, $second_tmp->strip->as_tree); |
200 |
} |
|
197 |
} @purchase_reclamation_items, @sales_reclamation_items;
|
|
201 | 198 |
is_deeply($purchase_tmp->strip->as_tree, $sales_tmp->strip->as_tree); |
202 | 199 |
|
203 | 200 |
|
... | ... | |
232 | 229 |
$purchase_tmp2->$_(undef); |
233 | 230 |
} |
234 | 231 |
|
235 |
foreach my $pair (zip(@sales_reclamation_items, @new_sales_reclamation_items)) { |
|
236 |
my ($first, $second) = @{$pair}; |
|
237 |
my $first_tmp = clone($first); |
|
238 |
my $second_tmp = clone($second); |
|
232 |
pairwise { my $first_tmp = clone($a); my $second_tmp = clone($b); |
|
239 | 233 |
foreach (qw( |
240 | 234 |
id reclamation_id |
241 | 235 |
itime mtime |
... | ... | |
244 | 238 |
$second_tmp->$_(undef); |
245 | 239 |
} |
246 | 240 |
is_deeply($first_tmp->strip->as_tree, $second_tmp->strip->as_tree); |
247 |
} |
|
241 |
} @sales_reclamation_items, @new_sales_reclamation_items;
|
|
248 | 242 |
is_deeply($sales_tmp2->strip->as_tree, $new_sales_tmp->strip->as_tree); |
249 | 243 |
|
250 |
foreach my $pair (zip(@purchase_reclamation_items, @new_purchase_reclamation_items)) { |
|
251 |
my ($first, $second) = @{$pair}; |
|
252 |
my $first_tmp = clone($first); |
|
253 |
my $second_tmp = clone($second); |
|
244 |
pairwise { my $first_tmp = clone($a); my $second_tmp = clone($b); |
|
254 | 245 |
foreach (qw( |
255 | 246 |
id reclamation_id |
256 | 247 |
itime mtime |
... | ... | |
259 | 250 |
$second_tmp->$_(undef); |
260 | 251 |
} |
261 | 252 |
is_deeply($first_tmp->strip->as_tree, $second_tmp->strip->as_tree); |
262 |
} |
|
253 |
} @purchase_reclamation_items, @new_purchase_reclamation_items;
|
|
263 | 254 |
is_deeply($purchase_tmp2->strip->as_tree, $new_purchase_tmp->strip->as_tree); |
264 | 255 |
|
265 | 256 |
|
... | ... | |
286 | 277 |
} |
287 | 278 |
|
288 | 279 |
# from sales to purchase |
289 |
foreach my $pair (zip(@sales_reclamation_items, @converted_purchase_reclamation_items)) { |
|
290 |
my ($first, $second) = @{$pair}; |
|
291 |
my $first_tmp = clone($first); |
|
292 |
my $second_tmp = clone($second); |
|
280 |
pairwise { my $first_tmp = clone($a); my $second_tmp = clone($b); |
|
293 | 281 |
foreach (qw( |
294 | 282 |
id reclamation_id |
295 | 283 |
sellprice discount |
... | ... | |
299 | 287 |
$second_tmp->$_(undef); |
300 | 288 |
} |
301 | 289 |
is_deeply($first_tmp->strip->as_tree, $second_tmp->strip->as_tree); |
302 |
} |
|
290 |
} @sales_reclamation_items, @converted_purchase_reclamation_items;
|
|
303 | 291 |
is_deeply($sales_tmp3->strip->as_tree, $converted_purchase_tmp->strip->as_tree); |
304 | 292 |
|
305 | 293 |
|
306 | 294 |
# from purchase to sales |
307 |
foreach my $pair (zip(@purchase_reclamation_items, @converted_sales_reclamation_items)) { |
|
308 |
my ($first, $second) = @{$pair}; |
|
309 |
my $first_tmp = clone($first); |
|
310 |
my $second_tmp = clone($second); |
|
295 |
pairwise { my $first_tmp = clone($a); my $second_tmp = clone($b); |
|
311 | 296 |
foreach (qw( |
312 | 297 |
id reclamation_id |
313 | 298 |
lastcost |
... | ... | |
317 | 302 |
$second_tmp->$_(undef); |
318 | 303 |
} |
319 | 304 |
is_deeply($first_tmp->strip->as_tree, $second_tmp->strip->as_tree); |
320 |
} |
|
305 |
} @purchase_reclamation_items, @converted_sales_reclamation_items;
|
|
321 | 306 |
is_deeply($purchase_tmp3->strip->as_tree, $converted_sales_tmp->strip->as_tree); |
322 | 307 |
|
323 | 308 |
#diag Dumper($first->strip->as_tree); |
Auch abrufbar als: Unified diff
Reclamation: Test überarbeitet; test_deeply in Support::TestRoutines