[freeside-commits] freeside/FS/FS/cust_main Billing_Realtime.pm, 1.28, 1.29
Mark Wells
mark at wavetail.420.am
Tue Dec 6 21:50:35 PST 2011
Update of /home/cvs/cvsroot/freeside/FS/FS/cust_main
In directory wavetail.420.am:/tmp/cvs-serv25294/FS/FS/cust_main
Modified Files:
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.28
retrieving revision 1.29
diff -u -w -d -r1.28 -r1.29
--- Billing_Realtime.pm 26 Oct 2011 22:52:21 -0000 1.28
+++ Billing_Realtime.pm 7 Dec 2011 05:50:32 -0000 1.29
@@ -141,7 +141,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.
@@ -415,6 +416,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