From e2d27cf0dc408f4b883abc00a3311eb17f454a65 Mon Sep 17 00:00:00 2001
From: pines
Date: Fri, 18 Aug 2006 05:34:14 +0000
Subject: [PATCH] Voided total for bill receipts.. can't completely test at the
moment
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5582 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
.../staff_client/chrome/content/OpenILS/data.js | 2 +-
.../server/circ/print_list_template_editor.js | 3 ++-
.../staff_client/server/patron/bill_details.xul | 26 ++++++++++++--------
Open-ILS/xul/staff_client/server/patron/bills.js | 28 +++++++++++++++++++++-
.../staff_client/server/patron/bills_overlay.xul | 1 +
5 files changed, 47 insertions(+), 13 deletions(-)
diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
index a6de4a1000..9d91b92b3c 100644
--- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
+++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
@@ -167,7 +167,7 @@ OpenILS.data.prototype = {
},
'bill_payment' : {
'type' : 'payment',
- 'header' : 'Welcome to %LIBRARY%!
A receipt of your transaction:
| Original Balance: | $%original_balance% |
| Payment Method: | %payment_type% |
| Payment Received: | $%payment_received% |
| Payment Applied: | $%payment_applied% |
| Change Given: | $%change_given% |
| Credit Given: | $%credit_given% |
| New Balance: | $%new_balance% |
Note: %note%
Specific bills:
',
+ 'header' : 'Welcome to %LIBRARY%!
A receipt of your transaction:
| Original Balance: | $%original_balance% |
| Payment Method: | %payment_type% |
| Payment Received: | $%payment_received% |
| Payment Applied: | $%payment_applied% |
| Billings Voided: | $%voided_balance% |
| Change Given: | $%change_given% |
| New Balance: | $%new_balance% |
Note: %note%
Specific bills:
',
'line_item' : 'Bill #%bill_id% Received: $%payment%
',
'footer' : '
%PINES_CODE% %TODAY_TRIM%
',
},
diff --git a/Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js b/Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js
index cc4ef56774..47a6414d83 100644
--- a/Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js
+++ b/Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js
@@ -33,6 +33,7 @@ circ.print_list_template_editor.prototype = {
'payment_type' : 'Cash',
'payment_received' : '10.00',
'payment_applied' : '7.40',
+ 'voided_balance' : '0.00',
'change_given' : '2.60',
'credit_given' : '0.00',
'note' : "The patron's child paid this",
@@ -153,7 +154,7 @@ circ.print_list_template_editor.prototype = {
);
break;
case 'payment' :
- macros = [ '%original_balance%', '%payment_received%', '%payment_applied%', '%payment_type%', '%change_given%', '%new_balance%', '%note%', '%bill_id%', '%payment%' ];
+ macros = [ '%original_balance%', '%payment_received%', '%payment_applied%', '%payment_type%', '%voided_balance%', '%change_given%', '%new_balance%', '%note%', '%bill_id%', '%payment%' ];
break;
}
var macro_string = macros.join(', ');
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 a6837f07a7..3559efb3fc 100644
--- a/Open-ILS/xul/staff_client/server/patron/bill_details.xul
+++ b/Open-ILS/xul/staff_client/server/patron/bill_details.xul
@@ -146,19 +146,19 @@
}
function retrieve_mb() {
- var mb_list = g.network.simple_request( 'FM_MB_RETRIEVE_VIA_MBTS_ID', [ ses(), g.mbts_id ] );
- //g.error.sdump('D_DEBUG',g.error.pretty_print( js2JSON(mb_list) ));
+ g.mb_list = g.network.simple_request( 'FM_MB_RETRIEVE_VIA_MBTS_ID', [ ses(), g.mbts_id ] );
+ //g.error.sdump('D_DEBUG',g.error.pretty_print( js2JSON(g.mb_list) ));
var mb_funcs = [];
- function gen_mb_func(r) {
+ function gen_mb_func(i,r) {
return function() {
- g.bill_list.append( { 'retrieve_id' : r.id(), 'row' : { my : { 'mb' : r } } } );
+ g.bill_list.append( { 'retrieve_id' : i, 'row' : { my : { 'mb' : r } } } );
}
}
- for (var i = 0; i < mb_list.length; i++) {
- mb_funcs.push( gen_mb_func(mb_list[i]) );
+ for (var i = 0; i < g.mb_list.length; i++) {
+ mb_funcs.push( gen_mb_func(i,g.mb_list[i]) );
}
JSAN.use('util.exec');
@@ -231,16 +231,22 @@
}
function handle_void() {
- var msg = 'Are you sure you would like to void bill' + ( g.bill_list_selection.length > 1 ? 's ' : ' ') + g.bill_list_selection + '?';
+ JSAN.use('util.functional');
+ var msg = 'Are you sure you would like to void bill' + ( g.bill_list_selection.length > 1 ? 's ' : ' ') + util.functional.map_list( g.bill_list_selection, function(o) { return g.mb_list[o].id(); }) + '?';
var r = g.error.yns_alert(msg,'Voiding Bills','Yes','No',null,'Check here to confirm this message');
if (r == 0) {
+ g.data.stash_retrieve();
for (var i = 0; i < g.bill_list_selection.length; i++) {
- var robj = g.network.simple_request('FM_MB_VOID',[ses(),g.bill_list_selection[i]]);
+ var robj = g.network.simple_request('FM_MB_VOID',[ses(),g.mb_list[g.bill_list_selection[i]].id()]);
+ if (! g.data.voided_billings ) g.data.voided_billings = [];
if (robj.ilsevent) {
switch(robj.ilsevent) {
- case -1 : g.error.standard_network_error_alert('Void of Bill #' + g.bill_list_selection[i] + ' failed.'); break;
- default: g.error.standard_unexpected_error_alert('Void of Bill #' + g.bill_list_selection[i] + ' failed.',robj); break;
+ case -1 : g.error.standard_network_error_alert('Void of Bill #' + g.mb_list[g.bill_list_selection[i]].id() + ' failed.'); break;
+ default: g.error.standard_unexpected_error_alert('Void of Bill #' + g.mb_list[g.bill_list_selection[i]].id() + ' failed.',robj); break;
}
+ } else {
+ g.data.voided_billings.push( g.mb_list[g.bill_list_selection[i]] );
+ g.data.stash('voided_billings');
}
}
retrieve_mbts();
diff --git a/Open-ILS/xul/staff_client/server/patron/bills.js b/Open-ILS/xul/staff_client/server/patron/bills.js
index c4b87e2e0d..2f29f58780 100644
--- a/Open-ILS/xul/staff_client/server/patron/bills.js
+++ b/Open-ILS/xul/staff_client/server/patron/bills.js
@@ -9,6 +9,7 @@ patron.bills = function (params) {
try {
obj.OpenILS = {}; JSAN.use('OpenILS.data'); obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
obj.data = obj.OpenILS.data;
+ obj.data.voided_billings = []; obj.data.stash('voided_billings');
} catch(E) {
alert(E);
}
@@ -52,6 +53,7 @@ patron.bills.prototype = {
obj.controller.view.bill_payment_amount.focus();
obj.distribute_payment(obj.controller.view.bill_payment_amount);
obj.tally_selected();
+ obj.tally_voided();
} catch(E) {
obj.error.standard_unexpected_error_alert('bills -> refresh',E);
}
@@ -93,6 +95,7 @@ patron.bills.prototype = {
obj.distribute_payment(obj.controller.view.bill_payment_amount);
obj.controller.view.bill_payment_amount.select();
obj.tally_selected();
+ obj.tally_voided();
} catch(E) {
obj.error.standard_unexpected_error_alert('bills -> init',E);
}
@@ -246,6 +249,10 @@ patron.bills.prototype = {
obj.tally_selected();
}
],
+ 'voided_balance' : [
+ ['render'],
+ function(e) { return function() {}; }
+ ],
'selected_balance' : [
['render'],
function(e) { return function() {}; }
@@ -404,6 +411,24 @@ patron.bills.prototype = {
/*****************************************************************************************************************************/
+ 'tally_voided' : function() {
+
+ var obj = this;
+ JSAN.use('util.money');
+ var voided_total = 0;
+
+ obj.data.stash_retrieve();
+
+ for (var i = 0; i < obj.data.voided_billings.length; i++) {
+ var billing = obj.data.voided_billings[i];
+ var bv = util.money.dollars_float_to_cents_integer( billing.amount() );
+ voided_total += bv;
+ }
+ obj.controller.view.voided_balance.setAttribute('value', '$' + util.money.cents_as_dollars( voided_total ) );
+ },
+
+ /*****************************************************************************************************************************/
+
'apply_payment' : function() {
var obj = this;
@@ -457,8 +482,8 @@ patron.bills.prototype = {
}
if ( obj.pay( payment_blob ) ) {
+ obj.data.voided_billings = []; obj.data.stash('voided_billings');
obj.refresh();
- //alert('FIXME: Receipt goes here\n' + js2JSON(payment_blob));
try {
obj.data.stash_retrieve();
var template = 'bill_payment';
@@ -491,6 +516,7 @@ patron.bills.prototype = {
try {
obj.previous_summary = {
original_balance : obj.controller.view.bill_total_owed.value,
+ voided_balance : obj.controller.view.voided_balance.value,
payment_received : obj.controller.view.bill_payment_amount.value,
payment_applied : obj.controller.view.bill_payment_applied.value,
change_given : obj.controller.view.bill_change_amount.value,
diff --git a/Open-ILS/xul/staff_client/server/patron/bills_overlay.xul b/Open-ILS/xul/staff_client/server/patron/bills_overlay.xul
index 9019726d30..2f7caf1098 100644
--- a/Open-ILS/xul/staff_client/server/patron/bills_overlay.xul
+++ b/Open-ILS/xul/staff_client/server/patron/bills_overlay.xul
@@ -14,6 +14,7 @@
+
--
2.11.0