From b9ba7af711fedce245bcad4761ff274b276004c1 Mon Sep 17 00:00:00 2001 From: Alex Arnaud Date: Wed, 11 May 2016 16:57:11 +0200 Subject: [PATCH] Bug 16461 - Add branch and barcode in fine description for overdue Signed-off-by: Joy Nelson --- C4/Overdues.pm | 9 +++-- t/db_dependent/Circulation.t | 75 +++++++++++++++++++++++++++++------------- 2 files changed, 59 insertions(+), 25 deletions(-) diff --git a/C4/Overdues.pm b/C4/Overdues.pm index 3f0c32d..ea1735e 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -594,14 +594,17 @@ sub UpdateFine { } else { if ( $amount ) { # Don't add new fines with an amount of 0 my $sth4 = $dbh->prepare( - "SELECT title FROM biblio LEFT JOIN items ON biblio.biblionumber=items.biblionumber WHERE items.itemnumber=?" + "SELECT title,holdingbranch,barcode FROM biblio LEFT JOIN items ON biblio.biblionumber=items.biblionumber WHERE items.itemnumber=?" ); $sth4->execute($itemnum); - my $title = $sth4->fetchrow; + my ($title,$holdingbranch,$barcode) = $sth4->fetchrow; my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber); - my $desc = ( $type ? "$type " : '' ) . "$title $due"; # FIXEDME, avoid whitespace prefix on empty $type + my $desc = ( $type ? "$type " : '' ) . "$title" + . ( $holdingbranch ? " Branch:$holdingbranch" : '') + . ( $barcode ? " Barcode:$barcode " : '') + . ( $due ? " Due:$due" : ''); # FIXEDME, avoid whitespace prefix on empty $type my $accountline = Koha::Account::Line->new( { diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index cfee3e2..7894e9f 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -53,6 +53,10 @@ my $library = $builder->build({ my $library2 = $builder->build({ source => 'Branch', }); +my $category = $builder->build({ + source => 'Category', +}); +my $categorycode = $category->{categorycode}; my $CircControl = C4::Context->preference('CircControl'); my $HomeOrHoldingBranch = C4::Context->preference('HomeOrHoldingBranch'); @@ -185,7 +189,7 @@ my $sth = C4::Context->dbh->prepare("SELECT COUNT(*) FROM accountlines WHERE amo $sth->execute(); my ( $original_count ) = $sth->fetchrow_array(); -C4::Context->dbh->do("INSERT INTO borrowers ( cardnumber, surname, firstname, categorycode, branchcode ) VALUES ( '99999999999', 'Hall', 'Kyle', 'S', ? )", undef, $library2->{branchcode} ); +C4::Context->dbh->do("INSERT INTO borrowers ( cardnumber, surname, firstname, categorycode, branchcode ) VALUES ( '99999999999', 'Hall', 'Kyle', ?, ? )", undef, $categorycode, $library2->{branchcode} ); C4::Circulation::ProcessOfflinePayment({ cardnumber => '99999999999', amount => '123.45' }); @@ -203,10 +207,18 @@ C4::Context->dbh->do("DELETE FROM accountlines"); # Generate test biblio my $biblio = MARC::Record->new(); my $title = 'Silence in the library'; - $biblio->append_fields( - MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), - MARC::Field->new('245', ' ', ' ', a => $title), - ); + + if (C4::Context->preference('marcflavour') eq 'UNIMARC') { + $biblio->append_fields( + MARC::Field->new('200', ' ', ' ', f => 'Moffat, Steven'), + MARC::Field->new('200', ' ', ' ', a => $title), + ); + } else { + $biblio->append_fields( + MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), + MARC::Field->new('245', ' ', ' ', a => $title), + ); + } my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, ''); @@ -252,28 +264,28 @@ C4::Context->dbh->do("DELETE FROM accountlines"); my %renewing_borrower_data = ( firstname => 'John', surname => 'Renewal', - categorycode => 'S', + categorycode => $categorycode, branchcode => $branch, ); my %reserving_borrower_data = ( firstname => 'Katrin', surname => 'Reservation', - categorycode => 'S', + categorycode => $categorycode, branchcode => $branch, ); my %hold_waiting_borrower_data = ( firstname => 'Kyle', surname => 'Reservation', - categorycode => 'S', + categorycode => $categorycode, branchcode => $branch, ); my %restricted_borrower_data = ( firstname => 'Alice', surname => 'Reservation', - categorycode => 'S', + categorycode => $categorycode, debarred => '3228-01-01', branchcode => $branch, ); @@ -566,6 +578,11 @@ C4::Context->dbh->do("DELETE FROM accountlines"); undef, $renewing_borrower->{borrowernumber} ); + my $accountlines = Koha::Account::Lines->search({itemnumber => $itemnumber, borrowernumber => $renewing_borrower->{borrowernumber}, amount => '15.00'}); + my $accouline = $accountlines->next(); + my $itembranch = $item->get_column('holdingbranch'); + ok($accouline->description =~ /Silence in the library Branch:$itembranch Barcode:R00000342/); + ok( $total_due == 12, 'Borrower only charged replacement fee with both WhenLostForgiveFine and WhenLostChargeReplacementFee enabled' ); C4::Context->dbh->do("DELETE FROM accountlines"); @@ -621,10 +638,17 @@ C4::Context->dbh->do("DELETE FROM accountlines"); #Create another record my $biblio2 = MARC::Record->new(); my $title2 = 'Something is worng here'; - $biblio2->append_fields( - MARC::Field->new('100', ' ', ' ', a => 'Anonymous'), - MARC::Field->new('245', ' ', ' ', a => $title2), - ); + if (C4::Context->preference('marcflavour') eq 'UNIMARC') { + $biblio2->append_fields( + MARC::Field->new('200', ' ', ' ', f => 'Anonymous'), + MARC::Field->new('200', ' ', ' ', a => $title2), + ); + } else { + $biblio2->append_fields( + MARC::Field->new('100', ' ', ' ', a => 'Anonymous'), + MARC::Field->new('245', ' ', ' ', a => $title2), + ); + } my ($biblionumber2, $biblioitemnumber2) = AddBiblio($biblio2, ''); #Create third item @@ -641,7 +665,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); my %a_borrower_data = ( firstname => 'Fridolyn', surname => 'SOMERS', - categorycode => 'S', + categorycode => $categorycode, branchcode => $branch, ); @@ -720,7 +744,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); my %a_borrower_data = ( firstname => 'Kyle', surname => 'Hall', - categorycode => 'S', + categorycode => $categorycode, branchcode => $branch, ); @@ -783,13 +807,13 @@ C4::Context->dbh->do("DELETE FROM accountlines"); my $borrowernumber1 = AddMember( firstname => 'Kyle', surname => 'Hall', - categorycode => 'S', + categorycode => $categorycode, branchcode => $library2->{branchcode}, ); my $borrowernumber2 = AddMember( firstname => 'Chelsea', surname => 'Hall', - categorycode => 'S', + categorycode => $categorycode, branchcode => $library2->{branchcode}, ); @@ -841,10 +865,17 @@ C4::Context->dbh->do("DELETE FROM accountlines"); #Create another record my $biblio = MARC::Record->new(); - $biblio->append_fields( - MARC::Field->new('100', ' ', ' ', a => 'Anonymous'), - MARC::Field->new('245', ' ', ' ', a => 'A title'), - ); + if (C4::Context->preference('marcflavour') eq 'UNIMARC') { + $biblio->append_fields( + MARC::Field->new('200', ' ', ' ', f => 'Anonymous'), + MARC::Field->new('200', ' ', ' ', a => 'A title'), + ); + } else { + $biblio->append_fields( + MARC::Field->new('100', ' ', ' ', a => 'Anonymous'), + MARC::Field->new('245', ' ', ' ', a => 'A title'), + ); + } my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, ''); my (undef, undef, $itemnumber) = AddItem( @@ -859,7 +890,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); my $borrowernumber = AddMember( firstname => 'fn', surname => 'dn', - categorycode => 'S', + categorycode => $categorycode, branchcode => $branch, ); -- 1.7.10.4