Bug 24545: Fix license statements
[srvgit] / Koha / REST / V1 / Patrons / Account.pm
index b5bd5ca..4dd9ee2 100644 (file)
@@ -2,18 +2,18 @@ package Koha::REST::V1::Patrons::Account;
 
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use Modern::Perl;
 
@@ -92,7 +92,7 @@ sub add_credit {
     my $body    = $c->validation->param('body');
 
     return try {
-        my $credit_type = $body->{credit_type} || 'payment';    # default to 'payment'
+        my $credit_type = $body->{credit_type} || 'PAYMENT';    # default to 'PAYMENT'
         my $amount = $body->{amount};                           # mandatory, validated by openapi
 
         unless ( $amount > 0 ) {  # until we support newer JSON::Validator and thus minimumExclusive
@@ -107,7 +107,7 @@ sub add_credit {
 
         my $credit = $account->add_credit(
             {   amount       => $amount,
-                credit_type  => $credit_type,
+                type         => $credit_type,
                 payment_type => $payment_type,
                 description  => $description,
                 note         => $note,
@@ -157,100 +157,4 @@ sub add_credit {
     };
 }
 
-
-=head3 _to_api
-
-Helper function that maps unblessed Koha::Account::Line objects
-into REST API attribute names.
-
-=cut
-
-sub _to_api {
-    my $account_line = shift;
-
-    # Rename attributes
-    foreach my $column ( keys %{ $Koha::REST::V1::Patrons::Account::to_api_mapping } ) {
-        my $mapped_column = $Koha::REST::V1::Patrons::Account::to_api_mapping->{$column};
-        if (    exists $account_line->{ $column }
-             && defined $mapped_column )
-        {
-            # key != undef
-            $account_line->{ $mapped_column } = delete $account_line->{ $column };
-        }
-        elsif (    exists $account_line->{ $column }
-                && !defined $mapped_column )
-        {
-            # key == undef
-            delete $account_line->{ $column };
-        }
-    }
-
-    return $account_line;
-}
-
-=head3 _to_model
-
-Helper function that maps REST API objects into Koha::Account::Line
-attribute names.
-
-=cut
-
-sub _to_model {
-    my $account_line = shift;
-
-    foreach my $attribute ( keys %{ $Koha::REST::V1::Patrons::Account::to_model_mapping } ) {
-        my $mapped_attribute = $Koha::REST::V1::Patrons::Account::to_model_mapping->{$attribute};
-        if (    exists $account_line->{ $attribute }
-             && defined $mapped_attribute )
-        {
-            # key => !undef
-            $account_line->{ $mapped_attribute } = delete $account_line->{ $attribute };
-        }
-        elsif (    exists $account_line->{ $attribute }
-                && !defined $mapped_attribute )
-        {
-            # key => undef / to be deleted
-            delete $account_line->{ $attribute };
-        }
-    }
-
-    return $account_line;
-}
-
-=head2 Global variables
-
-=head3 $to_api_mapping
-
-=cut
-
-our $to_api_mapping = {
-    accountlines_id   => 'account_line_id',
-    credit_type_code  => 'credit_type',
-    debit_type_code   => 'debit_type',
-    amountoutstanding => 'amount_outstanding',
-    borrowernumber    => 'patron_id',
-    branchcode        => 'library_id',
-    issue_id          => 'checkout_id',
-    itemnumber        => 'item_id',
-    manager_id        => 'user_id',
-    note              => 'internal_note',
-};
-
-=head3 $to_model_mapping
-
-=cut
-
-our $to_model_mapping = {
-    account_line_id    => 'accountlines_id',
-    credit_type        => 'credit_type_code',
-    debit_type         => 'debit_type_code',
-    amount_outstanding => 'amountoutstanding',
-    checkout_id        => 'issue_id',
-    internal_note      => 'note',
-    item_id            => 'itemnumber',
-    library_id         => 'branchcode',
-    patron_id          => 'borrowernumber',
-    user_id            => 'manager_id'
-};
-
 1;