From 95ab58511b6acbe44cfc1c36ec32946bef02bbbd Mon Sep 17 00:00:00 2001
From: phasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Thu, 8 Jul 2010 15:25:15 +0000
Subject: [PATCH] record the billing_last and billing_first fields from
 bill_cc_info.xul into cc_first_name and cc_last_name on
 money.credit_card_payment, even for out-of-band (externally processed)
 payments.  Also protect the bill_cc_info dialog from patrons with no billing
 address (such as admin)

git-svn-id: svn://svn.open-ils.org/ILS/trunk@16883 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/examples/fm_IDL.xml                         |  2 ++
 .../src/perlmods/OpenILS/Application/Circ/Money.pm   |  6 ++++--
 .../xul/staff_client/server/patron/bill_cc_info.xul  | 20 +++++++++++---------
 3 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml
index a722609e94..4df20313d9 100644
--- a/Open-ILS/examples/fm_IDL.xml
+++ b/Open-ILS/examples/fm_IDL.xml
@@ -1464,6 +1464,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 			<field name="amount_collected" reporter:datatype="money" />
 			<field name="approval_code" reporter:datatype="text"/>
 			<field name="cash_drawer" reporter:datatype="link"/>
+			<field name="cc_first_name" reporter:datatype="text"/>
+			<field name="cc_last_name" reporter:datatype="text"/>
 			<field name="cc_number" reporter:datatype="text"/>
 			<field name="cc_type" reporter:datatype="text"/>
 			<field name="cc_processor" reporter:datatype="text"/>
diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm
index 7d8595e7b0..a4edcf84bf 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm
@@ -51,8 +51,8 @@ __PACKAGE__->register_method(
                         number          (for call to payment processor)
                         expire_month    (for call to payment processor)
                         expire_year     (for call to payment processor)
-                        billing_first   (for call to payment processor)
-                        billing_last    (for call to payment processor)
+                        billing_first   (for out-of-band payments and for call to payment processor)
+                        billing_last    (for out-of-band payments and for call to payment processor)
                         billing_address (for call to payment processor)
                         billing_city    (for call to payment processor)
                         billing_state   (for call to payment processor)
@@ -334,6 +334,8 @@ sub make_payments {
         $payment->approval_code($approval_code) if $approval_code;
         $payment->cc_type($cc_type) if $cc_type;
         $payment->cc_processor($cc_processor) if $cc_processor;
+        $payment->cc_first_name($cc_args->{'billing_first'}) if $cc_args->{'billing_first'};
+        $payment->cc_last_name($cc_args->{'billing_last'}) if $cc_args->{'billing_last'};
         if (!$e->$create_money_method($payment)) {
             return _recording_failure(
                 $e, "$create_money_method failed", $payment, $cc_payload
diff --git a/Open-ILS/xul/staff_client/server/patron/bill_cc_info.xul b/Open-ILS/xul/staff_client/server/patron/bill_cc_info.xul
index f52fe8ebc5..1c78639055 100644
--- a/Open-ILS/xul/staff_client/server/patron/bill_cc_info.xul
+++ b/Open-ILS/xul/staff_client/server/patron/bill_cc_info.xul
@@ -48,8 +48,8 @@
             "cc_number":        show['int'],
             "expire_month":     show['int'],
             "expire_year":      show['int'],
-            "billing_first":    show['int'],
-            "billing_last":     show['int'],
+            "billing_first":    show['ext'] + show['int'],
+            "billing_last":     show['ext'] + show['int'],
             "billing_address":  show['int'],
             "billing_city":     show['int'],
             "billing_state":    show['int'],
@@ -79,14 +79,16 @@
         function populate_address_fields() {
             $('billing_first').value = patron.first_given_name();
             $('billing_last').value = patron.family_name();
-            $('billing_address').value = patron.billing_address().street1();
-            var street2 = patron.billing_address().street2();
-            if (street2) {
-                $('billing_address').value += (' ' + street2);
+            if (patron.billing_address()) {
+                $('billing_address').value = patron.billing_address().street1();
+                var street2 = patron.billing_address().street2();
+                if (street2) {
+                    $('billing_address').value += (' ' + street2);
+                }
+                $('billing_city').value = patron.billing_address().city();
+                $('billing_state').value = patron.billing_address().state();
+                $('billing_zip').value = patron.billing_address().post_code();
             }
-            $('billing_city').value = patron.billing_address().city();
-            $('billing_state').value = patron.billing_address().state();
-            $('billing_zip').value = patron.billing_address().post_code();
         }
 
         function info_init() {
-- 
2.11.0