Revision 7866dd56
Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt
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); |
Auch abrufbar als: Unified diff
Reclamation: Test überarbeitet; test_deeply in Support::TestRoutines