diff options
author | ivan <ivan> | 2008-09-12 00:53:44 +0000 |
---|---|---|
committer | ivan <ivan> | 2008-09-12 00:53:44 +0000 |
commit | bc65cfbb3b554ce94479c52c16bc6a27538b797a (patch) | |
tree | cbeb4837fef7407d2e274c36a63ba645f9c09cc2 | |
parent | 95b85a6d3d7a154aa88a673d81b8a4d9e7a4a402 (diff) |
add recur_temporality to flat.pm, RT#3851
-rw-r--r-- | FS/FS/part_pkg/flat.pm | 32 | ||||
-rw-r--r-- | FS/FS/part_pkg/voip_cdr.pm | 2 |
2 files changed, 28 insertions, 6 deletions
diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm index 699b4d541..6f2a56a1c 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)', 'fields' => { @@ -17,6 +23,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', @@ -81,11 +94,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, ); @@ -111,6 +126,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 423127888..1af5d475e 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -42,7 +42,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, |