Bug 14402: (QA followup) Add notes to usage text about --fees
authorKyle M Hall <kyle@bywatersolutions.com>
Tue, 15 Sep 2015 12:28:45 +0000 (08:28 -0400)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 9 Nov 2015 18:00:02 +0000 (15:00 -0300)
Added notes to usage in misc/cronjobs/cleanup_database.pl that
--fees DAYS requires DAYS to be greater than or equal to 1.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

misc/cronjobs/cleanup_database.pl
t/db_dependent/Accounts.t

index c019486..d6d18e2 100755 (executable)
@@ -64,6 +64,8 @@ Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu
                       of Z39.50 searches
    --fees DAYS        purge entries accountlines older than DAYS days, where
                       amountoutstanding is 0 or NULL.
+                      In the case of --feees, DAYS must be greater than
+                      or equal to 1.
                       WARNING: Fees and payments may not be deleted together.
                       This will not affect the account balance but may be
                       confusing to staff.
@@ -82,28 +84,23 @@ USAGE
     exit $_[0];
 }
 
-my (
-    $help,
-    $sessions,
-    $sess_days,
-    $verbose,
-    $zebraqueue_days,
-    $mail,
-    $purge_merged,
-    $pImport,
-    $pLogs,
-    $pSearchhistory,
-    $pZ3950,
-    $pListShareInvites,
-    $pDebarments,
-    $allDebarments,
-    $pExpSelfReg,
-    $pUnvSelfReg,
-    $fees_days
-    $help,   $sessions,          $sess_days, $verbose, $zebraqueue_days,
-    $mail,   $purge_merged,      $pImport,   $pLogs,   $pSearchhistory,
-    $pZ3950, $pListShareInvites, $pDebarments, $allDebarments,
-);
+my $help;
+my $sessions;
+my $sess_days;
+my $verbose;
+my $zebraqueue_days;
+my $mail;
+my $purge_merged;
+my $pImport;
+my $pLogs;
+my $pSearchhistory;
+my $pZ3950;
+my $pListShareInvites;
+my $pDebarments;
+my $allDebarments;
+my $pExpSelfReg;
+my $pUnvSelfReg;
+my $fees_days;
 
 GetOptions(
     'h|help'          => \$help,
index 052cf2a..5b9c764 100644 (file)
@@ -81,7 +81,7 @@ $context->mock( 'userenv', sub {
 # 1 => yesterday
 # etc.
 
-$sth = $dbh->prepare(
+my $sth = $dbh->prepare(
     "INSERT INTO accountlines (
          borrowernumber,
          amountoutstanding,
@@ -99,15 +99,17 @@ my @test_data = (
     { amount => 0     , days_ago => $days     , description =>'purge_zero_balance_fees should not delete 0 balance fees with date on threshold day'          , delete => 0 } ,
     { amount => 0     , days_ago => $days + 1 , description =>'purge_zero_balance_fees should delete 0 balance fees with date after threshold day'           , delete => 1 } ,
     { amount => undef , days_ago => $days + 1 , description =>'purge_zero_balance_fees should delete NULL balance fees with date after threshold day'        , delete => 1 } ,
-    { amount => 5     , days_ago => $days - 1 , description =>'purge_zero_balance_fees should not delete fees with postive amout owed before threshold day'  , delete => 0 } ,
-    { amount => 5     , days_ago => $days     , description =>'purge_zero_balance_fees should not delete fees with postive amout owed on threshold day'      , delete => 0 } ,
-    { amount => 5     , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with postive amout owed after threshold day'   , delete => 0 } ,
+    { amount => 5     , days_ago => $days - 1 , description =>'purge_zero_balance_fees should not delete fees with positive amout owed before threshold day'  , delete => 0 } ,
+    { amount => 5     , days_ago => $days     , description =>'purge_zero_balance_fees should not delete fees with positive amout owed on threshold day'      , delete => 0 } ,
+    { amount => 5     , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with positive amout owed after threshold day'   , delete => 0 } ,
     { amount => -5    , days_ago => $days - 1 , description =>'purge_zero_balance_fees should not delete fees with negative amout owed before threshold day' , delete => 0 } ,
     { amount => -5    , days_ago => $days     , description =>'purge_zero_balance_fees should not delete fees with negative amout owed on threshold day'     , delete => 0 } ,
     { amount => -5    , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with negative amout owed after threshold day'  , delete => 0 }
 );
 
-for my $data  ( @test_data ) {
+my $borrower = Koha::Borrower->new( { firstname => 'Test', surname => 'Patron', categorycode => 'PT', branchcode => 'MPL' } )->store();
+
+for my $data ( @test_data ) {
     $sth->execute($borrower->borrowernumber, $data->{amount}, $data->{days_ago}, $data->{description});
 }
 
@@ -132,6 +134,8 @@ for my $data  (@test_data) {
     is_delete_correct( $data->{delete}, $data->{description});
 }
 
+$dbh->do(q|DELETE FROM accountlines|);
+
 subtest "recordpayment() tests" => sub {
 
     plan tests => 10;