summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2008-09-12 00:53:13 +0000
committerivan <ivan>2008-09-12 00:53:13 +0000
commitb800a3e44db3b68e72933242dae6d95b6968fd52 (patch)
tree1854f802ba4a9a9fb831f791c666a8b12640bd78
parentbbc49345e8101dae7311cb3f4043bc6d0775d0ca (diff)
add recur_temporality to flat.pm, RT#3851
-rw-r--r--FS/FS/part_pkg/flat.pm32
-rw-r--r--FS/FS/part_pkg/voip_cdr.pm2
2 files changed, 28 insertions, 6 deletions
diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm
index 3480964d0..2f8fadf7f 100644
--- a/FS/FS/part_pkg/flat.pm
+++ b/FS/FS/part_pkg/flat.pm
@@ -2,12 +2,18 @@ package FS::part_pkg::flat;
use strict;
use vars qw(@ISA %info);
+use Tie::IxHash;
#use FS::Record qw(qsearch);
use FS::UI::bytecount;
use FS::part_pkg;
@ISA = qw(FS::part_pkg);
+tie my %temporalities, 'Tie::IxHash',
+ 'upcoming' => "Upcoming (future)",
+ 'preceding' => "Preceding (past)",
+;
+
%info = (
'name' => 'Flat rate (anniversary billing)',
'shortname' => 'Anniversary',
@@ -18,6 +24,13 @@ use FS::part_pkg;
'recur_fee' => { 'name' => 'Recurring fee for this package',
'default' => 0,
},
+
+ #false laziness w/voip_cdr.pm
+ 'recur_temporality' => { 'name' => 'Charge recurring fee for period',
+ 'type' => 'select',
+ 'select_options' => \%temporalities,
+ },
+
'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
' of service at cancellation',
'type' => 'checkbox',
@@ -82,11 +95,13 @@ use FS::part_pkg;
'type' => 'checkbox',
},
},
- 'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit',
- 'seconds', 'upbytes', 'downbytes', 'totalbytes',
- 'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
- 'recharge_downbytes', 'recharge_totalbytes',
- 'usage_rollover', 'recharge_reset', 'externalid' ],
+ 'fieldorder' => [qw( setup_fee recur_fee recur_temporality unused_credit
+ seconds upbytes downbytes totalbytes
+ recharge_amount recharge_seconds recharge_upbytes
+ recharge_downbytes recharge_totalbytes
+ usage_rollover recharge_reset externalid
+ )
+ ],
'weight' => 10,
);
@@ -112,6 +127,13 @@ sub unit_setup {
sub calc_recur {
my($self, $cust_pkg) = @_;
+
+ #my $last_bill = $cust_pkg->last_bill;
+ my $last_bill = $cust_pkg->get('last_bill'); #->last_bill falls back to setup
+
+ return 0
+ if $self->option('recur_temporality') eq 'preceding' && $last_bill == 0;
+
$self->base_recur($cust_pkg);
}
diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index 0634cdc71..03306ad8b 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -43,7 +43,7 @@ tie my %temporalities, 'Tie::IxHash',
'default' => 0,
},
- #probably useful for other usage-charging price plans
+ #false laziness w/flat.pm
'recur_temporality' => { 'name' => 'Charge recurring fee for period',
'type' => 'select',
'select_options' => \%temporalities,