summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2009-10-05 02:36:03 +0000
committerivan <ivan>2009-10-05 02:36:03 +0000
commit357b4e26965895666685590d59f72de331fecb08 (patch)
tree1275e3c0985e721110074f4d0ad782879ee82429
parent0c2679eee18b3b073bc91657fcf85c5dd2e5efc0 (diff)
add manual_process-skip_first option, RT#5889
-rw-r--r--FS/FS/Conf.pm6
-rw-r--r--FS/FS/cust_main.pm16
-rw-r--r--httemplate/misc/payment.cgi2
3 files changed, 24 insertions, 0 deletions
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<FS::cust_pay>) 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<FS::cust_pay>) 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<FS::cust_pay>) 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' ? '+' : '-';