5 use Test::More tests => 54;
8 use DateTime::Duration;
15 use_ok('C4::Bookseller');
25 GetBooksellersWithLateOrders
30 my $dbh = C4::Context->dbh;
31 $dbh->{RaiseError} = 1;
32 $dbh->{AutoCommit} = 0;
35 $dbh->do(q|DELETE FROM aqorders|);
36 $dbh->do(q|DELETE FROM aqbasket|);
37 $dbh->do(q|DELETE FROM aqbooksellers|);
39 my $count = scalar( C4::Bookseller::GetBookSeller('') );
40 my $sample_supplier1 = {
42 address1 => 'address1_1',
43 address2 => 'address1-2',
44 address3 => 'address1_2',
45 address4 => 'address1_2',
48 accountnumber => 'accountnumber1',
51 contact => 'contact1',
52 contpos => 'contpos1',
53 contphone => 'contphone1',
54 contfax => 'contefax1',
55 contaltphone => 'contaltphone1',
56 contemail => 'contemail1',
57 contnotes => 'contnotes1',
67 my $sample_supplier2 = {
69 address1 => 'address1_2',
70 address2 => 'address2-2',
71 address3 => 'address3_2',
72 address4 => 'address4_2',
75 accountnumber => 'accountnumber2',
78 contact => 'contact2',
79 contpos => 'contpos2',
80 contphone => 'contphone2',
81 contfax => 'contefax2',
82 contaltphone => 'contaltphone2',
83 contemail => 'contemail2',
84 contnotes => 'contnotes2',
95 my $id_supplier1 = C4::Bookseller::AddBookseller($sample_supplier1);
96 my $id_supplier2 = C4::Bookseller::AddBookseller($sample_supplier2);
98 #my $id_bookseller3 = C4::Bookseller::AddBookseller();# NOTE : Doesn't work because the field name cannot be null
100 like( $id_supplier1, '/^\d+$/', "AddBookseller for supplier1 return an id" );
101 like( $id_supplier2, '/^\d+$/', "AddBookseller for supplier2 return an id" );
102 is( scalar( C4::Bookseller::GetBookSeller('') ),
103 $count + 2, "Supplier1 and Supplier2 have been added" );
106 my $del = C4::Bookseller::DelBookseller($id_supplier1);
107 is( $del, 1, "DelBookseller returns 1 - 1 supplier has been deleted " );
108 is( C4::Bookseller::GetBookSellerFromId($id_supplier1),
109 undef, "Supplier1 has been deleted - id_supplier1 doesnt exist anymore" );
112 my @bookseller2 = C4::Bookseller::GetBookSeller( $sample_supplier2->{name} );
113 is( scalar(@bookseller2), 1, "Get only Supplier2" );
114 $bookseller2[0] = field_filter( $bookseller2[0] );
115 delete $bookseller2[0]->{basketcount};
117 $sample_supplier2->{id} = $id_supplier2;
118 is_deeply( $bookseller2[0], $sample_supplier2,
119 "GetBookSeller returns the right informations about $sample_supplier2" );
121 $id_supplier1 = C4::Bookseller::AddBookseller($sample_supplier1);
122 my @booksellers = C4::Bookseller::GetBookSeller('')
123 ; #NOTE :without params, it returns all the booksellers
124 for my $i ( 0 .. scalar(@booksellers) - 1 ) {
125 $booksellers[$i] = field_filter( $booksellers[$i] );
126 delete $booksellers[$i]->{basketcount};
129 $sample_supplier1->{id} = $id_supplier1;
130 is( scalar(@booksellers), $count + 2, "Get Supplier1 and Supplier2" );
131 my @tab = ( $sample_supplier1, $sample_supplier2 );
132 is_deeply( \@booksellers, \@tab,
133 "Returns right fields of Supplier1 and Supplier2" );
136 my @bookseller1 = C4::Bookseller::GetBookSeller( $sample_supplier1->{name} );
137 #FIXME : if there is 0 basket, GetBookSeller returns 1 as basketcount
138 #is( $bookseller1[0]->{basketcount}, 0, 'Supplier1 has 0 basket' );
140 C4::Acquisition::NewBasket( $id_supplier1, 'authorisedby1', 'basketname1' );
142 C4::Acquisition::NewBasket( $id_supplier1, 'authorisedby2', 'basketname2' );
143 @bookseller1 = C4::Bookseller::GetBookSeller( $sample_supplier1->{name} );
144 is( $bookseller1[0]->{basketcount}, 2, 'Supplier1 has 2 baskets' );
146 #Test GetBookSellerFromId
147 my $bookseller1fromid = C4::Bookseller::GetBookSellerFromId();
148 is( $bookseller1fromid, undef,
149 "GetBookSellerFromId returns undef if no id given" );
150 $bookseller1fromid = C4::Bookseller::GetBookSellerFromId($id_supplier1);
151 $bookseller1fromid = field_filter($bookseller1fromid);
152 delete $bookseller1fromid->{basketcount};
153 delete $bookseller1fromid->{subscriptioncount};
154 is_deeply( $bookseller1fromid, $sample_supplier1,
155 "Get Supplier1 (GetBookSellerFromId)" );
158 $bookseller1fromid = C4::Bookseller::GetBookSellerFromId($id_supplier1);
159 is( $bookseller1fromid->{basketcount}, 2, 'Supplier1 has 2 baskets' );
161 #Test subscriptioncount
162 my $dt_today = dt_from_string;
163 my $today = output_pref( $dt_today, 'iso', '24hr', 1 );
165 my $dt_today1 = dt_from_string;
166 my $dur5 = DateTime::Duration->new( days => -5 );
167 $dt_today1->add_duration($dur5);
168 my $daysago5 = output_pref( $dt_today1, 'iso', '24hr', 1 );
170 my $budgetperiod = C4::Budgets::AddBudgetPeriod({
171 budget_period_startdate => $daysago5,
172 budget_period_enddate => $today,
173 budget_description => "budget desc"
175 my $id_budget = AddBudget({
176 budget_code => "CODE",
177 budget_amount => "123.132",
178 budget_name => "Budgetname",
179 budget_notes => "This is a note",
180 budget_description => "BudgetDescription",
182 budget_period_id => $budgetperiod
184 my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
185 $bookseller1fromid = C4::Bookseller::GetBookSellerFromId($id_supplier1);
186 is( $bookseller1fromid->{subscriptioncount},
187 0, 'Supplier1 has 0 subscription' );
188 my $id_subscription1 = C4::Serials::NewSubscription(
189 undef, "", $id_supplier1, undef,
190 $id_budget, $biblionumber, '01-01-2013', undef,
191 undef, undef, undef, undef,
192 undef, undef, undef, undef,
193 undef, undef, undef, undef,
194 undef, undef, undef, undef,
195 undef, undef, undef, undef,
196 undef, undef, undef, 1,
197 "notes", undef, undef, undef,
198 undef, undef, undef, 0,
199 "intnotes", 0, undef, undef,
200 0, undef, '31-12-2013',
202 my $id_subscription2 = C4::Serials::NewSubscription(
203 undef, "", $id_supplier1, undef,
204 $id_budget, $biblionumber, '01-01-2013', undef,
205 undef, undef, undef, undef,
206 undef, undef, undef, undef,
207 undef, undef, undef, undef,
208 undef, undef, undef, undef,
209 undef, undef, undef, undef,
210 undef, undef, undef, 1,
211 "notes", undef, undef, undef,
212 undef, undef, undef, 0,
213 "intnotes", 0, undef, undef,
214 0, undef, '31-12-2013',
216 $bookseller1fromid = C4::Bookseller::GetBookSellerFromId($id_supplier1);
217 is( $bookseller1fromid->{subscriptioncount},
218 2, 'Supplier1 has 2 subscriptions' );
221 $sample_supplier2 = {
223 name => 'Name2 modified',
224 address1 => 'address1_2 modified',
225 address2 => 'address2-2 modified',
226 address3 => 'address3_2 modified',
227 address4 => 'address4_2 modified',
228 postal => 'postal2 modified',
229 phone => 'phone2 modified',
230 accountnumber => 'accountnumber2 modified',
231 fax => 'fax2 modified',
232 url => 'url2 modified',
233 contact => 'contact2 modified',
234 contpos => 'contpos2 modified',
235 contphone => 'contphone2 modified',
236 contfax => 'contefax2 modified',
237 contaltphone => 'contaltphone2 modified',
238 contemail => 'contemail2 modified',
239 contnotes => 'contnotes2 modified',
244 gstrate => '2.0000 ',
245 discount => '2.0000',
246 notes => 'notes2 modified',
250 my $modif1 = C4::Bookseller::ModBookseller();
252 "ModBookseller returns undef if no params given - Nothing happened" );
253 $modif1 = C4::Bookseller::ModBookseller($sample_supplier2);
254 is( $modif1, 1, "ModBookseller modifies only the supplier2" );
255 is( scalar( C4::Bookseller::GetBookSeller('') ),
256 $count + 2, "Supplier2 has been modified - Nothing added" );
258 $modif1 = C4::Bookseller::ModBookseller(
265 # "ModBookseller returns OEO if the id doesnt exist - Nothing modified" );
267 #Test GetBooksellersWithLateOrders
269 my $sample_supplier3 = {
271 address1 => 'address1_3',
272 address2 => 'address1-3',
273 address3 => 'address1_3',
274 address4 => 'address1_3',
277 accountnumber => 'accountnumber3',
280 contact => 'contact3',
281 contpos => 'contpos3',
282 contphone => 'contphone3',
283 contfax => 'contefax3',
284 contaltphone => 'contaltphone3',
285 contemail => 'contemail3',
286 contnotes => 'contnotes3',
292 discount => '3.0000',
296 my $sample_supplier4 = {
298 address1 => 'address1_4',
299 address2 => 'address1-4',
300 address3 => 'address1_4',
301 address4 => 'address1_4',
304 accountnumber => 'accountnumber4',
307 contact => 'contact4',
308 contpos => 'contpos4',
309 contphone => 'contphone4',
310 contfax => 'contefax4',
311 contaltphone => 'contaltphone4',
312 contemail => 'contemail4',
313 contnotes => 'contnotes4',
319 discount => '3.0000',
322 my $id_supplier3 = C4::Bookseller::AddBookseller($sample_supplier3);
323 my $id_supplier4 = C4::Bookseller::AddBookseller($sample_supplier4);
327 C4::Acquisition::NewBasket( $id_supplier3, 'authorisedby3', 'basketname3',
330 C4::Acquisition::NewBasket( $id_supplier4, 'authorisedby4', 'basketname4',
333 #Modify the basket to add a close date
335 basketno => $sample_basket1,
337 booksellerid => $id_supplier1
341 basketno => $sample_basket2,
342 closedate => $daysago5,
343 booksellerid => $id_supplier2
346 my $dt_today2 = dt_from_string;
347 my $dur10 = DateTime::Duration->new( days => -10 );
348 $dt_today2->add_duration($dur10);
349 my $daysago10 = output_pref( $dt_today2, 'iso', '24hr', 1 );
351 basketno => $sample_basket3,
352 closedate => $daysago10,
356 basketno => $sample_basket4,
359 ModBasket($basket1info);
360 ModBasket($basket2info);
361 ModBasket($basket3info);
362 ModBasket($basket4info);
365 my $id_subscription3 = C4::Serials::NewSubscription(
366 undef, "", $id_supplier3, undef,
367 $id_budget, $biblionumber, '01-01-2013', undef,
368 undef, undef, undef, undef,
369 undef, undef, undef, undef,
370 undef, undef, undef, undef,
371 undef, undef, undef, undef,
372 undef, undef, undef, undef,
373 undef, undef, undef, 1,
374 "notes", undef, undef, undef,
375 undef, undef, undef, 0,
376 "intnotes", 0, undef, undef,
377 0, undef, '31-12-2013',
381 my ( $ordernumber1, $ordernumber2, $ordernumber3, $ordernumber4 );
382 my ( $basketno1, $basketno2, $basketno3, $basketno4 );
383 ( $basketno1, $ordernumber1 ) = C4::Acquisition::NewOrder(
385 basketno => $sample_basket1,
387 biblionumber => $biblionumber,
388 budget_id => $id_budget,
389 entrydate => '01-01-2013',
391 notes => "This is a note1",
394 subscriptionid => $id_subscription1,
395 quantityreceived => 2,
398 datereceived => '01-06-2013'
401 ( $basketno2, $ordernumber2 ) = C4::Acquisition::NewOrder(
403 basketno => $sample_basket2,
405 biblionumber => $biblionumber,
406 budget_id => $id_budget,
407 entrydate => '01-01-2013',
409 notes => "This is a note2",
412 subscriptionid => $id_subscription2,
417 ( $basketno3, $ordernumber3 ) = C4::Acquisition::NewOrder(
419 basketno => $sample_basket3,
421 biblionumber => $biblionumber,
422 budget_id => $id_budget,
423 entrydate => '02-02-2013',
425 notes => "This is a note3",
428 subscriptionid => $id_subscription3,
433 ( $basketno4, $ordernumber4 ) = C4::Acquisition::NewOrder(
435 basketno => $sample_basket4,
437 biblionumber => $biblionumber,
438 budget_id => $id_budget,
439 entrydate => '02-02-2013',
441 notes => "This is a note3",
444 subscriptionid => $id_subscription3,
447 quantityreceived => 20
453 # Supplier1: delivery -> undef Basket1 : closedate -> today
454 # Supplier2: delivery -> 2 Basket2 : closedate -> $daysago5
455 # Supplier3: delivery -> 3 Basket3 : closedate -> $daysago10
456 #Case 1 : Without parameters:
457 # quantityreceived < quantity AND rrp <> 0 AND ecost <> 0 AND quantity - COALESCE(quantityreceived,0) <> 0 AND closedate IS NOT NULL -LATE-
458 # datereceived !null AND rrp <> 0 AND ecost <> 0 AND quantity - COALESCE(quantityreceived,0) <> 0 AND closedate IS NOT NULL -LATE-
459 # datereceived !null AND rrp <> 0 AND ecost <> 0 AND quantity - COALESCE(quantityreceived,0) <> 0 AND closedate IS NOT NULL -LATE-
460 # quantityreceived = quantity -NOT LATE-
461 my %suppliers = C4::Bookseller::GetBooksellersWithLateOrders();
462 ok( exists( $suppliers{$id_supplier1} ), "Supplier1 has late orders" );
463 ok( exists( $suppliers{$id_supplier2} ), "Supplier2 has late orders" );
464 ok( exists( $suppliers{$id_supplier3} ), "Supplier3 has late orders" );
465 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" )
466 ; # Quantity = quantityreceived
468 #Case 2: With $delay = 4
469 # today + 0 > now-$delay -NOT LATE-
470 # (today-5) + 2 <= now() - $delay -NOT LATE-
471 # (today-10) + 3 <= now() - $delay -LATE-
472 # quantityreceived = quantity -NOT LATE-
473 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( 4, undef, undef );
474 isnt( exists( $suppliers{$id_supplier1} ),
475 1, "Supplier1 has late orders but today > now() - 4 days" );
476 #FIXME: If only the field delay is given, it doen't consider the deliverytime
477 #isnt( exists( $suppliers{$id_supplier2} ),
478 # 1, "Supplier2 has late orders and $daysago5 <= now() - (4 days+2)" );
479 ok( exists( $suppliers{$id_supplier3} ),
480 "Supplier3 has late orders and $daysago10 <= now() - (4 days+3)" );
481 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
483 #Case 3: With $delay = -1
484 #FIXME: GetBooksellersWithLateOrders doesn't test if the delay is a positive value
485 #is( C4::Bookseller::GetBooksellersWithLateOrders( -1, undef, undef ),
486 # undef, "-1 is a wrong value for a delay" );
488 #Case 4: With $delay = 0
489 # today == now-0 -LATE- (if no deliverytime or deliverytime == 0)
490 # today-5 <= now() - $delay+2 -LATE-
491 # today-10 <= now() - $delay+3 -LATE-
492 # quantityreceived = quantity -NOT LATE-
493 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( 0, undef, undef );
495 ok( exists( $suppliers{$id_supplier1} ),
496 "Supplier1 has late orders but $today == now() - 0 days" )
498 ok( exists( $suppliers{$id_supplier2} ),
499 "Supplier2 has late orders and $daysago5 <= now() - 2" );
500 ok( exists( $suppliers{$id_supplier3} ),
501 "Supplier3 has late orders and $daysago10 <= now() - 3" );
502 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
504 #Case 5 : With $estimateddeliverydatefrom = today-4
505 # today >= today-4 -NOT LATE-
506 # (today-5)+ 2 days >= today-4 -LATE-
507 # (today-10) + 3 days < today-4 -NOT LATE-
508 # quantityreceived = quantity -NOT LATE-
509 my $dt_today3 = dt_from_string;
510 my $dur4 = DateTime::Duration->new( days => -4 );
511 $dt_today3->add_duration($dur4);
512 my $daysago4 = output_pref( $dt_today3, 'iso', '24hr', 1 );
514 C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago4, undef );
516 #FIXME: if the deliverytime is undef, it doesn't consider the supplier
517 #ok( exists( $suppliers{$id_supplier1} ),
518 # "Supplier1 has late orders and $today >= $daysago4 -deliverytime undef" );
519 ok( exists( $suppliers{$id_supplier2} ),
520 "Supplier2 has late orders and $daysago5 + 2 days >= $daysago4 " );
521 isnt( exists( $suppliers{$id_supplier3} ),
522 1, "Supplier3 has late orders and $daysago10 + 5 days < $daysago4 " );
523 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
525 #Case 6: With $estimateddeliverydatefrom =today-10 and $estimateddeliverydateto = today - 5
526 # $daysago10<$daysago5<today -NOT LATE-
527 # $daysago10<$daysago5<$daysago5 +2 -NOT lATE-
528 # $daysago10<$daysago10 +3 <$daysago5 -LATE-
529 # quantityreceived = quantity -NOT LATE-
530 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10,
532 isnt( exists( $suppliers{$id_supplier1} ),
533 1, "Supplier1 has late orders but $daysago10 < $daysago5 < $today" );
535 exists( $suppliers{$id_supplier2} ),
537 "Supplier2 has late orders but $daysago10 < $daysago5 < $daysago5+2"
540 exists( $suppliers{$id_supplier3} ),
541 "Supplier3 has late orders and $daysago10 <= $daysago10 +3 <= $daysago5"
543 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
545 #Case 7: With $estimateddeliverydateto = today-5
546 # $today >= $daysago5 -NOT LATE-
547 # $daysago5 + 2 days > $daysago5 -NOT LATE-
548 # $daysago10 + 3 <+ $daysago5 -LATE-
549 # quantityreceived = quantity -NOT LATE-
551 C4::Bookseller::GetBooksellersWithLateOrders( undef, undef, $daysago5 );
552 #FIXME: if only the estimateddeliverydatefrom is given, it doesn't consider the parameters,
553 #but it replaces it today's date
554 #isnt( exists( $suppliers{$id_supplier1} ),
556 # "Supplier1 has late orders but $today >= $daysago5 - deliverytime undef" );
557 #isnt( exists( $suppliers{$id_supplier2} ),
558 # 1, "Supplier2 has late orders but $daysago5 + 2 days > $daysago5 " );
559 ok( exists( $suppliers{$id_supplier3} ),
560 "Supplier3 has late orders and $daysago10 + 3 <= $daysago5" );
561 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
563 #Test with $estimateddeliverydatefrom and $estimateddeliverydateto and $delay
564 #Case 8 :With $estimateddeliverydatefrom = 2013-07-05 and $estimateddeliverydateto = 2013-07-08 and $delay =5
565 # $daysago4<today<=$today and $today<now()-3 -NOT LATE-
566 # $daysago4 < $daysago5 + 2days <= today and $daysago5 <= now()-3+2 days -LATE-
567 # $daysago4 > $daysago10 + 3days < today and $daysago10 <= now()-3+3 days -NOT LATE-
568 # quantityreceived = quantity -NOT LATE-
570 C4::Bookseller::GetBooksellersWithLateOrders( 3, $daysago4, $today );
572 exists( $suppliers{$id_supplier1} ),
574 "Supplier1 has late orders but $daysago4<today<=$today and $today<now()-3"
577 exists( $suppliers{$id_supplier2} ),
578 "Supplier2 has late orders and $daysago4 < $daysago5 + 2days <= today and $daysago5 <= now()-3+2 days"
581 exists( $suppliers{$id_supplier3} ),
582 "Supplier3 has late orders but $daysago4 > $daysago10 + 3days < today and $daysago10 <= now()-3+3 days"
584 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
586 #Case 9 :With $estimateddeliverydatefrom = $daysago5 and $delay = 3
587 # $today < $daysago5 and $today > $today-5 -NOT LATE-
588 # $daysago5 + 2 days >= $daysago5 and $daysago5 < today - 3+2 -LATE-
589 # $daysago10 + 3 days < $daysago5 and $daysago10 < today -3+2-NOT LATE-
590 # quantityreceived = quantity -NOT LATE-
592 C4::Bookseller::GetBooksellersWithLateOrders( 3, $daysago5, undef );
593 isnt( exists( $suppliers{$id_supplier1} ),
594 1, "$today < $daysago10 and $today > $today-3" );
596 exists( $suppliers{$id_supplier2} ),
597 "Supplier2 has late orders and $daysago5 + 2 days >= $daysago5 and $daysago5 < today - 3+2"
600 exists( $suppliers{$id_supplier3} ),
602 "Supplier2 has late orders but $daysago10 + 3 days < $daysago5 and $daysago10 < today -3+2 "
604 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
606 #Test with $estimateddeliverydateto and $delay
607 #Case 10:With $estimateddeliverydateto = $daysago5 and $delay = 5
608 # today > $daysago5 today > now() -5 -NOT LATE-
609 # $daysago5 + 2 days > $daysago5 and $daysago5 > now() - 2+5 days -NOT LATE-
610 # $daysago10 + 3 days <= $daysago5 and $daysago10 <= now() - 3+5 days -LATE-
611 # quantityreceived = quantity -NOT LATE-
613 C4::Bookseller::GetBooksellersWithLateOrders( 5, undef, $daysago5 );
614 isnt( exists( $suppliers{$id_supplier1} ),
615 1, "Supplier2 has late orders but today > $daysago5 today > now() -5" );
616 #FIXME: GetBookSellersWithLateOrders replace estimateddeliverydateto by
617 #today's date when no estimateddeliverydatefrom is give
619 # exists( $suppliers{$id_supplier2} ),
621 #"Supplier2 has late orders but $daysago5 + 2 days > $daysago5 and $daysago5 > now() - 2+5 days"
624 exists( $suppliers{$id_supplier3} ),
625 "Supplier2 has late orders and $daysago10 + 3 days <= $daysago5 and $daysago10 <= now() - 3+5 days "
627 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
629 #Case 11: With $estimateddeliverydatefrom =today-10 and $estimateddeliverydateto = today - 10
630 # $daysago10==$daysago10==$daysago10 -NOT LATE-
631 # $daysago10==$daysago10<$daysago5+2-NOT lATE-
632 # $daysago10==$daysago10 <$daysago10+3-LATE-
633 # quantityreceived = quantity -NOT LATE-
635 #Basket1 closedate -> $daysago10
637 basketno => $sample_basket1,
638 closedate => $daysago10,
640 ModBasket($basket1info);
641 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10,
643 #FIXME :GetBookSellers doesn't take care if the closedate is ==$estimateddeliverydateto
644 # ok( exists( $suppliers{$id_supplier1} ),
645 # "Supplier1 has late orders and $daysago10==$daysago10==$daysago10 " )
647 isnt( exists( $suppliers{$id_supplier2} ),
649 "Supplier2 has late orders but $daysago10==$daysago10<$daysago5+2" );
650 isnt( exists( $suppliers{$id_supplier3} ),
652 "Supplier3 has late orders but $daysago10==$daysago10 <$daysago10+3" );
653 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
655 #Case 12: closedate == $estimateddeliverydatefrom =today-10
657 C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10, undef );
658 #FIXME :GetBookSellers doesn't take care if the closedate is ==$estimateddeliverydateto
659 #ok( exists( $suppliers{$id_supplier1} ),
660 # "Supplier1 has late orders and $daysago10==$daysago10 " );
662 #Case 13: closedate == $estimateddeliverydateto =today-10
664 C4::Bookseller::GetBooksellersWithLateOrders( undef, undef, $daysago10 );
665 ok( exists( $suppliers{$id_supplier1} ),
666 "Supplier1 has late orders and $daysago10==$daysago10 " )
672 #field_filter filters the useless fields or foreign keys
673 #NOTE: all the fields of aqbookseller arent considered
674 #returns a cleaned structure
679 'bookselleremail', 'booksellerfax',
680 'booksellerurl', 'othersupplier',
681 'currency', 'invoiceprice',
686 if ( grep { /^$field$/ } keys %$struct ) {
687 delete $struct->{$field};