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
/
);
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.
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 ) = @_;
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,
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,
(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);
--- /dev/null
+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;
+
'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' },
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
g.payment_list.retrieve_selection(),
function(o) { return o.getAttribute('retrieve_id'); }
);
+ $('edit_payment_note').disabled = g.payment_list_selection.length == 0;
},
} );
}
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');
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); }
}
}
};
+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];});
<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>