[freeside-commits] freeside/FS/FS cust_main.pm, 1.271.2.63, 1.271.2.64
Ivan,,,
ivan at wavetail.420.am
Tue Apr 14 10:14:52 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv24663
Modified Files:
Tag: FREESIDE_1_7_BRANCH
cust_main.pm
Log Message:
add configuration option to control recurring_flag behavior, RT#3843
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.271.2.63
retrieving revision 1.271.2.64
diff -u -d -r1.271.2.63 -r1.271.2.64
--- cust_main.pm 8 Apr 2009 07:32:50 -0000 1.271.2.63
+++ cust_main.pm 14 Apr 2009 17:14:50 -0000 1.271.2.64
@@ -2593,24 +2593,35 @@
);
###
- # select a gateway
+ # set taxclass and trans_is_recur based on invnum if there is one
###
my $taxclass = '';
+ my $trans_is_recur = 0;
if ( $options{'invnum'} ) {
+
my $cust_bill = qsearchs('cust_bill', { 'invnum' => $options{'invnum'} } );
die "invnum ". $options{'invnum'}. " not found" unless $cust_bill;
- my @taxclasses =
- map { $_->part_pkg->taxclass }
+
+ my @part_pkg =
+ map { $_->part_pkg }
grep { $_ }
map { $_->cust_pkg }
$cust_bill->cust_bill_pkg;
- unless ( grep { $taxclasses[0] ne $_ } @taxclasses ) { #unless there are
- #different taxclasses
- $taxclass = $taxclasses[0];
- }
+
+ my @taxclasses = map $_->taxclass, @part_pkg;
+ $taxclass = $taxclasses[0]
+ unless grep { $taxclasses[0] ne $_ } @taxclasses; #unless there are
+ #different taxclasses
+ $trans_is_recur = 1
+ if grep { $_->freq ne '0' } @part_pkg;
+
}
+ ###
+ # select a gateway
+ ###
+
#look for an agent gateway override first
my $cardtype;
if ( $method eq 'CC' ) {
@@ -2738,16 +2749,15 @@
: $self->payissue;
$content{issue_number} = $payissue if $payissue;
- $content{recurring_billing} = 'YES'
- if qsearch('cust_pay', { 'custnum' => $self->custnum,
- 'payby' => 'CARD',
- 'payinfo' => $payinfo,
- } )
- || qsearch('cust_pay', { 'custnum' => $self->custnum,
- 'payby' => 'CARD',
- 'paymask' => $self->mask_payinfo('CARD', $payinfo),
- } );
-
+ if ( $self->_bop_recurring_billing( 'payinfo' => $payinfo,
+ 'trans_is_recur' => $trans_is_recur,
+ )
+ )
+ {
+ $content{recurring_billing} = 'YES';
+ $content{acct_code} = 'rebill'
+ if $conf->exists('credit_card-recurring_billing_acct_code');
+ }
} elsif ( $method eq 'ECHECK' ) {
( $content{account_number}, $content{routing_code} ) =
@@ -2806,15 +2816,16 @@
#okay, good to go, if we're a duplicate, cust_pay_pending will kick us out
my $cust_pay_pending = new FS::cust_pay_pending {
- 'custnum' => $self->custnum,
- #'invnum' => $options{'invnum'},
- 'paid' => $amount,
- '_date' => '',
- 'payby' => $method2payby{$method},
- 'payinfo' => $payinfo,
- 'paydate' => $paydate,
- 'status' => 'new',
- 'gatewaynum' => ( $payment_gateway ? $payment_gateway->gatewaynum : '' ),
+ 'custnum' => $self->custnum,
+ #'invnum' => $options{'invnum'},
+ 'paid' => $amount,
+ '_date' => '',
+ 'payby' => $method2payby{$method},
+ 'payinfo' => $payinfo,
+ 'paydate' => $paydate,
+ 'recurring_billing' => $content{recurring_billing},
+ 'status' => 'new',
+ 'gatewaynum' => ( $payment_gateway ? $payment_gateway->gatewaynum : '' ),
};
$cust_pay_pending->payunique( $options{payunique} )
if defined($options{payunique}) && length($options{payunique});
@@ -3136,6 +3147,34 @@
'';
}
+sub _bop_recurring_billing {
+ my( $self, %opt ) = @_;
+
+ my $method = $conf->config('credit_card-recurring_billing_flag');
+
+ if ( $method eq 'transaction_is_recur' ) {
+
+ return 1 if $opt{'trans_is_recur'};
+
+ } else {
+
+ my %hash = ( 'custnum' => $self->custnum,
+ 'payby' => 'CARD',
+ );
+
+ return 1
+ if qsearch('cust_pay', { %hash, 'payinfo' => $opt{'payinfo'} } )
+ || qsearch('cust_pay', { %hash, 'paymask' => $self->mask_payinfo('CARD',
+ $opt{'payinfo'} )
+ } );
+
+ }
+
+ return 0;
+
+}
+
+
=item realtime_refund_bop METHOD [ OPTION => VALUE ... ]
Refunds a realtime credit card, ACH (electronic check) or phone bill transaction
More information about the freeside-commits
mailing list