[open-ils-commits] r12618 - in trunk/Open-ILS/src: perlmods/OpenILS perlmods/OpenILS/Application/Trigger/Reactor sql/Pg (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Mar 19 16:01:51 EDT 2009


Author: erickson
Date: 2009-03-19 16:01:47 -0400 (Thu, 19 Mar 2009)
New Revision: 12618

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor/ApplyCircFee.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Const.pm
   trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
Log:
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).

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor/ApplyCircFee.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor/ApplyCircFee.pm	2009-03-19 19:21:07 UTC (rev 12617)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor/ApplyCircFee.pm	2009-03-19 20:01:47 UTC (rev 12618)
@@ -2,22 +2,21 @@
 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 <<ABOUT;
     
-    Creates a bill (money.billing) for the configured amount, 
-    linked to the circulation.
+    Creates a bill (money.billing) for the configured amount, linked to the circulation.
+    This reactor uses the Notification Fee billing type.
+    If an event definition template is defined, it will be used to generate the bill note.
 
     Required event parameters:
         "amount" The amount to bill
-        "btype" The config.billing_type ID
-    Optional event parameters:
-        "note" Billing note
 
 ABOUT
 }
@@ -26,21 +25,14 @@
     my $self = shift;
     my $env = shift;
 
-    my $circ = $$env{target};
-    my $amount = $$env{params}{amount};
-    my $btype = $$env{params}{btype};
-    my $note = $$env{params}{note};
-
-    unless($circ and $amount and $btype) {
-        $logger->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);
 
-    unless($type) {
-        $logger->error("'$btype' is not a valid config.billing_type ID");
+    my $circ = $$env{target};
+    my $amount = $$env{params}{amount} || $btype->default_price;
+
+    unless($amount) {
+        $logger->error("ApplyCircFee needs a fee amount");
         $e->rollback;
         return 0;
     }
@@ -48,9 +40,9 @@
     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;

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Const.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Const.pm	2009-03-19 19:21:07 UTC (rev 12617)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Const.pm	2009-03-19 20:01:47 UTC (rev 12618)
@@ -113,7 +113,10 @@
 econst OILS_PENALTY_PATRON_EXCEEDS_OVERDUE_COUNT => 2;
 
 
+econst OILS_BILLING_TYPE_NOTIFICATION_FEE => 9;
 
+
+
 # ---------------------------------------------------------------------
 # finally, export all the constants
 # ---------------------------------------------------------------------

Modified: trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql	2009-03-19 19:21:07 UTC (rev 12617)
+++ trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql	2009-03-19 20:01:47 UTC (rev 12618)
@@ -868,6 +868,8 @@
 	( 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);
 



More information about the open-ils-commits mailing list