From: phasefx Date: Tue, 29 Sep 2009 07:01:37 +0000 (+0000) Subject: Adds an update rule to money.payment_view since the "mp" class is based on it and... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f4bef575b867b50a0ae22c4200a1dffa1b665d45;p=evergreen%2Fpines.git 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. git-svn-id: svn://svn.open-ils.org/ILS/trunk@14197 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm index 711f82460f..e83db83ba5 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm @@ -357,7 +357,7 @@ __PACKAGE__->register_method( 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 @@ sub edit_bill_note { 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,6 +443,40 @@ sub edit_bill_note { 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 ) = @_; diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 3fcc9f1234..67d4aa440b 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log ( 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, diff --git a/Open-ILS/src/sql/Pg/080.schema.money.sql b/Open-ILS/src/sql/Pg/080.schema.money.sql index 1923e69256..ace19a90da 100644 --- a/Open-ILS/src/sql/Pg/080.schema.money.sql +++ b/Open-ILS/src/sql/Pg/080.schema.money.sql @@ -79,6 +79,9 @@ CREATE OR REPLACE VIEW money.payment_view AS 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, 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 32f740f699..b077bc3bfe 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -1222,7 +1222,8 @@ INSERT INTO permission.perm_list VALUES (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); diff --git a/Open-ILS/src/sql/Pg/upgrade/0028.schema.payment_view_rule_and_edit_payment_note_perm.sql b/Open-ILS/src/sql/Pg/upgrade/0028.schema.payment_view_rule_and_edit_payment_note_perm.sql new file mode 100644 index 0000000000..77a13d599a --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0028.schema.payment_view_rule_and_edit_payment_note_perm.sql @@ -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; + diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 19d9a31f4d..3cd0600539 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -211,6 +211,7 @@ const api = { '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' }, diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties b/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties index 914ca9c90b..7967cba68d 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties @@ -15,6 +15,10 @@ staff.patron.bill_details.handle_edit_bill_note.note_dialog.title=Replacement No 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 diff --git a/Open-ILS/xul/staff_client/server/patron/bill_details.js b/Open-ILS/xul/staff_client/server/patron/bill_details.js index b586748b83..91e76f2930 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_details.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_details.js @@ -145,6 +145,7 @@ function init_lists() { 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_mb() { } 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 @@ function my_init() { 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_bill_note() { } }; +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];}); diff --git a/Open-ILS/xul/staff_client/server/patron/bill_details.xul b/Open-ILS/xul/staff_client/server/patron/bill_details.xul index 502dcdd6fc..30d3926d9d 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_details.xul +++ b/Open-ILS/xul/staff_client/server/patron/bill_details.xul @@ -64,6 +64,7 @@ +