5 use Test::More tests => 53;
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 #FIXME: DelBookSeller always returns undef (if it works or not)
108 #is( $del, 1, "DelBookseller returns 1 - 1 supplier has been deleted " );
109 is( C4::Bookseller::GetBookSellerFromId($id_supplier1),
110 undef, "Supplier1 has been deleted - id_supplier1 doesnt exist anymore" );
113 my @bookseller2 = C4::Bookseller::GetBookSeller( $sample_supplier2->{name} );
114 is( scalar(@bookseller2), 1, "Get only Supplier2" );
115 $bookseller2[0] = field_filter( $bookseller2[0] );
116 delete $bookseller2[0]->{basketcount};
118 $sample_supplier2->{id} = $id_supplier2;
119 is_deeply( $bookseller2[0], $sample_supplier2,
120 "GetBookSeller returns the right informations about $sample_supplier2" );
122 $id_supplier1 = C4::Bookseller::AddBookseller($sample_supplier1);
123 my @booksellers = C4::Bookseller::GetBookSeller('')
124 ; #NOTE :without params, it returns all the booksellers
125 for my $i ( 0 .. scalar(@booksellers) - 1 ) {
126 $booksellers[$i] = field_filter( $booksellers[$i] );
127 delete $booksellers[$i]->{basketcount};
130 $sample_supplier1->{id} = $id_supplier1;
131 is( scalar(@booksellers), $count + 2, "Get Supplier1 and Supplier2" );
132 my @tab = ( $sample_supplier1, $sample_supplier2 );
133 is_deeply( \@booksellers, \@tab,
134 "Returns right fields of Supplier1 and Supplier2" );
137 my @bookseller1 = C4::Bookseller::GetBookSeller( $sample_supplier1->{name} );
138 #FIXME : if there is 0 basket, GetBookSeller returns 1 as basketcount
139 #is( $bookseller1[0]->{basketcount}, 0, 'Supplier1 has 0 basket' );
141 C4::Acquisition::NewBasket( $id_supplier1, 'authorisedby1', 'basketname1' );
143 C4::Acquisition::NewBasket( $id_supplier1, 'authorisedby2', 'basketname2' );
144 @bookseller1 = C4::Bookseller::GetBookSeller( $sample_supplier1->{name} );
145 is( $bookseller1[0]->{basketcount}, 2, 'Supplier1 has 2 baskets' );
147 #Test GetBookSellerFromId
148 my $bookseller1fromid = C4::Bookseller::GetBookSellerFromId();
149 is( $bookseller1fromid, undef,
150 "GetBookSellerFromId returns undef if no id given" );
151 $bookseller1fromid = C4::Bookseller::GetBookSellerFromId($id_supplier1);
152 $bookseller1fromid = field_filter($bookseller1fromid);
153 delete $bookseller1fromid->{basketcount};
154 delete $bookseller1fromid->{subscriptioncount};
155 is_deeply( $bookseller1fromid, $sample_supplier1,
156 "Get Supplier1 (GetBookSellerFromId)" );
159 $bookseller1fromid = C4::Bookseller::GetBookSellerFromId($id_supplier1);
160 is( $bookseller1fromid->{basketcount}, 2, 'Supplier1 has 2 baskets' );
162 #Test subscriptioncount
163 my $dt_today = dt_from_string;
164 my $today = output_pref( $dt_today, 'iso', '24hr', 1 );
166 my $dt_today1 = dt_from_string;
167 my $dur5 = DateTime::Duration->new( days => -5 );
168 $dt_today1->add_duration($dur5);
169 my $daysago5 = output_pref( $dt_today1, 'iso', '24hr', 1 );
171 my $budgetperiod = C4::Budgets::AddBudgetPeriod({
172 budget_period_startdate => $daysago5,
173 budget_period_enddate => $today,
174 budget_description => "budget desc"
176 my $id_budget = AddBudget({
177 budget_code => "CODE",
178 budget_amount => "123.132",
179 budget_name => "Budgetname",
180 budget_notes => "This is a note",
181 budget_description => "BudgetDescription",
183 budget_period_id => $budgetperiod
185 my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
186 $bookseller1fromid = C4::Bookseller::GetBookSellerFromId($id_supplier1);
187 is( $bookseller1fromid->{subscriptioncount},
188 0, 'Supplier1 has 0 subscription' );
189 my $id_subscription1 = C4::Serials::NewSubscription(
190 undef, "", $id_supplier1, undef,
191 $id_budget, $biblionumber, '01-01-2013', 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, undef,
197 undef, undef, undef, 1,
198 "notes", undef, undef, undef,
199 undef, undef, undef, 0,
200 "intnotes", 0, undef, undef,
201 0, undef, '31-12-2013',
203 my $id_subscription2 = C4::Serials::NewSubscription(
204 undef, "", $id_supplier1, undef,
205 $id_budget, $biblionumber, '01-01-2013', 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, undef,
211 undef, undef, undef, 1,
212 "notes", undef, undef, undef,
213 undef, undef, undef, 0,
214 "intnotes", 0, undef, undef,
215 0, undef, '31-12-2013',
217 $bookseller1fromid = C4::Bookseller::GetBookSellerFromId($id_supplier1);
218 is( $bookseller1fromid->{subscriptioncount},
219 2, 'Supplier1 has 2 subscriptions' );
222 $sample_supplier2 = {
224 name => 'Name2 modified',
225 address1 => 'address1_2 modified',
226 address2 => 'address2-2 modified',
227 address3 => 'address3_2 modified',
228 address4 => 'address4_2 modified',
229 postal => 'postal2 modified',
230 phone => 'phone2 modified',
231 accountnumber => 'accountnumber2 modified',
232 fax => 'fax2 modified',
233 url => 'url2 modified',
234 contact => 'contact2 modified',
235 contpos => 'contpos2 modified',
236 contphone => 'contphone2 modified',
237 contfax => 'contefax2 modified',
238 contaltphone => 'contaltphone2 modified',
239 contemail => 'contemail2 modified',
240 contnotes => 'contnotes2 modified',
245 gstrate => '2.0000 ',
246 discount => '2.0000',
247 notes => 'notes2 modified',
251 #FIXME : ModBookseller always returns undef, even if the id isn't given
253 my $modif1 = C4::Bookseller::ModBookseller();
255 "ModBookseller returns undef if no params given - Nothing happened" );
256 $modif1 = C4::Bookseller::ModBookseller($sample_supplier2);
257 #is( $modif1, 1, "ModBookseller modifies only the supplier2" );
258 is( scalar( C4::Bookseller::GetBookSeller('') ),
259 $count + 2, "Supplier2 has been modified - Nothing added" );
261 $modif1 = C4::Bookseller::ModBookseller(
268 # "ModBookseller returns OEO if the id doesnt exist - Nothing modified" );
270 #Test GetBooksellersWithLateOrders
272 my $sample_supplier3 = {
274 address1 => 'address1_3',
275 address2 => 'address1-3',
276 address3 => 'address1_3',
277 address4 => 'address1_3',
280 accountnumber => 'accountnumber3',
283 contact => 'contact3',
284 contpos => 'contpos3',
285 contphone => 'contphone3',
286 contfax => 'contefax3',
287 contaltphone => 'contaltphone3',
288 contemail => 'contemail3',
289 contnotes => 'contnotes3',
295 discount => '3.0000',
299 my $sample_supplier4 = {
301 address1 => 'address1_4',
302 address2 => 'address1-4',
303 address3 => 'address1_4',
304 address4 => 'address1_4',
307 accountnumber => 'accountnumber4',
310 contact => 'contact4',
311 contpos => 'contpos4',
312 contphone => 'contphone4',
313 contfax => 'contefax4',
314 contaltphone => 'contaltphone4',
315 contemail => 'contemail4',
316 contnotes => 'contnotes4',
322 discount => '3.0000',
325 my $id_supplier3 = C4::Bookseller::AddBookseller($sample_supplier3);
326 my $id_supplier4 = C4::Bookseller::AddBookseller($sample_supplier4);
330 C4::Acquisition::NewBasket( $id_supplier3, 'authorisedby3', 'basketname3',
333 C4::Acquisition::NewBasket( $id_supplier4, 'authorisedby4', 'basketname4',
336 #Modify the basket to add a close date
338 basketno => $sample_basket1,
340 booksellerid => $id_supplier1
344 basketno => $sample_basket2,
345 closedate => $daysago5,
346 booksellerid => $id_supplier2
349 my $dt_today2 = dt_from_string;
350 my $dur10 = DateTime::Duration->new( days => -10 );
351 $dt_today2->add_duration($dur10);
352 my $daysago10 = output_pref( $dt_today2, 'iso', '24hr', 1 );
354 basketno => $sample_basket3,
355 closedate => $daysago10,
359 basketno => $sample_basket4,
362 ModBasket($basket1info);
363 ModBasket($basket2info);
364 ModBasket($basket3info);
365 ModBasket($basket4info);
368 my $id_subscription3 = C4::Serials::NewSubscription(
369 undef, "", $id_supplier3, undef,
370 $id_budget, $biblionumber, '01-01-2013', undef,
371 undef, undef, undef, undef,
372 undef, undef, undef, undef,
373 undef, undef, undef, undef,
374 undef, undef, undef, undef,
375 undef, undef, undef, undef,
376 undef, undef, undef, 1,
377 "notes", undef, undef, undef,
378 undef, undef, undef, 0,
379 "intnotes", 0, undef, undef,
380 0, undef, '31-12-2013',
384 my ( $ordernumber1, $ordernumber2, $ordernumber3, $ordernumber4 );
385 my ( $basketno1, $basketno2, $basketno3, $basketno4 );
386 ( $basketno1, $ordernumber1 ) = C4::Acquisition::NewOrder(
388 basketno => $sample_basket1,
390 biblionumber => $biblionumber,
391 budget_id => $id_budget,
392 entrydate => '01-01-2013',
394 notes => "This is a note1",
397 subscriptionid => $id_subscription1,
398 quantityreceived => 2,
401 datereceived => '01-06-2013'
404 ( $basketno2, $ordernumber2 ) = C4::Acquisition::NewOrder(
406 basketno => $sample_basket2,
408 biblionumber => $biblionumber,
409 budget_id => $id_budget,
410 entrydate => '01-01-2013',
412 notes => "This is a note2",
415 subscriptionid => $id_subscription2,
420 ( $basketno3, $ordernumber3 ) = C4::Acquisition::NewOrder(
422 basketno => $sample_basket3,
424 biblionumber => $biblionumber,
425 budget_id => $id_budget,
426 entrydate => '02-02-2013',
428 notes => "This is a note3",
431 subscriptionid => $id_subscription3,
436 ( $basketno4, $ordernumber4 ) = C4::Acquisition::NewOrder(
438 basketno => $sample_basket4,
440 biblionumber => $biblionumber,
441 budget_id => $id_budget,
442 entrydate => '02-02-2013',
444 notes => "This is a note3",
447 subscriptionid => $id_subscription3,
450 quantityreceived => 20
456 # Supplier1: delivery -> undef Basket1 : closedate -> today
457 # Supplier2: delivery -> 2 Basket2 : closedate -> $daysago5
458 # Supplier3: delivery -> 3 Basket3 : closedate -> $daysago10
459 #Case 1 : Without parameters:
460 # quantityreceived < quantity AND rrp <> 0 AND ecost <> 0 AND quantity - COALESCE(quantityreceived,0) <> 0 AND closedate IS NOT NULL -LATE-
461 # datereceived !null AND rrp <> 0 AND ecost <> 0 AND quantity - COALESCE(quantityreceived,0) <> 0 AND closedate IS NOT NULL -LATE-
462 # datereceived !null AND rrp <> 0 AND ecost <> 0 AND quantity - COALESCE(quantityreceived,0) <> 0 AND closedate IS NOT NULL -LATE-
463 # quantityreceived = quantity -NOT LATE-
464 my %suppliers = C4::Bookseller::GetBooksellersWithLateOrders();
465 ok( exists( $suppliers{$id_supplier1} ), "Supplier1 has late orders" );
466 ok( exists( $suppliers{$id_supplier2} ), "Supplier2 has late orders" );
467 ok( exists( $suppliers{$id_supplier3} ), "Supplier3 has late orders" );
468 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" )
469 ; # Quantity = quantityreceived
471 #Case 2: With $delay = 4
472 # today + 0 > now-$delay -NOT LATE-
473 # (today-5) + 2 <= now() - $delay -NOT LATE-
474 # (today-10) + 3 <= now() - $delay -LATE-
475 # quantityreceived = quantity -NOT LATE-
476 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( 4, undef, undef );
477 isnt( exists( $suppliers{$id_supplier1} ),
478 1, "Supplier1 has late orders but today > now() - 4 days" );
479 #FIXME: If only the field delay is given, it doen't consider the deliverytime
480 #isnt( exists( $suppliers{$id_supplier2} ),
481 # 1, "Supplier2 has late orders and $daysago5 <= now() - (4 days+2)" );
482 ok( exists( $suppliers{$id_supplier3} ),
483 "Supplier3 has late orders and $daysago10 <= now() - (4 days+3)" );
484 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
486 #Case 3: With $delay = -1
487 #FIXME: GetBooksellersWithLateOrders doesn't test if the delay is a positive value
488 #is( C4::Bookseller::GetBooksellersWithLateOrders( -1, undef, undef ),
489 # undef, "-1 is a wrong value for a delay" );
491 #Case 4: With $delay = 0
492 # today == now-0 -LATE- (if no deliverytime or deliverytime == 0)
493 # today-5 <= now() - $delay+2 -LATE-
494 # today-10 <= now() - $delay+3 -LATE-
495 # quantityreceived = quantity -NOT LATE-
496 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( 0, undef, undef );
498 ok( exists( $suppliers{$id_supplier1} ),
499 "Supplier1 has late orders but $today == now() - 0 days" )
501 ok( exists( $suppliers{$id_supplier2} ),
502 "Supplier2 has late orders and $daysago5 <= now() - 2" );
503 ok( exists( $suppliers{$id_supplier3} ),
504 "Supplier3 has late orders and $daysago10 <= now() - 3" );
505 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
507 #Case 5 : With $estimateddeliverydatefrom = today-4
508 # today >= today-4 -NOT LATE-
509 # (today-5)+ 2 days >= today-4 -LATE-
510 # (today-10) + 3 days < today-4 -NOT LATE-
511 # quantityreceived = quantity -NOT LATE-
512 my $dt_today3 = dt_from_string;
513 my $dur4 = DateTime::Duration->new( days => -4 );
514 $dt_today3->add_duration($dur4);
515 my $daysago4 = output_pref( $dt_today3, 'iso', '24hr', 1 );
517 C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago4, undef );
519 #FIXME: if the deliverytime is undef, it doesn't consider the supplier
520 #ok( exists( $suppliers{$id_supplier1} ),
521 # "Supplier1 has late orders and $today >= $daysago4 -deliverytime undef" );
522 ok( exists( $suppliers{$id_supplier2} ),
523 "Supplier2 has late orders and $daysago5 + 2 days >= $daysago4 " );
524 isnt( exists( $suppliers{$id_supplier3} ),
525 1, "Supplier3 has late orders and $daysago10 + 5 days < $daysago4 " );
526 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
528 #Case 6: With $estimateddeliverydatefrom =today-10 and $estimateddeliverydateto = today - 5
529 # $daysago10<$daysago5<today -NOT LATE-
530 # $daysago10<$daysago5<$daysago5 +2 -NOT lATE-
531 # $daysago10<$daysago10 +3 <$daysago5 -LATE-
532 # quantityreceived = quantity -NOT LATE-
533 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10,
535 isnt( exists( $suppliers{$id_supplier1} ),
536 1, "Supplier1 has late orders but $daysago10 < $daysago5 < $today" );
538 exists( $suppliers{$id_supplier2} ),
540 "Supplier2 has late orders but $daysago10 < $daysago5 < $daysago5+2"
543 exists( $suppliers{$id_supplier3} ),
544 "Supplier3 has late orders and $daysago10 <= $daysago10 +3 <= $daysago5"
546 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
548 #Case 7: With $estimateddeliverydateto = today-5
549 # $today >= $daysago5 -NOT LATE-
550 # $daysago5 + 2 days > $daysago5 -NOT LATE-
551 # $daysago10 + 3 <+ $daysago5 -LATE-
552 # quantityreceived = quantity -NOT LATE-
554 C4::Bookseller::GetBooksellersWithLateOrders( undef, undef, $daysago5 );
555 #FIXME: if only the estimateddeliverydatefrom is given, it doesn't consider the parameters,
556 #but it replaces it today's date
557 #isnt( exists( $suppliers{$id_supplier1} ),
559 # "Supplier1 has late orders but $today >= $daysago5 - deliverytime undef" );
560 #isnt( exists( $suppliers{$id_supplier2} ),
561 # 1, "Supplier2 has late orders but $daysago5 + 2 days > $daysago5 " );
562 ok( exists( $suppliers{$id_supplier3} ),
563 "Supplier3 has late orders and $daysago10 + 3 <= $daysago5" );
564 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
566 #Test with $estimateddeliverydatefrom and $estimateddeliverydateto and $delay
567 #Case 8 :With $estimateddeliverydatefrom = 2013-07-05 and $estimateddeliverydateto = 2013-07-08 and $delay =5
568 # $daysago4<today<=$today and $today<now()-3 -NOT LATE-
569 # $daysago4 < $daysago5 + 2days <= today and $daysago5 <= now()-3+2 days -LATE-
570 # $daysago4 > $daysago10 + 3days < today and $daysago10 <= now()-3+3 days -NOT LATE-
571 # quantityreceived = quantity -NOT LATE-
573 C4::Bookseller::GetBooksellersWithLateOrders( 3, $daysago4, $today );
575 exists( $suppliers{$id_supplier1} ),
577 "Supplier1 has late orders but $daysago4<today<=$today and $today<now()-3"
580 exists( $suppliers{$id_supplier2} ),
581 "Supplier2 has late orders and $daysago4 < $daysago5 + 2days <= today and $daysago5 <= now()-3+2 days"
584 exists( $suppliers{$id_supplier3} ),
585 "Supplier3 has late orders but $daysago4 > $daysago10 + 3days < today and $daysago10 <= now()-3+3 days"
587 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
589 #Case 9 :With $estimateddeliverydatefrom = $daysago5 and $delay = 3
590 # $today < $daysago5 and $today > $today-5 -NOT LATE-
591 # $daysago5 + 2 days >= $daysago5 and $daysago5 < today - 3+2 -LATE-
592 # $daysago10 + 3 days < $daysago5 and $daysago10 < today -3+2-NOT LATE-
593 # quantityreceived = quantity -NOT LATE-
595 C4::Bookseller::GetBooksellersWithLateOrders( 3, $daysago5, undef );
596 isnt( exists( $suppliers{$id_supplier1} ),
597 1, "$today < $daysago10 and $today > $today-3" );
599 exists( $suppliers{$id_supplier2} ),
600 "Supplier2 has late orders and $daysago5 + 2 days >= $daysago5 and $daysago5 < today - 3+2"
603 exists( $suppliers{$id_supplier3} ),
605 "Supplier2 has late orders but $daysago10 + 3 days < $daysago5 and $daysago10 < today -3+2 "
607 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
609 #Test with $estimateddeliverydateto and $delay
610 #Case 10:With $estimateddeliverydateto = $daysago5 and $delay = 5
611 # today > $daysago5 today > now() -5 -NOT LATE-
612 # $daysago5 + 2 days > $daysago5 and $daysago5 > now() - 2+5 days -NOT LATE-
613 # $daysago10 + 3 days <= $daysago5 and $daysago10 <= now() - 3+5 days -LATE-
614 # quantityreceived = quantity -NOT LATE-
616 C4::Bookseller::GetBooksellersWithLateOrders( 5, undef, $daysago5 );
617 isnt( exists( $suppliers{$id_supplier1} ),
618 1, "Supplier2 has late orders but today > $daysago5 today > now() -5" );
619 #FIXME: GetBookSellersWithLateOrders replace estimateddeliverydateto by
620 #today's date when no estimateddeliverydatefrom is give
622 # exists( $suppliers{$id_supplier2} ),
624 #"Supplier2 has late orders but $daysago5 + 2 days > $daysago5 and $daysago5 > now() - 2+5 days"
627 exists( $suppliers{$id_supplier3} ),
628 "Supplier2 has late orders and $daysago10 + 3 days <= $daysago5 and $daysago10 <= now() - 3+5 days "
630 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
632 #Case 11: With $estimateddeliverydatefrom =today-10 and $estimateddeliverydateto = today - 10
633 # $daysago10==$daysago10==$daysago10 -NOT LATE-
634 # $daysago10==$daysago10<$daysago5+2-NOT lATE-
635 # $daysago10==$daysago10 <$daysago10+3-LATE-
636 # quantityreceived = quantity -NOT LATE-
638 #Basket1 closedate -> $daysago10
640 basketno => $sample_basket1,
641 closedate => $daysago10,
643 ModBasket($basket1info);
644 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10,
646 #FIXME :GetBookSellers doesn't take care if the closedate is ==$estimateddeliverydateto
647 # ok( exists( $suppliers{$id_supplier1} ),
648 # "Supplier1 has late orders and $daysago10==$daysago10==$daysago10 " )
650 isnt( exists( $suppliers{$id_supplier2} ),
652 "Supplier2 has late orders but $daysago10==$daysago10<$daysago5+2" );
653 isnt( exists( $suppliers{$id_supplier3} ),
655 "Supplier3 has late orders but $daysago10==$daysago10 <$daysago10+3" );
656 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
658 #Case 12: closedate == $estimateddeliverydatefrom =today-10
660 C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10, undef );
661 #FIXME :GetBookSellers doesn't take care if the closedate is ==$estimateddeliverydateto
662 #ok( exists( $suppliers{$id_supplier1} ),
663 # "Supplier1 has late orders and $daysago10==$daysago10 " );
665 #Case 13: closedate == $estimateddeliverydateto =today-10
667 C4::Bookseller::GetBooksellersWithLateOrders( undef, undef, $daysago10 );
668 ok( exists( $suppliers{$id_supplier1} ),
669 "Supplier1 has late orders and $daysago10==$daysago10 " )
675 #field_filter filters the useless fields or foreign keys
676 #NOTE: all the fields of aqbookseller arent considered
677 #returns a cleaned structure
682 'bookselleremail', 'booksellerfax',
683 'booksellerurl', 'othersupplier',
684 'currency', 'invoiceprice',
689 if ( grep { /^$field$/ } keys %$struct ) {
690 delete $struct->{$field};