# bill recurring fee
###
- #XXX unit stuff here too
my $recur = 0;
my $unitrecur = 0;
my @recur_discounts = ();
my $sdate;
if ( ! $cust_pkg->start_date
- and ( ! $cust_pkg->susp || $part_pkg->option('suspend_bill', 1) )
+ and ( ! $cust_pkg->susp || $cust_pkg->option('suspend_bill',1)
+ || ( $part_pkg->option('suspend_bill', 1) )
+ && ! $cust_pkg->option('no_suspend_bill',1)
+ )
and
( $part_pkg->freq ne '0' && ( $cust_pkg->bill || 0 ) <= day_end($time) )
|| ( $part_pkg->plan eq 'voip_cdr'
return "$@ running $method for $cust_pkg\n"
if ( $@ );
+ #base_cancel???
+ $unitrecur = $cust_pkg->part_pkg->base_recur || $recur; #XXX uuh
+
if ( $increment_next_bill ) {
my $next_bill = $part_pkg->add_freq($sdate, $options{freq_override} || 0);
$taxhash{'taxclass'} = $part_pkg->taxclass;
+ warn "taxhash:\n". Dumper(\%taxhash) if $DEBUG > 2;
+
my @taxes = (); # entries are cust_main_county objects
my %taxhash_elim = %taxhash;
my @elim = qw( district city county state );
} while ( !scalar(@taxes) && scalar(@elim) );
- @taxes = grep { ! $_->taxname or ! $self->tax_exemption($_->taxname) }
+ @taxes = grep { ! $_->taxname || ! $self->tax_exemption($_->taxname) }
@taxes
if $self->cust_main_exemption; #just to be safe
+ warn "using taxes:\n". Dumper(@taxes) if $DEBUG > 2;
+
# all packages now have a locationnum and should get a
# cust_bill_pkg_tax_location record. The tax_locationnum
# may be the package's locationnum, or the customer's bill
cust_bill_batch
);
- my $is_realtime_event = ' ( '. join(' OR ', map "part_event.action = '$_'",
- @realtime_events
- ).
- ' ) ';
+ my $is_realtime_event =
+ ' part_event.action IN ( '.
+ join(',', map "'$_'", @realtime_events ).
+ ' ) ';
+
+ my $batch_or_statustext =
+ "( part_event.action = 'cust_bill_batch'
+ OR ( statustext IS NOT NULL AND statustext != '' )
+ )";
+
my @cust_event = qsearch({
'table' => 'cust_event',
'select' => 'cust_event.*',
'addl_from' => "LEFT JOIN part_event USING ( eventpart ) $join",
'hashref' => { 'status' => 'done' },
- 'extra_sql' => " AND statustext IS NOT NULL AND statustext != '' ".
+ 'extra_sql' => " AND $batch_or_statustext ".
" AND $mine AND $is_realtime_event AND $agent_virt $order" # LIMIT 1"
});