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

(-)a/Koha/Account/Line.pm (-2 / +15 lines)
Lines 129-135 sub void { Link Here
129
=head3 apply
129
=head3 apply
130
130
131
    my $debits = $account->outstanding_debits;
131
    my $debits = $account->outstanding_debits;
132
    my $outstanding_amount = $credit->apply({ debits =>  $debits, [ offset_type => $offset_type ] });
132
    my $outstanding_amount = $credit->apply( { debits => $debits, [ offset_type => $offset_type ] } );
133
134
Applies the credit to a given debits set.
135
136
=head4 arguments hashref
137
138
=over 4
139
140
=item debits - Koha::Account::Lines object set of debits
141
142
=item offset_type (optional) - a string indicating the offset type (valid values are those from
143
the 'account_offset_types' table)
144
145
=back
133
146
134
=cut
147
=cut
135
148
Lines 137-143 sub apply { Link Here
137
    my ( $self, $params ) = @_;
150
    my ( $self, $params ) = @_;
138
151
139
    my $debits      = $params->{debits};
152
    my $debits      = $params->{debits};
140
    my $offset_type = $params->{offset_type} // 'credit_applied';
153
    my $offset_type = $params->{offset_type} // 'Credit Applied';
141
154
142
    unless ( $self->is_credit ) {
155
    unless ( $self->is_credit ) {
143
        Koha::Exceptions::Account::IsNotCredit->throw(
156
        Koha::Exceptions::Account::IsNotCredit->throw(
(-)a/installer/data/mysql/account_offset_types.sql (-1 / +1 lines)
Lines 12-15 INSERT INTO account_offset_types ( type ) VALUES Link Here
12
('Fine Update'),
12
('Fine Update'),
13
('Fine'),
13
('Fine'),
14
('Void Payment'),
14
('Void Payment'),
15
('credit_applied');
15
('Credit Applied');
(-)a/installer/data/mysql/atomicupdate/bug_20997.perl (-1 / +1 lines)
Lines 3-9 if( CheckVersion( $DBversion ) ) { Link Here
3
3
4
    # Add 'credit_applied' offset type
4
    # Add 'credit_applied' offset type
5
    $dbh->do(q{
5
    $dbh->do(q{
6
        INSERT IGNORE INTO `account_offset_types` (`type`) VALUES ('credit_applied');
6
        INSERT IGNORE INTO `account_offset_types` (`type`) VALUES ('Credit Applied');
7
    });
7
    });
8
8
9
    SetVersion( $DBversion );
9
    SetVersion( $DBversion );
(-)a/t/db_dependent/Koha/Account/Lines.t (-2 / +1 lines)
Lines 217-223 subtest 'apply() tests' => sub { Link Here
217
    is( $offsets->count, 1, 'Only one offset is generated' );
217
    is( $offsets->count, 1, 'Only one offset is generated' );
218
    $THE_offset = $offsets->next;
218
    $THE_offset = $offsets->next;
219
    is( $THE_offset->amount * 1, 90, 'Amount was calculated correctly (less than the available credit)' );
219
    is( $THE_offset->amount * 1, 90, 'Amount was calculated correctly (less than the available credit)' );
220
    is( $THE_offset->type, 'credit_applied', 'Defaults to credit_applied offset type' );
220
    is( $THE_offset->type, 'Credit Applied', 'Defaults to \'Credit Applied\' offset type' );
221
221
222
    $debits = Koha::Account::Lines->search({ accountlines_id => $debit_1->id });
222
    $debits = Koha::Account::Lines->search({ accountlines_id => $debit_1->id });
223
    throws_ok
223
    throws_ok
224
- 

Return to bug 20997