Bugzilla – Attachment 67944 Details for
Bug 14826
Store account offsets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14826: Add unit tests for _FixAccountForLostAndReturned and _FixOverduesOnReturn
Bug-14826-Add-unit-tests-for-FixAccountForLostAndR.patch (text/plain), 5.90 KB, created by
Kyle M Hall (khall)
on 2017-10-11 11:27:10 UTC
(
hide
)
Description:
Bug 14826: Add unit tests for _FixAccountForLostAndReturned and _FixOverduesOnReturn
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2017-10-11 11:27:10 UTC
Size:
5.90 KB
patch
obsolete
>From b58edd985773ade83675fef044d5b042c85619ae Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 6 Jun 2017 09:33:46 -0400 >Subject: [PATCH] Bug 14826: Add unit tests for _FixAccountForLostAndReturned > and _FixOverduesOnReturn > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Circulation.t | 132 +++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 128 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 93d3f68..b893aef 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 103; >+use Test::More tests => 105; > > use DateTime; > >@@ -50,6 +50,7 @@ $dbh->{RaiseError} = 1; > > # Start with a clean slate > $dbh->do('DELETE FROM issues'); >+$dbh->do('DELETE FROM borrowers'); > > my $library = $builder->build({ > source => 'Branch', >@@ -259,9 +260,6 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > $biblionumber > ); > >- >- >- > # Create borrowers > my %renewing_borrower_data = ( > firstname => 'John', >@@ -1780,7 +1778,133 @@ subtest 'AddReturn | is_overdue' => sub { > AddReturn( $item->{barcode}, $library->{branchcode}, undef, 1, undef, $five_days_ago ); > is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue in dropbox mode' ); # FIXME? This is weird, the FU fine is created ( _CalculateAndUpdateFine > C4::Overdues::UpdateFine ) then remove later (in _FixOverduesOnReturn). Looks like it is a feature > Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; >+}; >+ >+subtest '_FixAccountForLostAndReturned' => sub { >+ plan tests => 2; >+ >+ # Generate test biblio >+ my $biblio = MARC::Record->new(); >+ my $title = 'Koha for Dummies'; >+ $biblio->append_fields( >+ MARC::Field->new( '100', ' ', ' ', a => 'Hall, Daria' ), >+ MARC::Field->new( '245', ' ', ' ', a => $title ), >+ ); >+ >+ my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); >+ >+ my $barcode = 'KD123456789'; >+ my $branchcode = $library2->{branchcode}; >+ >+ my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( >+ { >+ homebranch => $branchcode, >+ holdingbranch => $branchcode, >+ barcode => $barcode, >+ replacementprice => 99.00, >+ itype => $itemtype >+ }, >+ $biblionumber >+ ); >+ >+ my $patron = $builder->build( { source => 'Borrower' } ); >+ >+ my $accountline = Koha::Account::Line->new( >+ { >+ borrowernumber => $patron->{borrowernumber}, >+ accounttype => 'L', >+ itemnumber => $itemnumber, >+ amount => 99.00, >+ amountoutstanding => 99.00, >+ } >+ )->store(); >+ >+ C4::Circulation::_FixAccountForLostAndReturned( $itemnumber, $patron->{borrowernumber} ); >+ >+ $accountline->_result()->discard_changes(); >+ >+ is( $accountline->amountoutstanding, '0.000000', 'Lost fee has no outstanding amount' ); >+ is( $accountline->accounttype, 'LR', 'Lost fee now has account type of LR ( Lost Returned )'); >+}; >+ >+subtest '_FixOverduesOnReturn' => sub { >+ plan tests => 6; >+ >+ # Generate test biblio >+ my $biblio = MARC::Record->new(); >+ my $title = 'Koha for Dummies'; >+ $biblio->append_fields( >+ MARC::Field->new( '100', ' ', ' ', a => 'Hall, Kylie' ), >+ MARC::Field->new( '245', ' ', ' ', a => $title ), >+ ); >+ >+ my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); >+ >+ my $barcode = 'KD987654321'; >+ my $branchcode = $library2->{branchcode}; >+ >+ my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( >+ { >+ homebranch => $branchcode, >+ holdingbranch => $branchcode, >+ barcode => $barcode, >+ replacementprice => 99.00, >+ itype => $itemtype >+ }, >+ $biblionumber >+ ); >+ >+ my $patron = $builder->build( { source => 'Borrower' } ); >+ >+ ## Start with basic call, should just close out the open fine >+ my $accountline = Koha::Account::Line->new( >+ { >+ borrowernumber => $patron->{borrowernumber}, >+ accounttype => 'FU', >+ itemnumber => $itemnumber, >+ amount => 99.00, >+ amountoutstanding => 99.00, >+ lastincrement => 9.00, >+ } >+ )->store(); >+ >+ C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $itemnumber ); >+ >+ $accountline->_result()->discard_changes(); >+ >+ is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); >+ is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); >+ >+ >+ ## Run again, with exemptfine enabled >+ $accountline->set( >+ { >+ accounttype => 'FU', >+ amountoutstanding => 99.00, >+ } >+ )->store(); >+ >+ C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $itemnumber, 1 ); >+ >+ $accountline->_result()->discard_changes(); >+ >+ is( $accountline->amountoutstanding, '0.000000', 'Fine has been reduced to 0' ); >+ is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )'); >+ >+ ## Run again, with dropbox mode enabled >+ $accountline->set( >+ { >+ accounttype => 'FU', >+ amountoutstanding => 99.00, >+ } >+ )->store(); >+ >+ C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $itemnumber, 0, 1 ); >+ >+ $accountline->_result()->discard_changes(); > >+ is( $accountline->amountoutstanding, '90.000000', 'Fine has been reduced to 90' ); >+ is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); > }; > > subtest 'Set waiting flag' => sub { >-- >2.10.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14826
:
53318
|
53319
|
53320
|
53321
|
53324
|
53326
|
53602
|
53603
|
53604
|
53605
|
53606
|
53607
|
59254
|
59255
|
59256
|
59257
|
59258
|
60270
|
60271
|
60272
|
60273
|
60274
|
60275
|
60276
|
60277
|
60278
|
60439
|
60440
|
60441
|
60442
|
60443
|
60444
|
60445
|
60446
|
64051
|
64052
|
64053
|
64054
|
64055
|
64056
|
64057
|
64058
|
64059
|
64217
|
64220
|
64222
|
64223
|
64224
|
64225
|
64226
|
64227
|
64228
|
65459
|
65460
|
65461
|
65462
|
65463
|
65464
|
65465
|
65466
|
65467
|
65642
|
65643
|
65644
|
65645
|
65646
|
65647
|
65648
|
65649
|
65650
|
65651
|
65652
|
66387
|
66388
|
66389
|
66390
|
66391
|
66392
|
66393
|
66394
|
66395
|
66396
|
66397
|
66716
|
67453
|
67454
|
67455
|
67456
|
67457
|
67458
|
67459
|
67460
|
67461
|
67462
|
67463
|
67464
|
67465
|
67936
|
67937
|
67938
|
67939
|
67940
|
67941
|
67942
|
67943
|
67944
|
67945
|
67946
|
67947
|
67948
|
67949
|
68018
|
68019
|
68020
|
68021
|
68022
|
68023
|
68024
|
68025
|
68026
|
68027
|
68028
|
68029
|
68030
|
68031
|
68032
|
68334
|
68383