From c0c60f45429c4512e6484b2b85c9ca39ac783ed2 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 19 Mar 2009 20:01:47 +0000 Subject: [PATCH] use the event def template for the bill note (thanks, miker) instead of using a param. Created a system billing type of Notification Fee, also so none is needed via event param. Added first billing type const (yay). git-svn-id: svn://svn.open-ils.org/ILS/trunk@12618 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../Application/Trigger/Reactor/ApplyCircFee.pm | 36 +++++++++------------- Open-ILS/src/perlmods/OpenILS/Const.pm | 3 ++ Open-ILS/src/sql/Pg/950.data.seed-values.sql | 2 ++ 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor/ApplyCircFee.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor/ApplyCircFee.pm index bbabc84d98..1574b2bdee 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor/ApplyCircFee.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor/ApplyCircFee.pm @@ -2,22 +2,21 @@ 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::Const qw/:const/; use OpenILS::Utils::Fieldmapper; +use OpenSRF::Utils::Logger qw/:logger/; 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); + my $btype = $e->retrieve_config_billing_type(OILS_BILLING_TYPE_NOTIFICATION_FEE); + + my $circ = $$env{target}; + my $amount = $$env{params}{amount} || $btype->default_price; - unless($type) { - $logger->error("'$btype' is not a valid config.billing_type ID"); + unless($amount) { + $logger->error("ApplyCircFee needs a fee amount"); $e->rollback; return 0; } @@ -48,9 +40,9 @@ sub handler { my $bill = Fieldmapper::money::billing->new; $bill->xact($circ->id); $bill->amount($amount); - $bill->note($note); - $bill->btype($btype); - $bill->billing_type($type->name); + $bill->btype(OILS_BILLING_TYPE_NOTIFICATION_FEE); + $bill->billing_type($btype->name); + $bill->note($self->run_TT($env)); unless( $e->create_money_billing($bill) ) { $e->rollback; diff --git a/Open-ILS/src/perlmods/OpenILS/Const.pm b/Open-ILS/src/perlmods/OpenILS/Const.pm index 78c2af48d0..5d58ef63ee 100644 --- a/Open-ILS/src/perlmods/OpenILS/Const.pm +++ b/Open-ILS/src/perlmods/OpenILS/Const.pm @@ -113,6 +113,9 @@ econst OILS_PENALTY_PATRON_EXCEEDS_FINES => 1; econst OILS_PENALTY_PATRON_EXCEEDS_OVERDUE_COUNT => 2; +econst OILS_BILLING_TYPE_NOTIFICATION_FEE => 9; + + # --------------------------------------------------------------------- # finally, export all the constants diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 1c968fffb9..00eb86fb6f 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -868,6 +868,8 @@ INSERT INTO config.billing_type (id, name, owner) VALUES ( 7, oils_i18n_gettext(7, 'Damaged Item', 'cbt', 'name'), 1); INSERT INTO config.billing_type (id, name, owner) VALUES ( 8, oils_i18n_gettext(8, 'Damaged Item Processing Fee', 'cbt', 'name'), 1); +INSERT INTO config.billing_type (id, name, owner) VALUES + ( 9, oils_i18n_gettext(9, 'Notification Fee', 'cbt', 'name'), 1); SELECT SETVAL('config.billing_type_id_seq'::TEXT, 100); -- 2.11.0