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

(-)a/C4/Overdues.pm (-3 / +5 lines)
Lines 595-608 sub UpdateFine { Link Here
595
    } else {
595
    } else {
596
        if ( $amount ) { # Don't add new fines with an amount of 0
596
        if ( $amount ) { # Don't add new fines with an amount of 0
597
            my $sth4 = $dbh->prepare(
597
            my $sth4 = $dbh->prepare(
598
                "SELECT title FROM biblio LEFT JOIN items ON biblio.biblionumber=items.biblionumber WHERE items.itemnumber=?"
598
                "SELECT title,holdingbranch,barcode FROM biblio LEFT JOIN items ON biblio.biblionumber=items.biblionumber WHERE items.itemnumber=?"
599
            );
599
            );
600
            $sth4->execute($itemnum);
600
            $sth4->execute($itemnum);
601
            my $title = $sth4->fetchrow;
601
            my ($title,$holdingbranch,$barcode) = $sth4->fetchrow;
602
602
603
            my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
603
            my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
604
604
605
            my $desc = ( $type ? "$type " : '' ) . "$title $due";    # FIXEDME, avoid whitespace prefix on empty $type
605
            my $desc = ( $type ? "$type " : '' ) . "$title $due";    # FIXEDME, avoid whitespace prefix on empty $type;
606
606
607
            my $accountline = Koha::Account::Line->new(
607
            my $accountline = Koha::Account::Line->new(
608
                {
608
                {
Lines 616-621 sub UpdateFine { Link Here
616
                    lastincrement     => $amount,
616
                    lastincrement     => $amount,
617
                    accountno         => $nextaccntno,
617
                    accountno         => $nextaccntno,
618
                    issue_id          => $issue_id,
618
                    issue_id          => $issue_id,
619
                    barcode           => $barcode,
620
                    branchcode        => $holdingbranch
619
                }
621
                }
620
            )->store();
622
            )->store();
621
        }
623
        }
(-)a/installer/data/mysql/atomicupdate/bug_16461-Add-branch-and-barcode-columns-in-accountlines-table.sql (+4 lines)
Line 0 Link Here
1
ALTER TABLE accountlines ADD barcode varchar(20) NULL DEFAULT NULL;
2
ALTER TABLE accountlines ADD CONSTRAINT accountlines_ibfk_3 FOREIGN KEY (barcode) REFERENCES items (barcode) ON DELETE SET NULL ON UPDATE SET NULL;
3
ALTER TABLE accountlines ADD branchcode varchar(10) NULL DEFAULT NULL;
4
ALTER TABLE accountlines ADD CONSTRAINT accountlines_ibfk_4 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE SET NULL;
(-)a/installer/data/mysql/kohastructure.sql (-1 / +5 lines)
Lines 2703-2714 CREATE TABLE `accountlines` ( Link Here
2703
  `notify_level` int(2) NOT NULL default 0,
2703
  `notify_level` int(2) NOT NULL default 0,
2704
  `note` text NULL default NULL,
2704
  `note` text NULL default NULL,
2705
  `manager_id` int(11) NULL,
2705
  `manager_id` int(11) NULL,
2706
  `barcode` varchar(20) NULL default '',
2707
  `branchcode` varchar(10) NULL default '',
2706
  PRIMARY KEY (`accountlines_id`),
2708
  PRIMARY KEY (`accountlines_id`),
2707
  KEY `acctsborridx` (`borrowernumber`),
2709
  KEY `acctsborridx` (`borrowernumber`),
2708
  KEY `timeidx` (`timestamp`),
2710
  KEY `timeidx` (`timestamp`),
2709
  KEY `itemnumber` (`itemnumber`),
2711
  KEY `itemnumber` (`itemnumber`),
2710
  CONSTRAINT `accountlines_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2712
  CONSTRAINT `accountlines_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2711
  CONSTRAINT `accountlines_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL
2713
  CONSTRAINT `accountlines_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL,
2714
  CONSTRAINT `accountlines_ibfk_3` FOREIGN KEY (`barcode`) REFERENCES `items` (`barcode`) ON DELETE SET NULL ON UPDATE SET NULL,
2715
  CONSTRAINT `accountlines_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE SET NULL
2712
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2716
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2713
2717
2714
--
2718
--
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt (+4 lines)
Lines 76-81 function enableCheckboxActions(){ Link Here
76
    <th>&nbsp;</th>
76
    <th>&nbsp;</th>
77
    <th>Fines &amp; charges</th>
77
    <th>Fines &amp; charges</th>
78
    <th>Description</th>
78
    <th>Description</th>
79
    <th>Barcode</th>
80
    <th>Library</th>
79
    <th>Payment note</th>
81
    <th>Payment note</th>
80
    <th>Account type</th>
82
    <th>Account type</th>
81
    <th>Notify id</th>
83
    <th>Notify id</th>
Lines 141-146 function enableCheckboxActions(){ Link Here
141
        [%- IF line.description %], [% line.description %][% END %]
143
        [%- IF line.description %], [% line.description %][% END %]
142
        [% IF line.title %]([% line.title %])[% END %]
144
        [% IF line.title %]([% line.title %])[% END %]
143
    </td>
145
    </td>
146
    <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=93&itemnumber=[% line.itemnumber %]">[% line.barcode %]</a></td>
147
    <td>[% Branches.GetName( line.branchcode ) %]</td>
144
    <td><input type="text" name="payment_note_[% line.accountlines_id %]" /></td>
148
    <td><input type="text" name="payment_note_[% line.accountlines_id %]" /></td>
145
    <td>[% line.accounttype %]</td>
149
    <td>[% line.accounttype %]</td>
146
    <td>[% line.notify_id %]</td>
150
    <td>[% line.notify_id %]</td>
(-)a/t/db_dependent/Circulation.t (-22 / +53 lines)
Lines 60-65 my $itemtype = $builder->build( Link Here
60
        value  => { notforloan => undef, rentalcharge => 0 }
60
        value  => { notforloan => undef, rentalcharge => 0 }
61
    }
61
    }
62
)->{itemtype};
62
)->{itemtype};
63
my $category = $builder->build({
64
    source => 'Category',
65
});
66
my $categorycode = $category->{categorycode};
63
67
64
my $CircControl = C4::Context->preference('CircControl');
68
my $CircControl = C4::Context->preference('CircControl');
65
my $HomeOrHoldingBranch = C4::Context->preference('HomeOrHoldingBranch');
69
my $HomeOrHoldingBranch = C4::Context->preference('HomeOrHoldingBranch');
Lines 192-198 my $sth = C4::Context->dbh->prepare("SELECT COUNT(*) FROM accountlines WHERE amo Link Here
192
$sth->execute();
196
$sth->execute();
193
my ( $original_count ) = $sth->fetchrow_array();
197
my ( $original_count ) = $sth->fetchrow_array();
194
198
195
C4::Context->dbh->do("INSERT INTO borrowers ( cardnumber, surname, firstname, categorycode, branchcode ) VALUES ( '99999999999', 'Hall', 'Kyle', 'S', ? )", undef, $library2->{branchcode} );
199
C4::Context->dbh->do("INSERT INTO borrowers ( cardnumber, surname, firstname, categorycode, branchcode ) VALUES ( '99999999999', 'Hall', 'Kyle', ?, ? )", undef, $categorycode, $library2->{branchcode} );
196
200
197
C4::Circulation::ProcessOfflinePayment({ cardnumber => '99999999999', amount => '123.45' });
201
C4::Circulation::ProcessOfflinePayment({ cardnumber => '99999999999', amount => '123.45' });
198
202
Lines 210-219 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
210
    # Generate test biblio
214
    # Generate test biblio
211
    my $biblio = MARC::Record->new();
215
    my $biblio = MARC::Record->new();
212
    my $title = 'Silence in the library';
216
    my $title = 'Silence in the library';
213
    $biblio->append_fields(
217
214
        MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'),
218
    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
215
        MARC::Field->new('245', ' ', ' ', a => $title),
219
        $biblio->append_fields(
216
    );
220
            MARC::Field->new('200', ' ', ' ', f => 'Moffat, Steven'),
221
            MARC::Field->new('200', ' ', ' ', a => $title),
222
        );
223
    } else {
224
        $biblio->append_fields(
225
            MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'),
226
            MARC::Field->new('245', ' ', ' ', a => $title),
227
        );
228
    }
217
229
218
    my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, '');
230
    my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, '');
219
231
Lines 262-289 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
262
    my %renewing_borrower_data = (
274
    my %renewing_borrower_data = (
263
        firstname =>  'John',
275
        firstname =>  'John',
264
        surname => 'Renewal',
276
        surname => 'Renewal',
265
        categorycode => 'S',
277
        categorycode => $categorycode,
266
        branchcode => $branch,
278
        branchcode => $branch,
267
    );
279
    );
268
280
269
    my %reserving_borrower_data = (
281
    my %reserving_borrower_data = (
270
        firstname =>  'Katrin',
282
        firstname =>  'Katrin',
271
        surname => 'Reservation',
283
        surname => 'Reservation',
272
        categorycode => 'S',
284
        categorycode => $categorycode,
273
        branchcode => $branch,
285
        branchcode => $branch,
274
    );
286
    );
275
287
276
    my %hold_waiting_borrower_data = (
288
    my %hold_waiting_borrower_data = (
277
        firstname =>  'Kyle',
289
        firstname =>  'Kyle',
278
        surname => 'Reservation',
290
        surname => 'Reservation',
279
        categorycode => 'S',
291
        categorycode => $categorycode,
280
        branchcode => $branch,
292
        branchcode => $branch,
281
    );
293
    );
282
294
283
    my %restricted_borrower_data = (
295
    my %restricted_borrower_data = (
284
        firstname =>  'Alice',
296
        firstname =>  'Alice',
285
        surname => 'Reservation',
297
        surname => 'Reservation',
286
        categorycode => 'S',
298
        categorycode => $categorycode,
287
        debarred => '3228-01-01',
299
        debarred => '3228-01-01',
288
        branchcode => $branch,
300
        branchcode => $branch,
289
    );
301
    );
Lines 674-679 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
674
        undef, $renewing_borrower->{borrowernumber}
686
        undef, $renewing_borrower->{borrowernumber}
675
    );
687
    );
676
688
689
    my $accountlines = Koha::Account::Lines->search({itemnumber => $itemnumber, borrowernumber => $renewing_borrower->{borrowernumber}, amount => '15.00'});
690
    my $accouline = $accountlines->next();
691
    my $itembranch = $item->get_column('holdingbranch');
692
    ok($accouline->description =~ /Silence in the library Branch:$itembranch Barcode:R00000342/);
693
677
    ok( $total_due == 12, 'Borrower only charged replacement fee with both WhenLostForgiveFine and WhenLostChargeReplacementFee enabled' );
694
    ok( $total_due == 12, 'Borrower only charged replacement fee with both WhenLostForgiveFine and WhenLostChargeReplacementFee enabled' );
678
695
679
    C4::Context->dbh->do("DELETE FROM accountlines");
696
    C4::Context->dbh->do("DELETE FROM accountlines");
Lines 728-737 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
728
    #Create another record
745
    #Create another record
729
    my $biblio2 = MARC::Record->new();
746
    my $biblio2 = MARC::Record->new();
730
    my $title2 = 'Something is worng here';
747
    my $title2 = 'Something is worng here';
731
    $biblio2->append_fields(
748
    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
732
        MARC::Field->new('100', ' ', ' ', a => 'Anonymous'),
749
        $biblio2->append_fields(
733
        MARC::Field->new('245', ' ', ' ', a => $title2),
750
            MARC::Field->new('200', ' ', ' ', f => 'Anonymous'),
734
    );
751
            MARC::Field->new('200', ' ', ' ', a => $title2),
752
        );
753
    } else {
754
        $biblio2->append_fields(
755
            MARC::Field->new('100', ' ', ' ', a => 'Anonymous'),
756
            MARC::Field->new('245', ' ', ' ', a => $title2),
757
        );
758
    }
735
    my ($biblionumber2, $biblioitemnumber2) = AddBiblio($biblio2, '');
759
    my ($biblionumber2, $biblioitemnumber2) = AddBiblio($biblio2, '');
736
760
737
    #Create third item
761
    #Create third item
Lines 749-755 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
749
    my %a_borrower_data = (
773
    my %a_borrower_data = (
750
        firstname =>  'Fridolyn',
774
        firstname =>  'Fridolyn',
751
        surname => 'SOMERS',
775
        surname => 'SOMERS',
752
        categorycode => 'S',
776
        categorycode => $categorycode,
753
        branchcode => $branch,
777
        branchcode => $branch,
754
    );
778
    );
755
779
Lines 829-835 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
829
    my %a_borrower_data = (
853
    my %a_borrower_data = (
830
        firstname =>  'Kyle',
854
        firstname =>  'Kyle',
831
        surname => 'Hall',
855
        surname => 'Hall',
832
        categorycode => 'S',
856
        categorycode => $categorycode,
833
        branchcode => $branch,
857
        branchcode => $branch,
834
    );
858
    );
835
859
Lines 895-907 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
895
    my $borrowernumber1 = AddMember(
919
    my $borrowernumber1 = AddMember(
896
        firstname    => 'Kyle',
920
        firstname    => 'Kyle',
897
        surname      => 'Hall',
921
        surname      => 'Hall',
898
        categorycode => 'S',
922
        categorycode => $categorycode,
899
        branchcode   => $library2->{branchcode},
923
        branchcode   => $library2->{branchcode},
900
    );
924
    );
901
    my $borrowernumber2 = AddMember(
925
    my $borrowernumber2 = AddMember(
902
        firstname    => 'Chelsea',
926
        firstname    => 'Chelsea',
903
        surname      => 'Hall',
927
        surname      => 'Hall',
904
        categorycode => 'S',
928
        categorycode => $categorycode,
905
        branchcode   => $library2->{branchcode},
929
        branchcode   => $library2->{branchcode},
906
    );
930
    );
907
931
Lines 953-962 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
953
977
954
    #Create another record
978
    #Create another record
955
    my $biblio = MARC::Record->new();
979
    my $biblio = MARC::Record->new();
956
    $biblio->append_fields(
980
    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
957
        MARC::Field->new('100', ' ', ' ', a => 'Anonymous'),
981
        $biblio->append_fields(
958
        MARC::Field->new('245', ' ', ' ', a => 'A title'),
982
            MARC::Field->new('200', ' ', ' ', f => 'Anonymous'),
959
    );
983
            MARC::Field->new('200', ' ', ' ', a => 'A title'),
984
        );
985
    } else {
986
        $biblio->append_fields(
987
            MARC::Field->new('100', ' ', ' ', a => 'Anonymous'),
988
            MARC::Field->new('245', ' ', ' ', a => 'A title'),
989
        );
990
    }
960
    my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, '');
991
    my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, '');
961
992
962
    my (undef, undef, $itemnumber) = AddItem(
993
    my (undef, undef, $itemnumber) = AddItem(
Lines 972-978 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
972
    my $borrowernumber = AddMember(
1003
    my $borrowernumber = AddMember(
973
        firstname =>  'fn',
1004
        firstname =>  'fn',
974
        surname => 'dn',
1005
        surname => 'dn',
975
        categorycode => 'S',
1006
        categorycode => $categorycode,
976
        branchcode => $branch,
1007
        branchcode => $branch,
977
    );
1008
    );
978
1009
(-)a/t/db_dependent/Circulation/UpdateFine.t (-1 / +94 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use C4::Circulation;
21
use C4::Overdues;
22
23
use t::lib::TestBuilder;
24
25
use Test::More tests => 4;
26
27
BEGIN {
28
    require_ok('C4::Circulation');
29
}
30
31
my $schema = Koha::Database->schema;
32
$schema->storage->txn_begin;
33
my $builder = t::lib::TestBuilder->new;
34
35
my $library = $builder->build({
36
    source => 'Branch',
37
});
38
C4::Context->_new_userenv('xxx');
39
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', '');
40
my $category = $builder->build({
41
    source => 'Category',
42
});
43
my $patron = $builder->build({
44
    source => 'Borrower',
45
    value  => {
46
        categorycode => $category->{categorycode},
47
        branchcode   => $library->{branchcode},
48
    },
49
});
50
my $biblio = $builder->build({
51
    source => 'Biblio',
52
    value  => {
53
        branchcode => $library->{branchcode},
54
    },
55
});
56
my $item = $builder->build({
57
    source => 'Item',
58
    value  => {
59
        biblionumber     => $biblio->{biblionumber},
60
        homebranch       => $library->{branchcode},
61
        holdingbranch    => $library->{branchcode},
62
        replacementprice => '5.00',
63
    },
64
});
65
66
my $issue = AddIssue(
67
    $patron,
68
    $item->{barcode},
69
    '2013-06-01',
70
    undef,
71
    '2013-05-01'
72
);
73
74
UpdateFine({
75
    issue_id        => $issue->id,
76
    itemnumber      => $item->{itemnumber},
77
    borrowernumber  => $patron->{borrowernumber},
78
    amount          => 10,
79
    type            => 'F',
80
    due             => '2013-06-01'
81
});
82
83
my $accountline = Koha::Account::Lines->search({
84
    borrowernumber  => $patron->{borrowernumber},
85
    issue_id        => $issue->id,
86
    itemnumber      => $item->{itemnumber},
87
})->next();
88
89
is($accountline->amount, '10.000000', 'Accountline amount should be 10');
90
is($accountline->barcode, $item->{barcode}, 'Accountline barcode should be as expeted');
91
is($accountline->branchcode, $item->{holdingbranch}, 'Accountline barcode should be as expeted');
92
93
94
$schema->storage->txn_rollback;

Return to bug 16461