blob: dea1319d6fe4192e53fd875b0e6f2cec452fee9c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/usr/bin/perl
use strict;
use warnings;
use Date::Parse;
use FS::UID qw( adminsuidsetup );
use FS::Record qw( qsearchs );
use FS::cust_pkg;
use FS::msg_template;
adminsuidsetup shift or die 'Usage: cust_main-email_and_rebill username\n';
my $DRY_RUN = 1;
my $msgnum = 17;
my $sep1 = str2time('9/1/2017');
my $aug15 = str2time('8/15/2017') + 1802;
my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
or die "unknown msg_template $msgnum\n";
while (<>) {
chomp;
my $pkgnum = $_;
#find the package
my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum'=>$pkgnum } )
or die "pkgnum $pkgnum not found\n";
#reset its next bill date back to sep 1
$cust_pkg->set('bill', $sep1);
unless ( $DRY_RUN ) {
warn "updating cust_pkg $pkgnum bill to $sep1\n";
my $error = $cust_pkg->replace;
die $error if $error;
} else {
warn "DRY RUN: would update cust_pkg $pkgnum bill to $sep1\n";
}
#customer
my $cust_main = $cust_pkg->cust_main;
my $custnum = $cust_main->custnum;
#send the custoemr a notice
unless ( $DRY_RUN ) {
warn "emailing msg_template $msgnum to customer $custnum\n";
$msg_template->send( 'cust_main' => $cust_main,
'object' => $cust_main,
);
} else {
warn "DRY RUN: emailing msg_template $msgnum to customer $custnum\n";
}
#bill the package
unless ( $DRY_RUN ) {
warn "billing customer $custnum for package $pkgnum as of $sep1\n";
$cust_main->bill( 'time' => $sep1,
'invoice_time' => $aug15,
'pkg_list' => [ $cust_pkg ],
);
} else {
warn "DRY RUN: billing customer $custnum for package $pkgnum as of $sep1\n";
}
#something about removing their pending batch payment??
#hmm, there doesn't appear to be anything in a batch
#dating the invoices aug 15th will ensure payments for them are batched
#events will take care of the rest...
}
1;
|