my $balance_sql = FS::cust_main->balance_sql;
- "$balance_sql > CAST( $over AS numeric )";
+ "$balance_sql > CAST( $over AS DECIMAL(10,2) )";
}
my $balance_sql = FS::cust_main->balance_date_sql( $age );
- "$balance_sql > CAST( $over AS numeric )";
+ "$balance_sql > CAST( $over AS DECIMAL(10,2) )";
}
sub order_sql {
my $balance_sql = FS::cust_main->balance_sql;
- "$balance_sql <= CAST( $under AS numeric )";
+ "$balance_sql <= CAST( $under AS DECIMAL(10,2) )";
}
}
sub condition_sql {
- my( $class, $table ) = @_;
+ my( $class, $table, %opt ) = @_;
+
+ my $integer = $opt{'driver_name'} =~ /^mysql/ ? 'UNSIGNED INTEGER' : 'INTEGER';
my $servicenum = $class->condition_sql_option('has_service');
my $sql = qq| 0 < ( SELECT COUNT(cs.svcpart)
FROM cust_bill_pkg cbp, cust_svc cs
WHERE cbp.invnum = cust_bill.invnum
AND cs.pkgnum = cbp.pkgnum
- AND cs.svcpart = CAST( $servicenum AS integer )
+ AND cs.svcpart = CAST( $servicenum AS $integer )
)
|;
return $sql;
my $owed_sql = FS::cust_bill->owed_sql;
- "$owed_sql > CAST( $over AS numeric )";
+ "$owed_sql > CAST( $over AS DECIMAL(10,2) )";
}
1;
my $owed_sql = FS::cust_bill->owed_sql;
- "$owed_sql <= CAST( $under AS numeric )";
+ "$owed_sql <= CAST( $under AS DECIMAL(10,2) )";
}
1;
use strict;
use vars qw( @ISA $DEBUG @SKIP_CONDITION_SQL );
-use FS::UID qw(dbh);
+use FS::UID qw( dbh driver_name );
use FS::Record qw( qsearch qsearchs );
use FS::option_Common;
use FS::part_event; #for order_conditions_sql...
map {
my $conditionname = $_;
my $coderef = $conditions{$conditionname}->{condition_sql};
- my $sql = &$coderef( $eventtable, 'time'=>$time );
+ my $sql = &$coderef( $eventtable, 'time' => $time,
+ 'driver_name' => driver_name(),
+ );
die "$coderef is not a CODEREF" unless ref($coderef) eq 'CODE';
"( cond_$conditionname.conditionname IS NULL OR $sql )";
}