$realtime_bop_decline_quiet = 0;
-$DEBUG = 0;
+# 1 is mostly method/subroutine entry and options
+# 2 traces progress of some operations
+# 3 is even more information including possibly sensitive data
+$DEBUG = 3;
$me = '[FS::cust_main]';
$import = 0;
my $cust_pkgs = @_ ? shift : {};
my $invoicing_list = @_ ? shift : '';
my %options = @_;
- warn "FS::cust_main::insert called with options ".
+ warn "$me insert called with options ".
join(', ', map { "$_: $options{$_}" } keys %options ). "\n"
if $DEBUG;
$prepay_identifier = $self->payinfo;
$self->payinfo('');
+ warn " looking up prepaid card $prepay_identifier\n"
+ if $DEBUG > 1;
+
my $error = $self->get_prepay($prepay_identifier, \$amount, \$seconds);
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
}
+ warn " inserting $self\n"
+ if $DEBUG > 1;
+
my $error = $self->SUPER::insert;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
}
- # invoicing list
+ warn " setting invoicing list\n"
+ if $DEBUG > 1;
+
if ( $invoicing_list ) {
$error = $self->check_invoicing_list( $invoicing_list );
if ( $error ) {
$self->invoicing_list( $invoicing_list );
}
- # packages
+ warn " ordering packages\n"
+ if $DEBUG > 1;
+
$error = $self->order_pkgs($cust_pkgs, \$seconds, %options);
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
}
if ( $amount ) {
+ warn " inserting initial $payby payment of $amount\n"
+ if $DEBUG > 1;
$error = $self->insert_cust_pay($payby, $amount, $prepay_identifier);
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
}
}
-
-
unless ( $import || $skip_fuzzyfiles ) {
+ warn " queueing fuzzyfiles update\n"
+ if $DEBUG > 1;
$error = $self->queue_fuzzyfiles_update;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
}
}
+ warn " insert complete; committing transaction\n"
+ if $DEBUG > 1;
+
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
'';
my %svc_options = ();
$svc_options{'depend_jobnum'} = $options{'depend_jobnum'}
if exists $options{'depend_jobnum'};
- warn "FS::cust_main::order_pkgs called with options ".
+ warn "$me order_pkgs called with options ".
join(', ', map { "$_: $options{$_}" } keys %options ). "\n"
if $DEBUG;
my $cust_pkg = $cust_pkg[0];
warn " found package pkgnum ". $cust_pkg->pkgnum. "\n"
- if $DEBUG;
+ if $DEBUG > 1;
my @cust_svc =
$cust_pkg->cust_svc( $cust_pkg->part_pkg->svcpart('svc_acct') );
my $svc_acct = $cust_svc[0]->svc_x;
warn " found service svcnum ". $svc_acct->pkgnum.
' ('. $svc_acct->email. ")\n"
- if $DEBUG;
+ if $DEBUG > 1;
$svc_acct->increment_seconds($seconds);
sub reexport {
my $self = shift;
- carp "warning: FS::cust_main::reexport is deprectated; ".
+ carp "WARNING: FS::cust_main::reexport is deprectated; ".
"use the depend_jobnum option to insert or order_pkgs to delay export";
local $SIG{HUP} = 'IGNORE';
sub check {
my $self = shift;
- #warn "BEFORE: \n". $self->_dump;
+ warn "$me check BEFORE: \n". $self->_dump
+ if $DEBUG > 2;
my $error =
$self->ut_numbern('custnum')
$self->otaker(getotaker) unless $self->otaker;
- #warn "AFTER: \n". $self->_dump;
+ warn "$me check AFTER: \n". $self->_dump
+ if $DEBUG > 2;
$self->SUPER::check;
}
sub bill {
my( $self, %options ) = @_;
return '' if $self->payby eq 'COMP';
- warn "bill customer ". $self->custnum. "\n" if $DEBUG;
+ warn "$me bill customer ". $self->custnum. "\n"
+ if $DEBUG;
my $time = $options{'time'} || time;
#NO!! next if $cust_pkg->cancel;
next if $cust_pkg->getfield('cancel');
- warn " bill package ". $cust_pkg->pkgnum. "\n" if $DEBUG;
+ warn " bill package ". $cust_pkg->pkgnum. "\n" if $DEBUG > 1;
#? to avoid use of uninitialized value errors... ?
$cust_pkg->setfield('bill', '')
my $setup = 0;
if ( !$cust_pkg->setup || $options{'resetup'} ) {
- warn " bill setup\n" if $DEBUG;
+ warn " bill setup\n" if $DEBUG > 1;
$setup = eval { $cust_pkg->calc_setup( $time ) };
if ( $@ ) {
( $cust_pkg->getfield('bill') || 0 ) <= $time
) {
- warn " bill recur\n" if $DEBUG;
+ warn " bill recur\n" if $DEBUG > 1;
# XXX shared with $recur_prog
$sdate = $cust_pkg->bill || $cust_pkg->setup || $time;
if ( $cust_pkg->modified ) {
- warn " package ". $cust_pkg->pkgnum. " modified; updating\n" if $DEBUG;
+ warn " package ". $cust_pkg->pkgnum. " modified; updating\n"
+ if $DEBUG >1;
$error=$cust_pkg->replace($old_cust_pkg);
if ( $error ) { #just in case
}
if ( $setup != 0 || $recur != 0 ) {
warn " charges (setup=$setup, recur=$recur); queueing line items\n"
- if $DEBUG;
+ if $DEBUG > 1;
my $cust_bill_pkg = new FS::cust_bill_pkg ({
'pkgnum' => $cust_pkg->pkgnum,
'setup' => $setup,
$self->select_for_update; #mutex
my $balance = $self->balance;
- warn "collect customer ". $self->custnum. ": balance $balance\n" if $DEBUG;
+ warn "$me collect customer ". $self->custnum. ": balance $balance\n"
+ if $DEBUG;
unless ( $balance > 0 ) { #redundant?????
$dbh->rollback if $oldAutoCommit; #hmm
return '';
last if $self->balance <= 0;
- warn "invnum ". $cust_bill->invnum. " (owed ". $cust_bill->owed. ")\n"
- if $DEBUG;
+ warn " invnum ". $cust_bill->invnum. " (owed ". $cust_bill->owed. ")\n"
+ if $DEBUG > 1;
foreach my $part_bill_event (
sort { $a->seconds <=> $b->seconds
last if $cust_bill->owed <= 0 # don't run subsequent events if owed<=0
|| $self->balance <= 0; # or if balance<=0
- warn "calling invoice event (". $part_bill_event->eventcode. ")\n"
- if $DEBUG;
+ warn " calling invoice event (". $part_bill_event->eventcode. ")\n"
+ if $DEBUG > 1;
my $cust_main = $self; #for callback
my $error;
sub realtime_bop {
my( $self, $method, $amount, %options ) = @_;
if ( $DEBUG ) {
- warn "$self $method $amount\n";
+ warn "$me realtime_bop: $method $amount\n";
warn " $_ => $options{$_}\n" foreach keys %options;
}
) {
my $error = $self->remove_cvv;
if ( $error ) {
- warn "error removing cvv: $error\n";
+ warn "WARNING: error removing cvv: $error\n";
}
}
sub realtime_refund_bop {
my( $self, $method, %options ) = @_;
if ( $DEBUG ) {
- warn "$self $method refund\n";
+ warn "$me realtime_refund_bop: $method refund\n";
warn " $_ => $options{$_}\n" foreach keys %options;
}
if ( $options{'paynum'} ) {
- warn "FS::cust_main::realtime_bop: paynum: $options{paynum}\n" if $DEBUG;
+ warn " paynum: $options{paynum}\n" if $DEBUG > 1;
$cust_pay = qsearchs('cust_pay', { paynum=>$options{'paynum'} } )
or return "Unknown paynum $options{'paynum'}";
$amount ||= $cust_pay->paid;
#first try void if applicable
if ( $cust_pay && $cust_pay->paid == $amount ) { #and check dates?
- warn "FS::cust_main::realtime_bop: attempting void\n" if $DEBUG;
+ warn " attempting void\n" if $DEBUG > 1;
my $void = new Business::OnlinePayment( $processor, @bop_options );
$void->content( 'action' => 'void', %content );
$void->submit();
warn $e;
return $e;
}
- warn "FS::cust_main::realtime_bop: void successful\n" if $DEBUG;
+ warn " void successful\n" if $DEBUG > 1;
return '';
}
}
- warn "FS::cust_main::realtime_bop: void unsuccessful, trying refund\n"
- if $DEBUG;
+ warn " void unsuccessful, trying refund\n"
+ if $DEBUG > 1;
#massage data
my $address = $self->address1;