From: ivan Date: Thu, 2 Jul 2009 02:02:46 +0000 (+0000) Subject: fix late fees, RT#5665 X-Git-Tag: root_of_svc_elec_features~1069 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=8db53bcb53bbb32855c38f62afa4d1b39777cb7d fix late fees, RT#5665 --- diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 1e4351931..a1b891226 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -6790,7 +6790,7 @@ sub charge { $setuptax = exists($_[0]->{setuptax}) ? $_[0]->{setuptax} : ''; $taxclass = exists($_[0]->{taxclass}) ? $_[0]->{taxclass} : ''; $classnum = exists($_[0]->{classnum}) ? $_[0]->{classnum} : ''; - $additional = $_[0]->{additional}; + $additional = $_[0]->{additional} || []; $taxproduct = $_[0]->{taxproductnum}; $override = { '' => $_[0]->{tax_override} }; } else { diff --git a/FS/FS/part_event/Action/cust_bill_fee_percent.pm b/FS/FS/part_event/Action/cust_bill_fee_percent.pm index c6f37265a..354778f7d 100644 --- a/FS/FS/part_event/Action/cust_bill_fee_percent.pm +++ b/FS/FS/part_event/Action/cust_bill_fee_percent.pm @@ -14,6 +14,7 @@ sub option_fields { 'percent' => { label=>'Percent', size=>2, }, 'reason' => 'Reason', 'taxclass' => { label=>'Tax class', type=>'select-taxclass', }, + 'nextbill' => { label=>'Hold late fee until next invoice', type=>'checkbox', value=>'Y' }, ); } @@ -28,12 +29,16 @@ sub do_action { my $amount = sprintf('%.2f', $cust_bill->owed * $self->option('percent') / 100 ); - my $error = $cust_main->charge( { + my %charge = ( 'amount' => $amount, 'pkg' => $self->option('reason'), 'taxclass' => $self->option('taxclass'), - #'start_date' => $cust_main->next_bill_date, #unless its more than N months away? - } ); + ); + + $charge{'start_date'} = $cust_main->next_bill_date #unless its more than N months away? + if $self->option('nextbill'); + + my $error = $cust_main->charge( \%charge ); die $error if $error; diff --git a/FS/FS/part_event/Action/fee.pm b/FS/FS/part_event/Action/fee.pm index 7d07df5c7..6ea7103ab 100644 --- a/FS/FS/part_event/Action/fee.pm +++ b/FS/FS/part_event/Action/fee.pm @@ -10,6 +10,7 @@ sub option_fields { 'charge' => { label=>'Amount', type=>'money', }, # size=>7, }, 'reason' => 'Reason', 'taxclass' => { label=>'Tax class', type=>'select-taxclass', }, + 'nextbill' => { label=>'Hold late fee until next invoice', type=>'checkbox', value=>'Y' }, ); } @@ -20,12 +21,16 @@ sub do_action { my $cust_main = $self->cust_main($cust_object); - my $error = $cust_main->charge( { + my %charge = ( 'amount' => $self->option('charge'), 'pkg' => $self->option('reason'), 'taxclass' => $self->option('taxclass') - #'start_date' => $cust_main->next_bill_date, #unless its more than N months away? - } ); + ); + + $charge{'start_date'} = $cust_main->next_bill_date #unless its more than N months away? + if $self->option('nextbill'); + + my $error = $cust_main->charge( \%charge ); die $error if $error;