[freeside-commits] freeside/FS/FS cust_main.pm,1.317,1.318
Ivan,,,
ivan at wavetail.420.am
Mon Oct 29 03:31:33 PDT 2007
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv24240/FS/FS
Modified Files:
cust_main.pm
Log Message:
mysql me 1.9 more times
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.317
retrieving revision 1.318
diff -u -d -r1.317 -r1.318
--- cust_main.pm 27 Oct 2007 04:46:04 -0000 1.317
+++ cust_main.pm 29 Oct 2007 10:31:31 -0000 1.318
@@ -19,7 +19,7 @@
use Business::CreditCard 0.28;
use Locale::Country;
use Data::Dumper;
-use FS::UID qw( getotaker dbh );
+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::Msgcat qw(gettext);
@@ -2890,6 +2890,8 @@
$options{'description'} ||= 'Internet services';
+ return $self->fake_bop($method, $amount, %options) if $options{'fake'};
+
eval "use Business::OnlinePayment";
die $@ if $@;
@@ -3215,7 +3217,7 @@
'custnum' => $self->custnum,
'invnum' => $options{'invnum'},
'paid' => $amount,
- '_date' => '',
+ '_date' => '',
'payby' => $method2payby{$method},
'payinfo' => $payinfo,
'paybatch' => $paybatch,
@@ -3312,6 +3314,76 @@
}
+=item fake_bop
+
+=cut
+
+sub fake_bop {
+ my( $self, $method, $amount, %options ) = @_;
+
+ if ( $options{'fake_failure'} ) {
+ return "Error: No error; test failure requested with fake_failure";
+ }
+
+ my %method2payby = (
+ 'CC' => 'CARD',
+ 'ECHECK' => 'CHEK',
+ 'LEC' => 'LECB',
+ );
+
+ #my $paybatch = '';
+ #if ( $payment_gateway ) { # agent override
+ # $paybatch = $payment_gateway->gatewaynum. '-';
+ #}
+ #
+ #$paybatch .= "$processor:". $transaction->authorization;
+ #
+ #$paybatch .= ':'. $transaction->order_number
+ # if $transaction->can('order_number')
+ # && length($transaction->order_number);
+
+ my $paybatch = 'FakeProcessor:54:32';
+
+ my $cust_pay = new FS::cust_pay ( {
+ 'custnum' => $self->custnum,
+ 'invnum' => $options{'invnum'},
+ 'paid' => $amount,
+ '_date' => '',
+ 'payby' => $method2payby{$method},
+ #'payinfo' => $payinfo,
+ 'payinfo' => '4111111111111111',
+ 'paybatch' => $paybatch,
+ #'paydate' => $paydate,
+ 'paydate' => '2012-05-01',
+ } );
+ $cust_pay->payunique( $options{payunique} ) if length($options{payunique});
+
+ my $error = $cust_pay->insert($options{'manual'} ? ( 'manual' => 1 ) : () );
+
+ if ( $error ) {
+ $cust_pay->invnum(''); #try again with no specific invnum
+ my $error2 = $cust_pay->insert( $options{'manual'} ?
+ ( 'manual' => 1 ) : ()
+ );
+ if ( $error2 ) {
+ # gah, even with transactions.
+ my $e = 'WARNING: Card/ACH debited but database not updated - '.
+ "error inserting (fake!) payment: $error2".
+ " (previously tried insert with invnum #$options{'invnum'}" .
+ ": $error )";
+ warn $e;
+ return $e;
+ }
+ }
+
+ if ( $options{'paynum_ref'} ) {
+ ${ $options{'paynum_ref'} } = $cust_pay->paynum;
+ }
+
+ return ''; #no error
+
+}
+
=item default_payment_gateway
=cut
@@ -5852,9 +5924,20 @@
#yuck. this whole thing needs to be reconciled better with 1.9's idea of
#agent-specific Conf
+
+ use FS::part_event::Condition;
my $agentnum = $self->agentnum;
+ my $regexp = '';
+ if ( driver_name =~ /^Pg/i ) {
+ $regexp = '~';
+ } elsif ( driver_name =~ /^mysql/i ) {
+ $regexp = 'REGEXP';
+ } else {
+ die "don't know how to use regular expressions in ". driver_name. " databases";
+ }
+
my $part_event_option =
qsearchs({
'select' => 'part_event_option.*',
@@ -5864,7 +5947,7 @@
LEFT JOIN part_event_option AS peo_agentnum
ON ( part_event.eventpart = peo_agentnum.eventpart
AND peo_agentnum.optionname = 'agentnum'
- AND peo_agentnum.optionvalue ~ '(^|,)}. $agentnum. q{(,|$)'
+ AND peo_agentnum.optionvalue }. $regexp. q{ '(^|,)}. $agentnum. q{(,|$)'
)
LEFT JOIN part_event_option AS peo_cust_bill_age
ON ( part_event.eventpart = peo_cust_bill_age.eventpart
@@ -5882,13 +5965,8 @@
" ORDER BY
CASE WHEN peo_cust_bill_age.optionname != 'cust_bill_age'
THEN -1
- ELSE EXTRACT( EPOCH FROM
- REPLACE( peo_cust_bill_age.optionvalue,
- 'm',
- 'mon'
- )::interval
- )
- END
+ ELSE ". FS::part_event::Condition->age2seconds_sql('peo_cust_bill_age.optionvalue').
+ " END
, part_event.weight".
" LIMIT 1"
});
More information about the freeside-commits
mailing list