6 use FS::UID qw( adminsuidsetup );
7 use FS::Record qw( qsearchs );
11 adminsuidsetup shift or die 'Usage: cust_main-email_and_rebill username\n';
16 my $sep1 = str2time('9/1/2017');
17 my $aug15 = str2time('8/15/2017') + 1802;
19 my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
20 or die "unknown msg_template $msgnum\n";
27 my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum'=>$pkgnum } )
28 or die "pkgnum $pkgnum not found\n";
30 #reset its next bill date back to sep 1
31 $cust_pkg->set('bill', $sep1);
33 warn "updating cust_pkg $pkgnum bill to $sep1\n";
34 my $error = $cust_pkg->replace;
37 warn "DRY RUN: would update cust_pkg $pkgnum bill to $sep1\n";
41 my $cust_main = $cust_pkg->cust_main;
42 my $custnum = $cust_main->custnum;
44 #send the custoemr a notice
46 warn "emailing msg_template $msgnum to customer $custnum\n";
47 $msg_template->send( 'cust_main' => $cust_main,
48 'object' => $cust_main,
51 warn "DRY RUN: emailing msg_template $msgnum to customer $custnum\n";
56 warn "billing customer $custnum for package $pkgnum as of $sep1\n";
57 $cust_main->bill( 'time' => $sep1,
58 'invoice_time' => $aug15,
59 'pkg_list' => [ $cust_pkg ],
62 warn "DRY RUN: billing customer $custnum for package $pkgnum as of $sep1\n";
65 #something about removing their pending batch payment??
66 #hmm, there doesn't appear to be anything in a batch
67 #dating the invoices aug 15th will ensure payments for them are batched
69 #events will take care of the rest...