Bugzilla – Attachment 24810 Details for
Bug 6427
Rewrite of the accounts system
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6427 [Part 2] - Add new accounts related modules
Bug-6427-Part-2---Add-new-accounts-related-modules.patch (text/plain), 25.20 KB, created by
Kyle M Hall (khall)
on 2014-01-28 12:11:20 UTC
(
hide
)
Description:
Bug 6427 [Part 2] - Add new accounts related modules
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2014-01-28 12:11:20 UTC
Size:
25.20 KB
patch
obsolete
>From cd4bd4ca4e03d4c2e4f416d87323ea3ce43ae1c3 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 11 Dec 2013 10:45:26 -0500 >Subject: [PATCH] Bug 6427 [Part 2] - Add new accounts related modules > >--- > Koha/Accounts.pm | 540 ++++++++++++++++++++++++++++++++++++++++++ > Koha/Accounts/CreditTypes.pm | 117 +++++++++ > Koha/Accounts/DebitTypes.pm | 160 +++++++++++++ > Koha/Accounts/OffsetTypes.pm | 72 ++++++ > 4 files changed, 889 insertions(+), 0 deletions(-) > create mode 100644 Koha/Accounts.pm > create mode 100644 Koha/Accounts/CreditTypes.pm > create mode 100644 Koha/Accounts/DebitTypes.pm > create mode 100644 Koha/Accounts/OffsetTypes.pm > >diff --git a/Koha/Accounts.pm b/Koha/Accounts.pm >new file mode 100644 >index 0000000..0a3952a >--- /dev/null >+++ b/Koha/Accounts.pm >@@ -0,0 +1,540 @@ >+package Koha::Accounts; >+ >+# Copyright 2013 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Carp; >+use Data::Dumper qw(Dumper); >+ >+use C4::Context; >+use C4::Log qw(logaction); >+use Koha::DateUtils qw(get_timestamp); >+ >+use Koha::Accounts::CreditTypes; >+use Koha::Accounts::DebitTypes; >+ >+use vars qw($VERSION @ISA @EXPORT); >+ >+BEGIN { >+ require Exporter; >+ @ISA = qw(Exporter); >+ @EXPORT = qw( >+ AddDebit >+ AddCredit >+ >+ NormalizeBalances >+ >+ RecalculateAccountBalance >+ >+ DebitLostItem >+ CreditLostItem >+ ); >+} >+ >+=head1 NAME >+ >+Koha::Accounts - Functions for dealing with Koha accounts >+ >+=head1 SYNOPSIS >+ >+use Koha::Accounts; >+ >+=head1 DESCRIPTION >+ >+The functions in this module deal with the monetary aspect of Koha, >+including looking up and modifying the amount of money owed by a >+patron. >+ >+=head1 FUNCTIONS >+ >+=head2 AddDebit >+ >+my $debit = AddDebit({ >+ borrower => $borrower, >+ amount => $amount, >+ [ type => $type, ] >+ [ itemnumber => $itemnumber, ] >+ [ issue_id => $issue_id, ] >+ [ description => $description, ] >+ [ notes => $notes, ] >+ [ branchcode => $branchcode, ] >+ [ manager_id => $manager_id, ] >+ [ accruing => $accruing, ] # Default 0 if not accruing, 1 if accruing >+}); >+ >+Create a new debit for a given borrower. To standardize nomenclature, any charge >+against a borrower ( e.g. a fine, a new card charge, the cost of losing an item ) >+will be referred to as a 'debit'. >+ >+=cut >+ >+sub AddDebit { >+ my ($params) = @_; >+ >+ my $borrower = $params->{borrower}; >+ my $amount = $params->{amount}; >+ my $type = $params->{type}; >+ my $itemnumber = $params->{itemnumber}; >+ my $issue_id = $params->{issue_id}; >+ my $description = $params->{description}; >+ my $notes = $params->{notes}; >+ my $branchcode = $params->{branchcode}; >+ my $manager_id = $params->{manager_id}; >+ >+ my $userenv = C4::Context->userenv; >+ >+ $branchcode ||= >+ $userenv >+ ? $userenv->{branch} >+ : undef; >+ >+ $manager_id ||= >+ $userenv >+ ? $userenv->{number} >+ : undef; >+ >+ my $accruing = $params->{accruing} || 0; >+ >+ croak("Required parameter 'borrower' not passed in.") >+ unless ($borrower); >+ croak("Required parameter 'amount' not passed in.") >+ unless ($amount); >+ croak("Invalid debit type: '$type'!") >+ unless ( Koha::Accounts::DebitTypes::IsValid($type) ); >+ croak("No issue id passed in for accruing debit!") >+ if ( $accruing && !$issue_id ); >+ >+ my $debit = >+ Koha::Database->new()->schema->resultset('AccountDebit')->create( >+ { >+ borrowernumber => $borrower->borrowernumber(), >+ itemnumber => $itemnumber, >+ issue_id => $issue_id, >+ type => $type, >+ accruing => $accruing, >+ amount_original => $amount, >+ amount_outstanding => $amount, >+ amount_last_increment => $amount, >+ description => $description, >+ notes => $notes, >+ branchcode => $branchcode, >+ manager_id => $manager_id, >+ created_on => get_timestamp(), >+ } >+ ); >+ >+ if ($debit) { >+ $borrower->account_balance( $borrower->account_balance() + $amount ); >+ $borrower->update(); >+ >+ NormalizeBalances( { borrower => $borrower } ); >+ >+ if ( C4::Context->preference("FinesLog") ) { >+ logaction( "FINES", "CREATE_FEE", $debit->id, >+ Dumper( $debit->get_columns() ) ); >+ } >+ } >+ else { >+ carp("Something went wrong! Debit not created!"); >+ } >+ >+ return $debit; >+} >+ >+=head2 DebitLostItem >+ >+my $debit = DebitLostItem({ >+ borrower => $borrower, >+ issue => $issue, >+}); >+ >+DebitLostItem adds a replacement fee charge for the item >+of the given issue. >+ >+=cut >+ >+sub DebitLostItem { >+ my ($params) = @_; >+ >+ my $borrower = $params->{borrower}; >+ my $issue = $params->{issue}; >+ >+ croak("Required param 'borrower' not passed in!") unless ($borrower); >+ croak("Required param 'issue' not passed in!") unless ($issue); >+ >+# Don't add lost debit if borrower has already been charged for this lost item before, >+# for this issue. It seems reasonable that a borrower could lose an item, find and return it, >+# check it out again, and lose it again, so we should do this based on issue_id, not itemnumber. >+ unless ( >+ Koha::Database->new()->schema->resultset('AccountDebit')->search( >+ { >+ borrowernumber => $borrower->borrowernumber(), >+ issue_id => $issue->issue_id(), >+ type => Koha::Accounts::DebitTypes::Lost >+ } >+ )->count() >+ ) >+ { >+ my $item = $issue->item(); >+ >+ $params->{accruing} = 0; >+ $params->{type} = Koha::Accounts::DebitTypes::Lost; >+ $params->{amount} = $item->replacementprice(); >+ $params->{itemnumber} = $item->itemnumber(); >+ $params->{issue_id} = $issue->issue_id(); >+ >+ #TODO: Shouldn't we have a default replacement price as a syspref? >+ if ( $params->{amount} ) { >+ return AddDebit($params); >+ } >+ else { >+ carp("Cannot add lost debit! Item has no replacement price!"); >+ } >+ } >+} >+ >+=head2 CreditLostItem >+ >+my $debit = CreditLostItem( >+ { >+ borrower => $borrower, >+ debit => $debit, >+ } >+); >+ >+CreditLostItem creates a payment in the amount equal >+to the replacement price charge created by DebitLostItem. >+ >+=cut >+ >+sub CreditLostItem { >+ my ($params) = @_; >+ >+ my $borrower = $params->{borrower}; >+ my $debit = $params->{debit}; >+ >+ croak("Required param 'borrower' not passed in!") unless ($borrower); >+ croak("Required param 'debit' not passed in!") >+ unless ($debit); >+ >+ my $item = >+ Koha::Database->new()->schema->resultset('Item') >+ ->find( $debit->itemnumber() ); >+ carp("No item found!") unless $item; >+ >+ $params->{type} = Koha::Accounts::CreditTypes::Found; >+ $params->{amount} = $debit->amount_original(); >+ $params->{debit_id} = $debit->debit_id(); >+ $params->{notes} = "Lost item found: " . $item->barcode(); >+ >+ return AddCredit($params); >+} >+ >+=head2 AddCredit >+ >+AddCredit({ >+ borrower => $borrower, >+ amount => $amount, >+ [ branchcode => $branchcode, ] >+ [ manager_id => $manager_id, ] >+ [ debit_id => $debit_id, ] # The primary debit to be paid >+ [ notes => $notes, ] >+}); >+ >+Record credit by a patron. C<$borrowernumber> is the patron's >+borrower number. C<$credit> is a floating-point number, giving the >+amount that was paid. >+ >+Amounts owed are paid off oldest first. That is, if the patron has a >+$1 fine from Feb. 1, another $1 fine from Mar. 1, and makes a credit >+of $1.50, then the oldest fine will be paid off in full, and $0.50 >+will be credited to the next one. >+ >+debit_id can be passed as a scalar or an array ref to make the passed >+in debit or debits the first to be credited. >+ >+=cut >+ >+sub AddCredit { >+ my ($params) = @_; >+ >+ my $type = $params->{type}; >+ my $borrower = $params->{borrower}; >+ my $amount = $params->{amount}; >+ my $amount_received = $params->{amount_received}; >+ my $debit_id = $params->{debit_id}; >+ my $notes = $params->{notes}; >+ my $branchcode = $params->{branchcode}; >+ my $manager_id = $params->{manager_id}; >+ >+ my $userenv = C4::Context->userenv; >+ >+ $branchcode ||= >+ $userenv >+ ? $userenv->{branch} >+ : undef; >+ >+ $manager_id ||= >+ $userenv >+ ? $userenv->{number} >+ : undef; >+ >+ unless ($borrower) { >+ croak("Required parameter 'borrower' not passed in"); >+ } >+ unless ($amount) { >+ croak("Required parameter amount not passed in"); >+ } >+ >+ unless ( Koha::Accounts::CreditTypes::IsValid($type) ) { >+ carp("Invalid credit type! Returning without creating credit."); >+ return; >+ } >+ >+ unless ($type) { >+ carp("No type passed in, assuming Payment"); >+ $type = Koha::Accounts::CreditTypes::Payment; >+ } >+ >+ my $debit = >+ Koha::Database->new()->schema->resultset('AccountDebit')->find($debit_id); >+ >+ # First, we make the credit. We'll worry about what we paid later on >+ my $credit = >+ Koha::Database->new()->schema->resultset('AccountCredit')->create( >+ { >+ borrowernumber => $borrower->borrowernumber(), >+ type => $type, >+ amount_received => $amount_received, >+ amount_paid => $amount, >+ amount_remaining => $amount, >+ notes => $notes, >+ branchcode => $branchcode, >+ manager_id => $manager_id, >+ created_on => get_timestamp(), >+ } >+ ); >+ >+ if ( C4::Context->preference("FinesLog") ) { >+ logaction( "FINES", "CREATE_PAYMENT", $credit->id, >+ Dumper( $credit->get_columns() ) ); >+ } >+ >+ $borrower->account_balance( $borrower->account_balance() - $amount ); >+ $borrower->update(); >+ >+ # If we are given specific debits, pay those ones first. >+ if ($debit_id) { >+ my @debit_ids = ref($debit_id) eq "ARRAY" ? @$debit_id : $debit_id; >+ foreach my $debit_id (@debit_ids) { >+ my $debit = >+ Koha::Database->new()->schema->resultset('AccountDebit') >+ ->find($debit_id); >+ >+ if ($debit) { >+ CreditDebit( { credit => $credit, debit => $debit } ); >+ } >+ else { >+ carp("Invalid debit_id passed in!"); >+ } >+ } >+ } >+ >+ # We still have leftover money, or we weren't given a specific debit to pay >+ if ( $credit->amount_remaining() > 0 ) { >+ my @debits = >+ Koha::Database->new()->schema->resultset('AccountDebit')->search( >+ { >+ borrowernumber => $borrower->borrowernumber(), >+ amount_outstanding => { '>' => '0' } >+ } >+ ); >+ >+ foreach my $debit (@debits) { >+ if ( $credit->amount_remaining() > 0 ) { >+ CreditDebit( >+ { >+ credit => $credit, >+ debit => $debit, >+ borrower => $borrower, >+ type => $type, >+ } >+ ); >+ } >+ } >+ } >+ >+ return $credit; >+} >+ >+=head2 CreditDebit >+ >+$account_offset = CreditDebit({ >+ credit => $credit, >+ debit => $debit, >+}); >+ >+Given a credit and a debit, this subroutine >+will pay the appropriate amount of the debit, >+update the debit's amount outstanding, the credit's >+amout remaining, and create the appropriate account >+offset. >+ >+=cut >+ >+sub CreditDebit { >+ my ($params) = @_; >+ >+ my $credit = $params->{credit}; >+ my $debit = $params->{debit}; >+ >+ croak("Required parameter 'credit' not passed in!") >+ unless $credit; >+ croak("Required parameter 'debit' not passed in!") unless $debit; >+ >+ my $amount_to_pay = >+ ( $debit->amount_outstanding() > $credit->amount_remaining() ) >+ ? $credit->amount_remaining() >+ : $debit->amount_outstanding(); >+ >+ if ( $amount_to_pay > 0 ) { >+ $debit->amount_outstanding( >+ $debit->amount_outstanding() - $amount_to_pay ); >+ $debit->update(); >+ >+ $credit->amount_remaining( >+ $credit->amount_remaining() - $amount_to_pay ); >+ $credit->update(); >+ >+ my $offset = >+ Koha::Database->new()->schema->resultset('AccountOffset')->create( >+ { >+ amount => $amount_to_pay * -1, >+ debit_id => $debit->id(), >+ credit_id => $credit->id(), >+ created_on => get_timestamp(), >+ } >+ ); >+ >+ if ( C4::Context->preference("FinesLog") ) { >+ logaction( "FINES", "MODIFY", $offset->id, >+ Dumper( $offset->get_columns() ) ); >+ } >+ >+ return $offset; >+ } >+} >+ >+=head2 RecalculateAccountBalance >+ >+$account_balance = RecalculateAccountBalance({ >+ borrower => $borrower >+}); >+ >+Recalculates a borrower's balance based on the >+sum of the amount outstanding for the borrower's >+debits minus the sum of the amount remaining for >+the borrowers credits. >+ >+TODO: Would it be better to use af.amount_original - ap.amount_paid for any reason? >+ Or, perhaps calculate both and compare the two, for error checking purposes. >+=cut >+ >+sub RecalculateAccountBalance { >+ my ($params) = @_; >+ >+ my $borrower = $params->{borrower}; >+ croak("Requred paramter 'borrower' not passed in!") >+ unless ($borrower); >+ >+ my $debits = >+ Koha::Database->new()->schema->resultset('AccountDebit') >+ ->search( { borrowernumber => $borrower->borrowernumber() } ); >+ my $amount_outstanding = $debits->get_column('amount_outstanding')->sum() || 0; >+ >+ my $credits = >+ Koha::Database->new()->schema->resultset('AccountCredit') >+ ->search( { borrowernumber => $borrower->borrowernumber() } ); >+ my $amount_remaining = $credits->get_column('amount_remaining')->sum() || 0; >+ >+ my $account_balance = $amount_outstanding - $amount_remaining; >+ $borrower->account_balance($account_balance); >+ $borrower->update(); >+ >+ return $account_balance; >+} >+ >+=head2 NormalizeBalances >+ >+ $account_balance = NormalizeBalances({ borrower => $borrower }); >+ >+ For a given borrower, this subroutine will find all debits >+ with an outstanding balance and all credits with an unused >+ amount remaining and will pay those debits with those credits. >+ >+=cut >+ >+sub NormalizeBalances { >+ my ($params) = @_; >+ >+ my $borrower = $params->{borrower}; >+ >+ croak("Required param 'borrower' not passed in!") unless $borrower; >+ >+ my @credits = >+ Koha::Database->new()->schema->resultset('AccountCredit')->search( >+ { >+ borrowernumber => $borrower->borrowernumber(), >+ amount_remaining => { '>' => '0' } >+ } >+ ); >+ >+ return unless @credits; >+ >+ my @debits = >+ Koha::Database->new()->schema->resultset('AccountDebit')->search( >+ { >+ borrowernumber => $borrower->borrowernumber(), >+ amount_outstanding => { '>' => '0' } >+ } >+ ); >+ >+ return unless @debits; >+ >+ foreach my $credit (@credits) { >+ foreach my $debit (@debits) { >+ if ( $credit->amount_remaining() >+ && $debit->amount_outstanding() ) >+ { >+ CreditDebit( { credit => $credit, debit => $debit } ); >+ } >+ } >+ } >+ >+ return RecalculateAccountBalance( { borrower => $borrower } ); >+} >+ >+1; >+__END__ >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >diff --git a/Koha/Accounts/CreditTypes.pm b/Koha/Accounts/CreditTypes.pm >new file mode 100644 >index 0000000..3916c72 >--- /dev/null >+++ b/Koha/Accounts/CreditTypes.pm >@@ -0,0 +1,117 @@ >+package Koha::Accounts::CreditTypes; >+ >+# Copyright 2013 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+=head1 NAME >+ >+Koha::AccountsCreditTypes - Module representing the enumerated data types for account fees >+ >+=head1 SYNOPSIS >+ >+use Koha::Accounts::CreditTypes; >+ >+my $type = Koha::Accounts::CreditTypes::Payment; >+ >+=head1 DESCRIPTION >+ >+The subroutines in this modules act as enumerated data types for the >+different credit types in Koha ( i.e. payments, writeoffs, etc. ) >+ >+=head1 FUNCTIONS >+ >+=head2 IsValid >+ >+This subroutine takes a given string and returns 1 if >+the string matches one of the data types, and 0 if not. >+ >+FIXME: Perhaps we should use Class::Inspector instead of hard >+coding the subs? It seems like it would be a major trade off >+of speed just so we don't update something in two separate places >+in the same file. >+ >+=cut >+ >+sub IsValid { >+ my ($string) = @_; >+ >+ my $is_valid = >+ ( $string eq Koha::Accounts::CreditTypes::Payment() >+ || $string eq Koha::Accounts::CreditTypes::WriteOff() >+ || $string eq Koha::Accounts::CreditTypes::Found() >+ || $string eq Koha::Accounts::CreditTypes::Credit() >+ || $string eq Koha::Accounts::CreditTypes::Forgiven() ); >+ >+ unless ($is_valid) { >+ $is_valid = >+ Koha::Database->new()->schema->resultset('AuthorisedValue') >+ ->count( >+ { category => 'MANUAL_CREDIT', authorised_value => $string } ); >+ } >+ >+ return $is_valid; >+} >+ >+=head2 Credit >+ >+=cut >+ >+sub Credit { >+ return 'CREDIT'; >+} >+ >+=head2 Payment >+ >+=cut >+ >+sub Payment { >+ return 'PAYMENT'; >+} >+ >+=head2 Writeoff >+ >+=cut >+ >+sub WriteOff { >+ return 'WRITEOFF'; >+} >+ >+=head2 Writeoff >+ >+=cut >+ >+sub Found { >+ return 'FOUND'; >+} >+ >+=head2 Forgiven >+ >+=cut >+ >+sub Forgiven { >+ return 'FORGIVEN'; >+} >+ >+1; >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >diff --git a/Koha/Accounts/DebitTypes.pm b/Koha/Accounts/DebitTypes.pm >new file mode 100644 >index 0000000..435f6d6 >--- /dev/null >+++ b/Koha/Accounts/DebitTypes.pm >@@ -0,0 +1,160 @@ >+package Koha::Accounts::DebitTypes; >+ >+# Copyright 2013 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+=head1 NAME >+ >+Koha::Accounts::DebitTypes - Module representing an enumerated data type for account fees >+ >+=head1 SYNOPSIS >+ >+use Koha::Accounts::DebitTypes; >+ >+my $type = Koha::Accounts::DebitTypes::Fine; >+ >+=head1 DESCRIPTION >+ >+The subroutines in this modules act as an enumerated data type >+for debit types ( stored in account_debits.type ) in Koha. >+ >+=head1 FUNCTIONS >+ >+=head2 IsValid >+ >+This subroutine takes a given string and returns 1 if >+the string matches one of the data types, and 0 if not. >+ >+=cut >+ >+sub IsValid { >+ my ($string) = @_; >+ >+ my $is_valid = >+ ( $string eq Koha::Accounts::DebitTypes::Fine() >+ || $string eq Koha::Accounts::DebitTypes::AccountManagementFee() >+ || $string eq Koha::Accounts::DebitTypes::Sundry() >+ || $string eq Koha::Accounts::DebitTypes::Lost() >+ || $string eq Koha::Accounts::DebitTypes::Hold() >+ || $string eq Koha::Accounts::DebitTypes::Rental() >+ || $string eq Koha::Accounts::DebitTypes::NewCard() ); >+ >+ unless ($is_valid) { >+ $is_valid = >+ Koha::Database->new()->schema->resultset('AuthorisedValue') >+ ->count( { category => 'MANUAL_INV', authorised_value => $string } ); >+ } >+ >+ return $is_valid; >+} >+ >+=head2 Fine >+ >+This data type represents a standard fine within Koha. >+ >+A fine still accruing no longer needs to be differiated by type >+from a fine done accuring. Instead, that differentication is made >+by which table the fine exists in, account_fees_accruing vs account_fees_accrued. >+ >+In addition, fines can be checked for correctness based on the issue_id >+they have. A fine in account_fees_accruing should always have a matching >+issue_id in the issues table. A fine done accruing will almost always have >+a matching issue_id in the old_issues table. However, in the case of an overdue >+item with fines that has been renewed, and becomes overdue again, you may have >+a case where a given issue may have a matching fine in account_fees_accruing and >+one or more matching fines in account_fees_accrued ( one for each for the first >+checkout and one each for any subsequent renewals ) >+ >+=cut >+ >+sub Fine { >+ return 'FINE'; >+} >+ >+=head2 AccountManagementFee >+ >+This fee type is usually reserved for payments for library cards, >+in cases where a library must charge a patron for the ability to >+check out items. >+ >+=cut >+ >+sub AccountManagementFee { >+ return 'ACCOUNT_MANAGEMENT_FEE'; >+} >+ >+=head2 Sundry >+ >+This fee type is basically a 'misc' type, and should be used >+when no other fee type is more appropriate. >+ >+=cut >+ >+sub Sundry { >+ return 'SUNDRY'; >+} >+ >+=head2 Lost >+ >+This fee type is used when a library charges for lost items. >+ >+=cut >+ >+sub Lost { >+ return 'LOST'; >+} >+ >+=head2 Hold >+ >+This fee type is used when a library charges for holds. >+ >+=cut >+ >+sub Hold { >+ return 'HOLD'; >+} >+ >+=head2 Rental >+ >+This fee type is used when a library charges a rental fee for the item type. >+ >+=cut >+ >+sub Rental { >+ return 'RENTAL'; >+} >+ >+=head2 NewCard >+ >+This fee type is used when a library charges for replacement >+library cards. >+ >+=cut >+ >+sub NewCard { >+ return 'NEW_CARD'; >+} >+ >+1; >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >diff --git a/Koha/Accounts/OffsetTypes.pm b/Koha/Accounts/OffsetTypes.pm >new file mode 100644 >index 0000000..6650781 >--- /dev/null >+++ b/Koha/Accounts/OffsetTypes.pm >@@ -0,0 +1,72 @@ >+package Koha::Accounts::OffsetTypes; >+ >+# Copyright 2013 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+=head1 NAME >+ >+Koha::AccountsOffsetTypes - Module representing the enumerated data types for account fees >+ >+=head1 SYNOPSIS >+ >+use Koha::Accounts::OffsetTypes; >+ >+my $type = Koha::Accounts::OffsetTypes::Dropbox; >+ >+=head1 DESCRIPTION >+ >+The subroutines in this modules act as enumerated data types for the >+different automatic offset types in Koha ( i.e. forgiveness, dropbox mode, etc ) >+ >+These types are used for account offsets that have no corrosponding account credit, >+e.g. automatic fine increments, dropbox mode, etc. >+ >+=head1 FUNCTIONS >+ >+=cut >+ >+=head2 Dropbox >+ >+Offset type for automatic fine reductions >+via dropbox mode. >+ >+=cut >+ >+sub Dropbox { >+ return 'DROPBOX'; >+} >+ >+=head2 Fine >+ >+Indicates this offset was an automatically >+generated fine increment/decrement. >+ >+=cut >+ >+sub Fine { >+ return 'FINE'; >+} >+ >+1; >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6427
:
21922
|
22704
|
22705
|
22708
|
22709
|
22710
|
22741
|
22870
|
22871
|
22872
|
22873
|
22874
|
22875
|
22876
|
22881
|
22889
|
22940
|
22948
|
22949
|
22995
|
23000
|
23137
|
23158
|
23161
|
23171
|
23186
|
23269
|
23275
|
23276
|
23391
|
23392
|
23400
|
23401
|
23402
|
23403
|
23404
|
23405
|
23406
|
23407
|
23408
|
23409
|
23410
|
23411
|
23412
|
23413
|
23420
|
23421
|
23422
|
23423
|
23424
|
23425
|
23426
|
23427
|
23428
|
23429
|
23430
|
23431
|
23432
|
23433
|
23440
|
23441
|
23442
|
23443
|
23444
|
23445
|
23446
|
23447
|
23448
|
23449
|
23450
|
23451
|
23452
|
23453
|
23454
|
23458
|
23459
|
23460
|
23461
|
23462
|
23463
|
23464
|
23465
|
23466
|
23467
|
23468
|
23469
|
23470
|
23471
|
23603
|
23643
|
23644
|
23645
|
23646
|
23647
|
23648
|
23649
|
23650
|
23651
|
23652
|
23653
|
23654
|
23655
|
23656
|
23657
|
23937
|
23938
|
23939
|
23940
|
23941
|
23942
|
23943
|
23944
|
23945
|
23946
|
23947
|
23948
|
23949
|
23950
|
23951
|
24612
|
24613
|
24614
|
24615
|
24616
|
24617
|
24618
|
24619
|
24620
|
24621
|
24622
|
24623
|
24624
|
24625
|
24626
|
24627
|
24628
|
24757
|
24758
|
24759
|
24760
|
24761
|
24762
|
24763
|
24764
|
24765
|
24766
|
24767
|
24768
|
24769
|
24770
|
24771
|
24772
|
24777
|
24792
|
24793
|
24794
|
24795
|
24796
|
24797
|
24798
|
24799
|
24800
|
24801
|
24802
|
24803
|
24804
|
24805
|
24806
|
24807
|
24808
|
24809
|
24810
|
24811
|
24812
|
24813
|
24814
|
24815
|
24816
|
24817
|
24818
|
24819
|
24820
|
24821
|
24822
|
24823
|
24824
|
24825
|
24826
|
24827
|
24828
|
24829
|
24830
|
24831
|
24832
|
24833
|
24834
|
24835
|
24836
|
24837
|
24838
|
24839
|
24840
|
24841
|
24842
|
24843
|
24844
|
25777
|
25778
|
25779
|
25780
|
25781
|
25782
|
25783
|
25784
|
25785
|
25786
|
25787
|
25788
|
25789
|
25790
|
25791
|
25792
|
25793
|
25794
|
25795
|
25796
|
25797
|
25798
|
25799
|
25800
|
25801
|
25802
|
25803
|
25804
|
25805
|
25806
|
25807
|
25808
|
25809
|
25810
|
25811
|
25812
|
25813
|
25814
|
25815
|
25816
|
25930
|
25932
|
25933
|
25934
|
26033
|
26034
|
26035
|
26036
|
26107
|
27167
|
27168
|
27169
|
27170
|
27171
|
27172
|
27173
|
27174
|
27175
|
27176
|
27177
|
27178
|
27179
|
27180
|
27181
|
27182
|
27183
|
27184
|
27185
|
27186
|
27187
|
27189
|
27190
|
27197
|
28067
|
28068
|
28069
|
28070
|
28071
|
28072
|
28073
|
28074
|
28075
|
28076
|
28077
|
28078
|
28079
|
28080
|
28081
|
28082
|
28083
|
28084
|
28085
|
28086
|
28087
|
28088
|
28089
|
28090
|
28091
|
28527
|
28528
|
28529
|
28530
|
28531
|
28532
|
28533
|
28534
|
28535
|
28536
|
28537
|
28538
|
28539
|
28540
|
28541
|
28542
|
28543
|
28544
|
28545
|
28546
|
28547
|
28548
|
28549
|
28550
|
28551
|
28552
|
28553
|
28555
|
28556
|
28561
|
28563
|
28564
|
28795
|
28796
|
28797
|
28798
|
28799
|
28800
|
28801
|
28802
|
28803
|
28804
|
28805
|
28806
|
28807
|
28808
|
28809
|
28810
|
28811
|
28812
|
28813
|
28814
|
28815
|
28816
|
28817
|
28818
|
28819
|
28820
|
28821
|
28822
|
28887
|
28888
|
28889
|
28890
|
28909
|
29176
|
29230
|
29231
|
29232
|
29233
|
29234
|
29235
|
29236
|
29237
|
29238
|
29239
|
29240
|
29241
|
29242
|
29243
|
29244
|
29245
|
29246
|
29247
|
29248
|
29249
|
29250
|
29251
|
29252
|
29253
|
29254
|
29255
|
29256
|
29257
|
29258
|
29259
|
29260
|
29261
|
29262
|
29263
|
29264
|
29265
|
29706
|
29707
|
29708
|
29709
|
29710
|
29711
|
29712
|
29713
|
29714
|
29715
|
29716
|
29717
|
29719
|
29720
|
29721
|
29722
|
29723
|
29724
|
29725
|
29726
|
29727
|
29728
|
29729
|
29730
|
30271
|
30272
|
30273
|
30274
|
30275
|
30276
|
30277
|
30278
|
30279
|
30280
|
30281
|
30282
|
30320
|
30321
|
30322
|
30323
|
30324
|
30325
|
30326
|
30327
|
30328
|
30329
|
30330
|
30331
|
30416
|
30417
|
30418
|
30419
|
30420
|
30421
|
30422
|
30423
|
30424
|
30425
|
30426
|
30427
|
31477
|
31478
|
31479
|
31480
|
31481
|
31482
|
31483
|
31484
|
31485
|
31486
|
31487
|
31488
|
31754
|
31755
|
31756
|
31757
|
31758
|
31759
|
31760
|
31761
|
31762
|
31763
|
31764
|
31765
|
31766
|
31767
|
31768
|
31769
|
31770
|
31771
|
31772
|
31773
|
31774
|
31775
|
31776
|
31777
|
32478
|
32479
|
32480
|
32481
|
32482
|
32483
|
32484
|
32485
|
32486
|
32487
|
32488
|
32489
|
32591
|
32592
|
32593
|
32594
|
32595
|
32596
|
32597
|
32598
|
32599
|
32600
|
32601
|
32602
|
32827
|
32828
|
32829
|
32830
|
32831
|
32832
|
32833
|
32834
|
32835
|
32836
|
32837
|
32838
|
33251
|
33252
|
33253
|
33254
|
33255
|
33256
|
33257
|
33258
|
33259
|
33260
|
33261
|
33262
|
34096
|
34097
|
34098
|
34099
|
34100
|
34101
|
34102
|
34103
|
34104
|
34105
|
34106
|
34107
|
34204
|
34205
|
34206
|
34207
|
34208
|
34209
|
34210
|
34211
|
34212
|
34213
|
34214
|
34215
|
35196
|
35197
|
35198
|
35199
|
35200
|
35201
|
35202
|
35203
|
35204
|
35205
|
35206
|
35207
|
35208
|
35302
|
36324
|
36326
|
36327
|
36328
|
36329
|
36330
|
36331
|
36332
|
36333
|
36334
|
36335
|
36337
|
36338
|
36340
|
36380
|
36391
|
36393
|
37127
|
37128
|
37129
|
37130
|
37131
|
37133
|
37134
|
37135
|
37136
|
37137
|
37138
|
37139
|
37140
|
37141
|
37142
|
37143
|
37147
|
37148
|
37149
|
37150
|
37151
|
37152
|
37153
|
37154
|
37155
|
37156
|
37157
|
37158
|
37159
|
37160
|
37161
|
37162
|
37229
|
37230
|
37231
|
37232
|
37233
|
37234
|
37235
|
37236
|
37237
|
37238
|
37239
|
37240
|
37241
|
37242
|
37243
|
37244
|
38247
|
38248
|
38249
|
38250
|
38251
|
38252
|
38253
|
38254
|
38255
|
38256
|
38257
|
38258
|
38259
|
38260
|
38261
|
38262
|
39063
|
39064
|
39065
|
39066
|
39067
|
39069
|
39070
|
39071
|
39072
|
39073
|
39074
|
39075
|
39076
|
39077
|
39078
|
39079
|
39671
|
39672
|
39673
|
39674
|
39675
|
39676
|
39677
|
39678
|
39679
|
39680
|
39681
|
39682
|
39683
|
39684
|
39685
|
39686