This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / FS / FS / part_pkg / sesmon_hour.pm
1 package FS::part_pkg::sesmon_hour;
2
3 use strict;
4 use vars qw(@ISA %info);
5 #use FS::Record qw(qsearch qsearchs);
6 use FS::part_pkg::flat;
7
8 @ISA = qw(FS::part_pkg::flat);
9
10 %info = (
11   'name' => 'Base charge plus charge per-hour from the session monitor',
12   'fields' => {
13     'setup_fee' => { 'name' => 'Setup fee for this package',
14                      'default' => 0,
15                    },
16     'recur_flat' => { 'name' => 'Base monthly charge for this package',
17                       'default' => 0,
18                     },
19     'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
20                                    ' of service at cancellation',
21                          'type' => 'checkbox',
22                        },
23     'recur_included_hours' => { 'name' => 'Hours included',
24                                 'default' => 0,
25                               },
26     'recur_hourly_charge' => { 'name' => 'Additional charge per hour',
27                                'default' => 0,
28                              },
29   },
30   'fieldorder' => [ 'setup_fee', 'recur_flat', 'unused_credit', 'recur_included_hours', 'recur_hourly_charge' ],
31   #'setup' => 'what.setup_fee.value',
32   #'recur' => '\'my $hours = $cust_pkg->seconds_since($cust_pkg->bill || 0) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; \' + what.recur_flat.value + \' + \' + what.recur_hourly_charge.value + \' * $hours;\'',
33   'weight' => 80,
34 );
35
36 sub calc_recur {
37   my($self, $cust_pkg ) = @_;
38
39   my $hours = $cust_pkg->seconds_since($cust_pkg->bill || 0) / 3600;
40   $hours -= $self->option('recur_included_hours');
41   $hours = 0 if $hours < 0;
42
43   $self->option('recur_flat') + $hours * $self->option('recur_hourly_charge');
44
45 }
46
47 sub is_free_options {
48   qw( setup_fee recur_fee recur_hourly_charge );
49 }
50
51 sub base_recur {
52   my($self, $cust_pkg) = @_;
53   $self->option('recur_flat');
54 }
55
56 1;