communigate provisioning phase 2: add svc_domain.trailer -> communigate TrailerText...
[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   'shortname' => 'Session monitor (per-hour)',
13   'fields' => {
14     'setup_fee' => { 'name' => 'Setup fee for this package',
15                      'default' => 0,
16                    },
17     'recur_fee' => { 'name' => 'Base recurring fee for this package',
18                      'default' => 0,
19                    },
20     'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
21                                    ' of service at cancellation',
22                          'type' => 'checkbox',
23                        },
24     'recur_included_hours' => { 'name' => 'Hours included',
25                                 'default' => 0,
26                               },
27     'recur_hourly_charge' => { 'name' => 'Additional charge per hour',
28                                'default' => 0,
29                              },
30   },
31   'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', 'recur_included_hours', 'recur_hourly_charge' ],
32   #'setup' => 'what.setup_fee.value',
33   #'recur' => '\'my $hours = $cust_pkg->seconds_since($cust_pkg->bill || 0) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; \' + what.recur_fee.value + \' + \' + what.recur_hourly_charge.value + \' * $hours;\'',
34   'weight' => 80,
35 );
36
37 sub calc_recur {
38   my($self, $cust_pkg ) = @_;
39
40   my $hours = $cust_pkg->seconds_since($cust_pkg->bill || 0) / 3600;
41   $hours -= $self->option('recur_included_hours');
42   $hours = 0 if $hours < 0;
43
44   $self->option('recur_fee') + $hours * $self->option('recur_hourly_charge');
45
46 }
47
48 sub can_discount { 0; }
49
50 sub is_free_options {
51   qw( setup_fee recur_fee recur_hourly_charge );
52 }
53
54 sub base_recur {
55   my($self, $cust_pkg) = @_;
56   $self->option('recur_fee');
57 }
58
59 1;