View | Details | Raw Unified | Return to bug 6721
Collapse All | Expand All

(-)a/C4/Acquisition.pm (-77 / +109 lines)
Lines 20-25 package C4::Acquisition; Link Here
20
20
21
use strict;
21
use strict;
22
use warnings;
22
use warnings;
23
use Carp;
23
use C4::Context;
24
use C4::Context;
24
use C4::Debug;
25
use C4::Debug;
25
use C4::Dates qw(format_date format_date_in_iso);
26
use C4::Dates qw(format_date format_date_in_iso);
Lines 897-903 sub NewOrder { Link Here
897
898
898
    # if these parameters are missing, we can't continue
899
    # if these parameters are missing, we can't continue
899
    for my $key (qw/basketno quantity biblionumber budget_id/) {
900
    for my $key (qw/basketno quantity biblionumber budget_id/) {
900
        die "Mandatory parameter $key missing" unless $orderinfo->{$key};
901
        croak "Mandatory parameter $key missing" unless $orderinfo->{$key};
901
    }
902
    }
902
903
903
    if ( defined $orderinfo->{subscription} && $orderinfo->{'subscription'} eq 'yes' ) {
904
    if ( defined $orderinfo->{subscription} && $orderinfo->{'subscription'} eq 'yes' ) {
Lines 1486-1495 sub GetLateOrders { Link Here
1486
1487
1487
=head3 GetHistory
1488
=head3 GetHistory
1488
1489
1489
  (\@order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( $title, $author, $name, $from_placed_on, $to_placed_on );
1490
  (\@order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( %params );
1490
1491
1491
Retreives some acquisition history information
1492
Retreives some acquisition history information
1492
1493
1494
params:  
1495
  title
1496
  author
1497
  name
1498
  from_placed_on
1499
  to_placed_on
1500
  basket                  - search both basket name and number
1501
  booksellerinvoicenumber 
1502
1493
returns:
1503
returns:
1494
    $order_loop is a list of hashrefs that each look like this:
1504
    $order_loop is a list of hashrefs that each look like this:
1495
            {
1505
            {
Lines 1515-1608 returns: Link Here
1515
=cut
1525
=cut
1516
1526
1517
sub GetHistory {
1527
sub GetHistory {
1518
    my ( $title, $author, $name, $from_placed_on, $to_placed_on ) = @_;
1528
# don't run the query if there are no parameters (list would be too long for sure !)
1529
    croak "No search params" unless @_;
1530
    my %params = @_;
1531
    my $title = $params{title};
1532
    my $author = $params{author};
1533
    my $name = $params{name};
1534
    my $from_placed_on = $params{from_placed_on};
1535
    my $to_placed_on = $params{to_placed_on};
1536
    my $basket = $params{basket};
1537
    my $booksellerinvoicenumber = $params{booksellerinvoicenumber};
1538
1519
    my @order_loop;
1539
    my @order_loop;
1520
    my $total_qty         = 0;
1540
    my $total_qty         = 0;
1521
    my $total_qtyreceived = 0;
1541
    my $total_qtyreceived = 0;
1522
    my $total_price       = 0;
1542
    my $total_price       = 0;
1523
1543
1524
# don't run the query if there are no parameters (list would be too long for sure !)
1544
    my $dbh   = C4::Context->dbh;
1525
    if ( $title || $author || $name || $from_placed_on || $to_placed_on ) {
1545
    my $query ="
1526
        my $dbh   = C4::Context->dbh;
1546
        SELECT
1527
        my $query ="
1547
            biblio.title,
1528
            SELECT
1548
            biblio.author,
1529
                biblio.title,
1549
            aqorders.basketno,
1530
                biblio.author,
1550
    aqbasket.basketname,
1531
                aqorders.basketno,
1551
    aqbasket.basketgroupid,
1532
		aqbasket.basketname,
1552
    aqbasketgroups.name as groupname,
1533
		aqbasket.basketgroupid,
1553
            aqbooksellers.name,
1534
		aqbasketgroups.name as groupname,
1554
    aqbasket.creationdate,
1535
                aqbooksellers.name,
1555
            aqorders.datereceived,
1536
		aqbasket.creationdate,
1556
            aqorders.quantity,
1537
                aqorders.datereceived,
1557
            aqorders.quantityreceived,
1538
                aqorders.quantity,
1558
            aqorders.ecost,
1539
                aqorders.quantityreceived,
1559
            aqorders.ordernumber,
1540
                aqorders.ecost,
1560
            aqorders.booksellerinvoicenumber as invoicenumber,
1541
                aqorders.ordernumber,
1561
            aqbooksellers.id as id,
1542
                aqorders.booksellerinvoicenumber as invoicenumber,
1562
            aqorders.biblionumber
1543
                aqbooksellers.id as id,
1563
        FROM aqorders
1544
                aqorders.biblionumber
1564
        LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno
1545
            FROM aqorders
1565
    LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
1546
            LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno
1566
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
1547
	    LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
1567
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber";
1548
            LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
1549
            LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber";
1550
1551
        $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
1552
        if ( C4::Context->preference("IndependantBranches") );
1553
	
1554
        $query .= " WHERE (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') ";
1555
1556
        my @query_params  = ();
1557
1558
        if ( defined $title ) {
1559
            $query .= " AND biblio.title LIKE ? ";
1560
            $title =~ s/\s+/%/g;
1561
            push @query_params, "%$title%";
1562
        }
1563
1568
1564
        if ( defined $author ) {
1569
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
1565
            $query .= " AND biblio.author LIKE ? ";
1570
    if ( C4::Context->preference("IndependantBranches") );
1566
            push @query_params, "%$author%";
1567
        }
1568
1571
1569
        if ( defined $name ) {
1572
    $query .= " WHERE (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') ";
1570
            $query .= " AND aqbooksellers.name LIKE ? ";
1571
            push @query_params, "%$name%";
1572
        }
1573
1573
1574
        if ( defined $from_placed_on ) {
1574
    my @query_params  = ();
1575
            $query .= " AND creationdate >= ? ";
1576
            push @query_params, $from_placed_on;
1577
        }
1578
1575
1579
        if ( defined $to_placed_on ) {
1576
    if ( defined $title ) {
1580
            $query .= " AND creationdate <= ? ";
1577
        $query .= " AND biblio.title LIKE ? ";
1581
            push @query_params, $to_placed_on;
1578
        $title =~ s/\s+/%/g;
1582
        }
1579
        push @query_params, "%$title%";
1580
    }
1583
1581
1584
        if ( C4::Context->preference("IndependantBranches") ) {
1582
    if ( defined $author ) {
1585
            my $userenv = C4::Context->userenv;
1583
        $query .= " AND biblio.author LIKE ? ";
1586
            if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
1584
        push @query_params, "%$author%";
1587
                $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
1585
    }
1588
                push @query_params, $userenv->{branch};
1586
1589
            }
1587
    if ( defined $name ) {
1588
        $query .= " AND aqbooksellers.name LIKE ? ";
1589
        push @query_params, "%$name%";
1590
    }
1591
1592
    if ( defined $from_placed_on ) {
1593
        $query .= " AND creationdate >= ? ";
1594
        push @query_params, $from_placed_on;
1595
    }
1596
1597
    if ( defined $to_placed_on ) {
1598
        $query .= " AND creationdate <= ? ";
1599
        push @query_params, $to_placed_on;
1600
    }
1601
1602
    if ($basket) {
1603
        if ($basket =~ m/^\d+$/) {
1604
            $query .= " AND aqorders.basketno = ? ";
1605
            push @query_params, $basket;
1606
        } else {
1607
            $query .= " AND aqbasket.name LIKE ? ";
1608
            push @query_params, "%$basket%";
1590
        }
1609
        }
1591
        $query .= " ORDER BY id";
1610
    }
1592
        my $sth = $dbh->prepare($query);
1611
1593
        $sth->execute( @query_params );
1612
    if ($booksellerinvoicenumber) {
1594
        my $cnt = 1;
1613
        $query .= " AND (aqorders.booksellerinvoicenumber LIKE ? OR aqbasket.booksellerinvoicenumber LIKE ?)";
1595
        while ( my $line = $sth->fetchrow_hashref ) {
1614
        push @query_params, "%$booksellerinvoicenumber%", "%$booksellerinvoicenumber%";
1596
            $line->{count} = $cnt++;
1615
    }
1597
            $line->{toggle} = 1 if $cnt % 2;
1616
1598
            push @order_loop, $line;
1617
    if ( C4::Context->preference("IndependantBranches") ) {
1599
            $line->{creationdate} = format_date( $line->{creationdate} );
1618
        my $userenv = C4::Context->userenv;
1600
            $line->{datereceived} = format_date( $line->{datereceived} );
1619
        if ( $userenv && ($userenv->{flags} || 0) != 1 ) {
1601
            $total_qty         += $line->{'quantity'};
1620
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
1602
            $total_qtyreceived += $line->{'quantityreceived'};
1621
            push @query_params, $userenv->{branch};
1603
            $total_price       += $line->{'quantity'} * $line->{'ecost'};
1604
        }
1622
        }
1605
    }
1623
    }
1624
    $query .= " ORDER BY id";
1625
    my $sth = $dbh->prepare($query);
1626
    $sth->execute( @query_params );
1627
    my $cnt = 1;
1628
    while ( my $line = $sth->fetchrow_hashref ) {
1629
        $line->{count} = $cnt++;
1630
        $line->{toggle} = 1 if $cnt % 2;
1631
        push @order_loop, $line;
1632
        $line->{creationdate} = format_date( $line->{creationdate} );
1633
        $line->{datereceived} = format_date( $line->{datereceived} );
1634
        $total_qty         += $line->{'quantity'};
1635
        $total_qtyreceived += $line->{'quantityreceived'};
1636
        $total_price       += $line->{'quantity'} * $line->{'ecost'};
1637
    }
1606
    return \@order_loop, $total_qty, $total_price, $total_qtyreceived;
1638
    return \@order_loop, $total_qty, $total_price, $total_qtyreceived;
1607
}
1639
}
1608
1640
(-)a/acqui/histsearch.pl (-8 / +19 lines)
Lines 56-67 use C4::Acquisition; Link Here
56
use C4::Dates;
56
use C4::Dates;
57
use C4::Debug;
57
use C4::Debug;
58
58
59
my $input          = new CGI;
59
my $input = new CGI;
60
my $title          = $input->param( 'title');
60
my $title                   = $input->param( 'title');
61
my $author         = $input->param('author');
61
my $author                  = $input->param('author');
62
my $name           = $input->param( 'name' );
62
my $name                    = $input->param( 'name' );
63
my $from_placed_on = C4::Dates->new($input->param('from'));
63
my $basket                  = $input->param( 'basket' );
64
my $to_placed_on   = C4::Dates->new($input->param(  'to'));
64
my $booksellerinvoicenumber = $input->param( 'booksellerinvoicenumber' );
65
my $from_placed_on          = C4::Dates->new($input->param('from'));
66
my $to_placed_on            = C4::Dates->new($input->param(  'to'));
65
67
66
my $dbh = C4::Context->dbh;
68
my $dbh = C4::Context->dbh;
67
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
69
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 83-90 if ( $d = $input->param('iso') ) { Link Here
83
    $to_iso = C4::Dates->new($d)->output('iso');
85
    $to_iso = C4::Dates->new($d)->output('iso');
84
}
86
}
85
87
86
my ( $order_loop, $total_qty, $total_price, $total_qtyreceived ) =
88
my ( $order_loop, $total_qty, $total_price, $total_qtyreceived ) = GetHistory(
87
  GetHistory( $title, $author, $name, $from_iso, $to_iso );
89
    title => $title,
90
    author => $author,
91
    name => $name,
92
    from_placed_on => $from_iso,
93
    to_placed_on => $to_iso,
94
    basket => $basket,
95
    booksellerinvoicenumber => $booksellerinvoicenumber,
96
);
88
97
89
$template->param(
98
$template->param(
90
    suggestions_loop        => $order_loop,
99
    suggestions_loop        => $order_loop,
Lines 95-100 $template->param( Link Here
95
    title                   => $title,
104
    title                   => $title,
96
    author                  => $author,
105
    author                  => $author,
97
    name                    => $name,
106
    name                    => $name,
107
    basket                  => $basket,
108
    booksellerinvoicenumber => $booksellerinvoicenumber,
98
    from_placed_on          => $from_placed_on->output('syspref'),
109
    from_placed_on          => $from_placed_on->output('syspref'),
99
    to_placed_on            =>   $to_placed_on->output('syspref'),
110
    to_placed_on            =>   $to_placed_on->output('syspref'),
100
    DHTMLcalendar_dateformat=> C4::Dates->DHTMLcalendar(),
111
    DHTMLcalendar_dateformat=> C4::Dates->DHTMLcalendar(),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-search.inc (-1 / +7 lines)
Lines 12-21 Link Here
12
	
12
	
13
		<form action="/cgi-bin/koha/acqui/histsearch.pl" method="post">
13
		<form action="/cgi-bin/koha/acqui/histsearch.pl" method="post">
14
		<label for="title">Title: </label><input type="text" id="title" name="title" size="15" value="[% title %]" /> <label for="searchsupplier">Vendor:</label> <input type="text" id="searchsupplier" name="name" size="15" value="[% name %]" />
14
		<label for="title">Title: </label><input type="text" id="title" name="title" size="15" value="[% title %]" /> <label for="searchsupplier">Vendor:</label> <input type="text" id="searchsupplier" name="name" size="15" value="[% name %]" />
15
        <span class="filteraction" id="filteraction_off" style="display:none"> <a href="#" onclick="$('#filters').toggle();$('.filteraction').hide();">[-]</a></span>
16
        <span class="filteraction" id="filteraction_on"> <a href="#" onclick="$('#filters').show();$('.filteraction').toggle();">[+]</a></span>
15
	<input value="Submit" class="submit" type="submit" /> <a href="/cgi-bin/koha/acqui/histsearch.pl">Advanced Search</a>
17
	<input value="Submit" class="submit" type="submit" /> <a href="/cgi-bin/koha/acqui/histsearch.pl">Advanced Search</a>
18
    <p id="filters" style="display:none">
19
      <label for="basket">Basket: </label><input type="text" name="basket" id="basket">
20
      <label for="booksellerinvoicenumber">Invoice No.: </label><input type="text" name="booksellerinvoicenumber" id="booksellerinvoicenumber">
21
    </p>
16
	</form>
22
	</form>
17
	</div>	
23
	</div>	
18
			<ul>
24
			<ul id="tabtriggers">
19
			<li><a href="/cgi-bin/koha/acqui/booksellers.pl#supplier_search">Vendor Search</a></li>
25
			<li><a href="/cgi-bin/koha/acqui/booksellers.pl#supplier_search">Vendor Search</a></li>
20
			<li><a href="/cgi-bin/koha/acqui/histsearch.pl#orders_search">Orders Search</a></li>
26
			<li><a href="/cgi-bin/koha/acqui/histsearch.pl#orders_search">Orders Search</a></li>
21
			</ul>	
27
			</ul>	
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt (+2 lines)
Lines 22-27 Link Here
22
		<li><label for="title">Title: </label> <input type="text" name="title" id="title" value="[% title %]" /></li>
22
		<li><label for="title">Title: </label> <input type="text" name="title" id="title" value="[% title %]" /></li>
23
		<li><label for="author">Author: </label> <input type="text" name="author" id="author" value="[% author %]" /></li>
23
		<li><label for="author">Author: </label> <input type="text" name="author" id="author" value="[% author %]" /></li>
24
		<li><label for="name">Vendor: </label> <input type="text" name="name" id="name" value="[% name %]" /></li>
24
		<li><label for="name">Vendor: </label> <input type="text" name="name" id="name" value="[% name %]" /></li>
25
		<li><label for="basket">Basket: </label> <input type="text" name="basket" id="basket" value="[% basket %]" /></li>
26
		<li><label for="booksellerinvoicenumber ">Bookseller Invoice No: </label> <input type="text" name="booksellerinvoicenumber" id="booksellerinvoicenumber" value="[% booksellerinvoicenumber %]" /></li>
25
		<li><label for="from">From: </label> 
27
		<li><label for="from">From: </label> 
26
			<input type="text" size="10" id="from" name="from" value="[% from_placed_on %]" />
28
			<input type="text" size="10" id="from" name="from" value="[% from_placed_on %]" />
27
			<img src="[% themelang %]/lib/calendar/cal.gif" id="openCalendarFrom" style="cursor: pointer;" alt="Show Calendar" />
29
			<img src="[% themelang %]/lib/calendar/cal.gif" id="openCalendarFrom" style="cursor: pointer;" alt="Show Calendar" />
(-)a/t/db_dependent/lib/KohaTest.pm (-4 / +2 lines)
Lines 201-208 sub startup_15_truncate_tables : Test( startup => 1 ) { Link Here
201
                              ethnicity
201
                              ethnicity
202
                              issues
202
                              issues
203
                              issuingrules
203
                              issuingrules
204
                              labels
205
                              labels_profile
206
                              matchchecks
204
                              matchchecks
207
                              notifys
205
                              notifys
208
                              nozebra
206
                              nozebra
Lines 268-275 we need a bookfund for many of the tests. This currently uses one that Link Here
268
is in the skeleton database.  free to use this one, or insert your
266
is in the skeleton database.  free to use this one, or insert your
269
own.
267
own.
270
268
271
=cut
272
273
sub startup_22_add_bookfund : Test(startup => 2) {
269
sub startup_22_add_bookfund : Test(startup => 2) {
274
    my $self = shift;
270
    my $self = shift;
275
271
Lines 283-288 sub startup_22_add_bookfund : Test(startup => 2) { Link Here
283
    return;
279
    return;
284
}
280
}
285
281
282
=cut
283
286
=head2 startup_24_add_branch
284
=head2 startup_24_add_branch
287
285
288
=cut
286
=cut
(-)a/t/db_dependent/lib/KohaTest/Acquisition.pm (-22 / +16 lines)
Lines 7-12 use warnings; Link Here
7
use Test::More;
7
use Test::More;
8
8
9
use C4::Acquisition;
9
use C4::Acquisition;
10
use C4::Budgets;
10
use C4::Context;
11
use C4::Context;
11
use C4::Members;
12
use C4::Members;
12
use Time::localtime;
13
use Time::localtime;
Lines 25-31 sub methods : Test( 1 ) { Link Here
25
                       GetOrder 
26
                       GetOrder 
26
                       NewOrder 
27
                       NewOrder 
27
                       ModOrder 
28
                       ModOrder 
28
                       ModOrderBiblioNumber 
29
                       ModReceiveOrder 
29
                       ModReceiveOrder 
30
                       SearchOrder 
30
                       SearchOrder 
31
                       DelOrder 
31
                       DelOrder 
Lines 71-97 sub create_new_basket { Link Here
71
    $self->add_biblios( add_items => 1 );
71
    $self->add_biblios( add_items => 1 );
72
    ok( scalar @{$self->{'biblios'}} > 0, 'we have added at least one biblio' );
72
    ok( scalar @{$self->{'biblios'}} > 0, 'we have added at least one biblio' );
73
73
74
    my ( $basketno, $ordernumber ) = NewOrder( undef, # $basketno,
74
    my $rand = int(rand(10000));
75
                                          $self->{'biblios'}[0], # $bibnum,
75
    my $basketno = NewBasket( $self->{'booksellerid'}, $param{'authorizedby'},  "Basket $rand");
76
                                          undef, # $title,
76
#             $basketnote, $basketbooksellernote, $basketcontractnumber );
77
                                          1, # $quantity,
77
#   The following keys are used: "biblionumber", "title", "basketno", "quantity", "notes", "biblioitemnumber", "rrp", "ecost", "gst", "unitprice", "subscription", "sort1", "sort2", "booksellerinvoicenumber", "listprice", "budgetdate", "purchaseordernumber", "branchcode", "booksellerinvoicenumber", "bookfundid".
78
                                          undef, # $listprice,
78
    my $budget_id = AddBudget( { budget_name => "Budget $rand" } );
79
                                          $self->{'booksellerid'}, # $booksellerid,
79
    my ( undef, $ordernumber ) = NewOrder( {
80
                                          $param{'authorizedby'}, # $authorisedby,
80
            basketno => $basketno,
81
                                          undef, # $notes,
81
            budget_id => $budget_id,
82
                                          $self->{'bookfundid'},     # $bookfund,
82
            biblionumber => $self->{'biblios'}[0],
83
                                          undef, # $bibitemnum,
83
            quantity => 1,
84
                                          1, # $rrp,
84
            bookfundid => $self->{'bookfundid'},
85
                                          1, # $ecost,
85
            rrp => 1,
86
                                          undef, # $gst,
86
            ecost => 1,
87
                                          undef, # $budget,
87
            booksellerinvoicenumber => $param{'invoice'},
88
                                          undef, # $cost,
88
        } );
89
                                          undef, # $sub,
90
                                          $param{'invoice'}, # $invoice,
91
                                          undef, # $sort1,
92
                                          undef, # $sort2,
93
                                          undef, # $purchaseorder
94
                                     );
95
    ok( $basketno, "my basket number is $basketno" );
89
    ok( $basketno, "my basket number is $basketno" );
96
    ok( $ordernumber,   "my order number is $ordernumber" );
90
    ok( $ordernumber,   "my order number is $ordernumber" );
97
    
91
    
(-)a/t/db_dependent/lib/KohaTest/Acquisition/GetHistory.pm (-14 / +37 lines)
Lines 38-59 sub no_history : Test( 4 ) { Link Here
38
38
39
=cut
39
=cut
40
40
41
sub one_order : Test( 50 ) {
41
my $INVOICE = "1234-56 AB";
42
sub one_order : Test( 55 ) {
42
    my $self = shift;
43
    my $self = shift;
43
    
44
    
44
    my ( $basketno, $ordernumber ) = $self->create_new_basket();
45
    my ( $basketno, $ordernumber ) = $self->create_new_basket(invoice => $INVOICE);
45
    ok( $basketno, "basketno is $basketno" );
46
    ok( $basketno, "basketno is $basketno" );
46
    ok( $ordernumber, "ordernumber is $ordernumber" );
47
    ok( $ordernumber, "ordernumber is $ordernumber" );
47
48
48
    # No arguments fetches no history.
49
    # No arguments fetches no history.
49
    {
50
    {
50
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory();
51
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = eval { GetHistory() };
51
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
52
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
52
        
53
        
53
        is( scalar @$order_loop, 0, 'order_loop is empty' );
54
        is( $order_loop, undef, 'order_loop is empty' );
54
        is( $total_qty,          0, 'total_qty' );
55
        is( $total_price,        0, 'total_price' );
56
        is( $total_qtyreceived,  0, 'total_qtyreceived' );
57
    }
55
    }
58
56
59
    my $bibliodata = GetBiblioData( $self->{'biblios'}[0] );
57
    my $bibliodata = GetBiblioData( $self->{'biblios'}[0] );
Lines 62-68 sub one_order : Test( 50 ) { Link Here
62
    
60
    
63
    # searching by title should find it.
61
    # searching by title should find it.
64
    {
62
    {
65
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( $bibliodata->{'title'} );
63
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( title => $bibliodata->{'title'} );
66
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
64
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
67
    
65
    
68
        is( scalar @$order_loop, 1, 'order_loop searched by title' );
66
        is( scalar @$order_loop, 1, 'order_loop searched by title' );
Lines 73-81 sub one_order : Test( 50 ) { Link Here
73
        # diag( Data::Dumper->Dump( [ $order_loop ], [ 'order_loop' ] ) );
71
        # diag( Data::Dumper->Dump( [ $order_loop ], [ 'order_loop' ] ) );
74
    }
72
    }
75
73
74
    # searching by basket number
75
    {
76
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( basket => $basketno );
77
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
78
    
79
        is( scalar @$order_loop, 1, 'order_loop searched by basket no' );
80
        is( $total_qty,          1, 'total_qty searched by basket no' );
81
        is( $total_price,        1, 'total_price searched by basket no' );
82
        is( $total_qtyreceived,  0, 'total_qtyreceived searched by basket no' );
83
84
        # diag( Data::Dumper->Dump( [ $order_loop ], [ 'order_loop' ] ) );
85
    }
86
87
    # searching by invoice number
88
    {
89
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( booksellerinvoicenumber  => $INVOICE );
90
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
91
    
92
        is( scalar @$order_loop, 1, 'order_loop searched by invoice no' );
93
        is( $total_qty,          1, 'total_qty searched by invoice no' );
94
        is( $total_price,        1, 'total_price searched by invoice no' );
95
        is( $total_qtyreceived,  0, 'total_qtyreceived searched by invoice no' );
96
97
        # diag( Data::Dumper->Dump( [ $order_loop ], [ 'order_loop' ] ) );
98
    }
99
76
    # searching by author
100
    # searching by author
77
    {
101
    {
78
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( undef, $bibliodata->{'author'} );
102
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( author => $bibliodata->{'author'} );
79
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
103
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
80
    
104
    
81
        is( scalar @$order_loop, 1, 'order_loop searched by author' );
105
        is( scalar @$order_loop, 1, 'order_loop searched by author' );
Lines 92-98 sub one_order : Test( 50 ) { Link Here
92
        ok( $bookseller->{'name'}, 'bookseller name' )
116
        ok( $bookseller->{'name'}, 'bookseller name' )
93
          or diag( Data::Dumper->Dump( [ $bookseller ], [ 'bookseller' ] ) );
117
          or diag( Data::Dumper->Dump( [ $bookseller ], [ 'bookseller' ] ) );
94
        
118
        
95
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( undef, undef, $bookseller->{'name'} );
119
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( name => $bookseller->{'name'} );
96
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
120
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
97
    
121
    
98
        is( scalar @$order_loop, 1, 'order_loop searched by name' );
122
        is( scalar @$order_loop, 1, 'order_loop searched by name' );
Lines 106-112 sub one_order : Test( 50 ) { Link Here
106
        my $tomorrow = $self->tomorrow();
130
        my $tomorrow = $self->tomorrow();
107
        # diag( "tomorrow is $tomorrow" );
131
        # diag( "tomorrow is $tomorrow" );
108
132
109
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( undef, undef, undef, undef, $tomorrow );
133
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( to_placed_on =>  $tomorrow );
110
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
134
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
111
    
135
    
112
        is( scalar @$order_loop, 1, 'order_loop searched by to_date' );
136
        is( scalar @$order_loop, 1, 'order_loop searched by to_date' );
Lines 120-126 sub one_order : Test( 50 ) { Link Here
120
        my $yesterday = $self->yesterday();
144
        my $yesterday = $self->yesterday();
121
        # diag( "yesterday was $yesterday" );
145
        # diag( "yesterday was $yesterday" );
122
    
146
    
123
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( undef, undef, undef, $yesterday );
147
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( from_placed_on =>  $yesterday );
124
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
148
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
125
    
149
    
126
        is( scalar @$order_loop, 1, 'order_loop searched by from_date' );
150
        is( scalar @$order_loop, 1, 'order_loop searched by from_date' );
Lines 134-140 sub one_order : Test( 50 ) { Link Here
134
158
135
    # just search by title here, we need to search by something.
159
    # just search by title here, we need to search by something.
136
    {
160
    {
137
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( $bibliodata->{'title'} );
161
        my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( title => $bibliodata->{'title'} );
138
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
162
        # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
139
    
163
    
140
        is( scalar @$order_loop, 1, 'order_loop searched by title' );
164
        is( scalar @$order_loop, 1, 'order_loop searched by title' );
141
- 

Return to bug 6721