5 use Test::More tests => 69;
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 => $dt_today, dateformat => 'iso', timeformat => '24hr', dateonly => 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 => $dt_today1, dateformat => 'iso', timeformat => '24hr', dateonly => 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 $bib = MARC::Record->new();
186 MARC::Field->new('245', ' ', ' ', a => 'Journal of ethnology'),
187 MARC::Field->new('500', ' ', ' ', a => 'bib notes'),
189 my ($biblionumber, $biblioitemnumber) = AddBiblio($bib, '');
190 $bookseller1fromid = C4::Bookseller::GetBookSellerFromId($id_supplier1);
191 is( $bookseller1fromid->{subscriptioncount},
192 0, 'Supplier1 has 0 subscription' );
194 my $id_subscription1 = NewSubscription(
195 undef, "", $id_supplier1, undef, $id_budget, $biblionumber,
196 '01-01-2013',undef, undef, undef, undef,
197 undef, undef, undef, undef, undef, undef,
198 1, "subscription notes",undef, '01-01-2013', undef, undef,
199 undef, 'CALL ABC', 0, "intnotes", 0,
200 undef, undef, 0, undef, '2013-11-30', 0
203 my @subscriptions = SearchSubscriptions({biblionumber => $biblionumber});
204 is($subscriptions[0]->{publicnotes}, 'subscription notes', 'subscription search results include public notes (bug 10689)');
206 my $id_subscription2 = NewSubscription(
207 undef, "", $id_supplier1, undef, $id_budget, $biblionumber,
208 '01-01-2013',undef, undef, undef, undef,
209 undef, undef, undef, undef, undef, undef,
210 1, "subscription notes",undef, '01-01-2013', undef, undef,
211 undef, 'CALL DEF', 0, "intnotes", 0,
212 undef, undef, 0, undef, '2013-07-31', 0
215 $bookseller1fromid = C4::Bookseller::GetBookSellerFromId($id_supplier1);
216 is( $bookseller1fromid->{subscriptioncount},
217 2, 'Supplier1 has 2 subscriptions' );
220 $sample_supplier2 = {
222 name => 'Name2 modified',
223 address1 => 'address1_2 modified',
224 address2 => 'address2-2 modified',
225 address3 => 'address3_2 modified',
226 address4 => 'address4_2 modified',
227 postal => 'postal2 modified',
228 phone => 'phone2 modified',
229 accountnumber => 'accountnumber2 modified',
230 fax => 'fax2 modified',
231 url => 'url2 modified',
232 contact => 'contact2 modified',
233 contpos => 'contpos2 modified',
234 contphone => 'contphone2 modified',
235 contfax => 'contefax2 modified',
236 contaltphone => 'contaltphone2 modified',
237 contemail => 'contemail2 modified',
238 contnotes => 'contnotes2 modified',
243 gstrate => '2.0000 ',
244 discount => '2.0000',
245 notes => 'notes2 modified',
249 my $modif1 = C4::Bookseller::ModBookseller();
251 "ModBookseller returns undef if no params given - Nothing happened" );
252 $modif1 = C4::Bookseller::ModBookseller($sample_supplier2);
253 is( $modif1, 1, "ModBookseller modifies only the supplier2" );
254 is( scalar( C4::Bookseller::GetBookSeller('') ),
255 $count + 2, "Supplier2 has been modified - Nothing added" );
257 $modif1 = C4::Bookseller::ModBookseller(
264 # "ModBookseller returns OEO if the id doesnt exist - Nothing modified" );
266 #Test GetBooksellersWithLateOrders
268 my $sample_supplier3 = {
270 address1 => 'address1_3',
271 address2 => 'address1-3',
272 address3 => 'address1_3',
273 address4 => 'address1_3',
276 accountnumber => 'accountnumber3',
279 contact => 'contact3',
280 contpos => 'contpos3',
281 contphone => 'contphone3',
282 contfax => 'contefax3',
283 contaltphone => 'contaltphone3',
284 contemail => 'contemail3',
285 contnotes => 'contnotes3',
291 discount => '3.0000',
295 my $sample_supplier4 = {
297 address1 => 'address1_4',
298 address2 => 'address1-4',
299 address3 => 'address1_4',
300 address4 => 'address1_4',
303 accountnumber => 'accountnumber4',
306 contact => 'contact4',
307 contpos => 'contpos4',
308 contphone => 'contphone4',
309 contfax => 'contefax4',
310 contaltphone => 'contaltphone4',
311 contemail => 'contemail4',
312 contnotes => 'contnotes4',
318 discount => '3.0000',
321 my $id_supplier3 = C4::Bookseller::AddBookseller($sample_supplier3);
322 my $id_supplier4 = C4::Bookseller::AddBookseller($sample_supplier4);
326 C4::Acquisition::NewBasket( $id_supplier3, 'authorisedby3', 'basketname3',
329 C4::Acquisition::NewBasket( $id_supplier4, 'authorisedby4', 'basketname4',
332 #Modify the basket to add a close date
334 basketno => $sample_basket1,
336 booksellerid => $id_supplier1
340 basketno => $sample_basket2,
341 closedate => $daysago5,
342 booksellerid => $id_supplier2
345 my $dt_today2 = dt_from_string;
346 my $dur10 = DateTime::Duration->new( days => -10 );
347 $dt_today2->add_duration($dur10);
348 my $daysago10 = output_pref({ dt => $dt_today2, dateformat => 'iso', timeformat => '24hr', dateonly => 1 });
350 basketno => $sample_basket3,
351 closedate => $daysago10,
355 basketno => $sample_basket4,
358 ModBasket($basket1info);
359 ModBasket($basket2info);
360 ModBasket($basket3info);
361 ModBasket($basket4info);
364 my $id_subscription3 = NewSubscription(
365 undef, "", $id_supplier1, undef, $id_budget, $biblionumber,
366 '01-01-2013',undef, undef, undef, undef,
367 undef, undef, undef, undef, undef, undef,
368 1, "subscription notes",undef, '01-01-2013', undef, undef,
369 undef, undef, 0, "intnotes", 0,
370 undef, undef, 0, 'LOCA', '2013-12-31', 0
373 @subscriptions = SearchSubscriptions({expiration_date => '2013-12-31'});
374 is(scalar(@subscriptions), 3, 'search for subscriptions by expiration date');
375 @subscriptions = SearchSubscriptions({expiration_date => '2013-08-15'});
376 is(scalar(@subscriptions), 1, 'search for subscriptions by expiration date');
377 @subscriptions = SearchSubscriptions({callnumber => 'CALL'});
378 is(scalar(@subscriptions), 2, 'search for subscriptions by call number');
379 @subscriptions = SearchSubscriptions({callnumber => 'DEF'});
380 is(scalar(@subscriptions), 1, 'search for subscriptions by call number');
381 @subscriptions = SearchSubscriptions({location => 'LOCA'});
382 is(scalar(@subscriptions), 1, 'search for subscriptions by location');
385 my ( $ordernumber1, $ordernumber2, $ordernumber3, $ordernumber4 );
386 my ( $basketno1, $basketno2, $basketno3, $basketno4 );
387 ( $basketno1, $ordernumber1 ) = C4::Acquisition::NewOrder(
389 basketno => $sample_basket1,
391 biblionumber => $biblionumber,
392 budget_id => $id_budget,
393 entrydate => '01-01-2013',
395 notes => "This is a note1",
398 subscriptionid => $id_subscription1,
399 quantityreceived => 2,
402 datereceived => '01-06-2013'
405 ( $basketno2, $ordernumber2 ) = C4::Acquisition::NewOrder(
407 basketno => $sample_basket2,
409 biblionumber => $biblionumber,
410 budget_id => $id_budget,
411 entrydate => '01-01-2013',
413 notes => "This is a note2",
416 subscriptionid => $id_subscription2,
421 ( $basketno3, $ordernumber3 ) = C4::Acquisition::NewOrder(
423 basketno => $sample_basket3,
425 biblionumber => $biblionumber,
426 budget_id => $id_budget,
427 entrydate => '02-02-2013',
429 notes => "This is a note3",
432 subscriptionid => $id_subscription3,
437 ( $basketno4, $ordernumber4 ) = C4::Acquisition::NewOrder(
439 basketno => $sample_basket4,
441 biblionumber => $biblionumber,
442 budget_id => $id_budget,
443 entrydate => '02-02-2013',
445 notes => "This is a note3",
448 subscriptionid => $id_subscription3,
451 quantityreceived => 20
457 # Supplier1: delivery -> undef Basket1 : closedate -> today
458 # Supplier2: delivery -> 2 Basket2 : closedate -> $daysago5
459 # Supplier3: delivery -> 3 Basket3 : closedate -> $daysago10
460 #Case 1 : Without parameters:
461 # quantityreceived < quantity 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 # datereceived !null AND rrp <> 0 AND ecost <> 0 AND quantity - COALESCE(quantityreceived,0) <> 0 AND closedate IS NOT NULL -LATE-
464 # quantityreceived = quantity -NOT LATE-
465 my %suppliers = C4::Bookseller::GetBooksellersWithLateOrders();
466 ok( exists( $suppliers{$id_supplier1} ), "Supplier1 has late orders" );
467 ok( exists( $suppliers{$id_supplier2} ), "Supplier2 has late orders" );
468 ok( exists( $suppliers{$id_supplier3} ), "Supplier3 has late orders" );
469 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" )
470 ; # Quantity = quantityreceived
472 #Case 2: With $delay = 4
473 # today + 0 > now-$delay -NOT LATE-
474 # (today-5) + 2 <= now() - $delay -NOT LATE-
475 # (today-10) + 3 <= now() - $delay -LATE-
476 # quantityreceived = quantity -NOT LATE-
477 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( 4, undef, undef );
478 isnt( exists( $suppliers{$id_supplier1} ),
479 1, "Supplier1 has late orders but today > now() - 4 days" );
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 is( C4::Bookseller::GetBooksellersWithLateOrders( -1, undef, undef ),
488 undef, "-1 is a wrong value for a delay" );
490 #Case 4: With $delay = 0
491 # today == now-0 -LATE- (if no deliverytime or deliverytime == 0)
492 # today-5 <= now() - $delay+2 -LATE-
493 # today-10 <= now() - $delay+3 -LATE-
494 # quantityreceived = quantity -NOT LATE-
495 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( 0, undef, undef );
497 ok( exists( $suppliers{$id_supplier1} ),
498 "Supplier1 has late orders but $today == now() - 0 days" )
500 ok( exists( $suppliers{$id_supplier2} ),
501 "Supplier2 has late orders and $daysago5 <= now() - 2" );
502 ok( exists( $suppliers{$id_supplier3} ),
503 "Supplier3 has late orders and $daysago10 <= now() - 3" );
504 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
506 #Case 5 : With $estimateddeliverydatefrom = today-4
507 # today >= today-4 -NOT LATE-
508 # (today-5)+ 2 days >= today-4 -LATE-
509 # (today-10) + 3 days < today-4 -NOT LATE-
510 # quantityreceived = quantity -NOT LATE-
511 my $dt_today3 = dt_from_string;
512 my $dur4 = DateTime::Duration->new( days => -4 );
513 $dt_today3->add_duration($dur4);
514 my $daysago4 = output_pref({ dt => $dt_today3, dateformat => 'iso', timeformat => '24hr', dateonly => 1 });
516 C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago4, undef );
518 ok( exists( $suppliers{$id_supplier1} ),
519 "Supplier1 has late orders and $today >= $daysago4 -deliverytime undef" );
520 ok( exists( $suppliers{$id_supplier2} ),
521 "Supplier2 has late orders and $daysago5 + 2 days >= $daysago4 " );
522 isnt( exists( $suppliers{$id_supplier3} ),
523 1, "Supplier3 has late orders and $daysago10 + 5 days < $daysago4 " );
524 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
526 #Case 6: With $estimateddeliverydatefrom =today-10 and $estimateddeliverydateto = today - 5
527 # $daysago10<$daysago5<today -NOT LATE-
528 # $daysago10<$daysago5<$daysago5 +2 -NOT lATE-
529 # $daysago10<$daysago10 +3 <$daysago5 -LATE-
530 # quantityreceived = quantity -NOT LATE-
531 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10,
533 isnt( exists( $suppliers{$id_supplier1} ),
534 1, "Supplier1 has late orders but $daysago10 < $daysago5 < $today" );
536 exists( $suppliers{$id_supplier2} ),
538 "Supplier2 has late orders but $daysago10 < $daysago5 < $daysago5+2"
541 exists( $suppliers{$id_supplier3} ),
542 "Supplier3 has late orders and $daysago10 <= $daysago10 +3 <= $daysago5"
544 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
546 #Case 7: With $estimateddeliverydateto = today-5
547 # $today >= $daysago5 -NOT LATE-
548 # $daysago5 + 2 days > $daysago5 -NOT LATE-
549 # $daysago10 + 3 <+ $daysago5 -LATE-
550 # quantityreceived = quantity -NOT LATE-
552 C4::Bookseller::GetBooksellersWithLateOrders( undef, undef, $daysago5 );
553 isnt( exists( $suppliers{$id_supplier1} ),
555 "Supplier1 has late orders but $today >= $daysago5 - deliverytime undef" );
556 isnt( exists( $suppliers{$id_supplier2} ),
557 1, "Supplier2 has late orders but $daysago5 + 2 days > $daysago5 " );
558 ok( exists( $suppliers{$id_supplier3} ),
559 "Supplier3 has late orders and $daysago10 + 3 <= $daysago5" );
560 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
562 #Test with $estimateddeliverydatefrom and $estimateddeliverydateto and $delay
563 #Case 8 :With $estimateddeliverydatefrom = 2013-07-05 and $estimateddeliverydateto = 2013-07-08 and $delay =5
564 # $daysago4<today<=$today and $today<now()-3 -NOT LATE-
565 # $daysago4 < $daysago5 + 2days <= today and $daysago5 <= now()-3+2 days -LATE-
566 # $daysago4 > $daysago10 + 3days < today and $daysago10 <= now()-3+3 days -NOT LATE-
567 # quantityreceived = quantity -NOT LATE-
569 C4::Bookseller::GetBooksellersWithLateOrders( 3, $daysago4, $today );
571 exists( $suppliers{$id_supplier1} ),
573 "Supplier1 has late orders but $daysago4<today<=$today and $today<now()-3"
576 exists( $suppliers{$id_supplier2} ),
577 "Supplier2 has late orders and $daysago4 < $daysago5 + 2days <= today and $daysago5 <= now()-3+2 days"
580 exists( $suppliers{$id_supplier3} ),
581 "Supplier3 has late orders but $daysago4 > $daysago10 + 3days < today and $daysago10 <= now()-3+3 days"
583 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
585 #Case 9 :With $estimateddeliverydatefrom = $daysago5 and $delay = 3
586 # $today < $daysago5 and $today > $today-5 -NOT LATE-
587 # $daysago5 + 2 days >= $daysago5 and $daysago5 < today - 3+2 -LATE-
588 # $daysago10 + 3 days < $daysago5 and $daysago10 < today -3+2-NOT LATE-
589 # quantityreceived = quantity -NOT LATE-
591 C4::Bookseller::GetBooksellersWithLateOrders( 3, $daysago5, undef );
592 isnt( exists( $suppliers{$id_supplier1} ),
593 1, "$today < $daysago10 and $today > $today-3" );
595 exists( $suppliers{$id_supplier2} ),
596 "Supplier2 has late orders and $daysago5 + 2 days >= $daysago5 and $daysago5 < today - 3+2"
599 exists( $suppliers{$id_supplier3} ),
601 "Supplier2 has late orders but $daysago10 + 3 days < $daysago5 and $daysago10 < today -3+2 "
603 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
605 #Test with $estimateddeliverydateto and $delay
606 #Case 10:With $estimateddeliverydateto = $daysago5 and $delay = 5
607 # today > $daysago5 today > now() -5 -NOT LATE-
608 # $daysago5 + 2 days > $daysago5 and $daysago5 > now() - 2+5 days -NOT LATE-
609 # $daysago10 + 3 days <= $daysago5 and $daysago10 <= now() - 3+5 days -LATE-
610 # quantityreceived = quantity -NOT LATE-
612 C4::Bookseller::GetBooksellersWithLateOrders( 5, undef, $daysago5 );
613 isnt( exists( $suppliers{$id_supplier1} ),
614 1, "Supplier2 has late orders but today > $daysago5 today > now() -5" );
616 exists( $suppliers{$id_supplier2} ),
618 "Supplier2 has late orders but $daysago5 + 2 days > $daysago5 and $daysago5 > now() - 2+5 days"
621 exists( $suppliers{$id_supplier3} ),
622 "Supplier2 has late orders and $daysago10 + 3 days <= $daysago5 and $daysago10 <= now() - 3+5 days "
624 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
626 #Case 11: With $estimateddeliverydatefrom =today-10 and $estimateddeliverydateto = today - 10
627 # $daysago10==$daysago10==$daysago10 -NOT LATE-
628 # $daysago10==$daysago10<$daysago5+2-NOT lATE-
629 # $daysago10==$daysago10 <$daysago10+3-LATE-
630 # quantityreceived = quantity -NOT LATE-
632 #Basket1 closedate -> $daysago10
634 basketno => $sample_basket1,
635 closedate => $daysago10,
637 ModBasket($basket1info);
638 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10,
640 ok( exists( $suppliers{$id_supplier1} ),
641 "Supplier1 has late orders and $daysago10==$daysago10==$daysago10 " )
643 isnt( exists( $suppliers{$id_supplier2} ),
645 "Supplier2 has late orders but $daysago10==$daysago10<$daysago5+2" );
646 isnt( exists( $suppliers{$id_supplier3} ),
648 "Supplier3 has late orders but $daysago10==$daysago10 <$daysago10+3" );
649 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
651 #Case 12: closedate == $estimateddeliverydatefrom =today-10
653 C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10, undef );
654 ok( exists( $suppliers{$id_supplier1} ),
655 "Supplier1 has late orders and $daysago10==$daysago10 " );
657 #Case 13: closedate == $estimateddeliverydateto =today-10
659 C4::Bookseller::GetBooksellersWithLateOrders( undef, undef, $daysago10 );
660 ok( exists( $suppliers{$id_supplier1} ),
661 "Supplier1 has late orders and $daysago10==$daysago10 " )
667 #field_filter filters the useless fields or foreign keys
668 #NOTE: all the fields of aqbookseller arent considered
669 #returns a cleaned structure
674 'bookselleremail', 'booksellerfax',
675 'booksellerurl', 'othersupplier',
676 'currency', 'invoiceprice',
681 if ( grep { /^$field$/ } keys %$struct ) {
682 delete $struct->{$field};