=cut
sub unapplied_payments_date_sql {
- my( $class, $start, $end, ) = @_;
+ my( $class, $start, $end, %opt ) = @_;
+
+ my $cutoff = $opt{'cutoff'};
- my $unapp_pay = FS::cust_pay->unapplied_sql;
+ my $unapp_pay = FS::cust_pay->unapplied_sql($cutoff);
my $pay_where = $class->_money_table_where( 'cust_pay', $start, $end,
'unapplied_date'=>1 );
=cut
sub unapplied_sql {
- my ($class, $start, $end) = shift;
+ my ($class, $start, $end) = @_;
my $bill_start = $start ? "AND cust_bill_pay._date <= $start" : '';
my $bill_end = $end ? "AND cust_bill_pay._date > $end" : '';
my $refund_start = $start ? "AND cust_pay_refund._date <= $start" : '';
=cut
sub unapplied_sql {
- my ($class, $start, $end) = shift;
+ my ($class, $start, $end) = @_;
my $credit_start = $start ? "AND cust_credit_refund._date <= $start" : '';
my $credit_end = $end ? "AND cust_credit_refund._date > $end" : '';
my $pay_start = $start ? "AND cust_pay_refund._date <= $start" : '';
}
push @where,
- call_range_sub($range_sub, $days + $offset, 0, 'no_as'=>1). ' > 0'; # != 0';
+ call_range_sub($range_sub, $days, 0, 'offset' => $offset, 'no_as'=>1). ' > 0'; # != 0';
}
if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
"( $str2time now() $closing - ".($end + $offset) * 86400 . ' )'
: '';
- FS::cust_main->unapplied_payments_date_sql( $start, $end );
+ FS::cust_main->unapplied_payments_date_sql( $start, $end,
+ 'cutoff' => "( $str2time now() $closing - ".$offset * 86400 . ')' );
}