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|);
38 $dbh->do(q|DELETE FROM subscription|);
41 my $count = scalar( C4::Bookseller::GetBookSeller('') );
42 my $sample_supplier1 = {
44 address1 => 'address1_1',
45 address2 => 'address1-2',
46 address3 => 'address1_2',
47 address4 => 'address1_2',
50 accountnumber => 'accountnumber1',
53 contact => 'contact1',
54 contpos => 'contpos1',
55 contphone => 'contphone1',
56 contfax => 'contefax1',
57 contaltphone => 'contaltphone1',
58 contemail => 'contemail1',
59 contnotes => 'contnotes1',
69 my $sample_supplier2 = {
71 address1 => 'address1_2',
72 address2 => 'address2-2',
73 address3 => 'address3_2',
74 address4 => 'address4_2',
77 accountnumber => 'accountnumber2',
80 contact => 'contact2',
81 contpos => 'contpos2',
82 contphone => 'contphone2',
83 contfax => 'contefax2',
84 contaltphone => 'contaltphone2',
85 contemail => 'contemail2',
86 contnotes => 'contnotes2',
97 my $id_supplier1 = C4::Bookseller::AddBookseller($sample_supplier1);
98 my $id_supplier2 = C4::Bookseller::AddBookseller($sample_supplier2);
100 #my $id_bookseller3 = C4::Bookseller::AddBookseller();# NOTE : Doesn't work because the field name cannot be null
102 like( $id_supplier1, '/^\d+$/', "AddBookseller for supplier1 return an id" );
103 like( $id_supplier2, '/^\d+$/', "AddBookseller for supplier2 return an id" );
104 is( scalar( C4::Bookseller::GetBookSeller('') ),
105 $count + 2, "Supplier1 and Supplier2 have been added" );
108 my $del = C4::Bookseller::DelBookseller($id_supplier1);
109 is( $del, 1, "DelBookseller returns 1 - 1 supplier has been deleted " );
110 is( C4::Bookseller::GetBookSellerFromId($id_supplier1),
111 undef, "Supplier1 has been deleted - id_supplier1 doesnt exist anymore" );
114 my @bookseller2 = C4::Bookseller::GetBookSeller( $sample_supplier2->{name} );
115 is( scalar(@bookseller2), 1, "Get only Supplier2" );
116 $bookseller2[0] = field_filter( $bookseller2[0] );
117 delete $bookseller2[0]->{basketcount};
119 $sample_supplier2->{id} = $id_supplier2;
120 is_deeply( $bookseller2[0], $sample_supplier2,
121 "GetBookSeller returns the right informations about $sample_supplier2" );
123 $id_supplier1 = C4::Bookseller::AddBookseller($sample_supplier1);
124 my @booksellers = C4::Bookseller::GetBookSeller('')
125 ; #NOTE :without params, it returns all the booksellers
126 for my $i ( 0 .. scalar(@booksellers) - 1 ) {
127 $booksellers[$i] = field_filter( $booksellers[$i] );
128 delete $booksellers[$i]->{basketcount};
131 $sample_supplier1->{id} = $id_supplier1;
132 is( scalar(@booksellers), $count + 2, "Get Supplier1 and Supplier2" );
133 my @tab = ( $sample_supplier1, $sample_supplier2 );
134 is_deeply( \@booksellers, \@tab,
135 "Returns right fields of Supplier1 and Supplier2" );
138 my @bookseller1 = C4::Bookseller::GetBookSeller( $sample_supplier1->{name} );
139 #FIXME : if there is 0 basket, GetBookSeller returns 1 as basketcount
140 #is( $bookseller1[0]->{basketcount}, 0, 'Supplier1 has 0 basket' );
142 C4::Acquisition::NewBasket( $id_supplier1, 'authorisedby1', 'basketname1' );
144 C4::Acquisition::NewBasket( $id_supplier1, 'authorisedby2', 'basketname2' );
145 @bookseller1 = C4::Bookseller::GetBookSeller( $sample_supplier1->{name} );
146 is( $bookseller1[0]->{basketcount}, 2, 'Supplier1 has 2 baskets' );
148 #Test GetBookSellerFromId
149 my $bookseller1fromid = C4::Bookseller::GetBookSellerFromId();
150 is( $bookseller1fromid, undef,
151 "GetBookSellerFromId returns undef if no id given" );
152 $bookseller1fromid = C4::Bookseller::GetBookSellerFromId($id_supplier1);
153 $bookseller1fromid = field_filter($bookseller1fromid);
154 delete $bookseller1fromid->{basketcount};
155 delete $bookseller1fromid->{subscriptioncount};
156 is_deeply( $bookseller1fromid, $sample_supplier1,
157 "Get Supplier1 (GetBookSellerFromId)" );
160 $bookseller1fromid = C4::Bookseller::GetBookSellerFromId($id_supplier1);
161 is( $bookseller1fromid->{basketcount}, 2, 'Supplier1 has 2 baskets' );
163 #Test subscriptioncount
164 my $dt_today = dt_from_string;
165 my $today = output_pref({ dt => $dt_today, dateformat => 'iso', timeformat => '24hr', dateonly => 1 });
167 my $dt_today1 = dt_from_string;
168 my $dur5 = DateTime::Duration->new( days => -5 );
169 $dt_today1->add_duration($dur5);
170 my $daysago5 = output_pref({ dt => $dt_today1, dateformat => 'iso', timeformat => '24hr', dateonly => 1 });
172 my $budgetperiod = C4::Budgets::AddBudgetPeriod({
173 budget_period_startdate => $daysago5,
174 budget_period_enddate => $today,
175 budget_description => "budget desc"
177 my $id_budget = AddBudget({
178 budget_code => "CODE",
179 budget_amount => "123.132",
180 budget_name => "Budgetname",
181 budget_notes => "This is a note",
182 budget_description => "BudgetDescription",
184 budget_period_id => $budgetperiod
186 my $bib = MARC::Record->new();
188 MARC::Field->new('245', ' ', ' ', a => 'Journal of ethnology'),
189 MARC::Field->new('500', ' ', ' ', a => 'bib notes'),
191 my ($biblionumber, $biblioitemnumber) = AddBiblio($bib, '');
192 $bookseller1fromid = C4::Bookseller::GetBookSellerFromId($id_supplier1);
193 is( $bookseller1fromid->{subscriptioncount},
194 0, 'Supplier1 has 0 subscription' );
196 my $id_subscription1 = NewSubscription(
197 undef, "", $id_supplier1, undef, $id_budget, $biblionumber,
198 '01-01-2013',undef, undef, undef, undef,
199 undef, undef, undef, undef, undef, undef,
200 1, "subscription notes",undef, '01-01-2013', undef, undef,
201 undef, 'CALL ABC', 0, "intnotes", 0,
202 undef, undef, 0, undef, '2013-11-30', 0
205 my @subscriptions = SearchSubscriptions({biblionumber => $biblionumber});
206 is($subscriptions[0]->{publicnotes}, 'subscription notes', 'subscription search results include public notes (bug 10689)');
208 my $id_subscription2 = NewSubscription(
209 undef, "", $id_supplier1, undef, $id_budget, $biblionumber,
210 '01-01-2013',undef, undef, undef, undef,
211 undef, undef, undef, undef, undef, undef,
212 1, "subscription notes",undef, '01-01-2013', undef, undef,
213 undef, 'CALL DEF', 0, "intnotes", 0,
214 undef, undef, 0, undef, '2013-07-31', 0
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 my $modif1 = C4::Bookseller::ModBookseller();
253 "ModBookseller returns undef if no params given - Nothing happened" );
254 $modif1 = C4::Bookseller::ModBookseller($sample_supplier2);
255 is( $modif1, 1, "ModBookseller modifies only the supplier2" );
256 is( scalar( C4::Bookseller::GetBookSeller('') ),
257 $count + 2, "Supplier2 has been modified - Nothing added" );
259 $modif1 = C4::Bookseller::ModBookseller(
266 # "ModBookseller returns OEO if the id doesnt exist - Nothing modified" );
268 #Test GetBooksellersWithLateOrders
270 my $sample_supplier3 = {
272 address1 => 'address1_3',
273 address2 => 'address1-3',
274 address3 => 'address1_3',
275 address4 => 'address1_3',
278 accountnumber => 'accountnumber3',
281 contact => 'contact3',
282 contpos => 'contpos3',
283 contphone => 'contphone3',
284 contfax => 'contefax3',
285 contaltphone => 'contaltphone3',
286 contemail => 'contemail3',
287 contnotes => 'contnotes3',
293 discount => '3.0000',
297 my $sample_supplier4 = {
299 address1 => 'address1_4',
300 address2 => 'address1-4',
301 address3 => 'address1_4',
302 address4 => 'address1_4',
305 accountnumber => 'accountnumber4',
308 contact => 'contact4',
309 contpos => 'contpos4',
310 contphone => 'contphone4',
311 contfax => 'contefax4',
312 contaltphone => 'contaltphone4',
313 contemail => 'contemail4',
314 contnotes => 'contnotes4',
320 discount => '3.0000',
323 my $id_supplier3 = C4::Bookseller::AddBookseller($sample_supplier3);
324 my $id_supplier4 = C4::Bookseller::AddBookseller($sample_supplier4);
328 C4::Acquisition::NewBasket( $id_supplier3, 'authorisedby3', 'basketname3',
331 C4::Acquisition::NewBasket( $id_supplier4, 'authorisedby4', 'basketname4',
334 #Modify the basket to add a close date
336 basketno => $sample_basket1,
338 booksellerid => $id_supplier1
342 basketno => $sample_basket2,
343 closedate => $daysago5,
344 booksellerid => $id_supplier2
347 my $dt_today2 = dt_from_string;
348 my $dur10 = DateTime::Duration->new( days => -10 );
349 $dt_today2->add_duration($dur10);
350 my $daysago10 = output_pref({ dt => $dt_today2, dateformat => 'iso', timeformat => '24hr', dateonly => 1 });
352 basketno => $sample_basket3,
353 closedate => $daysago10,
357 basketno => $sample_basket4,
360 ModBasket($basket1info);
361 ModBasket($basket2info);
362 ModBasket($basket3info);
363 ModBasket($basket4info);
366 my $id_subscription3 = NewSubscription(
367 undef, "", $id_supplier1, undef, $id_budget, $biblionumber,
368 '01-01-2013',undef, undef, undef, undef,
369 undef, undef, undef, undef, undef, undef,
370 1, "subscription notes",undef, '01-01-2013', undef, undef,
371 undef, undef, 0, "intnotes", 0,
372 undef, undef, 0, 'LOCA', '2013-12-31', 0
375 @subscriptions = SearchSubscriptions({expiration_date => '2013-12-31'});
376 is(scalar(@subscriptions), 3, 'search for subscriptions by expiration date');
377 @subscriptions = SearchSubscriptions({expiration_date => '2013-08-15'});
378 is(scalar(@subscriptions), 1, 'search for subscriptions by expiration date');
379 @subscriptions = SearchSubscriptions({callnumber => 'CALL'});
380 is(scalar(@subscriptions), 2, 'search for subscriptions by call number');
381 @subscriptions = SearchSubscriptions({callnumber => 'DEF'});
382 is(scalar(@subscriptions), 1, 'search for subscriptions by call number');
383 @subscriptions = SearchSubscriptions({location => 'LOCA'});
384 is(scalar(@subscriptions), 1, 'search for subscriptions by location');
387 my ( $ordernumber1, $ordernumber2, $ordernumber3, $ordernumber4 );
388 my ( $basketno1, $basketno2, $basketno3, $basketno4 );
389 ( $basketno1, $ordernumber1 ) = C4::Acquisition::NewOrder(
391 basketno => $sample_basket1,
393 biblionumber => $biblionumber,
394 budget_id => $id_budget,
395 entrydate => '01-01-2013',
397 notes => "This is a note1",
400 subscriptionid => $id_subscription1,
401 quantityreceived => 2,
404 datereceived => '01-06-2013'
407 ( $basketno2, $ordernumber2 ) = C4::Acquisition::NewOrder(
409 basketno => $sample_basket2,
411 biblionumber => $biblionumber,
412 budget_id => $id_budget,
413 entrydate => '01-01-2013',
415 notes => "This is a note2",
418 subscriptionid => $id_subscription2,
423 ( $basketno3, $ordernumber3 ) = C4::Acquisition::NewOrder(
425 basketno => $sample_basket3,
427 biblionumber => $biblionumber,
428 budget_id => $id_budget,
429 entrydate => '02-02-2013',
431 notes => "This is a note3",
434 subscriptionid => $id_subscription3,
439 ( $basketno4, $ordernumber4 ) = C4::Acquisition::NewOrder(
441 basketno => $sample_basket4,
443 biblionumber => $biblionumber,
444 budget_id => $id_budget,
445 entrydate => '02-02-2013',
447 notes => "This is a note3",
450 subscriptionid => $id_subscription3,
453 quantityreceived => 20
459 # Supplier1: delivery -> undef Basket1 : closedate -> today
460 # Supplier2: delivery -> 2 Basket2 : closedate -> $daysago5
461 # Supplier3: delivery -> 3 Basket3 : closedate -> $daysago10
462 #Case 1 : Without parameters:
463 # quantityreceived < quantity AND rrp <> 0 AND ecost <> 0 AND quantity - COALESCE(quantityreceived,0) <> 0 AND closedate IS NOT NULL -LATE-
464 # datereceived !null AND rrp <> 0 AND ecost <> 0 AND quantity - COALESCE(quantityreceived,0) <> 0 AND closedate IS NOT NULL -LATE-
465 # datereceived !null AND rrp <> 0 AND ecost <> 0 AND quantity - COALESCE(quantityreceived,0) <> 0 AND closedate IS NOT NULL -LATE-
466 # quantityreceived = quantity -NOT LATE-
467 my %suppliers = C4::Bookseller::GetBooksellersWithLateOrders();
468 ok( exists( $suppliers{$id_supplier1} ), "Supplier1 has late orders" );
469 ok( exists( $suppliers{$id_supplier2} ), "Supplier2 has late orders" );
470 ok( exists( $suppliers{$id_supplier3} ), "Supplier3 has late orders" );
471 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" )
472 ; # Quantity = quantityreceived
474 #Case 2: With $delay = 4
475 # today + 0 > now-$delay -NOT LATE-
476 # (today-5) + 2 <= now() - $delay -NOT LATE-
477 # (today-10) + 3 <= now() - $delay -LATE-
478 # quantityreceived = quantity -NOT LATE-
479 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( 4, undef, undef );
480 isnt( exists( $suppliers{$id_supplier1} ),
481 1, "Supplier1 has late orders but today > now() - 4 days" );
482 isnt( exists( $suppliers{$id_supplier2} ),
483 1, "Supplier2 has late orders and $daysago5 <= now() - (4 days+2)" );
484 ok( exists( $suppliers{$id_supplier3} ),
485 "Supplier3 has late orders and $daysago10 <= now() - (4 days+3)" );
486 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
488 #Case 3: With $delay = -1
489 is( C4::Bookseller::GetBooksellersWithLateOrders( -1, undef, undef ),
490 undef, "-1 is a wrong value for a delay" );
492 #Case 4: With $delay = 0
493 # today == now-0 -LATE- (if no deliverytime or deliverytime == 0)
494 # today-5 <= now() - $delay+2 -LATE-
495 # today-10 <= now() - $delay+3 -LATE-
496 # quantityreceived = quantity -NOT LATE-
497 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( 0, undef, undef );
499 ok( exists( $suppliers{$id_supplier1} ),
500 "Supplier1 has late orders but $today == now() - 0 days" )
502 ok( exists( $suppliers{$id_supplier2} ),
503 "Supplier2 has late orders and $daysago5 <= now() - 2" );
504 ok( exists( $suppliers{$id_supplier3} ),
505 "Supplier3 has late orders and $daysago10 <= now() - 3" );
506 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
508 #Case 5 : With $estimateddeliverydatefrom = today-4
509 # today >= today-4 -NOT LATE-
510 # (today-5)+ 2 days >= today-4 -LATE-
511 # (today-10) + 3 days < today-4 -NOT LATE-
512 # quantityreceived = quantity -NOT LATE-
513 my $dt_today3 = dt_from_string;
514 my $dur4 = DateTime::Duration->new( days => -4 );
515 $dt_today3->add_duration($dur4);
516 my $daysago4 = output_pref({ dt => $dt_today3, dateformat => 'iso', timeformat => '24hr', dateonly => 1 });
518 C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago4, undef );
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 isnt( exists( $suppliers{$id_supplier1} ),
557 "Supplier1 has late orders but $today >= $daysago5 - deliverytime undef" );
558 isnt( exists( $suppliers{$id_supplier2} ),
559 1, "Supplier2 has late orders but $daysago5 + 2 days > $daysago5 " );
560 ok( exists( $suppliers{$id_supplier3} ),
561 "Supplier3 has late orders and $daysago10 + 3 <= $daysago5" );
562 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
564 #Test with $estimateddeliverydatefrom and $estimateddeliverydateto and $delay
565 #Case 8 :With $estimateddeliverydatefrom = 2013-07-05 and $estimateddeliverydateto = 2013-07-08 and $delay =5
566 # $daysago4<today<=$today and $today<now()-3 -NOT LATE-
567 # $daysago4 < $daysago5 + 2days <= today and $daysago5 <= now()-3+2 days -LATE-
568 # $daysago4 > $daysago10 + 3days < today and $daysago10 <= now()-3+3 days -NOT LATE-
569 # quantityreceived = quantity -NOT LATE-
571 C4::Bookseller::GetBooksellersWithLateOrders( 3, $daysago4, $today );
573 exists( $suppliers{$id_supplier1} ),
575 "Supplier1 has late orders but $daysago4<today<=$today and $today<now()-3"
578 exists( $suppliers{$id_supplier2} ),
579 "Supplier2 has late orders and $daysago4 < $daysago5 + 2days <= today and $daysago5 <= now()-3+2 days"
582 exists( $suppliers{$id_supplier3} ),
583 "Supplier3 has late orders but $daysago4 > $daysago10 + 3days < today and $daysago10 <= now()-3+3 days"
585 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
587 #Case 9 :With $estimateddeliverydatefrom = $daysago5 and $delay = 3
588 # $today < $daysago5 and $today > $today-5 -NOT LATE-
589 # $daysago5 + 2 days >= $daysago5 and $daysago5 < today - 3+2 -LATE-
590 # $daysago10 + 3 days < $daysago5 and $daysago10 < today -3+2-NOT LATE-
591 # quantityreceived = quantity -NOT LATE-
593 C4::Bookseller::GetBooksellersWithLateOrders( 3, $daysago5, undef );
594 isnt( exists( $suppliers{$id_supplier1} ),
595 1, "$today < $daysago10 and $today > $today-3" );
597 exists( $suppliers{$id_supplier2} ),
598 "Supplier2 has late orders and $daysago5 + 2 days >= $daysago5 and $daysago5 < today - 3+2"
601 exists( $suppliers{$id_supplier3} ),
603 "Supplier2 has late orders but $daysago10 + 3 days < $daysago5 and $daysago10 < today -3+2 "
605 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
607 #Test with $estimateddeliverydateto and $delay
608 #Case 10:With $estimateddeliverydateto = $daysago5 and $delay = 5
609 # today > $daysago5 today > now() -5 -NOT LATE-
610 # $daysago5 + 2 days > $daysago5 and $daysago5 > now() - 2+5 days -NOT LATE-
611 # $daysago10 + 3 days <= $daysago5 and $daysago10 <= now() - 3+5 days -LATE-
612 # quantityreceived = quantity -NOT LATE-
614 C4::Bookseller::GetBooksellersWithLateOrders( 5, undef, $daysago5 );
615 isnt( exists( $suppliers{$id_supplier1} ),
616 1, "Supplier2 has late orders but today > $daysago5 today > now() -5" );
618 exists( $suppliers{$id_supplier2} ),
620 "Supplier2 has late orders but $daysago5 + 2 days > $daysago5 and $daysago5 > now() - 2+5 days"
623 exists( $suppliers{$id_supplier3} ),
624 "Supplier2 has late orders and $daysago10 + 3 days <= $daysago5 and $daysago10 <= now() - 3+5 days "
626 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
628 #Case 11: With $estimateddeliverydatefrom =today-10 and $estimateddeliverydateto = today - 10
629 # $daysago10==$daysago10==$daysago10 -NOT LATE-
630 # $daysago10==$daysago10<$daysago5+2-NOT lATE-
631 # $daysago10==$daysago10 <$daysago10+3-LATE-
632 # quantityreceived = quantity -NOT LATE-
634 #Basket1 closedate -> $daysago10
636 basketno => $sample_basket1,
637 closedate => $daysago10,
639 ModBasket($basket1info);
640 %suppliers = C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10,
642 ok( exists( $suppliers{$id_supplier1} ),
643 "Supplier1 has late orders and $daysago10==$daysago10==$daysago10 " )
645 isnt( exists( $suppliers{$id_supplier2} ),
647 "Supplier2 has late orders but $daysago10==$daysago10<$daysago5+2" );
648 isnt( exists( $suppliers{$id_supplier3} ),
650 "Supplier3 has late orders but $daysago10==$daysago10 <$daysago10+3" );
651 isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
653 #Case 12: closedate == $estimateddeliverydatefrom =today-10
655 C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10, undef );
656 ok( exists( $suppliers{$id_supplier1} ),
657 "Supplier1 has late orders and $daysago10==$daysago10 " );
659 #Case 13: closedate == $estimateddeliverydateto =today-10
661 C4::Bookseller::GetBooksellersWithLateOrders( undef, undef, $daysago10 );
662 ok( exists( $suppliers{$id_supplier1} ),
663 "Supplier1 has late orders and $daysago10==$daysago10 " )
669 #field_filter filters the useless fields or foreign keys
670 #NOTE: all the fields of aqbookseller arent considered
671 #returns a cleaned structure
676 'bookselleremail', 'booksellerfax',
677 'booksellerurl', 'othersupplier',
678 'currency', 'invoiceprice',
683 if ( grep { /^$field$/ } keys %$struct ) {
684 delete $struct->{$field};