report on failed billing events...
authorivan <ivan>
Tue, 16 Apr 2002 10:47:35 +0000 (10:47 +0000)
committerivan <ivan>
Tue, 16 Apr 2002 10:47:35 +0000 (10:47 +0000)
FS/FS/Conf.pm
FS/FS/cust_bill.pm
FS/FS/cust_bill_event.pm
httemplate/index.html
httemplate/search/cust_bill_event.cgi [new file with mode: 0644]
httemplate/search/cust_bill_event.html [new file with mode: 0755]
httemplate/search/report_cc.html
httemplate/search/report_credit.html
httemplate/search/report_tax.html
httemplate/view/cust_bill.cgi

index dc1cbb8..6bcf9c4 100644 (file)
@@ -896,14 +896,14 @@ httemplate/docs/config.html
   },
 
   {
-    'key'         => 'declinetemplate'
+    'key'         => 'declinetemplate',
     'section'     => 'billing',
     'description' => 'Template file for credit card decline emails.',
     'type'        => 'textarea',
   },
 
   {
-    'key'         => 'emaildecline'
+    'key'         => 'emaildecline',
     'section'     => 'billing',
     'description' => 'Enable emailing of credit card decline notices.',
     'type'        => 'checkbox',
index cb2aa46..816553b 100644 (file)
@@ -582,9 +582,9 @@ sub realtime_card {
       my $template = new Text::Template (
         TYPE   => 'ARRAY',
         SOURCE => [ map "$_\n", @templ ],
-      ) or die "($perror) can't create template: $Text::Template::ERROR";
+      ) or return "($perror) can't create template: $Text::Template::ERROR";
       $template->compile()
-        or die "($perror) can't compile template: $Text::Template::ERROR";
+        or return "($perror) can't compile template: $Text::Template::ERROR";
 
       my $error = $transaction->error_message;
 
@@ -605,7 +605,7 @@ sub realtime_card {
       $!=0;
       $message->smtpsend( Host => $smtpmachine )
         or $message->smtpsend( Host => $smtpmachine, Debug => 1 )
-          or die "($perror) (customer # ". $self->custnum.
+          or return "($perror) (customer # ". $self->custnum.
             ") can't send card decline email to ".
             join(', ', grep { $_ ne 'POST' } $cust_main->invoicing_list ).
             " via server $smtpmachine with SMTP: $!";
@@ -944,7 +944,7 @@ sub print_text {
 
 =head1 VERSION
 
-$Id: cust_bill.pm,v 1.28 2002-04-16 09:38:19 ivan Exp $
+$Id: cust_bill.pm,v 1.29 2002-04-16 10:47:34 ivan Exp $
 
 =head1 BUGS
 
index 146a30e..d5ca55f 100644 (file)
@@ -132,6 +132,17 @@ sub part_bill_event {
   qsearchs( 'part_bill_event', { 'eventpart' => $self->eventpart } );
 }
 
+=item cust_bill
+
+Returns the invoice (see L<FS::cust_bill>) for this completed invoice event.
+
+=cut
+
+sub cust_bill {
+  my $self = shift;
+  qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
+}
+
 =back
 
 =head1 BUGS
index 934767d..b562a22 100644 (file)
@@ -58,6 +58,7 @@
       <BR><A HREF="browse/cust_pay_batch.cgi">View pending credit card batch</A>
       <BR><BR>Invoice reports
             <UL>
+              <LI><a href="search/cust_bill_event.html">Invoice event errors (failed credit cards)</a>
               <LI>open invoices (<A HREF="search/cust_bill.cgi?OPEN_invnum">by invoice number</A>) (<A HREF="search/cust_bill.cgi?OPEN_date">by date</A>) (<A HREF="search/cust_bill.cgi?OPEN_custnum">by customer number</A>)
               <LI>30 day open invoices (<A HREF="search/cust_bill.cgi?OPEN30_invnum">by invoice number</A>) (<A HREF="search/cust_bill.cgi?OPEN30_date">by date</A>) (<A HREF="search/cust_bill.cgi?OPEN30_custnum">by customer number</A>)
               <LI>60 day open invoices (<A HREF="search/cust_bill.cgi?OPEN60_invnum">by invoice number</A>) (<A HREF="search/cust_bill.cgi?OPEN60_date">by date</A>) (<A HREF="search/cust_bill.cgi?OPEN60_custnum">by customer number</A>)
       </UL>
       Invoices
       <UL>
+        <LI><a href="search/cust_bill_event.html">Invoice event errors (failed credit cards)</a>
         <LI>open invoices (<A HREF="search/cust_bill.cgi?OPEN_invnum">by invoice number</A>) (<A HREF="search/cust_bill.cgi?OPEN_date">by date</A>) (<A HREF="search/cust_bill.cgi?OPEN_custnum">by customer number</A>)
         <LI>30 day open invoices (<A HREF="search/cust_bill.cgi?OPEN30_invnum">by invoice number</A>) (<A HREF="search/cust_bill.cgi?OPEN30_date">by date</A>) (<A HREF="search/cust_bill.cgi?OPEN30_custnum">by customer number</A>)
         <LI>60 day open invoices (<A HREF="search/cust_bill.cgi?OPEN60_invnum">by invoice number</A>) (<A HREF="search/cust_bill.cgi?OPEN60_date">by date</A>) (<A HREF="search/cust_bill.cgi?OPEN60_custnum">by customer number</A>)
diff --git a/httemplate/search/cust_bill_event.cgi b/httemplate/search/cust_bill_event.cgi
new file mode 100644 (file)
index 0000000..9cb36d2
--- /dev/null
@@ -0,0 +1,62 @@
+<!-- mason kludge -->
+<%
+
+#false laziness with view/cust_bill.cgi
+
+$cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/;
+my $beginning = str2time($1);
+
+$cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/;
+my $ending = str2time($1) + 86400;
+
+my @cust_bill_event =
+  sort { $a->_date <=> $b->_date }
+    qsearch('cust_bill_event', {
+      _date => { op=> '>=', value=>$beginning },
+      statustext => { op=> '!=', value=>'' },
+# i wish...
+#      _date => { op=> '<=', value=>$ending },
+    }, '', "AND _date <= $ending");
+
+%>
+
+<%= header('Failed billing events') %>
+
+<%= table() %>
+<TR>
+  <TH>Event</TH>
+  <TH>Date</TH>
+  <TH>Status</TH>
+  <TH>Invoice</TH>
+  <TH>(bill) name</TH>
+  <TH>company</TH>
+<% if ( defined dbdef->table('cust_main')->column('ship_last') ) { %>
+  <TH>(service) name</TH>
+  <TH>company</TH>
+<% } %>
+</TR>
+
+<% foreach my $cust_bill_event ( @cust_bill_event ) {
+   my $status = $cust_bill_event->status;
+   $status .= ': '.$cust_bill_event->statustext if $cust_bill_event->statustext;
+   my $cust_bill = $cust_bill_event->cust_bill;
+   my $cust_main = $cust_bill->cust_main;
+   my $invlink = "${p}view/cust_bill.cgi?". $cust_bill->invnum;
+   my $custlink = "${p}view/cust_main.cgi?". $cust_main->custnum;
+%>
+<TR>
+  <TD><%= $cust_bill_event->part_bill_event->event %></TD>
+  <TD><%= time2str("%a %b %e %T %Y", $cust_bill_event->_date) %></TD>
+  <TD><%= $status %></TD>
+  <TD><A HREF="<%=$invlink%>">Invoice #<%= $cust_bill->invnum %> (<%= time2str("%D", $cust_bill->_date ) %>)</A></TD>
+  <TD><A HREF="<%=$custlink%>"><%= $cust_main->last. ', '. $cust_main->first %></A></TD>
+  <TD><A HREF="<%=$custlink%>"><%= $cust_main->company %></A></TD>
+  <% if ( defined dbdef->table('cust_main')->column('ship_last') ) { %>
+    <TD><A HREF="<%=$custlink%>"><%= $cust_main->ship_last. ', '. $cust_main->ship_first %></A></TD>
+    <TD><A HREF="<%=$custlink%>"><%= $cust_main->ship_company %></A></TD>
+  <% } %>
+</TR>
+<% } %>
+</TABLE>
+
+</BODY></HTML>
diff --git a/httemplate/search/cust_bill_event.html b/httemplate/search/cust_bill_event.html
new file mode 100755 (executable)
index 0000000..d76ce3c
--- /dev/null
@@ -0,0 +1,23 @@
+<HTML>
+  <HEAD>
+    <TITLE>Failed billing events</TITLE>
+  </HEAD>
+  <BODY>
+    <CENTER>
+      <H1>Failed billing events</H1>
+    </CENTER>
+    <HR>
+    <FORM ACTION="cust_bill_event.cgi" METHOD="post">
+      Return <B>failed billing events</B> for period: 
+      from <INPUT TYPE="text" NAME="beginning"> <i>m/d/y</i>
+      to <INPUT TYPE="text" NAME="ending"> <i>m/d/y</i>
+
+      <P><INPUT TYPE="submit" VALUE="Get Report">
+
+    </FORM>
+
+  <HR>
+
+  </BODY>
+</HTML>
+
index a028a87..8653dcc 100755 (executable)
@@ -9,8 +9,8 @@
     <HR>
     <FORM ACTION="report_cc.cgi" METHOD="post">
       Return <B>credit card receipt report</B> for period: 
-      from <INPUT TYPE="text" NAME="beginning"> 
-      to <INPUT TYPE="text" NAME="ending">
+      from <INPUT TYPE="text" NAME="beginning"> <i>m/d/y</i>
+      to <INPUT TYPE="text" NAME="ending"> <i>m/d/y</i>
 
       <P><INPUT TYPE="submit" VALUE="Get Report">
 
index bda08e3..df9b958 100755 (executable)
@@ -9,8 +9,8 @@
     <HR>
     <FORM ACTION="report_credit.cgi" METHOD="post">
       Return <B>in house credit report</B> for period: 
-      from <INPUT TYPE="text" NAME="beginning"> 
-      to <INPUT TYPE="text" NAME="ending">
+      from <INPUT TYPE="text" NAME="beginning"> <i>m/d/y</i>
+      to <INPUT TYPE="text" NAME="ending"> <i>m/d/y</i>
 
       <P><INPUT TYPE="submit" VALUE="Get Report">
 
index a7beb24..7bf681b 100755 (executable)
@@ -9,8 +9,8 @@
     <HR>
     <FORM ACTION="report_tax.cgi" METHOD="post">
       Return <B>tax report</B> for period: 
-      from <INPUT TYPE="text" NAME="beginning"> 
-      to <INPUT TYPE="text" NAME="ending">
+      from <INPUT TYPE="text" NAME="beginning"> <i>m/d/y</i>
+      to <INPUT TYPE="text" NAME="ending"> <i>m/d/y</i>
 
       <P><INPUT TYPE="submit" VALUE="Get Report">
 
index 95f1a0a..53d7bc0 100755 (executable)
@@ -22,6 +22,8 @@ print qq!<A HREF="${p}edit/cust_pay.cgi?$invnum">Enter payments (check/cash) aga
 
 print qq!<A HREF="${p}misc/print-invoice.cgi?$invnum">Reprint this invoice</A>!.      '<BR><BR>';
 
+#false laziness with search/cust_bill_event.cgi
+
 print table(). '<TR><TH>Event</TH><TH>Date</TH><TH>Status</TH></TR>';
 foreach my $cust_bill_event (
   sort { $a->_date <=> $b->_date } $cust_bill->cust_bill_event