Bug 23049: Capitalise type passed to add_debit for `account`
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 10 Oct 2019 15:31:17 +0000 (16:31 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 24 Oct 2019 16:24:27 +0000 (17:24 +0100)
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Koha/Account.pm
Koha/Patron.pm
t/db_dependent/Accounts.t
t/db_dependent/SIP/Transaction.t

index 8dfd3a4..183928a 100644 (file)
@@ -444,8 +444,8 @@ my $debit_line = Koha::Account->new({ patron_id => $patron_id })->add_debit(
 );
 
 $debit_type can be any of:
-  - account
-  - account_renew
+  - ACCOUNT
+  - ACCOUNT_RENEW
   - hold_expired
   - lost_item
   - sundry
@@ -709,8 +709,8 @@ our $offset_type = {
     'lost_item_return' => 'Lost Item',
     'payment'          => 'Payment',
     'writeoff'         => 'Writeoff',
-    'account'          => 'Account Fee',
-    'account_renew'    => 'Account Fee',
+    'ACCOUNT'          => 'Account Fee',
+    'ACCOUNT_RENEW'    => 'Account Fee',
     'RESERVE'          => 'Reserve Fee',
     'PROCESSING'       => 'Processing Fee',
     'lost_item'        => 'Lost Item',
@@ -740,8 +740,8 @@ our $account_type_credit = {
 =cut
 
 our $account_type_debit = {
-    'account'          => 'ACCOUNT',
-    'account_renew'    => 'ACCOUNT_RENEW',
+    'ACCOUNT'          => 'ACCOUNT',
+    'ACCOUNT_RENEW'    => 'ACCOUNT_RENEW',
     'hold_expired'     => 'HE',
     'lost_item'        => 'LOST',
     'sundry'           => 'M',
index 2655f1c..67ab9bf 100644 (file)
@@ -887,7 +887,7 @@ sub add_enrolment_fee_if_needed {
     my ($self, $renewal) = @_;
     my $enrolment_fee = $self->category->enrolmentfee;
     if ( $enrolment_fee && $enrolment_fee > 0 ) {
-        my $type = $renewal ? 'account_renew' : 'account';
+        my $type = $renewal ? 'ACCOUNT_RENEW' : 'ACCOUNT';
         $self->account->add_debit(
             {
                 amount     => $enrolment_fee,
index a34c523..4e93b9e 100644 (file)
@@ -183,8 +183,8 @@ subtest "Koha::Account::pay tests" => sub {
 
     my $account = Koha::Account->new({ patron_id => $borrower->id });
 
-    my $line1 = $account->add_debit({ type => 'account', amount => 100, interface => 'commandline' });
-    my $line2 = $account->add_debit({ type => 'account', amount => 200, interface => 'commandline' });
+    my $line1 = $account->add_debit({ type => 'ACCOUNT', amount => 100, interface => 'commandline' });
+    my $line2 = $account->add_debit({ type => 'ACCOUNT', amount => 200, interface => 'commandline' });
 
     $sth = $dbh->prepare("SELECT count(*) FROM accountlines");
     $sth->execute;
@@ -283,7 +283,7 @@ subtest "Koha::Account::pay tests" => sub {
     $note = $sth->fetchrow_array;
     is($note,'$200.00 payment note', '$200.00 payment note is registered');
 
-    my $line3 = $account->add_debit({ type => 'account', amount => 42, interface => 'commandline' });
+    my $line3 = $account->add_debit({ type => 'ACCOUNT', amount => 42, interface => 'commandline' });
     my $payment_id = $account->pay( { lines => [$line3], amount => 42 } );
     my $payment = Koha::Account::Lines->find( $payment_id );
     is( $payment->amount(), '-42.000000', "Payment paid the specified fine" );
@@ -311,10 +311,10 @@ subtest "Koha::Account::pay particular line tests" => sub {
 
     my $account = Koha::Account->new({ patron_id => $borrower->id });
 
-    my $line1 = $account->add_debit({ type => 'account', amount => 1, interface => 'commandline' });
-    my $line2 = $account->add_debit({ type => 'account', amount => 2, interface => 'commandline' });
-    my $line3 = $account->add_debit({ type => 'account', amount => 3, interface => 'commandline' });
-    my $line4 = $account->add_debit({ type => 'account', amount => 4, interface => 'commandline' });
+    my $line1 = $account->add_debit({ type => 'ACCOUNT', amount => 1, interface => 'commandline' });
+    my $line2 = $account->add_debit({ type => 'ACCOUNT', amount => 2, interface => 'commandline' });
+    my $line3 = $account->add_debit({ type => 'ACCOUNT', amount => 3, interface => 'commandline' });
+    my $line4 = $account->add_debit({ type => 'ACCOUNT', amount => 4, interface => 'commandline' });
 
     is( $account->balance(), 10, "Account balance is 10" );
 
@@ -356,7 +356,7 @@ subtest "Koha::Account::pay writeoff tests" => sub {
 
     my $account = Koha::Account->new({ patron_id => $borrower->id });
 
-    my $line = $account->add_debit({ type => 'account', amount => 42, interface => 'commandline' });
+    my $line = $account->add_debit({ type => 'ACCOUNT', amount => 42, interface => 'commandline' });
 
     is( $account->balance(), 42, "Account balance is 42" );
 
index c630fad..53d59d8 100755 (executable)
@@ -106,9 +106,9 @@ subtest "FeePayment->pay tests" => sub {
     my $account =
       Koha::Account->new( { patron_id => $patron->{borrowernumber} } );
     my $debt1 = $account->add_debit(
-        { type => 'account', amount => 100, interface => 'commandline' } );
+        { type => 'ACCOUNT', amount => 100, interface => 'commandline' } );
     my $debt2 = $account->add_debit(
-        { type => 'account', amount => 200, interface => 'commandline' } );
+        { type => 'ACCOUNT', amount => 200, interface => 'commandline' } );
 
     # Instantiate a new FeePayment transaction object
     my $trans = C4::SIP::ILS::Transaction::FeePayment->new();