1 package FS::part_pkg::subscription;
4 use vars qw(@ISA %info);
5 use Time::Local qw(timelocal);
6 #use FS::Record qw(qsearch qsearchs);
7 use FS::part_pkg::flat;
9 @ISA = qw(FS::part_pkg::flat);
12 'name' => 'First partial month full charge, then flat-rate (selectable billing day)',
14 'setup_fee' => { 'name' => 'Setup fee for this package',
17 'recur_fee' => { 'name' => 'Recurring fee for this package',
20 'cutoff_day' => { 'name' => 'billing day',
23 'seconds' => { 'name' => 'Time limit for this package',
26 'upbytes' => { 'name' => 'Upload limit for this package',
29 'downbytes' => { 'name' => 'Download limit for this package',
32 'totalbytes' => { 'name' => 'Transfer limit for this package',
35 'recharge_amount' => { 'name' => 'Cost of recharge for this package',
38 'recharge_seconds' => { 'name' => 'Recharge time for this package',
41 'recharge_upbytes' => { 'name' => 'Recharge upload for this package',
44 'recharge_downbytes' => { 'name' => 'Recharge download for this package', 'default' => '',
46 'recharge_totalbytes' => { 'name' => 'Recharge transfer for this package', 'default' => '',
48 #it would be better if this had to be turned on, its confusing
49 'externalid' => { 'name' => 'Optional External ID',
53 'fieldorder' => [ 'setup_fee', 'recur_fee', 'cutoff_day', 'seconds',
54 'upbytes', 'downbytes', 'totalbytes',
55 'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
56 'recharge_downbytes', 'recharge_totalbytes',
58 'fieldorder' => [ 'setup_fee', 'recur_fee','cutoff_day', 'seconds',
59 'upbytes', 'downbytes', 'totalbytes',
60 'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
61 'recharge_downbytes', 'recharge_totalbytes',
68 my($self, $cust_pkg, $sdate ) = @_;
69 my $cutoff_day = $self->option('cutoff_day', 1) || 1;
71 my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($mnow) )[0,1,2,3,4,5];
73 if ( $mday < $cutoff_day ) {
74 if ($mon==0) {$mon=11;$year--;}
78 $$sdate = timelocal(0,0,0,$cutoff_day,$mon,$year);
80 $self->reset_usage($cust_pkg);
82 $self->option('recur_fee');