summaryrefslogtreecommitdiff
path: root/FS/FS/part_pkg
diff options
context:
space:
mode:
authorjeff <jeff>2009-04-23 20:34:13 +0000
committerjeff <jeff>2009-04-23 20:34:13 +0000
commit2f7258c405692391d07ae96efef2e471a71849f9 (patch)
treea2fcad89a34a94c1d3b5d243c28c18fe836aaa5f /FS/FS/part_pkg
parentec71691725b6c5211b6967323cbc56a03038385d (diff)
add subscription option to voip_cdr
Diffstat (limited to 'FS/FS/part_pkg')
-rw-r--r--FS/FS/part_pkg/voip_cdr.pm50
1 files changed, 40 insertions, 10 deletions
diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index e25bba5..d89a684 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -4,6 +4,7 @@ use strict;
use vars qw(@ISA $DEBUG %info);
use Date::Format;
use Tie::IxHash;
+use Time::Local;
use FS::Conf;
use FS::Record qw(qsearchs qsearch);
use FS::part_pkg::flat;
@@ -22,6 +23,12 @@ tie my %rating_method, 'Tie::IxHash',
'upstream_simple' => 'Simply pass through and charge the "upstream_price" amount.',
;
+tie my %recur_method, 'Tie::IxHash',
+ 'anniversary' => 'Charge the recurring fee at the frequency specified above',
+ 'prorate' => 'Charge a prorated fee the first time (selectable billing date)',
+ 'subscription' => 'Charge the full fee for the first partial period (selectable billing date)',
+;
+
#tie my %cdr_location, 'Tie::IxHash',
# 'internal' => 'Internal: CDR records imported into the internal CDR table',
# 'external' => 'External: CDR records queried directly from an external '.
@@ -55,14 +62,18 @@ tie my %temporalities, 'Tie::IxHash',
'type' => 'checkbox',
},
- 'enable_prorate' => { 'name' => 'Enable prorating of the first month',
- 'type' => 'checkbox',
- },
-
- 'cutoff_day' => { 'name' => 'Billing Day (1 - 28) for prorating ',
+ 'cutoff_day' => { 'name' => 'Billing Day (1 - 28) for prorating or '.
+ 'subscription',
'default' => '1',
},
+ 'recur_method' => { 'name' => 'Recurring fee method',
+ #'type' => 'radio',
+ #'options' => \%recur_method,
+ 'type' => 'select',
+ 'select_options' => \%recur_method,
+ },
+
'rating_method' => { 'name' => 'Region rating method',
'type' => 'radio',
'options' => \%rating_method,
@@ -187,7 +198,7 @@ tie my %temporalities, 'Tie::IxHash',
},
'fieldorder' => [qw(
setup_fee recur_fee recur_temporality unused_credit
- enable_prorate cutoff_day
+ recur_method cutoff_day
rating_method ratenum ignore_unrateable
default_prefix
disable_src
@@ -558,12 +569,31 @@ sub calc_recur {
} #if ( $spool_cdr && length($downstream_cdr) )
if ($param->{'increment_next_bill'}) {
- if ( $self->option('enable_prorate', 1) ) {
+ my $recur_method = $self->option('recur_method', 1) || 'anniversary';
+
+ if ( $recur_method eq 'prorate' ) {
+
$charges += $self->SUPER::calc_recur(@_);
+
} else {
- $charges += $self->option('recur_fee')
- }
- }
+
+ $charges += $self->option('recur_fee');
+
+ if ( $recur_method eq 'subscription' ) {
+
+ my $cutoff_day = $self->option('cutoff_day', 1) || 1;
+ my ($day, $mon, $year) = ( localtime($$sdate) )[ 3..5 ];
+
+ if ( $day < $cutoff_day ) {
+ if ( $mon == 0 ) { $mon=11; $year--; }
+ else { $mon--; }
+ }
+
+ $$sdate = timelocal(0, 0, 0, $cutoff_day, $mon, $year);
+
+ }#$recur_method eq 'subscription'
+ }#$recur_method eq 'prorate'
+ }#increment_next_bill
$charges;
}