multiple payment options (new complimentary flag), RT#23741
authorIvan Kohler <ivan@freeside.biz>
Mon, 16 Feb 2015 07:35:12 +0000 (23:35 -0800)
committerIvan Kohler <ivan@freeside.biz>
Mon, 16 Feb 2015 07:35:12 +0000 (23:35 -0800)
14 files changed:
FS/FS/API.pm
FS/FS/Cron/breakage.pm
FS/FS/Setup.pm
FS/FS/cust_bill.pm
FS/FS/cust_main/API.pm
FS/FS/cust_main/Billing.pm
FS/FS/cust_pay.pm
FS/FS/tax_rate.pm
httemplate/edit/cust_main/billing.html
httemplate/search/cust_tax_exempt.cgi
httemplate/search/cust_tax_exempt_pkg.cgi
httemplate/view/cust_bill.cgi
httemplate/view/cust_main/billing.html
httemplate/view/cust_statement.html

index c49fb20..f848361 100644 (file)
@@ -365,26 +365,6 @@ comma-separated list of email addresses for email invoices. The special value 'P
 postal_invoicing
 Set to 1 to enable postal invoicing
 
-=item payby
-
-CARD, DCRD, CHEK, DCHK, LECB, BILL, COMP or PREPAY
-
-=item payinfo
-
-Card number for CARD/DCRD, account_number@aba_number for CHEK/DCHK, prepaid "pin" for PREPAY, purchase order number for BILL
-
-=item paycvv
-
-Credit card CVV2 number (1.5+ or 1.4.2 with CVV schema patch)
-
-=item paydate
-
-Expiration date for CARD/DCRD
-
-=item payname
-
-Exact name on credit card for CARD/DCRD, bank name for CHEK/DCHK
-
 =item referral_custnum
 
 Referring customer number
@@ -505,27 +485,6 @@ addition to email addresses),
 postal_invoicing
 Set to 1 to enable postal invoicing
 
-=item payby
-
-CARD, DCRD, CHEK, DCHK, LECB, BILL, COMP or PREPAY
-
-=item payinfo
-
-Card number for CARD/DCRD, account_number@aba_number for CHEK/DCHK, prepaid 
-"pin" for PREPAY, purchase order number for BILL
-
-=item paycvv
-
-Credit card CVV2 number (1.5+ or 1.4.2 with CVV schema patch)
-
-=item paydate
-
-Expiration date for CARD/DCRD
-
-=item payname
-
-Exact name on credit card for CARD/DCRD, bank name for CHEK/DCHK
-
 =item referral_custnum
 
 Referring customer number
index 6dd904d..56a9df4 100644 (file)
@@ -47,7 +47,7 @@ sub reconcile_breakage {
     my @customers = qsearch({
       'table'     => 'cust_main',
       'hashref'   => { 'agentnum' => $agent->agentnum,
-                       'payby'    => { op=>'!=', value=>'COMP', },
+                       'complimentary' => { op=>'!=', value=>'Y', },
                      },
       'extra_sql' => $extra_sql,
     });
index 5528c89..f26e50e 100644 (file)
@@ -363,13 +363,11 @@ sub initial_data {
     #with billing type Complimentary. Leave the First package dropdown set to
     #(none).
     'cust_main' => [
-      { 'agentnum'  => 1, #XXX
-        'refnum'    => 1, #XXX
-        'first'     => 'System',
-        'last'      => 'Accounts',
-        'payby'     => 'COMP',
-        'payinfo'   => 'system', #or something
-        'paydate'   => '1/2037',
+      { 'agentnum'      => 1, #XXX
+        'refnum'        => 1, #XXX
+        'first'         => 'System',
+        'last'          => 'Accounts',
+        'complimentary' => 'Y',
         'bill_location' => $cust_location,
         'ship_location' => $cust_location,
       },
index 26f10da..8d69661 100644 (file)
@@ -6,6 +6,7 @@ use base qw( FS::cust_bill::Search FS::Template_Mixin
 use strict;
 use vars qw( $DEBUG $me );
              # but NOT $conf
+use Carp;
 use Fcntl qw(:flock); #for spool_csv
 use Cwd;
 use List::Util qw(min max sum);
@@ -1953,24 +1954,8 @@ sub print_csv {
 
 }
 
-=item comp
-
-Pays this invoice with a compliemntary payment.  If there is an error,
-returns the error, otherwise returns false.
-
-=cut
-
 sub comp {
-  my $self = shift;
-  my $cust_pay = new FS::cust_pay ( {
-    'invnum'   => $self->invnum,
-    'paid'     => $self->owed,
-    '_date'    => '',
-    'payby'    => 'COMP',
-    'payinfo'  => $self->cust_main->payinfo,
-    'paybatch' => '',
-  } );
-  $cust_pay->insert;
+  croak 'cust_bill->comp is deprecated (COMP payments are deprecated)';
 }
 
 =item realtime_card
index 158b5cf..2d6da9e 100644 (file)
@@ -21,8 +21,7 @@ use vars qw(
   first last company daytime night fax mobile
 );
 #  locale
-#  payby payinfo payname paystart_month paystart_year payissue payip
-#  ss paytype paystate stateid stateid_state
+#  ss stateid stateid_state
 @location_editable_fields = qw(
   address1 address2 city county state zip country
 );
@@ -106,14 +105,12 @@ sub API_insert {
   #same for refnum like signup_server-default_refnum?
 
   my $cust_main = new FS::cust_main ( { # $class->new( {
-      'payby'  => 'BILL',
       'tagnum' => [ FS::part_tag->default_tags ],
 
       map { $_ => $opt{$_} } qw(
         agentnum salesnum refnum agent_custid referral_custnum
         last first company 
         daytime night fax mobile
-        payby payinfo paydate paycvv payname
       ),
 
   } );
@@ -176,7 +173,6 @@ sub API_update {
         agentnum salesnum refnum agent_custid referral_custnum
         last first company
         daytime night fax mobile
-        payby payinfo paydate paycvv payname
       ),
 
   my @invoicing_list;
index 9e2082f..b3d4e70 100644 (file)
@@ -390,7 +390,7 @@ terms or the default terms are used.
 sub bill {
   my( $self, %options ) = @_;
 
-  return '' if $self->payby eq 'COMP';
+  return '' if $self->complimentary eq 'Y';
 
   local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG;
   my $log = FS::Log->new('FS::cust_main::Billing::bill');
index 139d2ff..e8f9aee 100644 (file)
@@ -978,7 +978,6 @@ sub _upgrade_data {  #class method
         $cust_pay->set('otaker', 'legacy');
       }
 
-      delete $FS::payby::hash{'COMP'}->{cust_pay}; #quelle kludge
       my $error = $cust_pay->replace;
 
       if ( $error ) {
@@ -987,8 +986,6 @@ sub _upgrade_data {  #class method
         next;
       }
 
-      $FS::payby::hash{'COMP'}->{cust_pay} = ''; #restore it
-
       $count++;
       if ( $DEBUG > 1 && $lastprog + 30 < time ) {
         warn "$me $count/$total (".sprintf('%.2f',100*$count/$total). '%)'."\n";
@@ -1042,9 +1039,7 @@ sub _upgrade_data {  #class method
   # otaker->usernum upgrade
   ###
 
-  delete $FS::payby::hash{'COMP'}->{cust_pay}; #quelle kludge
   $class->_upgrade_otaker(%opt);
-  $FS::payby::hash{'COMP'}->{cust_pay} = ''; #restore it
 
   # if we do this anywhere else, it should become an FS::Upgrade method
   my $num_to_upgrade = $class->count('paybatch is not null');
index ec3bb12..0047f9d 100644 (file)
@@ -2055,9 +2055,6 @@ sub generate_liability_report {
         join(';', map { "$_=". uri_escape($t->$_) } @params);
 
       my $itemdesc_loc = 
-      # "    payby != 'COMP' ". # breaks the entire report under 4.x
-      #                         # and unnecessary since COMP accounts don't
-      #                         # get taxes calculated in the first place
         "    ( itemdesc = ? OR ? = '' AND itemdesc IS NULL ) ".
         "AND ". FS::tax_rate_location->location_sql( map { $_ => $t->$_ }
                                                          @taxparams
index fa392bb..d25e887 100644 (file)
   <% &ntable("#cccccc") %>
 
 %   my $curuser = $FS::CurrentUser::CurrentUser;
+
+%   ###
+%   # complimentry flag
+%   ###
+
+%   if ( $curuser->access_right('Complimentary customer') ) {
+
+      <TR>
+        <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="complimentary" VALUE="Y" <% $cust_main->complimentary eq "Y" ? 'CHECKED' : '' %>>Complimentary customer
+      </TR>
+
+%   } else {
+
+      <INPUT TYPE="hidden" NAME="complimentary" VALUE="<% $cust_main->complimentary eq 'Y' ? 'Y' : '' %>">
+
+%   }
+
+%   ###
+%   # tax exemptions
+%   ###
+
 %   my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
 %   if (    $conf->exists('cust_class-tax_exempt')
 %        || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
@@ -31,7 +52,7 @@
 %   } else {
 
       <TR>
-        <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="tax" VALUE="Y" <% $cust_main->tax eq "Y" ? 'CHECKED' : '' %>> Tax Exempt<% @exempt_groups ? ' (all taxes)' : '' %></TD>
+        <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="tax" VALUE="Y" <% $cust_main->tax eq "Y" ? 'CHECKED' : '' %>> Tax Exempt<% @exempt_groups ? ' (all taxes)' : '' %></TD>
       </TR>
 
 %   }
 %     }
 %   }
 
+%   ###
+%   # postal invoices
+%   ###
+
 % unless ( $conf->exists('emailinvoiceonly') ) {
 
     <TR>
-      <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST" <%
+      <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST" <%
 
         ( grep { $_ eq 'POST' } @invoicing_list )
 
 
 % }
 
+%   ###
+%   # email invoices
+%   ###
+
     <TR>
-      <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoice_email" VALUE="Y" <%
+      <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoice_email" VALUE="Y" <%
 
         ( $cust_main->invoice_noemail eq 'Y' )
           ? ''
     </TR>
 % }
 
+%   ###
+%   # prorate_day
+%   ###
+
 % if ( $conf->exists('cust_main-select-prorate_day') ) {
     <TR>
       <TD ALIGN="right" WIDTH="200"><% mt('Prorate day (1-28)') |h %> </TD>
     <INPUT TYPE="hidden" NAME="prorate_day" VALUE="<% $cust_main->prorate_day %>">
 % }
 
+%   ###
+%   # billday
+%   ###
+
     <TR>
       <TD ALIGN="right" WIDTH="200"><% mt('Charge card/e-check on this day of the month') |h %> </TD>
       <TD>
 %   $ret;
 %  }
 
+%   ###
+%   # invoice_terms
+%   ###
+
     <TR>
       <TD ALIGN="right" WIDTH="200"><% mt('Invoice terms') |h %> </TD>
       <TD WIDTH="408">
       </TD>
     </TR>
 
+%   ###
+%   # credit_limit
+%   ###
+
     <TR>
       <TD ALIGN="right" WIDTH="200"><% mt('Credit limit') |h %> </TD>
       <TD WIDTH="408">
@@ -162,6 +207,10 @@ function toggle(obj) {
       </TD>
     </TR>
 
+%   ###
+%   # CDR flags / options
+%   ###
+
 % if ( $conf->exists('voip-cust_cdr_spools') ) { 
       <TR>
        <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="spool_cdr" VALUE="Y" <% $cust_main->spool_cdr eq "Y" ? 'CHECKED' : '' %>> <% mt('Spool CDRs') |h %></TD>
@@ -213,6 +262,10 @@ function toggle(obj) {
       <INPUT TYPE="hidden" NAME="cdr_termination_percentage" VALUE="<% $cust_main->cdr_termination_percentage %>">
 % }
 
+%   ###
+%   # Invoicing currency
+%   ###
+
 %my @currencies = $conf->config('currencies');
 %if ( scalar(@currencies) ) {
 %  unshift @currencies, ''; #default
@@ -229,6 +282,9 @@ function toggle(obj) {
     &>
 % }
 
+%   ###
+%   # Invoicing locale
+%   ###
 
 %my @available_locales = $conf->config('available-locales');
 %if ( scalar(@available_locales) ) {
@@ -268,11 +324,6 @@ my $conf = new FS::Conf;
 
 my $money_char = $conf->config('money_char') || '$';
 
-my @payby = grep /\w/, $conf->config('payby');
-#@payby = (qw( CARD DCRD CHEK DCHK BILL CASH WEST COMP ))
-@payby = (qw( CARD DCRD CHEK DCHK BILL CASH COMP ))
-  unless @payby;
-
 my $show_term = '';
 if ( $cust_main->custnum ) {
   #false laziness w/view/cust_main/billing.html
index 005d77c..91b2001 100644 (file)
@@ -61,7 +61,6 @@ my @where = ();
 #if ( $beginning || $ending ) {
 #  push @where, "_date >= $beginning",
 #               "_date <= $ending";
-#               #"payby != 'COMP';
 #}
 
 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
index ba3f275..7b4a6d0 100644 (file)
@@ -107,7 +107,6 @@ my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
 if ( $beginning || $ending ) {
   push @where, "_date >= $beginning",
                "_date <= $ending";
-               #"payby != 'COMP';
 }
 
 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
index 4ee4efb..6bc499a 100755 (executable)
@@ -174,8 +174,7 @@ my %opt = (
 $opt{'barcode_img'} = 1 if $conf->exists('invoice-barcode');
 
 my @payby =  grep /\w/, $conf->config('payby');
-#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
-@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
+@payby = (qw( CARD DCRD CHEK DCHK BILL CASH ))
   unless @payby;
 my %payby = map { $_=>1 } @payby;
 
index f1125c0..4f4b745 100644 (file)
   &>
 % } 
 
+% my $yes = emt('yes');
+% my $no = emt('no');
+
 <TABLE CLASS="fsinnerbox">
 
+% if ( $cust_main->complimentary ) {
+  <TR>
+    <TD ALIGN="right"><% mt('Complimentary') |h %></TD>
+    <TD BGCOLOR="#ffffff"><% $yes %></TD>
+  </TR>
+% }
+
 %( my $balance = $cust_main->balance )
 %  =~ s/^(\-?)(.*)$/<FONT SIZE=+1>$1<\/FONT>$money_char$2/;
 
@@ -53,9 +63,6 @@
     </TR>
 % } 
 
-% my $yes = emt('yes');
-% my $no = emt('no');
-
 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
 
 % unless (    $conf->exists('cust_class-tax_exempt')
index 5d37b31..87a185f 100755 (executable)
@@ -55,12 +55,6 @@ my $statementnum = $3;
 
 my $conf = new FS::Conf;
 
-my @payby =  grep /\w/, $conf->config('payby');
-#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
-@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
-  unless @payby;
-my %payby = map { $_=>1 } @payby;
-
 my $cust_statement = qsearchs({
   'select'    => 'cust_statement.*',
   'table'     => 'cust_statement',