Bug 23384: Fix use statement order for ArticleRequest::Status
[srvgit] / Koha / Account.pm
index ddd6012..81f7a34 100644 (file)
@@ -22,16 +22,20 @@ use Modern::Perl;
 use Carp;
 use Data::Dumper;
 use List::MoreUtils qw( uniq );
+use Try::Tiny;
 
-use C4::Circulation qw( ReturnLostItem );
+use C4::Circulation qw( ReturnLostItem CanBookBeRenewed AddRenewal );
 use C4::Letters;
 use C4::Log qw( logaction );
 use C4::Stats qw( UpdateStats );
+use C4::Overdues qw(GetFine);
 
 use Koha::Patrons;
 use Koha::Account::Lines;
 use Koha::Account::Offsets;
+use Koha::Account::DebitTypes;
 use Koha::DateUtils qw( dt_from_string );
+use Koha::Exceptions;
 use Koha::Exceptions::Account;
 
 =head1 NAME
@@ -55,12 +59,11 @@ This method allows payments to be made against fees/fines
 Koha::Account->new( { patron_id => $borrowernumber } )->pay(
     {
         amount      => $amount,
-        sip         => $sipmode,
         note        => $note,
         description => $description,
         library_id  => $branchcode,
-        lines        => $lines, # Arrayref of Koha::Account::Line objects to pay
-        account_type => $type,  # accounttype code
+        lines       => $lines, # Arrayref of Koha::Account::Line objects to pay
+        credit_type => $type,  # credit_type_code code
         offset_type => $offset_type,    # offset type code
     }
 );
@@ -70,25 +73,35 @@ Koha::Account->new( { patron_id => $borrowernumber } )->pay(
 sub pay {
     my ( $self, $params ) = @_;
 
-    my $amount       = $params->{amount};
-    my $sip          = $params->{sip};
-    my $description  = $params->{description};
-    my $note         = $params->{note} || q{};
-    my $library_id   = $params->{library_id};
-    my $lines        = $params->{lines};
-    my $type         = $params->{type} || 'payment';
-    my $payment_type = $params->{payment_type} || undef;
-    my $account_type = $params->{account_type};
-    my $offset_type  = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
+    my $amount        = $params->{amount};
+    my $description   = $params->{description};
+    my $note          = $params->{note} || q{};
+    my $library_id    = $params->{library_id};
+    my $lines         = $params->{lines};
+    my $type          = $params->{type} || 'PAYMENT';
+    my $payment_type  = $params->{payment_type} || undef;
+    my $credit_type   = $params->{credit_type};
+    my $offset_type   = $params->{offset_type} || $type eq 'WRITEOFF' ? 'Writeoff' : 'Payment';
+    my $cash_register = $params->{cash_register};
 
     my $userenv = C4::Context->userenv;
 
     my $patron = Koha::Patrons->find( $self->{patron_id} );
 
     my $manager_id = $userenv ? $userenv->{number} : 0;
+    my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface;
+    Koha::Exceptions::Account::RegisterRequired->throw()
+      if ( C4::Context->preference("UseCashRegisters")
+        && defined($payment_type)
+        && ( $payment_type eq 'CASH' )
+        && !defined($cash_register) );
 
     my @fines_paid; # List of account lines paid on with this payment
 
+    # The outcome of any attempted item renewals as a result of fines being
+    # paid off
+    my $renew_outcomes = [];
+
     my $balance_remaining = $amount; # Set it now so we can adjust the amount if necessary
     $balance_remaining ||= 0;
 
@@ -106,7 +119,21 @@ sub pay {
         $fine->amountoutstanding($new_amountoutstanding)->store();
         $balance_remaining = $balance_remaining - $amount_to_pay;
 
-        if ( $fine->itemnumber && $fine->accounttype && ( $fine->accounttype eq 'Rep' || $fine->accounttype eq 'L' ) )
+        # Attempt to renew the item associated with this debit if
+        # appropriate
+        if ($fine->renewable) {
+            # We're ignoring the definition of $interface above, by all
+            # accounts we can't rely on C4::Context::interface, so here
+            # we're only using what we've been explicitly passed
+            my $outcome = $fine->renew_item({ interface => $interface });
+            push @{$renew_outcomes}, $outcome if $outcome;
+        }
+
+        # Same logic exists in Koha::Account::Line::apply
+        if (   $new_amountoutstanding == 0
+            && $fine->itemnumber
+            && $fine->debit_type_code
+            && ( $fine->debit_type_code eq 'LOST' ) )
         {
             C4::Circulation::ReturnLostItem( $self->{patron_id}, $fine->itemnumber );
         }
@@ -135,7 +162,8 @@ sub pay {
                         manager_id            => $manager_id,
                         note                  => $note,
                     }
-                )
+                ),
+                $interface
             );
             push( @fines_paid, $fine->id );
         }
@@ -161,6 +189,22 @@ sub pay {
         $fine->amountoutstanding( $old_amountoutstanding - $amount_to_pay );
         $fine->store();
 
+        # If we need to make a note of the item associated with this line,
+        # in order that we can potentially renew it, do so.
+        my $amt = $old_amountoutstanding - $amount_to_pay;
+        if ($fine->renewable) {
+            my $outcome = $fine->renew_item;
+            push @{$renew_outcomes}, $outcome;
+        }
+
+        if (   $fine->amountoutstanding == 0
+            && $fine->itemnumber
+            && $fine->debit_type_code
+            && ( $fine->debit_type_code eq 'LOST' ) )
+        {
+            C4::Circulation::ReturnLostItem( $self->{patron_id}, $fine->itemnumber );
+        }
+
         my $account_offset = Koha::Account::Offset->new(
             {
                 debit_id => $fine->id,
@@ -185,7 +229,8 @@ sub pay {
                         manager_id            => $manager_id,
                         note                  => $note,
                     }
-                )
+                ),
+                $interface
             );
             push( @fines_paid, $fine->id );
         }
@@ -194,12 +239,12 @@ sub pay {
         last unless $balance_remaining > 0;
     }
 
-    $account_type ||=
-        $type eq 'writeoff' ? 'W'
-      : defined($sip)       ? "Pay$sip"
-      :                       'Pay';
+    $credit_type ||=
+      $type eq 'WRITEOFF'
+      ? 'WRITEOFF'
+      : 'PAYMENT';
 
-    $description ||= $type eq 'writeoff' ? 'Writeoff' : q{};
+    $description ||= $type eq 'WRITEOFF' ? 'Writeoff' : q{};
 
     my $payment = Koha::Account::Line->new(
         {
@@ -207,11 +252,13 @@ sub pay {
             date              => dt_from_string(),
             amount            => 0 - $amount,
             description       => $description,
-            accounttype       => $account_type,
+            credit_type_code  => $credit_type,
             payment_type      => $payment_type,
             amountoutstanding => 0 - $balance_remaining,
             manager_id        => $manager_id,
+            interface         => $interface,
             branchcode        => $library_id,
+            register_id       => $cash_register,
             note              => $note,
         }
     )->store();
@@ -224,7 +271,7 @@ sub pay {
     UpdateStats(
         {
             branch         => $library_id,
-            type           => $type,
+            type           => lc($type),
             amount         => $amount,
             borrowernumber => $self->{patron_id},
         }
@@ -240,11 +287,12 @@ sub pay {
                     borrowernumber    => $self->{patron_id},
                     amount            => 0 - $amount,
                     amountoutstanding => 0 - $balance_remaining,
-                    accounttype       => $account_type,
+                    credit_type_code  => $credit_type,
                     accountlines_paid => \@fines_paid,
                     manager_id        => $manager_id,
                 }
-            )
+            ),
+            $interface
         );
     }
 
@@ -257,7 +305,7 @@ sub pay {
                 lang    => $patron->lang,
                 tables => {
                     borrowers       => $self->{patron_id},
-                    branches        => $self->{library_id},
+                    branches        => $library_id,
                 },
                 substitute => {
                     credit => $payment,
@@ -276,7 +324,7 @@ sub pay {
         }
     }
 
-    return $payment->id;
+    return { payment_id => $payment->id, renew_result => $renew_outcomes };
 }
 
 =head3 add_credit
@@ -289,8 +337,8 @@ my $credit_line = Koha::Account->new({ patron_id => $patron_id })->add_credit(
         description  => $description,
         note         => $note,
         user_id      => $user_id,
+        interface    => $interface,
         library_id   => $library_id,
-        sip          => $sip,
         payment_type => $payment_type,
         type         => $credit_type,
         item_id      => $item_id
@@ -298,11 +346,11 @@ my $credit_line = Koha::Account->new({ patron_id => $patron_id })->add_credit(
 );
 
 $credit_type can be any of:
-  - 'credit'
-  - 'payment'
-  - 'forgiven'
-  - 'lost_item_return'
-  - 'writeoff'
+  - 'CREDIT'
+  - 'PAYMENT'
+  - 'FORGIVEN'
+  - 'LOST_FOUND'
+  - 'WRITEOFF'
 
 =cut
 
@@ -310,83 +358,116 @@ sub add_credit {
 
     my ( $self, $params ) = @_;
 
-    # amount is passed as a positive value, but we store credit as negative values
-    my $amount       = $params->{amount} * -1;
-    my $description  = $params->{description} // q{};
-    my $note         = $params->{note} // q{};
-    my $user_id      = $params->{user_id};
-    my $library_id   = $params->{library_id};
-    my $sip          = $params->{sip};
-    my $payment_type = $params->{payment_type};
-    my $type         = $params->{type} || 'payment';
-    my $item_id      = $params->{item_id};
+    # check for mandatory params
+    my @mandatory = ( 'interface', 'amount' );
+    for my $param (@mandatory) {
+        unless ( defined( $params->{$param} ) ) {
+            Koha::Exceptions::MissingParameter->throw(
+                error => "The $param parameter is mandatory" );
+        }
+    }
 
-    my $schema = Koha::Database->new->schema;
+    # amount should always be passed as a positive value
+    my $amount = $params->{amount} * -1;
+    unless ( $amount < 0 ) {
+        Koha::Exceptions::Account::AmountNotPositive->throw(
+            error => 'Debit amount passed is not positive' );
+    }
 
-    my $account_type = $Koha::Account::account_type_credit->{$type};
-    $account_type .= $sip
-        if defined $sip &&
-           $type eq 'payment';
+    my $description   = $params->{description} // q{};
+    my $note          = $params->{note} // q{};
+    my $user_id       = $params->{user_id};
+    my $interface     = $params->{interface};
+    my $library_id    = $params->{library_id};
+    my $cash_register = $params->{cash_register};
+    my $payment_type  = $params->{payment_type};
+    my $credit_type   = $params->{type} || 'PAYMENT';
+    my $item_id       = $params->{item_id};
+
+    Koha::Exceptions::Account::RegisterRequired->throw()
+      if ( C4::Context->preference("UseCashRegisters")
+        && defined($payment_type)
+        && ( $payment_type eq 'CASH' )
+        && !defined($cash_register) );
 
     my $line;
+    my $schema = Koha::Database->new->schema;
+    try {
+        $schema->txn_do(
+            sub {
 
-    $schema->txn_do(
-        sub {
-
-            # Insert the account line
-            $line = Koha::Account::Line->new(
-                {   borrowernumber    => $self->{patron_id},
-                    date              => \'NOW()',
-                    amount            => $amount,
-                    description       => $description,
-                    accounttype       => $account_type,
-                    amountoutstanding => $amount,
-                    payment_type      => $payment_type,
-                    note              => $note,
-                    manager_id        => $user_id,
-                    branchcode        => $library_id,
-                    itemnumber        => $item_id,
-                    lastincrement     => undef,
-                }
-            )->store();
+                # Insert the account line
+                $line = Koha::Account::Line->new(
+                    {
+                        borrowernumber    => $self->{patron_id},
+                        date              => \'NOW()',
+                        amount            => $amount,
+                        description       => $description,
+                        credit_type_code  => $credit_type,
+                        amountoutstanding => $amount,
+                        payment_type      => $payment_type,
+                        note              => $note,
+                        manager_id        => $user_id,
+                        interface         => $interface,
+                        branchcode        => $library_id,
+                        register_id       => $cash_register,
+                        itemnumber        => $item_id,
+                    }
+                )->store();
 
-            # Record the account offset
-            my $account_offset = Koha::Account::Offset->new(
-                {   credit_id => $line->id,
-                    type      => $Koha::Account::offset_type->{$type},
-                    amount    => $amount
-                }
-            )->store();
+                # Record the account offset
+                my $account_offset = Koha::Account::Offset->new(
+                    {
+                        credit_id => $line->id,
+                        type   => $Koha::Account::offset_type->{$credit_type} // $Koha::Account::offset_type->{CREDIT},
+                        amount => $amount
+                    }
+                )->store();
 
-            UpdateStats(
-                {   branch         => $library_id,
-                    type           => $type,
-                    amount         => $amount,
-                    borrowernumber => $self->{patron_id},
+                UpdateStats(
+                    {
+                        branch         => $library_id,
+                        type           => lc($credit_type),
+                        amount         => $amount,
+                        borrowernumber => $self->{patron_id},
+                    }
+                ) if grep { $credit_type eq $_ } ( 'PAYMENT', 'WRITEOFF' );
+
+                if ( C4::Context->preference("FinesLog") ) {
+                    logaction(
+                        "FINES", 'CREATE',
+                        $self->{patron_id},
+                        Dumper(
+                            {
+                                action            => "create_$credit_type",
+                                borrowernumber    => $self->{patron_id},
+                                amount            => $amount,
+                                description       => $description,
+                                amountoutstanding => $amount,
+                                credit_type_code  => $credit_type,
+                                note              => $note,
+                                itemnumber        => $item_id,
+                                manager_id        => $user_id,
+                                branchcode        => $library_id,
+                            }
+                        ),
+                        $interface
+                    );
                 }
-            ) if grep { $type eq $_ } ('payment', 'writeoff') ;
-
-            if ( C4::Context->preference("FinesLog") ) {
-                logaction(
-                    "FINES", 'CREATE',
-                    $self->{patron_id},
-                    Dumper(
-                        {   action            => "create_$type",
-                            borrowernumber    => $self->{patron_id},
-                            amount            => $amount,
-                            description       => $description,
-                            amountoutstanding => $amount,
-                            accounttype       => $account_type,
-                            note              => $note,
-                            itemnumber        => $item_id,
-                            manager_id        => $user_id,
-                            branchcode        => $library_id,
-                        }
-                    )
-                );
+            }
+        );
+    }
+    catch {
+        if ( ref($_) eq 'Koha::Exceptions::Object::FKConstraint' ) {
+            if ( $_->broken_fk eq 'credit_type_code' ) {
+                Koha::Exceptions::Account::UnrecognisedType->throw(
+                    error => 'Type of credit not recognised' );
+            }
+            else {
+                $_->rethrow;
             }
         }
-    );
+    };
 
     return $line;
 }
@@ -401,6 +482,7 @@ my $debit_line = Koha::Account->new({ patron_id => $patron_id })->add_debit(
         description  => $description,
         note         => $note,
         user_id      => $user_id,
+        interface    => $interface,
         library_id   => $library_id,
         type         => $debit_type,
         item_id      => $item_id,
@@ -409,16 +491,19 @@ my $debit_line = Koha::Account->new({ patron_id => $patron_id })->add_debit(
 );
 
 $debit_type can be any of:
-  - fine
-  - lost_item
-  - new_card
-  - account
+  - ACCOUNT
+  - ACCOUNT_RENEW
+  - RESERVE_EXPIRED
+  - LOST
   - sundry
-  - processing
-  - rent
-  - reserve
-  - overdue
-  - manual
+  - NEW_CARD
+  - OVERDUE
+  - PROCESSING
+  - RENT
+  - RENT_DAILY
+  - RENT_RENEW
+  - RENT_DAILY_RENEW
+  - RESERVE
 
 =cut
 
@@ -426,84 +511,105 @@ sub add_debit {
 
     my ( $self, $params ) = @_;
 
-    # amount should always be a positive value
-    my $amount       = $params->{amount};
+    # check for mandatory params
+    my @mandatory = ( 'interface', 'type', 'amount' );
+    for my $param (@mandatory) {
+        unless ( defined( $params->{$param} ) ) {
+            Koha::Exceptions::MissingParameter->throw(
+                error => "The $param parameter is mandatory" );
+        }
+    }
 
+    # amount should always be a positive value
+    my $amount = $params->{amount};
     unless ( $amount > 0 ) {
         Koha::Exceptions::Account::AmountNotPositive->throw(
-            error => 'Debit amount passed is not positive'
-        );
-    }
-
-    my $description  = $params->{description} // q{};
-    my $note         = $params->{note} // q{};
-    my $user_id      = $params->{user_id};
-    my $library_id   = $params->{library_id};
-    my $type         = $params->{type};
-    my $item_id      = $params->{item_id};
-    my $issue_id     = $params->{issue_id};
-
-    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'
-        );
+            error => 'Debit amount passed is not positive' );
     }
 
-    my $account_type = $Koha::Account::account_type_debit->{$type};
+    my $description = $params->{description} // q{};
+    my $note        = $params->{note} // q{};
+    my $user_id     = $params->{user_id};
+    my $interface   = $params->{interface};
+    my $library_id  = $params->{library_id};
+    my $debit_type  = $params->{type};
+    my $item_id     = $params->{item_id};
+    my $issue_id    = $params->{issue_id};
+    my $offset_type = $Koha::Account::offset_type->{$debit_type} // 'Manual Debit';
 
     my $line;
+    my $schema = Koha::Database->new->schema;
+    try {
+        $schema->txn_do(
+            sub {
 
-    $schema->txn_do(
-        sub {
-
-            # Insert the account line
-            $line = Koha::Account::Line->new(
-                {   borrowernumber    => $self->{patron_id},
-                    date              => \'NOW()',
-                    amount            => $amount,
-                    description       => $description,
-                    accounttype       => $account_type,
-                    amountoutstanding => $amount,
-                    payment_type      => undef,
-                    note              => $note,
-                    manager_id        => $user_id,
-                    itemnumber        => $item_id,
-                    issue_id          => $issue_id,
-                    branchcode        => $library_id,
-                    ( $type eq 'fine' ? ( lastincrement => $amount ) : ()),
-                }
-            )->store();
+                # Insert the account line
+                $line = Koha::Account::Line->new(
+                    {
+                        borrowernumber    => $self->{patron_id},
+                        date              => \'NOW()',
+                        amount            => $amount,
+                        description       => $description,
+                        debit_type_code   => $debit_type,
+                        amountoutstanding => $amount,
+                        payment_type      => undef,
+                        note              => $note,
+                        manager_id        => $user_id,
+                        interface         => $interface,
+                        itemnumber        => $item_id,
+                        issue_id          => $issue_id,
+                        branchcode        => $library_id,
+                        (
+                            $debit_type eq 'OVERDUE'
+                            ? ( status => 'UNRETURNED' )
+                            : ()
+                        ),
+                    }
+                )->store();
 
-            # Record the account offset
-            my $account_offset = Koha::Account::Offset->new(
-                {   debit_id => $line->id,
-                    type      => $Koha::Account::offset_type->{$type},
-                    amount    => $amount
+                # Record the account offset
+                my $account_offset = Koha::Account::Offset->new(
+                    {
+                        debit_id => $line->id,
+                        type     => $offset_type,
+                        amount   => $amount
+                    }
+                )->store();
+
+                if ( C4::Context->preference("FinesLog") ) {
+                    logaction(
+                        "FINES", 'CREATE',
+                        $self->{patron_id},
+                        Dumper(
+                            {
+                                action            => "create_$debit_type",
+                                borrowernumber    => $self->{patron_id},
+                                amount            => $amount,
+                                description       => $description,
+                                amountoutstanding => $amount,
+                                debit_type_code   => $debit_type,
+                                note              => $note,
+                                itemnumber        => $item_id,
+                                manager_id        => $user_id,
+                            }
+                        ),
+                        $interface
+                    );
                 }
-            )->store();
-
-            if ( C4::Context->preference("FinesLog") ) {
-                logaction(
-                    "FINES", 'CREATE',
-                    $self->{patron_id},
-                    Dumper(
-                        {   action            => "create_$type",
-                            borrowernumber    => $self->{patron_id},
-                            amount            => $amount,
-                            description       => $description,
-                            amountoutstanding => $amount,
-                            accounttype       => $account_type,
-                            note              => $note,
-                            itemnumber        => $item_id,
-                            manager_id        => $user_id,
-                        }
-                    )
-                );
+            }
+        );
+    }
+    catch {
+        if ( ref($_) eq 'Koha::Exceptions::Object::FKConstraint' ) {
+            if ( $_->broken_fk eq 'debit_type_code' ) {
+                Koha::Exceptions::Account::UnrecognisedType->throw(
+                    error => 'Type of debit not recognised' );
+            }
+            else {
+                $_->rethrow;
             }
         }
-    );
+    };
 
     return $line;
 }
@@ -581,28 +687,21 @@ Charges exempt from non-issue are:
 sub non_issues_charges {
     my ($self) = @_;
 
-    # FIXME REMOVE And add a warning in the about page + update DB if length(MANUAL_INV) > 5
-    my $ACCOUNT_TYPE_LENGTH = 5;    # this is plain ridiculous...
-
+    #NOTE: With bug 23049 these preferences could be moved to being attached
+    #to individual debit types to give more flexability and specificity.
     my @not_fines;
-    push @not_fines, 'Res'
+    push @not_fines, 'RESERVE'
       unless C4::Context->preference('HoldsInNoissuesCharge');
-    push @not_fines, 'Rent'
+    push @not_fines, ( 'RENT', 'RENT_DAILY', 'RENT_RENEW', 'RENT_DAILY_RENEW' )
       unless C4::Context->preference('RentalsInNoissuesCharge');
     unless ( C4::Context->preference('ManInvInNoissuesCharge') ) {
-        my $dbh = C4::Context->dbh;
-        push @not_fines,
-          @{
-            $dbh->selectcol_arrayref(q|
-                SELECT authorised_value FROM authorised_values WHERE category = 'MANUAL_INV'
-            |)
-          };
+        my @man_inv = Koha::Account::DebitTypes->search({ is_system => 0 })->get_column('code');
+        push @not_fines, @man_inv;
     }
-    @not_fines = map { substr( $_, 0, $ACCOUNT_TYPE_LENGTH ) } uniq(@not_fines);
 
     return $self->lines->search(
         {
-            accounttype    => { -not_in => \@not_fines }
+            debit_type_code => { -not_in => \@not_fines }
         },
     )->total_outstanding;
 }
@@ -645,7 +744,7 @@ sub reconcile_balance {
             and my $credit = $outstanding_credits->next )
     {
         # there's both outstanding debits and credits
-        $credit->apply( { debits => $outstanding_debits } );    # applying credit, no special offset
+        $credit->apply( { debits => [ $outstanding_debits->as_list ] } );    # applying credit, no special offset
 
         $outstanding_debits = $self->outstanding_debits;
 
@@ -663,49 +762,22 @@ sub reconcile_balance {
 =cut
 
 our $offset_type = {
-    'credit'           => 'Manual Credit',
-    'forgiven'         => 'Writeoff',
-    'lost_item_return' => 'Lost Item',
-    'payment'          => 'Payment',
-    'writeoff'         => 'Writeoff',
-    'account'          => 'Account Fee',
-    'reserve'          => 'Reserve Fee',
-    'processing'       => 'Processing Fee',
-    'lost_item'        => 'Lost Item',
-    'rent'             => 'Rental Fee',
-    'fine'             => 'Fine',
-    'manual_debit'     => 'Manual Debit',
-    'hold_expired'     => 'Hold Expired'
-};
-
-=head3 $account_type_credit
-
-=cut
-
-our $account_type_credit = {
-    'credit'           => 'C',
-    'forgiven'         => 'FOR',
-    'lost_item_return' => 'CR',
-    'payment'          => 'Pay',
-    'writeoff'         => 'W'
-};
-
-=head3 $account_type_debit
-
-=cut
-
-our $account_type_debit = {
-    'account'       => 'A',
-    'fine'          => 'FU',
-    'lost_item'     => 'L',
-    'new_card'      => 'N',
-    'sundry'        => 'M',
-    'processing'    => 'PF',
-    'rent'          => 'Rent',
-    'reserve'       => 'Res',
-    'overdue'       => 'O',
-    'manual_debit'  => 'M',
-    'hold_expired'  => 'HE'
+    'CREDIT'           => 'Manual Credit',
+    'FORGIVEN'         => 'Writeoff',
+    'LOST_FOUND'       => 'Lost Item Found',
+    'PAYMENT'          => 'Payment',
+    'WRITEOFF'         => 'Writeoff',
+    'ACCOUNT'          => 'Account Fee',
+    'ACCOUNT_RENEW'    => 'Account Fee',
+    'RESERVE'          => 'Reserve Fee',
+    'PROCESSING'       => 'Processing Fee',
+    'LOST'             => 'Lost Item',
+    'RENT'             => 'Rental Fee',
+    'RENT_DAILY'       => 'Rental Fee',
+    'RENT_RENEW'       => 'Rental Fee',
+    'RENT_DAILY_RENEW' => 'Rental Fee',
+    'OVERDUE'          => 'OVERDUE',
+    'RESERVE_EXPIRED'  => 'Hold Expired'
 };
 
 =head1 AUTHORS