[freeside-commits] freeside/FS/FS/part_pkg sql_external.pm, 1.12, 1.13 recur_Common.pm, 1.7, 1.8 discount_Mixin.pm, 1.1, 1.2

Erik Levinson levinse at wavetail.420.am
Mon Jan 17 21:21:10 PST 2011


Update of /home/cvs/cvsroot/freeside/FS/FS/part_pkg
In directory wavetail.420.am:/tmp/cvs-serv19405/FS/FS/part_pkg

Modified Files:
	sql_external.pm recur_Common.pm discount_Mixin.pm 
Log Message:
add discount capability to sql_external, RT10481

Index: sql_external.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/sql_external.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -w -d -r1.12 -r1.13
--- sql_external.pm	24 Dec 2010 09:49:32 -0000	1.12
+++ sql_external.pm	18 Jan 2011 05:21:08 -0000	1.13
@@ -1,7 +1,7 @@
 package FS::part_pkg::sql_external;
 
 use strict;
-use base qw( FS::part_pkg::recur_Common );
+use base qw( FS::part_pkg::recur_Common FS::part_pkg::discount_Mixin );
 use vars qw( %info );
 use DBI;
 #use FS::Record qw(qsearch qsearchs);
@@ -47,9 +47,8 @@
 
 sub calc_recur {
   my $self = shift;
-  my($cust_pkg) = @_; #, $sdate, $details, $param ) = @_;
-
-  my $price = $self->calc_recur_Common(@_);
+  my($cust_pkg, $sdate, $details, $param ) = @_;
+  my $price = 0;
 
   my $dbh = DBI->connect( map { $self->option($_) }
                               qw( datasrc db_username db_password )
@@ -67,10 +66,11 @@
     $price += $sth->fetchrow_arrayref->[0];
   }
 
-  $price;
+  $param->{'override_charges'} = $price;
+  $self->calc_recur_Common($cust_pkg,$sdate,$details,$param);
 }
 
-sub can_discount { 0; }
+sub can_discount { 1; }
 
 sub is_free { 0; }
 

Index: recur_Common.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/recur_Common.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -d -r1.7 -r1.8
--- recur_Common.pm	30 Oct 2010 23:22:31 -0000	1.7
+++ recur_Common.pm	18 Jan 2011 05:21:08 -0000	1.8
@@ -32,6 +32,7 @@
     my $recur_method = $self->option('recur_method', 1) || 'anniversary';
     
     $charges = $self->base_recur;
+    $charges += $param->{'override_charges'} if $param->{'override_charges'};
 
     if ( $recur_method eq 'prorate' ) {
       my $cutoff_day = $self->option('cutoff_day') || 1;

Index: discount_Mixin.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/discount_Mixin.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- discount_Mixin.pm	30 Oct 2010 23:22:31 -0000	1.1
+++ discount_Mixin.pm	18 Jan 2011 05:21:08 -0000	1.2
@@ -42,6 +42,7 @@
   my($self, $cust_pkg, $sdate, $details, $param ) = @_;
 
   my $br = $self->base_recur($cust_pkg);
+  $br += $param->{'override_charges'} if $param->{'override_charges'};
 
   my $tot_discount = 0;
   #UI enforces just 1 for now, will need ordering when they can be stacked



More information about the freeside-commits mailing list