X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fbase_rate.pm;h=43a05061069640a211b2e14aa71fb99513fe0664;hb=a6fe07e49e3fc12169e801b1ed6874c3a5bd8500;hp=04896e0fd490beb54c98512a2a59507ee081f43d;hpb=5e05724a635a22776f1b973f5d7e77989da4e048;p=freeside.git diff --git a/FS/FS/part_pkg/base_rate.pm b/FS/FS/part_pkg/base_rate.pm index 04896e0fd..43a050610 100644 --- a/FS/FS/part_pkg/base_rate.pm +++ b/FS/FS/part_pkg/base_rate.pm @@ -9,26 +9,33 @@ use FS::part_pkg; %info = ( 'name' => 'Base rate (anniversary billing, Times units ordered)', + # XXX it multiplies recurring fee by cust_pkg option "units", how to + # express that + 'shortname' => 'Bulk (manual from "units" option)', + 'inherit_fields' => [ 'global_Mixin' ], 'fields' => { - 'setup_fee' => { 'name' => 'Setup fee for this package', - 'default' => 0, - }, - 'recur_fee' => { 'name' => 'Recurring Base fee for this package', - 'default' => 0, - }, - 'unused_credit' => { 'name' => 'Credit the customer for the unused portion'. - ' of service at cancellation', - 'type' => 'checkbox', - }, - 'externalid' => { 'name' => 'Optional External ID', + 'externalid' => { 'name' => 'Optional External ID', 'default' => '', }, }, - 'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', - 'externalid' ], - 'weight' => 10, + 'fieldorder' => [ qw( externalid ) ], + 'weight' => 52, ); +sub price_info { + my $self = shift; + my $conf = new FS::Conf; + my $money_char = $conf->config('money_char') || '$'; + my $setup = $self->option('setup_fee') || 0; + my $recur = $self->option('recur_fee', 1) || 0; + my $str = ''; + $str = $money_char . $setup . ' one-time' if $setup; + $str .= ', ' if ($setup && $recur); + $str .= $money_char . $recur . ' recurring per unit ' if $recur; + $str; +} + + sub calc_setup { my($self, $cust_pkg, $sdate, $details ) = @_; @@ -56,13 +63,10 @@ sub base_recur { } sub calc_remain { - my ($self, $cust_pkg) = @_; - my $time = time; #should be able to pass this in for credit calculation + my ($self, $cust_pkg, %options) = @_; + my $time = $options{'time'} || time; my $next_bill = $cust_pkg->getfield('bill') || 0; - my $last_bill = $cust_pkg->last_bill || 0; - return 0 if ! $self->base_recur - || ! $self->option('unused_credit', 1) - || ! $last_bill + return 0 if ! $self->base_recur($cust_pkg) || ! $next_bill || $next_bill < $time; @@ -78,7 +82,7 @@ sub calc_remain { my $freq_sec = $1 * $sec{$2||'m'}; return 0 unless $freq_sec; - sprintf("%.2f", $self->base_recur * ( $next_bill - $time ) / $freq_sec ); + sprintf("%.2f", $self->base_recur($cust_pkg) * ( $next_bill - $time ) / $freq_sec ); }