[freeside-commits] freeside/FS/FS/cust_main Billing_Realtime.pm, 1.25.2.1, 1.25.2.2
Mark Wells
mark at wavetail.420.am
Tue Dec 6 21:50:52 PST 2011
Update of /home/cvs/cvsroot/freeside/FS/FS/cust_main
In directory wavetail.420.am:/tmp/cvs-serv25431/FS/FS/cust_main
Modified Files:
Tag: FREESIDE_2_3_BRANCH
Billing_Realtime.pm
Log Message:
minor refactor and better safeguards on term discounts, #15068
Index: Billing_Realtime.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main/Billing_Realtime.pm,v
retrieving revision 1.25.2.1
retrieving revision 1.25.2.2
diff -u -w -d -r1.25.2.1 -r1.25.2.2
--- Billing_Realtime.pm 8 Aug 2011 22:09:35 -0000 1.25.2.1
+++ Billing_Realtime.pm 7 Dec 2011 05:50:50 -0000 1.25.2.2
@@ -138,7 +138,8 @@
I<depend_jobnum> allows payment capture to unlock export jobs
-I<discount_term> attempts to take a discount by prepaying for discount_term
+I<discount_term> attempts to take a discount by prepaying for discount_term.
+The payment will fail if I<amount> is incorrect for this discount term.
A direct (Business::OnlinePayment) transaction will return nothing on success,
or an error message on failure.
@@ -412,6 +413,24 @@
return "Banned credit card" if $ban && $ban->bantype ne 'warn';
###
+ # check for term discount validity
+ ###
+
+ my $discount_term = $options{discount_term};
+ if ( $discount_term ) {
+ my $bill = ($self->cust_bill)[-1]
+ or return "Can't apply a term discount to an unbilled customer";
+ my $plan = FS::discount_plan->new(
+ cust_bill => $bill,
+ months => $discount_term
+ ) or return "No discount available for term '$discount_term'";
+
+ if ( $plan->discounted_total != $options{amount} ) {
+ return "Incorrect term prepayment amount (term $discount_term, amount $options{amount}, requires ".$plan->discounted_total.")";
+ }
+ }
+
+ ###
# massage data
###
More information about the freeside-commits
mailing list