Merge branch 'master' of git.freeside.biz:/home/git/freeside
authorIvan Kohler <ivan@freeside.biz>
Thu, 26 Jul 2012 21:05:08 +0000 (14:05 -0700)
committerIvan Kohler <ivan@freeside.biz>
Thu, 26 Jul 2012 21:05:08 +0000 (14:05 -0700)
1  2 
FS/FS/Conf.pm
FS/FS/Schema.pm
FS/FS/cust_main.pm
httemplate/misc/order_pkg.html

diff --combined FS/FS/Conf.pm
@@@ -2538,7 -2538,7 +2538,7 @@@ and customer address. Include units.'
    {
      'key'         => 'manual_process-pkgpart',
      'section'     => 'billing',
-     'description' => 'Package to add to each manual credit card and ACH payments entered from the backend.  Enabling this option may be in violation of your merchant agreement(s), so please check them carefully before enabling this option.',
+     'description' => 'Package to add to each manual credit card and ACH payment entered by employees from the backend.  Enabling this option may be in violation of your merchant agreement(s), so please check it(/them) carefully before enabling this option.',
      'type'        => 'select-part_pkg',
    },
  
    },
  
    {
+     'key'         => 'selfservice_process-pkgpart',
+     'section'     => 'billing',
+     'description' => 'Package to add to each manual credit card and ACH payment entered by the customer themselves in the self-service interface.  Enabling this option may be in violation of your merchant agreement(s), so please check it(/them) carefully before enabling this option.',
+     'type'        => 'select-part_pkg',
+   },
+   {
+     'key'         => 'selfservice_process-display',
+     'section'     => 'billing',
+     'description' => 'When using selfservice_process-pkgpart, add the fee to the amount entered (default), or subtract the fee from the amount entered.',
+     'type'        => 'select',
+     'select_hash' => [
+                        'add'      => 'Add fee to amount entered',
+                        'subtract' => 'Subtract fee from amount entered',
+                      ],
+   },
+   {
+     'key'         => 'selfservice_process-skip_first',
+     'section'     => 'billing',
+     'description' => "When using selfservice_process-pkgpart, omit the fee if it is the customer's first payment.",
+     'type'        => 'checkbox',
+   },
+   {
+     'key'         => 'suto_process-pkgpart',
+     'section'     => 'billing',
+     'description' => 'Package to add to each automatic credit card and ACH payment processed by billing events.  Enabling this option may be in violation of your merchant agreement(s), so please check them carefully before enabling this option.',
+     'type'        => 'select-part_pkg',
+   },
+ #  {
+ #    'key'         => 'auto_process-display',
+ #    'section'     => 'billing',
+ #    'description' => 'When using auto_process-pkgpart, add the fee to the amount entered (default), or subtract the fee from the amount entered.',
+ #    'type'        => 'select',
+ #    'select_hash' => [
+ #                       'add'      => 'Add fee to amount entered',
+ #                       'subtract' => 'Subtract fee from amount entered',
+ #                     ],
+ #  },
+   {
+     'key'         => 'auto_process-skip_first',
+     'section'     => 'billing',
+     'description' => "When using auto_process-pkgpart, omit the fee if it is the customer's first payment.",
+     'type'        => 'checkbox',
+   },
+   {
      'key'         => 'allow_negative_charges',
      'section'     => 'billing',
      'description' => 'Allow negative charges.  Normally not used unless importing data from a legacy system that requires this.',
      'select_enum' => [ 'approve', 'decline' ],
    },
  
+   {
+     'key'         => 'batch-errors_to',
+     'section'     => 'billing',
+     'description' => 'Email errors when processing batches to this address.  If unspecified, batch processing will stop immediately on error.',
+     'type'        => 'text',
+   },
    #lists could be auto-generated from pay_batch info
    {
      'key'         => 'batch-fixed_format-CARD',
    },
  
    {
 +    'key'         => 'cust_main-enable_anniversary_date',
 +    'section'     => 'UI',
 +    'description' => 'Enable tracking of an anniversary date with each customer record',
 +    'type'        => 'checkbox',
 +  },
 +
 +  {
      'key'         => 'cust_main-edit_calling_list_exempt',
      'section'     => 'UI',
      'description' => 'Display the "calling_list_exempt" checkbox on customer edit.',
    {
      'key'         => 'disable_previous_balance',
      'section'     => 'invoicing',
-     'description' => 'Disable inclusion of previous balance, payment, and credit lines on invoices',
+     'description' => 'Disable inclusion of previous balance, payment, and credit lines on invoices.',
      'type'        => 'checkbox',
      'per_agent'   => 1,
    },
    },
  
    {
+     'key'         => 'previous_balance-show_on_statements',
+     'section'     => 'invoicing',
+     'description' => 'Show previous invoices on statements, without itemized charges.',
+     'type'        => 'checkbox',
+   },
+   {
      'key'         => 'balance_due_below_line',
      'section'     => 'invoicing',
      'description' => 'Place the balance due message below a line.  Only meaningful when when invoice_sections is false.',
      'description' => 'If set, automatically log users out of the backoffice after this many minutes.',
      'type'       => 'text',
    },
+   
+   {
+     'key'         => 'spreadsheet_format',
+     'section'     => 'UI',
+     'description' => 'Default format for spreadsheet download.',
+     'type'        => 'select',
+     'select_hash' => [
+       'XLS' => 'XLS (Excel 97/2000/XP)',
+       'XLSX' => 'XLSX (Excel 2007+)',
+     ],
+   },
  
    { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
    { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
diff --combined FS/FS/Schema.pm
@@@ -858,7 -858,6 +858,7 @@@ sub tables_hashref 
          'stateid_state', 'varchar', 'NULL', $char_d, '', '', 
          'birthdate' ,@date_type, '', '', 
          'spouse_birthdate' ,@date_type, '', '', 
 +        'anniversary_date' ,@date_type, '', '', 
          'signupdate',@date_type, '', '', 
          'dundate',   @date_type, '', '', 
          'company',  'varchar', 'NULL', $char_d, '', '', 
          'depositor',  'varchar', 'NULL', $char_d, '', '',
          'account',    'varchar', 'NULL', 20,      '', '',
          'teller',     'varchar', 'NULL', 20,      '', '',
+         'batchnum',       'int', 'NULL', '', '', '', #pay_batch foreign key
        ],
        'primary_key' => 'paynum',
        #i guess not now, with cust_pay_pending, if we actually make it here, we _do_ want to record it# 'unique' => [ [ 'payunique' ] ],
        'columns' => [
          'batchnum', 'serial',     '', '', '', '', 
          'agentnum',    'int', 'NULL', '', '', '', 
-       'payby',      'char',     '',  4, '', '', # CARD/CHEK
+         'payby',      'char',     '',  4, '', '', # CARD/CHEK
          'status',     'char', 'NULL',  1, '', '', 
          'download',       @date_type,     '', '', 
          'upload',         @date_type,     '', '', 
+         'title',   'varchar', 'NULL',255, '', '',
        ],
        'primary_key' => 'batchnum',
        'unique' => [],
diff --combined FS/FS/cust_main.pm
@@@ -1779,10 -1779,8 +1779,10 @@@ sub check 
      || $self->ut_textn('custbatch')
      || $self->ut_name('last')
      || $self->ut_name('first')
 -    || $self->ut_snumbern('birthdate')
      || $self->ut_snumbern('signupdate')
 +    || $self->ut_snumbern('birthdate')
 +    || $self->ut_snumbern('spouse_birthdate')
 +    || $self->ut_snumbern('anniversary_date')
      || $self->ut_textn('company')
      || $self->ut_anything('comments')
      || $self->ut_numbern('referral_custnum')
@@@ -2465,6 -2463,25 +2465,25 @@@ Adds a payment for this invoice to the 
  L<FS::cust_pay_batch>), or, if the B<realtime> option is set to a true value,
  runs the payment using a realtime gateway.
  
+ Options may include:
+ B<amount>: the amount to be paid; defaults to the customer's balance minus
+ any payments in transit.
+ B<payby>: the payment method; defaults to cust_main.payby
+ B<realtime>: runs this as a realtime payment instead of adding it to a 
+ batch.  Deprecated.
+ B<invnum>: sets cust_pay_batch.invnum.
+ B<address1>, B<address2>, B<city>, B<state>, B<zip>, B<country>: sets 
+ the billing address for the payment; defaults to the customer's billing
+ location.
+ B<payinfo>, B<paydate>, B<payname>: sets the payment account, expiration
+ date, and name; defaults to those fields in cust_main.
  =cut
  
  sub batch_card {
      'state'    => $options{state}    || $loc->state,
      'zip'      => $options{zip}      || $loc->zip,
      'country'  => $options{country}  || $loc->country,
-     'payby'    => $options{payby}    || $loc->payby,
-     'payinfo'  => $options{payinfo}  || $loc->payinfo,
-     'exp'      => $options{paydate}  || $loc->paydate,
-     'payname'  => $options{payname}  || $loc->payname,
+     'payby'    => $options{payby}    || $self->payby,
+     'payinfo'  => $options{payinfo}  || $self->payinfo,
+     'exp'      => $options{paydate}  || $self->paydate,
+     'payname'  => $options{payname}  || $self->payname,
      'amount'   => $amount,                         # consolidating
    } );
    
@@@ -1,6 -1,4 +1,6 @@@
 -<& /elements/header-popup.html, mt('Order new package') &>
 +<& /elements/header-popup.html, $quotationnum ? mt('Add package to quotation')
 +                                              : mt('Order new package')
 +&>
  
  <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
  <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
  
  <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST">
  
 -<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main->custnum %>">
 +<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main ? $cust_main->custnum : '' %>">
 +<INPUT TYPE="hidden" NAME="prospectnum" VALUE="<% $prospect_main ? $prospect_main->prospectnum : '' %>">
  <INPUT TYPE="hidden" NAME="qualnum" VALUE="<% scalar($cgi->param('qualnum')) |h %>">
 +<INPUT TYPE="hidden" NAME="quotationnum" VALUE="<% $quotationnum %>">
  % if ( $svcpart ) {
      <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
  % }
      </TR>
  % } else {
      <& /elements/tr-select-cust-part_pkg.html,
 -                 'curr_value' => $pkgpart,
 -                 'classnum'   => -1,
 -                 'cust_main'  => $cust_main,
 +                 'curr_value'    => $pkgpart,
 +                 'classnum'      => -1,
 +                 'cust_main'     => $cust_main,
 +                 'prospect_main' => $prospect_main,
      &>
  % }
  
@@@ -44,6 -39,8 +44,8 @@@
          <INPUT TYPE="text" NAME="quantity" SIZE=4 VALUE="<% $quantity %>">
        </TD>
      </TR>
+ % } else {
+     <INPUT TYPE="hidden" NAME="quantity" VALUE="1">
  % }
  
  <TR>
@@@ -59,7 -56,7 +61,7 @@@
    </TD>
  </TR>
  
 -% if ( $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
 +% if ( $cust_main && $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
  %   my $what = lc(FS::payby->shortname($cust_main->payby));
      <TR>
        <TH ALIGN="right"><% mt("Disable automatic $what charge") |h %> </TH>
  % } else {
  
      <& /elements/tr-select-cust_location.html,
 -                 'cgi'       => $cgi,
 -                 'cust_main' => $cust_main,
 +                 'cgi'           => $cgi,
 +                 'cust_main'     => $cust_main,
 +                 'prospect_main' => $prospect_main,
      &>
  
  % }
@@@ -158,42 -154,20 +160,42 @@@ die "access denied
  my $conf = new FS::Conf;
  my $date_format = $conf->config('date_format') || '%m/%d/%Y';
  
 -$cgi->param('custnum') =~ /^(\d+)$/ or die "no custnum";
 -my $custnum = $1;
 -my $cust_main = qsearchs({
 -  'table'     => 'cust_main',
 -  'hashref'   => { 'custnum' => $custnum },
 -  'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
 -});
 +my $cust_main = '';
 +if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
 +  my $custnum = $1;
 +  $cust_main = qsearchs({
 +    'table'     => 'cust_main',
 +    'hashref'   => { 'custnum' => $custnum },
 +    'extra_sql' => ' AND '. $curuser->agentnums_sql,
 +  });
 +}
 +
 +my $prospect_main = '';
 +if ( $cgi->param('prospectnum') =~ /^(\d+)$/ ) {
 +  my $prospectnum = $1;
 +  $prospect_main = qsearchs({
 +    'table'     => 'prospect_main',
 +    'hashref'   => { 'prospectnum' => $prospectnum },
 +    'extra_sql' => ' AND '. $curuser->agentnums_sql,
 +  });
 +}
 +
 +my $quotationnum = '';
 +if ( $cgi->param('quotationnum') =~ /^(\d+)$/ ) {
 +  $quotationnum = $1;
 +}
 +
 +die 'no custnum or prospectnum' unless $cust_main || $prospect_main;
  
  my $part_pkg = '';
  if ( $cgi->param('lock_pkgpart') ) {
    $part_pkg = qsearchs({
      'table'     => 'part_pkg',
      'hashref'   => { 'pkgpart' => scalar($cgi->param('lock_pkgpart')) },
 -    'extra_sql' => ' AND '. FS::part_pkg->agent_pkgs_sql( $cust_main->agent ),
 +    'extra_sql' => ' AND '. FS::part_pkg->agent_pkgs_sql(
 +                              $cust_main ? $cust_main->agent
 +                                         : $prospect_main->agent
 +                            ),
    })
      or die "unknown pkgpart ". $cgi->param('lock_pkgpart');
  }
@@@ -207,7 -181,7 +209,7 @@@ if ( $cgi->param('quantity') =~ /^\s*(\
  
  my $format = $date_format. ' %T %z (%Z)'; #false laziness w/REAL_cust_pkg.cgi?
  my $start_date = '';
 -if( ! $conf->exists('order_pkg-no_start_date') ) {
 +if( ! $conf->exists('order_pkg-no_start_date') && $cust_main ) {
    $start_date = $cust_main->next_bill_date;
    $start_date = $start_date ? time2str($format, $start_date) : '';
  }