From b800a3e44db3b68e72933242dae6d95b6968fd52 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 12 Sep 2008 00:53:13 +0000 Subject: [PATCH] add recur_temporality to flat.pm, RT#3851 --- FS/FS/part_pkg/flat.pm | 32 +++++++++++++++++++++++++++----- 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 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, -- 2.11.0