[freeside-commits] branch FREESIDE_3_BRANCH updated. 3afbcad2c1bcc67d242839f2696cb14e380b4a6a

Jonathan Prykop jonathan at 420.am
Wed Oct 28 21:39:57 PDT 2015


The branch, FREESIDE_3_BRANCH has been updated
       via  3afbcad2c1bcc67d242839f2696cb14e380b4a6a (commit)
       via  338b3a1cc10549a57a491af5dc4ff85686b916d2 (commit)
       via  d793ab5b5050e29654183b6d0a645f934bb87df0 (commit)
       via  249f7d6cf45f8df5679ac36fc28dd8376e695496 (commit)
      from  9527575801494bc501c555928e4bf922049b0abe (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3afbcad2c1bcc67d242839f2696cb14e380b4a6a
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Wed Oct 28 23:37:58 2015 -0500

    RT#38432: OFM - Send refund receipt [v3 message prepare]

diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm
index d156d22..166e537 100644
--- a/FS/FS/cust_refund.pm
+++ b/FS/FS/cust_refund.pm
@@ -377,20 +377,17 @@ sub send_receipt {
   return "Could not load template"
     unless $msg_template;
 
-  my $cust_msg = $msg_template->prepare(
-    'cust_main'     => $cust_main,
-    'object'        => $self,
-    'msgtype'       => 'receipt',
-  );
-  return 'Error preparing message' unless $cust_msg;
-  my $error = $cust_msg->insert;
-  return $error if $error;
-
   my $queue = new FS::queue {
-    'job'     => 'FS::cust_msg::process_send',
+    'job'     => 'FS::Misc::process_send_email',
     'custnum' => $cust_main->custnum,
   };
-  $error = $queue->insert( $cust_msg->custmsgnum );
+  my $error = $queue->insert(
+    FS::msg_template->by_key($msgnum)->prepare(
+      'cust_main'     => $cust_main,
+      'object'        => $self,
+    ),
+    'msgtype' => 'receipt', # override msg_template's default
+  );
 
   return $error;
 }

commit 338b3a1cc10549a57a491af5dc4ff85686b916d2
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Wed Oct 28 22:12:48 2015 -0500

    RT#38533: One click re-send refund,payment receipt, invoice [changed link text]

diff --git a/httemplate/view/cust_main/payment_history/invoice.html b/httemplate/view/cust_main/payment_history/invoice.html
index 925b8b4..ea20c20 100644
--- a/httemplate/view/cust_main/payment_history/invoice.html
+++ b/httemplate/view/cust_main/payment_history/invoice.html
@@ -43,12 +43,12 @@ $delete = areyousure_link("${p}misc/delete-cust_bill.html?$invnum",
     if ( $opt{'deleteinvoices'} && $opt{'Delete invoices'} );
 
 my $email = ($opt{'has_email_address'} && $opt{'Resend invoices'}) ? 
-  q! (<A HREF="javascript:void(0)" ONCLICK="areyousure_popup('Send email receipt for invoice #!.
+  q! (<A HREF="javascript:void(0)" ONCLICK="areyousure_popup('Send email copy of invoice #!.
   $cust_bill->invnum.
   q! to customer?','!.
   "${p}misc/send-invoice.cgi?method=email;notice_name=Invoice;popup=1;invnum=".
   $cust_bill->invnum.
-  q!','Email Invoice Receipt')" TITLE="Send email receipt">email receipt</A>)!
+  q!','Email Invoice Receipt')" TITLE="Send email invoice">email invoice</A>)!
   : '';
 
 my $events = '';

commit d793ab5b5050e29654183b6d0a645f934bb87df0
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Fri Oct 23 20:46:01 2015 -0500

    RT#38533: One click re-send refund,payment receipt, invoice [v3 merge]

diff --git a/httemplate/elements/popup_link_onclick.html b/httemplate/elements/popup_link_onclick.html
index 09ce93e..783e7a2 100644
--- a/httemplate/elements/popup_link_onclick.html
+++ b/httemplate/elements/popup_link_onclick.html
@@ -9,12 +9,13 @@ Example:
     #required
     'action'         => 'content.html', # uri for content of popup
 
-    #alternately, use instead of action
-    'js_action'      => 'url',          # javascript variable or expression
-   
     #strongly recommended
     'actionlabel     => 'You clicked',  # popup title
    
+    #alternately, use instead of action, values will be passed unquoted to overlib
+    'js_action'      => 'url',          # javascript variable or expression
+    'js_actionlabel' => 'actionlabel',  # javascript variable or expression   
+
     #opt
     'width'          => 540,
     'height'         => 336,
@@ -50,9 +51,10 @@ if (ref($_[0]) eq 'HASH') {
   $params = { @_ };
 }
 
-$action      = q(') . $params->{'action'} . q(') if exists $params->{'action'};
+$action      = q(') . $params->{'action'} . q(');
 $action      = $params->{'js_action'}   if exists $params->{'js_action'};
-$actionlabel = $params->{'actionlabel'} if exists $params->{'actionlabel'};
+$actionlabel = q(') . $params->{'actionlabel'} . q(');
+$actionlabel = $params->{'js_actionlabel'} if exists $params->{'js_actionlabel'};
 $width       = $params->{'width'}       if exists $params->{'width'};
 $height      = $params->{'height'}      if exists $params->{'height'};
 $color       = $params->{'color'}       if exists $params->{'color'};
@@ -66,7 +68,7 @@ my $popup_name = 'popup-'.random_id();
 
 my $onclick =
   "overlib( OLiframeContent($action, $width, $height, '$popup_name', 0, '$scrolling' ), ".
-    "CAPTION, '$actionlabel', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, ".
+    "CAPTION, $actionlabel, STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, ".
     "DRAGGABLE, CLOSECLICK, ".
     "BGCOLOR, '$color', CGCOLOR, '$color', CLOSETEXT, '$closetext'".
     ( $frame ? ", FRAME, $frame" : '' ).
diff --git a/httemplate/misc/send-invoice.cgi b/httemplate/misc/send-invoice.cgi
index dd9c3ad..4358753 100644
--- a/httemplate/misc/send-invoice.cgi
+++ b/httemplate/misc/send-invoice.cgi
@@ -1,4 +1,12 @@
-% if ( $error ) {
+% if ($cgi->param('popup')) {
+%   my $title = $error ? 'Error sending invoice email' : 'Invoice email sent';
+<% include('/elements/header-popup.html', $title ) %>
+<DIV STYLE="text-align: center;">
+<SPAN STYLE="color: red; font-weight: bold;"><% $error %></SPAN><BR>
+<BUTTON TYPE="button" onClick="parent.cClick();">Close</BUTTON>
+</DIV>
+<% include('/elements/footer.html') %>
+% } elsif ( $error ) {
 %   errorpage($error);
 % } else {
 <% $cgi->redirect("${p}view/cust_main.cgi?$custnum") %>
diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi
index cd8b028..287658f 100755
--- a/httemplate/view/cust_main.cgi
+++ b/httemplate/view/cust_main.cgi
@@ -38,6 +38,14 @@ function areyousure(href, message) {
   if (confirm(message) == true)
     window.location.href = href;
 }
+function areyousure_popup(message, action, actionlabel) {
+  if (confirm(message) == true) {
+<% include('/elements/popup_link_onclick.html',
+     'js_action' => 'action',
+     'js_actionlabel' => 'actionlabel',
+   ) %>
+  }
+}
 </SCRIPT>
 
 
diff --git a/httemplate/view/cust_main/payment_history.html b/httemplate/view/cust_main/payment_history.html
index 1cd8386..5418fb8 100644
--- a/httemplate/view/cust_main/payment_history.html
+++ b/httemplate/view/cust_main/payment_history.html
@@ -430,7 +430,7 @@ my %opt = (
   #rights
   ( map { $_ => $curuser->access_right($_) }
       (
-        'View invoices', 'Void invoices', 'Unvoid invoices', 'Delete invoices',
+        'View invoices', 'Void invoices', 'Unvoid invoices', 'Delete invoices', 'Resend invoices',
         'Apply payment', 'Refund credit card payment', 'Refund Echeck payment',
         'Post refund', 'Post check refund', 'Post cash refund ', 'Refund payment',
         'Credit card void', 'Echeck void', 'Void payments', 'Unvoid payments',
@@ -444,6 +444,7 @@ my %opt = (
   #customer information
   'total_owed'              => $cust_main->total_owed,
   'total_unapplied_refunds' => $cust_main->total_unapplied_refunds,
+  'has_email_address'       => scalar($cust_main->invoicing_list_emailonly),
 );
 
 $opt{'date_format'} ||= '%m/%d/%Y';
diff --git a/httemplate/view/cust_main/payment_history/invoice.html b/httemplate/view/cust_main/payment_history/invoice.html
index acb1d69..925b8b4 100644
--- a/httemplate/view/cust_main/payment_history/invoice.html
+++ b/httemplate/view/cust_main/payment_history/invoice.html
@@ -1,4 +1,4 @@
-<% $link %><% $invoice %><% $link ? '</A>' : '' %><% "$void$delete$under" %>
+<% $link %><% $invoice %><% $link ? '</A>' : '' %><% "$email$void$delete$under" %>
 <%init>
 
 my( $cust_bill, %opt ) = @_;
@@ -42,6 +42,15 @@ $delete = areyousure_link("${p}misc/delete-cust_bill.html?$invnum",
                         )
     if ( $opt{'deleteinvoices'} && $opt{'Delete invoices'} );
 
+my $email = ($opt{'has_email_address'} && $opt{'Resend invoices'}) ? 
+  q! (<A HREF="javascript:void(0)" ONCLICK="areyousure_popup('Send email receipt for invoice #!.
+  $cust_bill->invnum.
+  q! to customer?','!.
+  "${p}misc/send-invoice.cgi?method=email;notice_name=Invoice;popup=1;invnum=".
+  $cust_bill->invnum.
+  q!','Email Invoice Receipt')" TITLE="Send email receipt">email receipt</A>)!
+  : '';
+
 my $events = '';
 if ( $cust_bill->num_cust_event
      && ($opt{'Billing event reports'} || $opt{'View customer billing events'})
diff --git a/httemplate/view/cust_main/payment_history/payment.html b/httemplate/view/cust_main/payment_history/payment.html
index 0ed2f80..6520017 100644
--- a/httemplate/view/cust_main/payment_history/payment.html
+++ b/httemplate/view/cust_main/payment_history/payment.html
@@ -1,5 +1,5 @@
 <% $payment. ' '.  $info. $desc.
-   $view. $change_pkg. $apply. $refund. $void. $delete. $unapply
+   $view. $email. $change_pkg. $apply. $refund. $void. $delete. $unapply
 %>
 <%init>
 
@@ -139,6 +139,13 @@ my $view =
                ).
    ')';
 
+my $email = $opt{'has_email_address'} ? 
+  q! (<A HREF="javascript:void(0)" ONCLICK="areyousure_popup('Send email receipt for payment to customer?','!.
+  "${p}view/cust_pay.html?link=email;paynum=".
+  $cust_pay->paynum.
+  q!','Email Payment Receipt')" TITLE="Send email receipt">email receipt</A>)!
+  : '';
+
 my $change_pkg = '';
 if ( $apply && $opt{'pkg-balances'} && $cust_pay->pkgnum ) {
   $change_pkg =
diff --git a/httemplate/view/cust_main/payment_history/refund.html b/httemplate/view/cust_main/payment_history/refund.html
index fc2a5cc..e82df90 100644
--- a/httemplate/view/cust_main/payment_history/refund.html
+++ b/httemplate/view/cust_main/payment_history/refund.html
@@ -1,6 +1,6 @@
 <% $refund %> 
 (<% "$payby$payinfo" %>)
-<% "$view$delete" %>
+<% "$view$email$delete" %>
 <%init>
 
 my( $cust_refund, %opt ) = @_;
@@ -26,6 +26,13 @@ my $view =
                ).
    ')';
 
+my $email = $opt{'has_email_address'} ? 
+  q! (<A HREF="javascript:void(0)" ONCLICK="areyousure_popup('Send email receipt for refund to customer?','!.
+  "${p}view/cust_refund.html?link=email;refundnum=".
+  $cust_refund->refundnum.
+  q!','Email Refund Receipt')" TITLE="Send email receipt">email receipt</A>)!
+  : '';
+
 my $delete = '';
 $delete = areyousure_link("${p}misc/delete-cust_refund.cgi?".$cust_refund->refundnum,
                            emt('Are you sure you want to delete this refund?'),

commit 249f7d6cf45f8df5679ac36fc28dd8376e695496
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Fri Oct 23 20:24:40 2015 -0500

    RT#38432: OFM - Send refund receipt [v3 merge]

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 884ac9d..7c220b7 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1802,6 +1802,13 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'refund_receipt_msgnum',
+    'section'     => 'notification',
+    'description' => 'Template to use for manual refund receipts.',
+    %msg_template_options,
+  },
+  
+  {
     'key'         => 'trigger_export_insert_on_payment',
     'section'     => 'billing',
     'description' => 'Enable exports on payment application.',
diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm
index a3beb9b..d156d22 100644
--- a/FS/FS/cust_refund.pm
+++ b/FS/FS/cust_refund.pm
@@ -342,6 +342,59 @@ sub unapplied {
   sprintf("%.2f", $amount );
 }
 
+=item send_receipt HASHREF | OPTION => VALUE ...
+
+Sends a payment receipt for this payment.
+
+refund_receipt_msgnum must be configured.
+
+Available options:
+
+=over 4
+
+=item cust_main
+
+Customer (FS::cust_main) object (for efficiency).
+
+=cut
+
+=back
+
+=cut
+
+sub send_receipt {
+  my $self = shift;
+  my $opt = ref($_[0]) ? shift : { @_ };
+
+  my $cust_main = $opt->{'cust_main'} || $self->cust_main;
+
+  my $conf = new FS::Conf;
+  
+  my $msgnum = $conf->config('refund_receipt_msgnum', $cust_main->agentnum);
+  return "No refund_receipt_msgnum configured" unless $msgnum;
+
+  my $msg_template = qsearchs('msg_template',{ msgnum => $msgnum});
+  return "Could not load template"
+    unless $msg_template;
+
+  my $cust_msg = $msg_template->prepare(
+    'cust_main'     => $cust_main,
+    'object'        => $self,
+    'msgtype'       => 'receipt',
+  );
+  return 'Error preparing message' unless $cust_msg;
+  my $error = $cust_msg->insert;
+  return $error if $error;
+
+  my $queue = new FS::queue {
+    'job'     => 'FS::cust_msg::process_send',
+    'custnum' => $cust_main->custnum,
+  };
+  $error = $queue->insert( $cust_msg->custmsgnum );
+
+  return $error;
+}
+
 =back
 
 =head1 CLASS METHODS
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm
index cb13696..9c2b284 100644
--- a/FS/FS/msg_template.pm
+++ b/FS/FS/msg_template.pm
@@ -660,6 +660,18 @@ sub substitutions {
             $cust_pay->paymask : $cust_pay->decrypt($cust_pay->payinfo)
         } ],
     ],
+    # for refund receipts
+    'cust_refund' => [
+      'refundnum',
+      [ refund            => sub { sprintf("%.2f", shift->refund) } ],
+      [ payby             => sub { FS::payby->shortname(shift->payby) } ],
+      [ date              => sub { time2str("%a %B %o, %Y", shift->_date) } ],
+      [ payinfo           => sub { 
+          my $cust_refund = shift;
+          ($cust_refund->payby eq 'CARD' || $cust_refund->payby eq 'CHEK') ?
+            $cust_refund->paymask : $cust_refund->decrypt($cust_refund->payinfo)
+        } ],
+    ],
     # for payment decline messages
     # try to support all cust_pay fields
     # 'error' is a special case, it contains the raw error from the gateway
diff --git a/httemplate/edit/msg_template.html b/httemplate/edit/msg_template.html
index c6b2a7d..4bfdd62 100644
--- a/httemplate/edit/msg_template.html
+++ b/httemplate/edit/msg_template.html
@@ -296,6 +296,13 @@ my %substitutions = (
     '$payinfo'        => 'Card/account# (masked)',
     '$error'          => 'Decline reason',
   ],
+  'cust_refund'  => [
+    '$refundnum'      => 'Refund#',
+    '$refund'         => 'Refund Amount',
+    '$payby'          => 'Refund method',
+    '$date'           => 'Refund date',
+    '$payinfo'        => 'Card/account# (masked)',
+  ],
 );
 
 tie my %sections, 'Tie::IxHash', (
@@ -303,6 +310,7 @@ tie my %sections, 'Tie::IxHash', (
 'service'   => 'Service address',
 'cust_main' => 'Customer status and payment info',
 'cust_pkg'  => 'Package fields',
+'cust_refund' => 'Refund fields',
 'cust_bill' => 'Invoice fields',
 'cust_pay'  => 'Payment fields',
 'svc_acct'  => 'Login service fields',
diff --git a/httemplate/view/cust_pay.html b/httemplate/view/cust_pay.html
index 76a2488..b34a908 100644
--- a/httemplate/view/cust_pay.html
+++ b/httemplate/view/cust_pay.html
@@ -3,8 +3,10 @@
   <& /elements/header-popup.html, mt("$thing Receipt") &>
 
   <div align="center">
-    <A HREF="javascript:self.parent.location = '<% $pr_link %>'"><% mt('Print') |h %></A> | 
-    <A HREF="javascript:self.location = '<% $email_link %>'"><% mt('Re-email') |h %></A>
+    <A HREF="javascript:self.parent.location = '<% $pr_link %>'"><% mt('Print') |h %></A>
+%   if ( $cust_main->invoicing_list_emailonly ) {
+    | <A HREF="javascript:self.location = '<% $email_link %>'"><% mt('Re-email') |h %></A>
+%   }
   </div><BR>
 
 % } elsif ( $link eq 'print' ) { 
@@ -180,11 +182,13 @@ my $cust_pay = qsearchs({
 });
 die "$thing #$paynum not found!" unless $cust_pay;
 
+my $cust_main = $cust_pay->cust_main;
+
 my $pr_link = "${p}view/cust_pay.html?link=print;paynum=$paynum;void=$void";
 my $email_link = "${p}view/cust_pay.html?link=email;paynum=$paynum;void=$void";
 
 my $custnum = $cust_pay->custnum;
-my $display_custnum = $cust_pay->cust_main->display_custnum;
+my $display_custnum = $cust_main->display_custnum;
 
 my $conf = new FS::Conf;
 
@@ -195,8 +199,9 @@ tie my %payby, 'Tie::IxHash', FS::payby->payby2longname;
 my $email_error;
 
 if ( $link eq 'email' ) {
-    my $email_error = $cust_pay->send_receipt(
-	'manual' => 1,
+    $email_error = $cust_pay->send_receipt(
+      'manual' => 1,
+      'cust_main' => $cust_main,
     );
 
     warn "can't send payment receipt/statement: $email_error" if $email_error;
diff --git a/httemplate/view/cust_refund.html b/httemplate/view/cust_refund.html
index 3197615..d5f5eb2 100644
--- a/httemplate/view/cust_refund.html
+++ b/httemplate/view/cust_refund.html
@@ -2,7 +2,12 @@
 
   <& /elements/header-popup.html, mt('Refund Receipt') &>
 
-  <CENTER><A HREF="javascript:self.parent.location = '<% $pr_link %>'"><% mt('Print') |h %></A></CENTER><BR>
+  <DIV ALIGN="center">
+    <A HREF="javascript:self.parent.location = '<% $pr_link %>'"><% mt('Print') |h %></A>
+%   if ( $cust_main->invoicing_list_emailonly ) {
+    | <A HREF="javascript:self.location = '<% $email_link %>'"><% mt('Email') |h %></A>
+%   }
+  </DIV>
 
 % } elsif ( $link eq 'print' ) { 
 
@@ -16,6 +21,12 @@
   %>
   <BR><BR>
 
+% } elsif ( $link eq 'email' ) {
+%  if ( $email_error ) {
+      <& /elements/header-popup.html, mt("Error re-emailing receipt: [_1]", $email_error) &>
+%  } else {
+      <& /elements/header-popup.html, mt("Re-emailed receipt") &>
+%  }
 % } else { 
 
   <& /elements/header.html, mt('Refund Receipt'), menubar(
@@ -26,7 +37,7 @@
 
 % }
 
-% unless ($link eq 'popup' ) {
+% unless ($link =~ /^(popup|email)$/ ) {
   <& /elements/small_custview.html,
                $custnum,
                scalar($conf->config('countrydefault')),
@@ -91,9 +102,14 @@
     window.print();
   </SCRIPT>
 
-% }
+% } elsif ( $link eq 'email' ) {
 
-% if ( $link =~ /^(popup|print)$/ ) { 
+    <SCRIPT TYPE="text/javascript">
+      window.top.location.reload();
+    </SCRIPT>
+
+% }
+% if ( $link =~ /^(popup|print|email)$/ ) { 
     </BODY>
   </HTML>
 % } else {
@@ -125,10 +141,13 @@ my $cust_refund = qsearchs({
 });
 die "Refund #$refundnum not found!" unless $cust_refund;
 
+my $cust_main = $cust_refund->cust_main;
+
 my $pr_link = "${p}view/cust_refund.html?link=print;refundnum=$refundnum";
+my $email_link = "${p}view/cust_refund.html?link=email;refundnum=$refundnum";
 
 my $custnum = $cust_refund->custnum;
-my $display_custnum = $cust_refund->cust_main->display_custnum;
+my $display_custnum = $cust_main->display_custnum;
 
 my $conf = new FS::Conf;
 
@@ -136,4 +155,11 @@ my $money_char = $conf->config('money_char') || '$';
 
 tie my %payby, 'Tie::IxHash', FS::payby->payby2longname;
 
+my $email_error;
+
+if ( $link eq 'email' ) {
+    $email_error = $cust_refund->send_receipt( 'cust_main' => $cust_main );
+    warn "can't send refund receipt: $email_error" if $email_error;
+}
+
 </%init>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm                                      |    7 +++
 FS/FS/cust_refund.pm                               |   50 ++++++++++++++++++++
 FS/FS/msg_template.pm                              |   12 +++++
 httemplate/edit/msg_template.html                  |    8 ++++
 httemplate/elements/popup_link_onclick.html        |   14 +++---
 httemplate/misc/send-invoice.cgi                   |   10 +++-
 httemplate/view/cust_main.cgi                      |    8 ++++
 httemplate/view/cust_main/payment_history.html     |    3 +-
 .../view/cust_main/payment_history/invoice.html    |   11 ++++-
 .../view/cust_main/payment_history/payment.html    |    9 +++-
 .../view/cust_main/payment_history/refund.html     |    9 +++-
 httemplate/view/cust_pay.html                      |   15 ++++--
 httemplate/view/cust_refund.html                   |   36 ++++++++++++--
 13 files changed, 171 insertions(+), 21 deletions(-)




More information about the freeside-commits mailing list