X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fflat.pm;h=9ff9e2e5bd0ec87d6d4f74e930da43df3c3387bb;hb=0935d2f172064807c5a7fe3c15d1c477b3a2b482;hp=c9f2858988a3fa98e999d84eba62dbdbaa8153e5;hpb=184cfcddbb0f9148d0ef1c01756647946b8c2df9;p=freeside.git diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm index c9f285898..9ff9e2e5b 100644 --- a/FS/FS/part_pkg/flat.pm +++ b/FS/FS/part_pkg/flat.pm @@ -1,14 +1,13 @@ package FS::part_pkg::flat; - -use strict; -use base qw( FS::part_pkg - FS::part_pkg::prorate_Mixin +use base qw( FS::part_pkg::prorate_Mixin FS::part_pkg::discount_Mixin + FS::part_pkg ); + +use strict; use vars qw( %info %usage_recharge_fields @usage_recharge_fieldorder ); use Tie::IxHash; -use List::Util qw(min); # max); -#use FS::Record qw(qsearch); +use List::Util qw( min ); use FS::UI::bytecount; use FS::Conf; @@ -88,7 +87,7 @@ sub price_info { } sub calc_setup { - my($self, $cust_pkg, $sdate, $details ) = @_; + my($self, $cust_pkg, $sdate, $details, $param ) = @_; my $i = 0; my $count = $self->option( 'additional_count', 'quiet' ) || 0; @@ -98,7 +97,16 @@ sub calc_setup { my $quantity = $cust_pkg->quantity || 1; - sprintf("%.2f", $quantity * $self->unit_setup($cust_pkg, $sdate, $details) ); + my $charge = $quantity * $self->unit_setup($cust_pkg, $sdate, $details); + + my $discount = 0; + if ( $charge > 0 ) { + $param->{'setup_charge'} = $charge; + $discount = $self->calc_discount($cust_pkg, $sdate, $details, $param); + delete $param->{'setup_charge'}; + } + + sprintf('%.2f', $charge - $discount); } sub unit_setup { @@ -187,11 +195,9 @@ sub is_free_options { sub is_prepaid { 0; } #no, we're postpaid -#XXX discounts only on recurring fees for now (no setup/one-time or usage) -sub can_discount { - my $self = shift; - $self->freq =~ /^\d+$/ && $self->freq > 0; -} +sub can_start_date { ! shift->option('start_1st', 1) } + +sub can_discount { 1; } sub usage_valuehash { my $self = shift;