From: ivan Date: Mon, 5 Oct 2009 02:36:03 +0000 (+0000) Subject: add manual_process-skip_first option, RT#5889 X-Git-Tag: root_of_svc_elec_features~813 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=357b4e26965895666685590d59f72de331fecb08 add manual_process-skip_first option, RT#5889 --- diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index b125b6253..be4c74413 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1873,6 +1873,12 @@ worry that config_items is freeside-specific and icky. ], }, + { + 'key' => 'manual_process-skip_first', + 'section' => 'billing', + 'description' => "When using manual_process-pkgpart, omit the fee if it is the customer's first payment.", + 'type' => 'checkbox', + }, { 'key' => 'allow_negative_charges', diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index d61ebd21e..638036a15 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -7377,10 +7377,26 @@ Returns all the payments (see L) for this customer. sub cust_pay { my $self = shift; + return $self->num_cust_pay unless wantarray; sort { $a->_date <=> $b->_date } qsearch( 'cust_pay', { 'custnum' => $self->custnum } ) } +=item num_cust_pay + +Returns the number of payments (see L) for this customer. Also +called automatically when the cust_pay method is used in a scalar context. + +=cut + +sub num_cust_pay { + my $self = shift; + my $sql = "SELECT COUNT(*) FROM cust_pay WHERE custnum = ?"; + my $sth = dbh->prepare($sql) or die dbh->errstr; + $sth->execute($self->custnum) or die $sth->errstr; + $sth->fetchrow_arrayref->[0]; +} + =item cust_pay_pkgnum Returns all the payments (see L) for this customer's specific diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi index d35e73f14..ada925c55 100644 --- a/httemplate/misc/payment.cgi +++ b/httemplate/misc/payment.cgi @@ -302,6 +302,8 @@ my $fee_display = ''; my $fee_op = ''; if ( $conf->config('manual_process-pkgpart') ) { + last if $conf->exists('manual_process-skip_first') && ! $cust_main->cust_pay; + $fee_display = $conf->config('manual_process-display') || 'add'; $fee_op = $fee_display eq 'add' ? '+' : '-';