Bug 23805: Update references to accounttype to credit_type_code
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 14 Oct 2019 10:27:31 +0000 (11:27 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 24 Oct 2019 16:35:19 +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>

Koha/Account.pm
Koha/Account/Line.pm
Koha/REST/V1/Patrons/Account.pm
koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc
koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt
koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc
reports/cash_register_stats.pl

index 2a8d557..4d1947e 100644 (file)
@@ -60,8 +60,8 @@ Koha::Account->new( { patron_id => $borrowernumber } )->pay(
         note        => $note,
         description => $description,
         library_id  => $branchcode,
-        lines        => $lines, # Arrayref of Koha::Account::Line objects to pay
-        account_type => $type,  # accounttype code
+        lines       => $lines, # Arrayref of Koha::Account::Line objects to pay
+        credit_type => $type,  # credit_type_code code
         offset_type => $offset_type,    # offset type code
     }
 );
@@ -78,7 +78,7 @@ sub pay {
     my $lines         = $params->{lines};
     my $type          = $params->{type} || 'payment';
     my $payment_type  = $params->{payment_type} || undef;
-    my $account_type  = $params->{account_type};
+    my $credit_type   = $params->{credit_type};
     my $offset_type   = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
     my $cash_register = $params->{cash_register};
 
@@ -215,7 +215,7 @@ sub pay {
         last unless $balance_remaining > 0;
     }
 
-    $account_type ||=
+    $credit_type ||=
       $type eq 'writeoff'
       ? 'W'
       : 'Pay';
@@ -228,7 +228,7 @@ sub pay {
             date              => dt_from_string(),
             amount            => 0 - $amount,
             description       => $description,
-            accounttype       => $account_type,
+            credit_type_code  => $credit_type,
             payment_type      => $payment_type,
             amountoutstanding => 0 - $balance_remaining,
             manager_id        => $manager_id,
@@ -263,7 +263,7 @@ sub pay {
                     borrowernumber    => $self->{patron_id},
                     amount            => 0 - $amount,
                     amountoutstanding => 0 - $balance_remaining,
-                    accounttype       => $account_type,
+                    credit_type_code  => $credit_type,
                     accountlines_paid => \@fines_paid,
                     manager_id        => $manager_id,
                 }
@@ -360,7 +360,7 @@ sub add_credit {
 
     my $schema = Koha::Database->new->schema;
 
-    my $account_type = $Koha::Account::account_type_credit->{$type};
+    my $credit_type = $Koha::Account::account_type_credit->{$type};
     my $line;
 
     $schema->txn_do(
@@ -372,7 +372,7 @@ sub add_credit {
                     date              => \'NOW()',
                     amount            => $amount,
                     description       => $description,
-                    accounttype       => $account_type,
+                    credit_type_code  => $credit_type,
                     amountoutstanding => $amount,
                     payment_type      => $payment_type,
                     note              => $note,
@@ -410,7 +410,7 @@ sub add_credit {
                             amount            => $amount,
                             description       => $description,
                             amountoutstanding => $amount,
-                            accounttype       => $account_type,
+                            credit_type_code  => $credit_type,
                             note              => $note,
                             itemnumber        => $item_id,
                             manager_id        => $user_id,
index 14fdbd3..922e7a8 100644 (file)
@@ -150,7 +150,7 @@ sub void {
                             amount            => $self->amount,
                             amountoutstanding => $self->amountoutstanding,
                             description       => $self->description,
-                            accounttype       => $self->accounttype,
+                            credit_type_code  => $self->credit_type_code,
                             payment_type      => $self->payment_type,
                             note              => $self->note,
                             itemnumber        => $self->itemnumber,
index 5c7a7f3..b5bd5ca 100644 (file)
@@ -225,7 +225,7 @@ sub _to_model {
 
 our $to_api_mapping = {
     accountlines_id   => 'account_line_id',
-    accounttype       => 'account_type',
+    credit_type_code  => 'credit_type',
     debit_type_code   => 'debit_type',
     amountoutstanding => 'amount_outstanding',
     borrowernumber    => 'patron_id',
@@ -242,7 +242,7 @@ our $to_api_mapping = {
 
 our $to_model_mapping = {
     account_line_id    => 'accountlines_id',
-    account_type       => 'accounttype',
+    credit_type        => 'credit_type_code',
     debit_type         => 'debit_type_code',
     amount_outstanding => 'amountoutstanding',
     checkout_id        => 'issue_id',
index 8a5c20b..332b350 100644 (file)
@@ -1,7 +1,7 @@
 [%- BLOCK account_type_description -%]
     <span>
-    [%- IF account.accounttype -%]
-        [%- SWITCH account.accounttype -%]
+    [%- IF account.credit_type_code -%]
+        [%- SWITCH account.credit_type_code -%]
             [%- CASE 'Pay'              -%]Payment
             [%- CASE 'W'                -%]Writeoff
             [%- CASE 'FOR'              -%]Forgiven
@@ -9,7 +9,7 @@
             [%- CASE 'WO'               -%]Writeoff
             [%- CASE 'C'                -%]Credit
             [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
-            [%- CASE                    -%][% account.accounttype | html %]
+            [%- CASE                    -%][% account.credit_type.description | html %]
         [%- END -%]
     [%- ELSIF account.debit_type_code -%]
        [%- SWITCH account.debit_type_code -%]
index c145ce3..dc2b1c8 100644 (file)
                 <td>[% loopresul.branchname | html %]</td>
                 <td>[% loopresul.date | $KohaDates %]</td>
                 <td>
-                    [% IF loopresul.accounttype == "ACT" %]
+                    [% IF loopresul.credit_type == "ACT" %]
                         <span>All payments to the library</span>
                     [% ELSE %]
                         [%- PROCESS account_type_description account=loopresul -%]
index 2d5093a..937eacd 100644 (file)
 
 [%- BLOCK account_type_description -%]
     <span>
-    [%- IF account.accounttype -%]
-        [%- SWITCH account.accounttype -%]
+    [%- IF account.credit_type_code -%]
+        [%- SWITCH account.credit_type_code -%]
             [%- CASE 'Pay'              -%]Payment
             [%- CASE 'W'                -%]Writeoff
             [%- CASE 'FOR'              -%]Forgiven
             [%- CASE 'WO'               -%]Writeoff
             [%- CASE 'C'                -%]Credit
             [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
-            [%- CASE                    -%][% account.accounttype | html %]
+            [%- CASE                    -%][% account.credit_type.description | html %]
         [%- END -%]
     [%- ELSIF account.debit_type_code -%]
        [%- SWITCH account.debit_type_code -%]
index b4340c9..d0889bf 100755 (executable)
@@ -72,15 +72,15 @@ if ($do_it) {
     if ($transaction_type eq 'ALL') { #All Transactons
         $whereTType = q{};
     } elsif ($transaction_type eq 'ACT') { #Active
-        $whereTType = q{ AND accounttype IN ('Pay','C') };
+        $whereTType = q{ AND credit_type_code IN ('Pay','C') };
     } elsif ($transaction_type eq 'FORW') {
-        $whereTType = q{ AND accounttype IN ('FOR','W') };
+        $whereTType = q{ AND credit_type_code IN ('FOR','W') };
     } else {
         if ( any { $transaction_type eq $_->code } @debit_types ) {
             $whereTType = q{ AND debit_type_code = ? };
             push @extra_params, $transaction_type;
         } else {
-            $whereTType = q{ AND accounttype = ? };
+            $whereTType = q{ AND credit_type_code = ? };
             push @extra_params, $transaction_type;
         }
     }
@@ -96,7 +96,7 @@ if ($do_it) {
     SELECT round(amount,2) AS amount, description,
         bo.surname AS bsurname, bo.firstname AS bfirstname, m.surname AS msurname, m.firstname AS mfirstname,
         bo.cardnumber, br.branchname, bo.borrowernumber,
-        al.borrowernumber, DATE(al.date) as date, al.accounttype, al.debit_type_code, al.amountoutstanding, al.note,
+        al.borrowernumber, DATE(al.date) as date, al.credit_type_code, al.debit_type_code, al.amountoutstanding, al.note,
         bi.title, bi.biblionumber, i.barcode, i.itype
         FROM accountlines al
         LEFT JOIN borrowers bo ON (al.borrowernumber = bo.borrowernumber)
@@ -121,14 +121,14 @@ if ($do_it) {
             $row->{date} = dt_from_string($row->{date}, 'sql');
 
             push (@loopresult, $row);
-            if($transaction_type eq 'ACT' && ($row->{accounttype} !~ /^C$|^CR$|^Pay$/)){
+            if($transaction_type eq 'ACT' && ($row->{credit_type_code} !~ /^C$|^CR$|^Pay$/)){
                 pop @loopresult;
                 next;
             }
-            if($row->{accounttype} =~ /^C$|^CR$/){
+            if($row->{credit_type_code} =~ /^C$|^CR$/){
                 $grantotal -= abs($row->{amount});
                 $row->{amount} = '-' . $row->{amount};
-            }elsif($row->{accounttype} eq 'FORW' || $row->{accounttype} eq 'W'){
+            }elsif($row->{credit_type_code} eq 'FORW' || $row->{credit_type_code} eq 'W'){
             }else{
                 $grantotal += abs($row->{amount});
             }
@@ -155,7 +155,7 @@ if ($do_it) {
                         $row->{bfirstname} . ' ' . $row->{bsurname},
                         $row->{branchname},
                         $row->{date},
-                        $row->{accounttype},
+                        $row->{credit_type},
                         $row->{debit_type},
                         $row->{note},
                         $row->{amount},