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

(-)a/t/db_dependent/Overdues.t (-1 / +80 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
5
use C4::Members;
6
use C4::Biblio;
7
use C4::Items;
8
9
use Test::More tests => 3;
10
11
BEGIN {
12
    use_ok('C4::Overdues');
13
}
14
15
my $dbh = C4::Context->dbh;
16
17
# Start transaction
18
$dbh->{AutoCommit} = 0;
19
$dbh->{RaiseError} = 1;
20
21
#Populate database
22
my $biblio = MARC::Record->new();
23
my $title = 'Title to add';
24
25
$biblio->append_fields(
26
    MARC::Field->new('100', ' ', ' ', a => 'Anonymous'),
27
    MARC::Field->new('245', ' ', ' ', a => $title),
28
);
29
my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, '');
30
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem(
31
    {
32
        homebranch       => 'CPL',
33
        holdingbranch    => 'CPL',
34
        barcode          => 'T000001',
35
    },
36
    $biblionumber
37
);
38
my ( $item_bibnum2, $item_bibitemnum2, $itemnumber2 ) = AddItem(
39
    {
40
        homebranch       => 'CPL',
41
        holdingbranch    => 'CPL',
42
        barcode          => 'T000002',
43
    },
44
    $biblionumber
45
);
46
47
my $borrowernumber = AddMember(
48
    firstname =>  'my firstname',
49
    surname => 'my surname',
50
    categorycode => 'S',
51
    branchcode => 'CPL',
52
);
53
54
my $insertdb = q/
55
    INSERT INTO accountlines (
56
        borrowernumber, itemnumber, amount,
57
        accounttype, amountoutstanding, timestamp )
58
    VALUES ( ?, ?, ?, ?, ?, CURRENT_TIMESTAMP )/;
59
my @data = (
60
            [$borrowernumber, $itemnumber, 123.50, 'F', 123.45],
61
            [$borrowernumber, $itemnumber, 12.34, 'FU', 123.45],
62
            [$borrowernumber, $itemnumber, 123.45, 'Rent', 12.34],
63
            [$borrowernumber, $itemnumber, 567.89, 'F', 89.01],
64
            [$borrowernumber, $itemnumber2, 543.21, 'F', 543.21],
65
            );
66
67
my $sth = $dbh->prepare($insertdb);
68
foreach my $loop (@data) {
69
    $sth->execute(@$loop);
70
}
71
72
ok(GetItemCharges($itemnumber, $borrowernumber) == 348.25, "GetItemCharges returns all outstanding charges for item");
73
74
my $anotheritemnumber = $itemnumber + 999999;
75
my $anotherborrowernumber = $borrowernumber + 999999;
76
ok(GetItemCharges($anotheritemnumber, $anotherborrowernumber) == 0, "There's no charges for item");
77
78
79
$dbh->rollback;
80

Return to bug 9481