commissions per agent and package class, RT#18232
[freeside.git] / FS / FS / ClientAPI / MyAccount.pm
index 15c47c6..9d9ab14 100644 (file)
@@ -14,6 +14,7 @@ use Business::CreditCard;
 use HTML::Entities;
 use Text::CSV_XS;
 use Spreadsheet::WriteExcel;
+use OLE::Storage_Lite;
 use FS::UI::Web::small_custview qw(small_custview); #less doh
 use FS::UI::Web;
 use FS::UI::bytecount qw( display_bytecount );
@@ -898,7 +899,12 @@ sub validate_payment {
   my $conf = new FS::Conf;
   my $fee_display = $conf->config('selfservice_process-display') || 'add';
   my $fee_pkgpart = $conf->config('selfservice_process-pkgpart');
-  if ( $fee_display eq 'add' && $fee_pkgpart ) {
+  my $fee_skip_first = $conf->exists('selfservice_process-skip_first');
+  if ( $fee_display eq 'add'
+         and $fee_pkgpart
+         and ! $fee_skip_first || scalar($cust_main->cust_pay)
+     )
+  {
     my $fee_pkg = qsearchs('part_pkg', { pkgpart=>$fee_pkgpart } );
     $amount = sprintf('%.2f', $amount + $fee_pkg->option('setup_fee') );
   }
@@ -1065,7 +1071,9 @@ sub do_process_payment {
   #no error, so order the fee package if applicable...
   my $conf = new FS::Conf;
   my $fee_pkgpart = $conf->config('selfservice_process-pkgpart');
-  if ( $fee_pkgpart ) {
+  my $fee_skip_first = $conf->exists('selfservice_process-skip_first');
+  
+  if ( $fee_pkgpart and ! $fee_skip_first || scalar($cust_main->cust_pay) ) {
 
     my $cust_pkg = new FS::cust_pkg { 'pkgpart' => $fee_pkgpart };