Bug 23843: Add mapping to Koha::Account::Line
[koha-ffzg.git] / Koha / Account / Line.pm
index f4f9498..ae7bbc1 100644 (file)
@@ -166,7 +166,7 @@ sub void {
     my $debits = $account->outstanding_debits;
     my $outstanding_amount = $credit->apply( { debits => $debits, [ offset_type => $offset_type ] } );
 
-Applies the credit to a given debits set.
+Applies the credit to a given debits array reference.
 
 =head4 arguments hashref
 
@@ -204,7 +204,7 @@ sub apply {
     my $schema = Koha::Database->new->schema;
 
     $schema->txn_do( sub {
-        while ( my $debit = $debits->next ) {
+        for my $debit ( @{$debits} ) {
 
             unless ( $debit->is_debit ) {
                 Koha::Exceptions::Account::IsNotDebit->throw(
@@ -398,6 +398,27 @@ sub is_debit {
     return !$self->is_credit;
 }
 
+=head3 to_api_mapping
+
+This method returns the mapping for representing a Koha::Account::Line object
+on the API.
+
+=cut
+
+sub to_api_mapping {
+    return {
+        accountlines_id   => 'account_line_id',
+        accounttype       => 'account_type',
+        amountoutstanding => 'amount_outstanding',
+        borrowernumber    => 'patron_id',
+        branchcode        => 'library_id',
+        issue_id          => 'checkout_id',
+        itemnumber        => 'item_id',
+        manager_id        => 'user_id',
+        note              => 'internal_note',
+    };
+}
+
 =head2 Internal methods
 
 =cut