From: erickson Date: Thu, 19 Mar 2009 19:02:30 +0000 (+0000) Subject: reactor to apply fees to a circulation X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=30456ec58aaaa5ba2b3348e4d2168f2eaf342b0a;p=evergreen%2Fmasslnc.git reactor to apply fees to a circulation git-svn-id: svn://svn.open-ils.org/ILS/trunk@12615 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor/ApplyCircFee.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor/ApplyCircFee.pm new file mode 100644 index 0000000000..bbabc84d98 --- /dev/null +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor/ApplyCircFee.pm @@ -0,0 +1,64 @@ +package OpenILS::Application::Trigger::Reactor::ApplyCircFee; +use base 'OpenILS::Application::Trigger::Reactor'; +use strict; use warnings; +use Error qw/:try/; +use OpenSRF::Utils::Logger qw/:logger/; +use OpenILS::Utils::Fieldmapper; +use OpenILS::Utils::CStoreEditor q/:funcs/; + + +sub ABOUT { + return <error("ApplyCircFee requires 'amount' and 'btype' params"); + return 0; + } + + my $e = new_editor(xact => 1); + my $type = $e->retrieve_config_billing_type($btype); + + unless($type) { + $logger->error("'$btype' is not a valid config.billing_type ID"); + $e->rollback; + return 0; + } + + my $bill = Fieldmapper::money::billing->new; + $bill->xact($circ->id); + $bill->amount($amount); + $bill->note($note); + $bill->btype($btype); + $bill->billing_type($type->name); + + unless( $e->create_money_billing($bill) ) { + $e->rollback; + return 0; + } + + $e->commit; + return 1; +} + +1;