From ac54e35b20793a8a84a705acb8068589251e3e14 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 27 Jul 2018 14:55:14 -0300 Subject: [PATCH] Bug 20997: (QA follow-up) POD fixes and offset type consistency This patch addresses minor issues highlighted by QA. - The POD is enhanced based on the proposal in bug 11983. - The introduced offset type value is made consistent with the rest of them. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart Signed-off-by: Nick Clemens --- Koha/Account/Line.pm | 17 +++++++++++++++-- installer/data/mysql/account_offset_types.sql | 2 +- .../data/mysql/atomicupdate/bug_20997.perl | 2 +- t/db_dependent/Koha/Account/Lines.t | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm index 491d55bab3..9cf8867bce 100644 --- a/Koha/Account/Line.pm +++ b/Koha/Account/Line.pm @@ -129,7 +129,20 @@ sub void { =head3 apply my $debits = $account->outstanding_debits; - my $outstanding_amount = $credit->apply({ debits => $debits, [ offset_type => $offset_type ] }); + my $outstanding_amount = $credit->apply( { debits => $debits, [ offset_type => $offset_type ] } ); + +Applies the credit to a given debits set. + +=head4 arguments hashref + +=over 4 + +=item debits - Koha::Account::Lines object set of debits + +=item offset_type (optional) - a string indicating the offset type (valid values are those from +the 'account_offset_types' table) + +=back =cut @@ -137,7 +150,7 @@ sub apply { my ( $self, $params ) = @_; my $debits = $params->{debits}; - my $offset_type = $params->{offset_type} // 'credit_applied'; + my $offset_type = $params->{offset_type} // 'Credit Applied'; unless ( $self->is_credit ) { Koha::Exceptions::Account::IsNotCredit->throw( diff --git a/installer/data/mysql/account_offset_types.sql b/installer/data/mysql/account_offset_types.sql index baf3a26a6a..083e56ca21 100644 --- a/installer/data/mysql/account_offset_types.sql +++ b/installer/data/mysql/account_offset_types.sql @@ -12,4 +12,4 @@ INSERT INTO account_offset_types ( type ) VALUES ('Fine Update'), ('Fine'), ('Void Payment'), -('credit_applied'); +('Credit Applied'); diff --git a/installer/data/mysql/atomicupdate/bug_20997.perl b/installer/data/mysql/atomicupdate/bug_20997.perl index 159917aacb..49f22787c1 100644 --- a/installer/data/mysql/atomicupdate/bug_20997.perl +++ b/installer/data/mysql/atomicupdate/bug_20997.perl @@ -3,7 +3,7 @@ if( CheckVersion( $DBversion ) ) { # Add 'credit_applied' offset type $dbh->do(q{ - INSERT IGNORE INTO `account_offset_types` (`type`) VALUES ('credit_applied'); + INSERT IGNORE INTO `account_offset_types` (`type`) VALUES ('Credit Applied'); }); SetVersion( $DBversion ); diff --git a/t/db_dependent/Koha/Account/Lines.t b/t/db_dependent/Koha/Account/Lines.t index 506be99cff..20033e70b6 100755 --- a/t/db_dependent/Koha/Account/Lines.t +++ b/t/db_dependent/Koha/Account/Lines.t @@ -217,7 +217,7 @@ subtest 'apply() tests' => sub { is( $offsets->count, 1, 'Only one offset is generated' ); $THE_offset = $offsets->next; is( $THE_offset->amount * 1, 90, 'Amount was calculated correctly (less than the available credit)' ); - is( $THE_offset->type, 'credit_applied', 'Defaults to credit_applied offset type' ); + is( $THE_offset->type, 'Credit Applied', 'Defaults to \'Credit Applied\' offset type' ); $debits = Koha::Account::Lines->search({ accountlines_id => $debit_1->id }); throws_ok -- 2.39.5