X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=718fccf2f1de56373e7104cf78402c0f4ea3b5da;hb=0269c850cfefc00d5da255f88c63a314e1ab6cd0;hp=ff441dbc0fce597ab703a1059330b071670f89cb;hpb=931aa447df899ead7e5dd6ded2243d5288f8df6f;p=freeside.git diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index ff441dbc0..718fccf2f 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -8,6 +8,7 @@ use vars qw( $realtime_bop_decline_quiet ); #ugh use Safe; use Carp; use Exporter; +use Scalar::Util qw( blessed ); use Time::Local qw(timelocal_nocheck); use Data::Dumper; use Tie::IxHash; @@ -15,13 +16,14 @@ use Digest::MD5 qw(md5_base64); use Date::Format; use Date::Parse; #use Date::Manip; +use File::Slurp qw( slurp ); +use File::Temp qw( tempfile ); use String::Approx qw(amatch); use Business::CreditCard 0.28; use Locale::Country; -use Data::Dumper; use FS::UID qw( getotaker dbh driver_name ); use FS::Record qw( qsearchs qsearch dbdef ); -use FS::Misc qw( send_email generate_ps do_print ); +use FS::Misc qw( generate_email send_email generate_ps do_print ); use FS::Msgcat qw(gettext); use FS::cust_pkg; use FS::cust_svc; @@ -35,6 +37,7 @@ use FS::cust_credit; use FS::cust_refund; use FS::part_referral; use FS::cust_main_county; +use FS::cust_tax_location; use FS::agent; use FS::cust_main_invoice; use FS::cust_credit_bill; @@ -45,8 +48,6 @@ use FS::part_pkg; use FS::part_event; use FS::part_event_condition; #use FS::cust_event; -use FS::cust_tax_exempt; -use FS::cust_tax_exempt_pkg; use FS::type_pkgs; use FS::payment_gateway; use FS::agent_payment_gateway; @@ -54,7 +55,7 @@ use FS::banned_pay; use FS::payinfo_Mixin; use FS::TicketSystem; -@ISA = qw( FS::Record FS::payinfo_Mixin ); +@ISA = qw( FS::payinfo_Mixin FS::Record ); @EXPORT_OK = qw( smart_search ); @@ -225,6 +226,8 @@ Card Verification Value, "CVV2" (also known as CVC2 or CID), the 3 or 4 digit nu =item spool_cdr - Enable individual CDR spooling, empty or `Y' +=item squelch_cdr - Discourage individual CDR printing, empty or `Y' + =back =head1 METHODS @@ -1054,7 +1057,7 @@ sub delete { } -=item replace OLD_RECORD [ INVOICING_LIST_ARYREF ] +=item replace [ OLD_RECORD ] [ INVOICING_LIST_ARYREF ] Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false. @@ -1070,23 +1073,16 @@ check_invoicing_list first. Here's an example: sub replace { my $self = shift; - my $old = shift; + + my $old = ( blessed($_[0]) && $_[0]->isa('FS::Record') ) + ? shift + : $self->replace_old; + my @param = @_; + warn "$me replace called\n" if $DEBUG; - local $SIG{HUP} = 'IGNORE'; - local $SIG{INT} = 'IGNORE'; - local $SIG{QUIT} = 'IGNORE'; - local $SIG{TERM} = 'IGNORE'; - local $SIG{TSTP} = 'IGNORE'; - local $SIG{PIPE} = 'IGNORE'; - - # We absolutely have to have an old vs. new record to make this work. - if (!defined($old)) { - $old = qsearchs( 'cust_main', { 'custnum' => $self->custnum } ); - } - my $curuser = $FS::CurrentUser::CurrentUser; if ( $self->payby eq 'COMP' && $self->payby ne $old->payby @@ -1101,6 +1097,13 @@ sub replace { && $self->payby =~ /^(CARD|DCRD)$/ && ( $old->payinfo eq $self->payinfo || $old->paymask eq $self->paymask ); + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + my $oldAutoCommit = $FS::UID::AutoCommit; local $FS::UID::AutoCommit = 0; my $dbh = dbh; @@ -1209,6 +1212,7 @@ sub check { || $self->ut_number('agentnum') || $self->ut_textn('agent_custid') || $self->ut_number('refnum') + || $self->ut_textn('custbatch') || $self->ut_name('last') || $self->ut_name('first') || $self->ut_snumbern('birthdate') @@ -1532,7 +1536,7 @@ sub check { $self->payname($1); } - foreach my $flag (qw( tax spool_cdr )) { + foreach my $flag (qw( tax spool_cdr squelch_cdr )) { $self->$flag() =~ /^(Y?)$/ or return "Illegal $flag: ". $self->$flag(); $self->$flag($1); } @@ -1951,10 +1955,12 @@ sub bill_and_collect { # cancel packages ### - #$^T not $options{time} because freeside-daily -d is for pre-printing invoices - foreach my $cust_pkg ( - grep { $_->expire && $_->expire <= $^T } $self->ncancelled_pkgs - ) { + #$options{actual_time} not $options{time} because freeside-daily -d is for + #pre-printing invoices + my @cancel_pkgs = grep { $_->expire && $_->expire <= $options{actual_time} } + $self->ncancelled_pkgs; + + foreach my $cust_pkg ( @cancel_pkgs ) { my $error = $cust_pkg->cancel; warn "Error cancelling expired pkg ". $cust_pkg->pkgnum. " for custnum ". $self->custnum. ": $error" @@ -1965,15 +1971,22 @@ sub bill_and_collect { # suspend packages ### - #$^T not $options{time} because freeside-daily -d is for pre-printing invoices - foreach my $cust_pkg ( - grep { ( $_->part_pkg->is_prepaid && $_->bill && $_->bill < $^T - || $_->adjourn && $_->adjourn <= $^T - ) - && ! $_->susp + #$options{actual_time} not $options{time} because freeside-daily -d is for + #pre-printing invoices + my @susp_pkgs = + grep { ! $_->susp + && ( ( $_->part_pkg->is_prepaid + && $_->bill + && $_->bill < $options{actual_time} + ) + || ( $_->adjourn + && $_->adjourn <= $options{actual_time} + ) + ) } - $self->ncancelled_pkgs - ) { + $self->ncancelled_pkgs; + + foreach my $cust_pkg ( @susp_pkgs ) { my $error = $cust_pkg->suspend; warn "Error suspending package ". $cust_pkg->pkgnum. " for custnum ". $self->custnum. ": $error" @@ -2034,13 +2047,12 @@ Used in conjunction with the I