From 889d5a960c8a318e72883795fd62ca8d698e392a Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 10 Oct 2019 16:58:23 +0100 Subject: [PATCH] Bug 23049: Drop type lookup as it's now a foreign key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Séverine QUEUNE --- Koha/Account.pm | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/Koha/Account.pm b/Koha/Account.pm index 57a0d4e5cf..794d684787 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -477,7 +477,7 @@ sub add_debit { my $user_id = $params->{user_id}; my $interface = $params->{interface}; my $library_id = $params->{library_id}; - my $type = $params->{type}; + my $debit_type = $params->{type}; my $item_id = $params->{item_id}; my $issue_id = $params->{issue_id}; @@ -488,14 +488,6 @@ sub add_debit { my $schema = Koha::Database->new->schema; - unless ( exists($Koha::Account::account_type_debit->{$type}) ) { - Koha::Exceptions::Account::UnrecognisedType->throw( - error => 'Type of debit not recognised' - ); - } - - my $debit_type_code = $Koha::Account::account_type_debit->{$type}; - my $line; $schema->txn_do( sub { @@ -507,7 +499,7 @@ sub add_debit { date => \'NOW()', amount => $amount, description => $description, - debit_type_code => $debit_type_code, + debit_type_code => $debit_type, amountoutstanding => $amount, payment_type => undef, note => $note, @@ -516,7 +508,7 @@ sub add_debit { itemnumber => $item_id, issue_id => $issue_id, branchcode => $library_id, - ( $type eq 'OVERDUE' ? ( status => 'UNRETURNED' ) : () ), + ( $debit_type eq 'OVERDUE' ? ( status => 'UNRETURNED' ) : () ), } )->store(); @@ -524,7 +516,7 @@ sub add_debit { my $account_offset = Koha::Account::Offset->new( { debit_id => $line->id, - type => $Koha::Account::offset_type->{$type}, + type => $Koha::Account::offset_type->{$debit_type}, amount => $amount } )->store(); @@ -535,12 +527,12 @@ sub add_debit { $self->{patron_id}, Dumper( { - action => "create_$type", + action => "create_$debit_type", borrowernumber => $self->{patron_id}, amount => $amount, description => $description, amountoutstanding => $amount, - debit_type_code => $debit_type_code, + debit_type_code => $debit_type, note => $note, itemnumber => $item_id, manager_id => $user_id, @@ -733,25 +725,6 @@ our $account_type_credit = { 'writeoff' => 'W' }; -=head3 $account_type_debit - -=cut - -our $account_type_debit = { - 'ACCOUNT' => 'ACCOUNT', - 'ACCOUNT_RENEW' => 'ACCOUNT_RENEW', - 'RESERVE_EXPIRED' => 'RESERVE_EXPIRED', - 'LOST_ITEM' => 'LOST', - 'NEW_CARD' => 'NEW_CARD', - 'OVERDUE' => 'OVERDUE', - 'PROCESSING' => 'PROCESSING', - 'RENT' => 'RENT', - 'RENT_DAILY' => 'RENT_DAILY', - 'RENT_RENEW' => 'RENT_RENEW', - 'RENT_DAILY_RENEW' => 'RENT_DAILY_RENEW', - 'RESERVE' => 'RESERVE', -}; - =head1 AUTHORS =encoding utf8 -- 2.20.1