View | Details | Raw Unified | Return to bug 23843
Collapse All | Expand All

(-)a/Koha/Account/Line.pm (+21 lines)
Lines 398-403 sub is_debit { Link Here
398
    return !$self->is_credit;
398
    return !$self->is_credit;
399
}
399
}
400
400
401
=head3 to_api_mapping
402
403
This method returns the mapping for representing a Koha::Item object
404
on the API.
405
406
=cut
407
408
sub to_api_mapping {
409
    return {
410
        accountlines_id   => 'account_line_id',
411
        accounttype       => 'account_type',
412
        amountoutstanding => 'amount_outstanding',
413
        borrowernumber    => 'patron_id',
414
        branchcode        => 'library_id',
415
        issue_id          => 'checkout_id',
416
        itemnumber        => 'item_id',
417
        manager_id        => 'user_id',
418
        note              => 'internal_note',
419
    };
420
}
421
401
=head2 Internal methods
422
=head2 Internal methods
402
423
403
=cut
424
=cut
(-)a/Koha/REST/V1/Patrons/Account.pm (-17 / +14 lines)
Lines 49-75 sub get { Link Here
49
    }
49
    }
50
50
51
    my $account = $patron->account;
51
    my $account = $patron->account;
52
    my $balance;
53
54
    $balance->{balance} = $account->balance;
55
52
56
    # get outstanding debits and credits
53
    # get outstanding debits and credits
57
    my $debits  = $account->outstanding_debits;
54
    my $debits  = $account->outstanding_debits;
58
    my $credits = $account->outstanding_credits;
55
    my $credits = $account->outstanding_credits;
59
56
60
    my @debit_lines = map { _to_api( $_->TO_JSON ) } @{ $debits->as_list };
57
    return $c->render(
61
    $balance->{outstanding_debits} = {
58
        status  => 200,
62
        total => $debits->total_outstanding,
59
        openapi => {
63
        lines => \@debit_lines
60
            balance => $account->balance,
64
    };
61
            outstanding_debits => {
65
62
                total => $debits->total_outstanding,
66
    my @credit_lines = map { _to_api( $_->TO_JSON ) } @{ $credits->as_list };
63
                lines => $debits->to_api
67
    $balance->{outstanding_credits} = {
64
            },
68
        total => $credits->total_outstanding,
65
            outstanding_credits => {
69
        lines => \@credit_lines
66
                total => $credits->total_outstanding,
70
    };
67
                lines => $credits->to_api
71
68
              }
72
    return $c->render( status => 200, openapi => $balance );
69
        }
70
    );
73
}
71
}
74
72
75
=head3 add_credit
73
=head3 add_credit
76
- 

Return to bug 23843