use Locale::Country;
use FS::UID qw( datasrc );
use FS::Misc qw( send_email send_fax );
-use FS::Record qw( qsearch qsearchs );
+use FS::Record qw( qsearch qsearchs dbh );
use FS::cust_main_Mixin;
use FS::cust_main;
use FS::cust_bill_pkg;
=item agent_spools - if set to a true value, will spool to per-agent files rather than a single global file
+=item balanceover - if set, only spools the invoice if the total amount owed on this invoice and all older invoices is greater than the specified amount.
+
=back
=cut
|| ! keys %invoicing_list;
}
+ if ( $opt{'balanceover'} ) {
+ return 'N/A'
+ if $cust_main->total_owed_date($self->_date) < $opt{'balanceover'};
+ }
+
my $spooldir = "/usr/local/etc/freeside/export.". datasrc. "/cust_bill";
mkdir $spooldir, 0700 unless -d $spooldir;
sub batch_card {
my $self = shift;
my $cust_main = $self->cust_main;
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ my $dbh = dbh;
+
+ my $pay_batch = qsearchs('pay_batch', {'status' => 'O'});
+
+ unless ($pay_batch) {
+ $pay_batch = new FS::pay_batch;
+ $pay_batch->setfield('status' => 'O');
+ my $error = $pay_batch->insert;
+ if ( $error ) {
+ die "error creating new batch: $error\n";
+ }
+ }
my $cust_pay_batch = new FS::cust_pay_batch ( {
+ 'batchnum' => $pay_batch->getfield('batchnum'),
'invnum' => $self->getfield('invnum'),
'custnum' => $cust_main->getfield('custnum'),
'last' => $cust_main->getfield('last'),
'state' => $cust_main->getfield('state'),
'zip' => $cust_main->getfield('zip'),
'country' => $cust_main->getfield('country'),
- 'cardnum' => $cust_main->payinfo,
+ 'payinfo' => $cust_main->payinfo,
'exp' => $cust_main->getfield('paydate'),
'payname' => $cust_main->getfield('payname'),
'amount' => $self->owed,
my $error = $cust_pay_batch->insert;
die $error if $error;
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
'';
}
use MIME::Base64;
sub process_re_X {
my( $method, $job ) = ( shift, shift );
+ warn "process_re_X $method for job $job\n" if $DEBUG;
my $param = thaw(decode_base64(shift));
warn Dumper($param) if $DEBUG;
sub re_X {
my($method, $job, %param ) = @_;
# [ 'begin', 'end', 'agentnum', 'open', 'days', 'newest_percust' ],
+ if ( $DEBUG ) {
+ warn "re_X $method for job $job with param:\n".
+ join( '', map { " $_ => ". $param{$_}. "\n" } keys %param );
+ }
#some false laziness w/search/cust_bill.html
my $distinct = '';