[freeside] Here Goes Nothing

ivan ivan at 420.am
Tue Apr 17 14:26:11 PDT 2001


On Tue, Apr 17, 2001 at 02:17:12PM -0700, Kristian Hoffmann wrote:
> Here is the disable-overdue script Mark and I wrote a while back.  It
> works fine as far as I can remember.

No, it doesn't.

>   if($cust_main->balance_date(time - $opt{d} * 86400) > 0 &&

There's no balance_date method in cust_main.pm.

>  The "-s" option enables the call to
> suspend overdue packages.  If you leave it off you can do a dry run to
> make sure it does what you expect.  The script disables every package
> belonging to a customer who has any invoices that are n days
> overdue.  It's a really easy way to piss off customers that didn't pay $1
> for an extra email account and got their 20 dialup/web hosting accounts
> disabled for it. :)
> 
> -Kristian
> 
> 
> On Tue, 17 Apr 2001 rdailey at colusanet.com wrote:
> 
> > Thank you for your help.  I'm afraid, however, that I am not a perl 
> > programmer.  Is there any references that I should look to (tutorials,etc.) 
> > in order to implement this?  I am familiar with CRON, already, that's not 
> > the problem.  I guess I'll have to learn perl.  Or do you know of any perl 
> > programmers who would be able to write these scripts?
> > 
> > 
> > > > I have Freeside set up and all functionality is working. (i.e. Credit
> > > > Cards, etc.), however I want to set up Freeside to do the following, to
> > > > mirror our existing billing cycle:
> > > >
> > > > All setups are considered to be on the first of the month. (As opposed to
> > > > the current day, as it does now.)
> > > >
> > > > On the tenth day of every month, accounts with a non-zero balance have
> > > > their packages suspended.
> > >
> > >man cron
> > >man FS::cust_main (see the balance and all_pkgs methods)
> > >man FS::cust_pkg (see the suspend method)
> > >
> > > > Also, on the tenth day, invoices are sent out for the next month (i.e. on
> > > > 4/10/01 invoices are sent out for 5/1/01 to 6/1/01).  No credit cards are
> > > > charged at this time.
> > >
> > >man cron
> > >man FS::cust_main (see the payby field, the `time' option of the bill
> > >method and the `invoice_time' option of the collect method)
> > >
> > > > On the first day of every month, all credit cards are charged for that
> > > > month: (i.e. on 4/1/01 cards are charged for 4/1/01 to 5/1/01)
> > > >
> > > > Any help would be GREATLY appreciated.
> > >
> > >meow
> > >_ivan
> > 
> > 
> > Rick Dailey
> > ColusaNET
> > <mailto:%2F%2Frdailey at colusanet.com>rdailey at colusanet.com
> > 
> > 

> #!/usr/bin/perl
> 
> use strict;
> use vars qw( $days_to_pay $cust_main $cust_pkg 
>              $cust_svc $svc_acct );
> use Getopt::Std;
> use FS::cust_main;
> use FS::cust_pkg;
> use FS::cust_svc;
> use FS::svc_acct;
> use FS::Record qw(qsearch qsearchs);
> use FS::UID qw(adminsuidsetup swapuid);
> 
> &untaint_argv;
> my %opt;
> getopts('sd:', \%opt);
> my $user = shift or die &usage;
> 
> adminsuidsetup $user;
> 
> foreach $cust_main ( qsearch('cust_main',{} ) ) {
>   if($cust_main->balance_date(time - $opt{d} * 86400) > 0 &&
>      qsearchs( 'cust_pkg', { 'custnum' => $cust_main->custnum,
>                              'susp' => "", 'cancel' => "" } )
>     ) { 
>     print $cust_main->custnum, "\t",
>           $cust_main->last, "\t", $cust_main->first, "\t",
>           $cust_main->balance_date(time-$opt{d} * 86400);
>     foreach $cust_pkg ( qsearch( 'cust_pkg', 
>                                  { 'custnum' => $cust_main->custnum } ) ) {
>       if ($opt{s}) {
>                  print "\n\tSuspending pkgnum cust_pkg";
>                  $cust_pkg->suspend; }
>     }
>   print "\n";
>   }
> }
> 
> sub untaint_argv {
>   foreach $_ ( $[ .. $#ARGV ) { 
>     $ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
>     $ARGV[$_]=$1;
>   }
> }
> 
> sub usage {
>   die "Usage:\n\n  disable-overdue -s -d days user\n";
> }
> 
> 
> =head1 NAME
> 
> disable-overdue - Designed to disable accounts n days overdue.
> 
> =head1 SYNOPSIS
> 
>   disable-overdue -s -d days user
> 
> =head1 DESCRIPTION
> 
> Disables overdue accounts.  Sets svc_acct.active = 0 for all services listed
> 	under cust_svc for the overdue cust_pkgs. 
> 
>   -s:	Suspend overdue accounts instead of just listing them.
> 
>   -d:	Number of days allowed to be overdue before being disabled.
> 	Requires an integer argument.
> 
>   user: From the mapsecrets file - see config.html from the base documentation
> 	but be careful.
> 
> =head1 VERSION
> 
> $Id: disable-overdue,v 1.0.1 2000/03/03 11:58:06 mw/kwh $
> 
> =cut
> 


-- 
meow
_ivan



More information about the freeside-users mailing list