use the event def template for the bill note (thanks, miker) instead of using a param...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 19 Mar 2009 20:01:47 +0000 (20:01 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 19 Mar 2009 20:01:47 +0000 (20:01 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12618 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor/ApplyCircFee.pm
Open-ILS/src/perlmods/OpenILS/Const.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql

index bbabc84..1574b2b 100644 (file)
@@ -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 <<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 @@ sub handler {
     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);
+
+    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;
index 78c2af4..5d58ef6 100644 (file)
@@ -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
index 1c968ff..00eb86f 100644 (file)
@@ -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);