From: mark Date: Wed, 29 Sep 2010 23:41:34 +0000 (+0000) Subject: option to charge the next full period when prorating, RT#9874 X-Git-Tag: TORRUS_1_0_9~250 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=86119e342d95f16b799043e9cf66230d015c37de option to charge the next full period when prorating, RT#9874 --- diff --git a/FS/FS/part_pkg/agent.pm b/FS/FS/part_pkg/agent.pm index e5bd163f1..69ecf77ca 100644 --- a/FS/FS/part_pkg/agent.pm +++ b/FS/FS/part_pkg/agent.pm @@ -38,6 +38,10 @@ $me = '[FS::part_pkg::agent]'; 'cutoff_day' => { 'name' => 'Billing Day (1 - 28)', 'default' => '1', }, + 'add_full_period'=> { 'name' => 'When prorating first month, also bill '. + 'for one full period after that', + 'type' => 'checkbox', + }, 'no_pkg_prorate' => { 'name' => 'Disable prorating bulk packages (charge full price for packages active only a portion of the month)', 'type' => 'checkbox', @@ -46,7 +50,7 @@ $me = '[FS::part_pkg::agent]'; }, #'fieldorder' => [qw( setup_fee recur_fee recur_method cutoff_day ) ], - 'fieldorder' => [qw( setup_fee recur_fee cutoff_day no_pkg_prorate ) ], + 'fieldorder' => [qw( setup_fee recur_fee cutoff_day add_full_period no_pkg_prorate ) ], 'weight' => 51, diff --git a/FS/FS/part_pkg/cdr_termination.pm b/FS/FS/part_pkg/cdr_termination.pm index cfd6b4e71..0666d7939 100644 --- a/FS/FS/part_pkg/cdr_termination.pm +++ b/FS/FS/part_pkg/cdr_termination.pm @@ -58,6 +58,10 @@ tie my %temporalities, 'Tie::IxHash', 'subscription', 'default' => '1', }, + 'add_full_period'=> { 'name' => 'When prorating first month, also bill '. + 'for one full period after that', + 'type' => 'checkbox', + }, 'recur_method' => { 'name' => 'Recurring fee method', #'type' => 'radio', @@ -90,6 +94,7 @@ tie my %temporalities, 'Tie::IxHash', 'fieldorder' => [qw( setup_fee recur_fee recur_temporality unused_credit recur_method cutoff_day + add_full_period output_format usage_section summarize_usage usage_mandate ) ], diff --git a/FS/FS/part_pkg/prorate.pm b/FS/FS/part_pkg/prorate.pm index 918b910be..22bb80901 100644 --- a/FS/FS/part_pkg/prorate.pm +++ b/FS/FS/part_pkg/prorate.pm @@ -79,6 +79,11 @@ use FS::part_pkg::flat; 'package recharge', 'type' => 'checkbox', }, + 'add_full_period'=> { 'name' => 'When prorating first month, also bill '. + 'for one full period after that', + 'type' => 'checkbox', + }, + #it would be better if this had to be turned on, its confusing 'externalid' => { 'name' => 'Optional External ID', @@ -89,7 +94,8 @@ use FS::part_pkg::flat; 'seconds', 'upbytes', 'downbytes', 'totalbytes', 'recharge_amount', 'recharge_seconds', 'recharge_upbytes', 'recharge_downbytes', 'recharge_totalbytes', - 'usage_rollover', 'recharge_reset', 'externalid', ], + 'usage_rollover', 'recharge_reset', 'add_full_period', + 'externalid', ], 'freq' => 'm', 'weight' => 20, ); diff --git a/FS/FS/part_pkg/prorate_Mixin.pm b/FS/FS/part_pkg/prorate_Mixin.pm index 2adf2f16a..ed532ee12 100644 --- a/FS/FS/part_pkg/prorate_Mixin.pm +++ b/FS/FS/part_pkg/prorate_Mixin.pm @@ -80,12 +80,19 @@ sub calc_prorate { $mstart = timelocal(0,0,0,$cutoff_day,$mon == 0 ? 11 : $mon - 1,$year-($mon==11)); } - + + # next bill date will be figured as $$sdate + one period $$sdate = $mstart; my $permonth = $self->option('recur_fee', 1) / $self->freq; my $months = ( ( $self->freq - 1 ) + ($mend-$mnow) / ($mend-$mstart) ); - + + if ( $self->option('add_full_period',1) ) { + # charge a full period in addition to the partial month + $months += $self->freq; + $$sdate = $self->add_freq($mstart); + } + $param->{'months'} = $months; $charge = sprintf('%.2f', $permonth * $months); } diff --git a/FS/FS/part_pkg/sql_external.pm b/FS/FS/part_pkg/sql_external.pm index 3cf206452..8e803f967 100644 --- a/FS/FS/part_pkg/sql_external.pm +++ b/FS/FS/part_pkg/sql_external.pm @@ -24,6 +24,10 @@ use DBI; 'subscription', 'default' => '1', }, + 'add_full_period'=> { 'name' => 'When prorating first month, also bill '. + 'for one full period after that', + 'type' => 'checkbox', + }, 'recur_method' => { 'name' => 'Recurring fee method', #'type' => 'radio', @@ -45,7 +49,7 @@ use DBI; }, }, 'fieldorder' => [qw( setup_fee recur_fee unused_credit recur_method cutoff_day - datasrc db_username db_password query + add_full_period datasrc db_username db_password query )], 'weight' => '58', ); diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index 005009ae2..5b83cc77a 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -70,7 +70,10 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities(); 'subscription', 'default' => '1', }, - + 'add_full_period'=> { 'name' => 'When prorating first month, also bill '. + 'for one full period after that', + 'type' => 'checkbox', + }, 'recur_method' => { 'name' => 'Recurring fee method', #'type' => 'radio', #'options' => \%recur_method, @@ -253,6 +256,7 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities(); 'fieldorder' => [qw( setup_fee recur_fee recur_temporality unused_credit recur_method cutoff_day + add_full_period cdr_svc_method rating_method ratenum min_charge sec_granularity ignore_unrateable diff --git a/FS/FS/part_pkg/voip_inbound.pm b/FS/FS/part_pkg/voip_inbound.pm index 4937bb86b..8b1844ad9 100644 --- a/FS/FS/part_pkg/voip_inbound.pm +++ b/FS/FS/part_pkg/voip_inbound.pm @@ -47,6 +47,10 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities(); 'subscription', 'default' => '1', }, + 'add_full_period'=> { 'name' => 'When prorating first month, also bill '. + 'for one full period after that', + 'type' => 'checkbox', + }, 'recur_method' => { 'name' => 'Recurring fee method', 'type' => 'select', @@ -152,7 +156,7 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities(); }, 'fieldorder' => [qw( setup_fee recur_fee recur_temporality unused_credit - recur_method cutoff_day + recur_method cutoff_day add_full_period min_charge sec_granularity default_prefix disable_tollfree