Bug 23805: Update 'FOR' to 'FORGIVEN' for consistency
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 14 Oct 2019 15:33:43 +0000 (16:33 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 24 Oct 2019 16:35:20 +0000 (17:35 +0100)
Signed-off-by: Kyle Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

C4/Circulation.pm
Koha/Account.pm
api/v1/swagger/definitions/patron_account_credit.json
installer/data/mysql/account_credit_types.sql
installer/data/mysql/atomicupdate/bug_23805_credit.perl
koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc
koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc
reports/cash_register_stats.pl
t/db_dependent/Koha/Account.t

index 28665eb..86443ed 100644 (file)
@@ -2366,7 +2366,7 @@ sub _FixOverduesOnReturn {
                         user_id    => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
                         library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
                         interface  => C4::Context->interface,
-                        type       => 'forgiven',
+                        type       => 'FORGIVEN',
                         item_id    => $item
                     }
                 );
index f9d8105..f93ec49 100644 (file)
@@ -324,7 +324,7 @@ my $credit_line = Koha::Account->new({ patron_id => $patron_id })->add_credit(
 $credit_type can be any of:
   - 'CREDIT'
   - 'payment'
-  - 'forgiven'
+  - 'FORGIVEN'
   - 'lost_item_return'
   - 'writeoff'
 
@@ -717,7 +717,7 @@ sub reconcile_balance {
 
 our $offset_type = {
     'CREDIT'           => 'Manual Credit',
-    'forgiven'         => 'Writeoff',
+    'FORGIVEN'         => 'Writeoff',
     'lost_item_return' => 'Lost Item',
     'payment'          => 'Payment',
     'writeoff'         => 'Writeoff',
@@ -740,7 +740,7 @@ our $offset_type = {
 
 our $account_type_credit = {
     'CREDIT'           => 'CREDIT',
-    'forgiven'         => 'FOR',
+    'FORGIVEN'         => 'FORGIVEN',
     'lost_item_return' => 'LOST_RETURN',
     'payment'          => 'Pay',
     'writeoff'         => 'W'
index a2eee7a..6b0889b 100644 (file)
@@ -3,7 +3,7 @@
   "properties": {
     "credit_type": {
       "type": "string",
-      "description": "Type of credit ('CREDIT', 'forgiven', 'lost_item_return', 'payment', 'writeoff' )"
+      "description": "Type of credit ('CREDIT', 'FORGIVEN', 'lost_item_return', 'payment', 'writeoff' )"
     },
     "amount": {
       "type": "number",
index 021538e..a91a7a3 100644 (file)
@@ -3,6 +3,6 @@ INSERT INTO account_debit_types ( code, description, can_be_added_manually, is_s
 ('PAY', 'Payment', 0, 1),
 ('W', 'Writeoff', 0, 1),
 ('WO', 'Writeoff', 0, 1),
-('FOR', 'Forgiven', 1, 1),
+('FORGIVEN', 'Forgiven', 1, 1),
 ('CREDIT', 'Credit', 1, 1),
 ('LOST_RETURN', 'Lost item fee refund', 0, 1);
index 0ce6c07..d3ca751 100644 (file)
@@ -40,7 +40,7 @@ if ( CheckVersion($DBversion) ) {
               ('PAY', 'Payment', 0, 1),
               ('W', 'Writeoff', 0, 1),
               ('WO', 'Writeoff', 0, 1),
-              ('FOR', 'Forgiven', 1, 1),
+              ('FORGIVEN', 'Forgiven', 1, 1),
               ('CREDIT', 'Credit', 1, 1),
               ('LOST_RETURN', 'Lost item fee refund', 0, 1)
         }
@@ -82,6 +82,13 @@ if ( CheckVersion($DBversion) ) {
         }
     );
 
+    # Update accountype 'FOR' to 'FORGIVEN'
+    $dbh->do(
+        qq{
+          UPDATE accountlines SET accounttype = 'FORGIVEN' WHERE accounttype = 'FOR' OR accounttype = 'FORW'
+        }
+    );
+
     # Populating credit_type_code
     $dbh->do(
         qq{
index 010a89c..18fa309 100644 (file)
@@ -4,7 +4,7 @@
         [%- SWITCH account.credit_type_code -%]
             [%- CASE 'Pay'              -%]Payment
             [%- CASE 'W'                -%]Writeoff
-            [%- CASE 'FOR'              -%]Forgiven
+            [%- CASE 'FORGIVEN'         -%]Forgiven
             [%- CASE 'PAY'              -%]Payment
             [%- CASE 'WO'               -%]Writeoff
             [%- CASE 'CREDIT'           -%]Credit
index ecd1510..1269cec 100644 (file)
         [%- SWITCH account.credit_type_code -%]
             [%- CASE 'Pay'              -%]Payment
             [%- CASE 'W'                -%]Writeoff
-            [%- CASE 'FOR'              -%]Forgiven
+            [%- CASE 'FORGIVEN'         -%]Forgiven
             [%- CASE 'PAY'              -%]Payment
             [%- CASE 'WO'               -%]Writeoff
             [%- CASE 'CREDIT'           -%]Credit
index 9c9ae2e..52cf124 100755 (executable)
@@ -74,7 +74,7 @@ if ($do_it) {
     } elsif ($transaction_type eq 'ACT') { #Active
         $whereTType = q{ AND credit_type_code IN ('Pay','CREDIT') };
     } elsif ($transaction_type eq 'FORW') {
-        $whereTType = q{ AND credit_type_code IN ('FOR','W') };
+        $whereTType = q{ AND credit_type_code IN ('FORGIVEN','W') };
     } else {
         if ( any { $transaction_type eq $_->code } @debit_types ) {
             $whereTType = q{ AND debit_type_code = ? };
@@ -128,7 +128,7 @@ if ($do_it) {
             if($row->{credit_type_code} =~ /^C$|^CR$/){
                 $grantotal -= abs($row->{amount});
                 $row->{amount} = '-' . $row->{amount};
-            }elsif($row->{credit_type_code} eq 'FORW' || $row->{credit_type_code} eq 'W'){
+            }elsif($row->{credit_type_code} eq 'FORGIVEN' || $row->{credit_type_code} eq 'W'){
             }else{
                 $grantotal += abs($row->{amount});
             }
index 5f3140f..e211ccf 100755 (executable)
@@ -276,7 +276,7 @@ subtest 'add_credit() tests' => sub {
             description => 'Manual credit applied',
             library_id  => $patron->branchcode,
             user_id     => $patron->id,
-            type        => 'forgiven',
+            type        => 'FORGIVEN',
             interface   => 'commandline'
         }
     );