diff options
author | ivan <ivan> | 2001-12-13 09:17:52 +0000 |
---|---|---|
committer | ivan <ivan> | 2001-12-13 09:17:52 +0000 |
commit | 29acbc574cb1e29032c634e1f6ac63e92d14df3b (patch) | |
tree | b195958a859b180364d14217cf98fd5eb069025e /FS/bin/freeside-setinvoice | |
parent | aa0a7b4128ed5cf56684378c9cb6ebc1c3ec8c1a (diff) |
added util to set invoice destinations
Diffstat (limited to 'FS/bin/freeside-setinvoice')
-rw-r--r-- | FS/bin/freeside-setinvoice | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/FS/bin/freeside-setinvoice b/FS/bin/freeside-setinvoice new file mode 100644 index 000000000..aeaa0bb1b --- /dev/null +++ b/FS/bin/freeside-setinvoice @@ -0,0 +1,42 @@ +#!/usr/bin/perl + +use strict; +use FS::UID qw(adminsuidsetup); +use FS::Conf; +use FS::Record qw(qsearch); +use FS::cust_main; +use FS::svc_acct; + +&untaint_argv; #what it sounds like (eww) +my $user = shift or die &usage; + +adminsuidsetup $user; + +foreach my $cust_main ( + grep { ! scalar($_->invoicing_list) } + qsearch( 'cust_main', {} ) +) { + my @dest; + my @cust_pkg = $cust_main->ncancelled_pkgs; + foreach my $cust_pkg ( @cust_pkg ) { + foreach my $cust_svc ( $cust_pkg->cust_svc ) { + my $svc_acct = qsearchs( 'svc_acct', {} ); + push @dest, $svc_acct->svcnum if $svc_acct; + } + } + push @dest, 'POST' unless @dest; + $cust_main->invoicing_list(@dest); +} + +sub untaint_argv { + foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV + $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\""; + $ARGV[$_]=$1; + } +} + +sub usage { + die "Usage:\n\n freeside-setinvoice user\n"; +} + + |