[open-ils-commits] r14197 - in trunk/Open-ILS: src/perlmods/OpenILS/Application/Circ src/sql/Pg src/sql/Pg/upgrade xul/staff_client/chrome/content/main xul/staff_client/server/locale/en-US xul/staff_client/server/patron (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Sep 29 03:01:42 EDT 2009


Author: phasefx
Date: 2009-09-29 03:01:37 -0400 (Tue, 29 Sep 2009)
New Revision: 14197

Added:
   trunk/Open-ILS/src/sql/Pg/upgrade/0028.schema.payment_view_rule_and_edit_payment_note_perm.sql
Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm
   trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
   trunk/Open-ILS/src/sql/Pg/080.schema.money.sql
   trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
   trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js
   trunk/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties
   trunk/Open-ILS/xul/staff_client/server/patron/bill_details.js
   trunk/Open-ILS/xul/staff_client/server/patron/bill_details.xul
Log:
Adds an update rule to money.payment_view since the "mp" class is based on it and we want to be able to edit notes on mp's.  Perm, middle layer, and UI changes to support editing notes on payments.



Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm	2009-09-29 05:46:49 UTC (rev 14196)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm	2009-09-29 07:01:37 UTC (rev 14197)
@@ -357,7 +357,7 @@
 	signature	=> q/
 		Voids a bill
 		@param authtoken Login session key
-		@param billid Id for the bill to void.  This parameter may be repeated for reference other bills.
+		@param billid Id for the bill to void.  This parameter may be repeated to reference other bills.
 		@return 1 on success, Event on error
 	/
 );
@@ -428,15 +428,11 @@
 	return $e->die_event unless $e->checkauth;
 	return $e->die_event unless $e->allowed('UPDATE_BILL_NOTE');
 
-    my %users;
     for my $billid (@billids) {
 
 	    my $bill = $e->retrieve_money_billing($billid)
 		    or return $e->die_event;
 
-        my $xact = $e->retrieve_money_billable_transaction($bill->xact)
-            or return $e->die_event;
-
 	    $bill->note($note);
         # FIXME: Does this get audited?  Need some way so that the original creator of the bill does not get credit/blame for the new note.
     
@@ -447,7 +443,41 @@
 	return 1;
 }
 
+__PACKAGE__->register_method(
+	method		=>	'edit_payment_note',
+	api_name		=> 'open-ils.circ.money.payment.note.edit',
+	signature	=> q/
+		Edits the note for a payment
+		@param authtoken Login session key
+        @param note The replacement note for the payments we're editing
+		@param paymentid Id for the payment to edit the note of.  This parameter may be repeated to reference other payments.
+		@return 1 on success, Event on error
+	/
+);
 
+
+sub edit_payment_note {
+	my( $s, $c, $authtoken, $note, @paymentids ) = @_;
+
+	my $e = new_editor( authtoken => $authtoken, xact => 1 );
+	return $e->die_event unless $e->checkauth;
+	return $e->die_event unless $e->allowed('UPDATE_PAYMENT_NOTE');
+
+    for my $paymentid (@paymentids) {
+
+	    my $payment = $e->retrieve_money_payment($paymentid)
+		    or return $e->die_event;
+
+	    $payment->note($note);
+        # FIXME: Does this get audited?  Need some way so that the original taker of the payment does not get credit/blame for the new note.
+    
+	    $e->update_money_payment($payment) or return $e->die_event;
+    }
+
+	$e->commit;
+	return 1;
+}
+
 sub _check_open_xact {
 	my( $editor, $xactid, $xact ) = @_;
 

Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2009-09-29 05:46:49 UTC (rev 14196)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2009-09-29 07:01:37 UTC (rev 14197)
@@ -51,7 +51,7 @@
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0027'); -- phasefx
+INSERT INTO config.upgrade_log (version) VALUES ('0028'); -- phasefx
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,

Modified: trunk/Open-ILS/src/sql/Pg/080.schema.money.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/080.schema.money.sql	2009-09-29 05:46:49 UTC (rev 14196)
+++ trunk/Open-ILS/src/sql/Pg/080.schema.money.sql	2009-09-29 07:01:37 UTC (rev 14197)
@@ -79,6 +79,9 @@
 	  FROM	money.payment p
 	  	JOIN pg_class c ON (p.tableoid = c.oid);
 
+CREATE OR REPLACE RULE money_payment_view_update AS ON UPDATE TO money.payment_view DO INSTEAD 
+    UPDATE money.payment SET xact = NEW.xact, payment_ts = NEW.payment_ts, voided = NEW.voided, amount = NEW.amount, note = NEW.note WHERE id = NEW.id;
+
 CREATE OR REPLACE VIEW money.transaction_billing_type_summary AS
 	SELECT	xact,
 		billing_type AS last_billing_type,

Modified: trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql	2009-09-29 05:46:49 UTC (rev 14196)
+++ trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql	2009-09-29 07:01:37 UTC (rev 14197)
@@ -1222,7 +1222,8 @@
     (344,'SET_CIRC_CLAIMS_RETURNED.override', oils_i18n_gettext(344,'Allows staff to override the max claims returned value for a patron', 'ppl', 'description')),
     (345,'UPDATE_PATRON_CLAIM_RETURN_COUNT', oils_i18n_gettext(345,'Allows staff to manually change a patron''s claims returned count', 'ppl', 'description')),
 
-    (346,'UPDATE_BILL_NOTE', oils_i18n_gettext(346,'Allows staff to edit the note for a bill on a transaction', 'ppl', 'description'));
+    (346,'UPDATE_BILL_NOTE', oils_i18n_gettext(346,'Allows staff to edit the note for a bill on a transaction', 'ppl', 'description')),
+    (347,'UPDATE_PAYMENT_NOTE', oils_i18n_gettext(346,'Allows staff to edit the note for a payment on a transaction', 'ppl', 'description'));
 
 SELECT SETVAL('permission.perm_list_id_seq'::TEXT, 1000);
 

Added: trunk/Open-ILS/src/sql/Pg/upgrade/0028.schema.payment_view_rule_and_edit_payment_note_perm.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0028.schema.payment_view_rule_and_edit_payment_note_perm.sql	                        (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0028.schema.payment_view_rule_and_edit_payment_note_perm.sql	2009-09-29 07:01:37 UTC (rev 14197)
@@ -0,0 +1,12 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0028');
+
+INSERT INTO permission.perm_list VALUES
+    (347,'UPDATE_PAYMENT_NOTE', oils_i18n_gettext(346,'Allows staff to edit the note for a payment on a transaction', 'ppl', 'description'));
+
+CREATE RULE money_payment_view_update AS ON UPDATE TO money.payment_view DO INSTEAD 
+    UPDATE money.payment SET xact = NEW.xact, payment_ts = NEW.payment_ts, voided = NEW.voided, amount = NEW.amount, note = NEW.note WHERE id = NEW.id;
+
+COMMIT;
+


Property changes on: trunk/Open-ILS/src/sql/Pg/upgrade/0028.schema.payment_view_rule_and_edit_payment_note_perm.sql
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js	2009-09-29 05:46:49 UTC (rev 14196)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js	2009-09-29 07:01:37 UTC (rev 14197)
@@ -211,6 +211,7 @@
 	'FM_MBTS_IDS_RETRIEVE_FOR_HISTORY.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_bill.authoritative' },
 	'FM_MP_RETRIEVE_VIA_MBTS_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.retrieve.all' },
 	'FM_MP_RETRIEVE_VIA_MBTS_ID.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.retrieve.all.authoritative' },
+	'FM_MP_NOTE_EDIT' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.note.edit' },
 	'FM_MG_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.grocery.create' },
 	'FM_MG_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.grocery.retrieve' },
 	'FM_MOBTS_HAVING_BALANCE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.have_balance' },

Modified: trunk/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties	2009-09-29 05:46:49 UTC (rev 14196)
+++ trunk/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties	2009-09-29 07:01:37 UTC (rev 14197)
@@ -15,6 +15,10 @@
 staff.patron.bill_details.handle_edit_bill_note.note_dialog.prompt=Enter new note:
 staff.patron.bill_details.handle_edit_bill_note.note_dialog.default_value=
 staff.patron.bill_details.handle_edit_bill_note.failure=Note for selected bills not likely updated.
+staff.patron.bill_details.handle_edit_payment_note.note_dialog.title=Replacement Note
+staff.patron.bill_details.handle_edit_payment_note.note_dialog.prompt=Enter new note:
+staff.patron.bill_details.handle_edit_payment_note.note_dialog.default_value=
+staff.patron.bill_details.handle_edit_payment_note.failure=Note for selected payments not likely updated.
 staff.patron.bill_details.handle_void.voided_billings.alert=All selected billings have already voided.
 staff.patron.bill_details.handle_void.confirm_void_billing=Are you sure you would like to void $%1$s worth of line-item billings?
 staff.patron.bill_details.handle_void.confirm_void_billing_title=Voiding Bills

Modified: trunk/Open-ILS/xul/staff_client/server/patron/bill_details.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/bill_details.js	2009-09-29 05:46:49 UTC (rev 14196)
+++ trunk/Open-ILS/xul/staff_client/server/patron/bill_details.js	2009-09-29 07:01:37 UTC (rev 14197)
@@ -145,6 +145,7 @@
                 g.payment_list.retrieve_selection(),
                 function(o) { return o.getAttribute('retrieve_id'); }
             );
+            $('edit_payment_note').disabled = g.payment_list_selection.length == 0;
         },
     } );
 
@@ -173,19 +174,19 @@
 }
 
 function retrieve_mp() {
-    var mp_list = g.network.simple_request( 'FM_MP_RETRIEVE_VIA_MBTS_ID.authoritative', [ ses(), g.mbts_id ]);
+    g.mp_list = g.network.simple_request( 'FM_MP_RETRIEVE_VIA_MBTS_ID.authoritative', [ ses(), g.mbts_id ]);
     //g.error.sdump('D_DEBUG',g.error.pretty_print( js2JSON(mp_list) ));
 
     var mp_funcs = [];
 
-    function gen_mp_func(r) {
+    function gen_mp_func(i,r) {
         return function() {
-            g.payment_list.append( { 'retrieve_id' : r.id(), 'row' : { my : { 'mp' : r } } } );
+            g.payment_list.append( { 'retrieve_id' : i, 'row' : { my : { 'mp' : r } } } );
         }
     }
 
-    for (var i = 0; i < mp_list.length; i++) {
-        mp_funcs.push( gen_mp_func(mp_list[i]) );
+    for (var i = 0; i < g.mp_list.length; i++) {
+        mp_funcs.push( gen_mp_func(i,g.mp_list[i]) );
     }
 
     JSAN.use('util.exec');
@@ -231,6 +232,12 @@
             false
         );
 
+        $('edit_payment_note').addEventListener(
+            'command',
+            handle_edit_payment_note,
+            false
+        );
+
     } catch(E) {
         try { g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.bill_details.my_init.error'),E); } catch(F) { alert(E); }
     }
@@ -261,6 +268,31 @@
     }
 };
 
+function handle_edit_payment_note() {
+    try {
+        var mp_list = util.functional.map_list(g.payment_list_selection, function(o){return g.mp_list[o].id();}); 
+        if (mp_list.length == 0) return;
+        var new_note = window.prompt(
+            $("patronStrings").getString('staff.patron.bill_details.handle_edit_payment_note.note_dialog.prompt'),
+            $("patronStrings").getString('staff.patron.bill_details.handle_edit_payment_note.note_dialog.default_value'),
+            $("patronStrings").getString('staff.patron.bill_details.handle_edit_payment_note.note_dialog.title')
+        );
+        if (new_note) {
+            var r = g.network.simple_request('FM_MP_NOTE_EDIT',[ ses(), new_note ].concat(mp_list));
+            if (r == 1 /* success */) {
+                g.payment_list.clear();
+                retrieve_mp();
+            } else {
+                if (r.ilsevent != 5000 /* PERM_FAILURE */) {
+                    alert( $("patronStrings").getString('staff.patron.bill_details.handle_edit_payment_note.failure') );
+                }
+            } 
+        }
+    } catch(E) {
+        try { g.error.standard_unexpected_error_alert('bill_details.xul, handle_edit_payment_note:',E); } catch(F) { alert(E); }
+    }
+};
+
 function handle_void() {
     try {
         var mb_list = util.functional.map_list(g.bill_list_selection, function(o){return g.mb_list[o];}); 

Modified: trunk/Open-ILS/xul/staff_client/server/patron/bill_details.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/bill_details.xul	2009-09-29 05:46:49 UTC (rev 14196)
+++ trunk/Open-ILS/xul/staff_client/server/patron/bill_details.xul	2009-09-29 07:01:37 UTC (rev 14197)
@@ -64,6 +64,7 @@
 				<hbox>
                     <hbox id="payment_list_actions" />
 					<spacer flex="1"/>
+					<button id="edit_payment_note" label="&staff.patron.bill_details.edit_notes.label;" disabled="true"/>
 				</hbox>
 			</groupbox>
 



More information about the open-ils-commits mailing list