summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2001-12-28 14:40:35 +0000
committerivan <ivan>2001-12-28 14:40:35 +0000
commit5e25b996982d42eb2587ec54db0d5b39508aa730 (patch)
tree04e409d5cf14e01161ccee90eef8e31662836492
parentcf16b23820da69e3c8d0156ae27e21c635bf1ec5 (diff)
add more options to freeside-overdue
add charge method to FS::cust_main one-off packages default to disabled billing payname defaults to first and last, not "Accounts Payable"
-rw-r--r--FS/FS/cust_main.pm26
-rwxr-xr-xFS/bin/freeside-bill6
-rwxr-xr-xFS/bin/freeside-overdue85
-rwxr-xr-xhttemplate/edit/cust_main.cgi6
-rwxr-xr-xhttemplate/edit/part_pkg.cgi3
5 files changed, 95 insertions, 31 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 3995e6561..6c18f93a1 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -28,6 +28,7 @@ use FS::cust_credit_bill;
use FS::cust_bill_pay;
use FS::prepay_credit;
use FS::queue;
+use FS::part_pkg;
@ISA = qw( FS::Record );
@@ -1775,6 +1776,29 @@ sub credit {
$cust_credit->insert;
}
+=item charge AMOUNT PKG COMMENT
+
+Creates a one-time charge for this customer. If there is an error, returns
+the error, otherwise returns false.
+
+=cut
+
+sub charge {
+ my ( $self, $amount, $pkg, $comment ) = @_;
+
+ my $part_pkg = new FS::part_pkg ( {
+ 'pkg' => $pkg || 'One-time charge',
+ 'comment' => $comment,
+ 'setup' => $amount,
+ 'freq' => 0,
+ 'recur' => '0',
+ 'disabled' => 'Y',
+ } );
+
+ $part_pkg->insert;
+
+}
+
=back
=head1 SUBROUTINES
@@ -1916,7 +1940,7 @@ sub append_fuzzyfiles {
=head1 VERSION
-$Id: cust_main.pm,v 1.51 2001-12-26 11:17:49 ivan Exp $
+$Id: cust_main.pm,v 1.52 2001-12-28 14:40:35 ivan Exp $
=head1 BUGS
diff --git a/FS/bin/freeside-bill b/FS/bin/freeside-bill
index 7898936c5..49ec43c82 100755
--- a/FS/bin/freeside-bill
+++ b/FS/bin/freeside-bill
@@ -59,14 +59,14 @@ foreach $cust_main (
if ($opt_p) {
$cust_main->apply_payments;
- $error=$cust_main->apply_credits;
+ $cust_main->apply_credits;
}
if ($opt_c) {
$error=$cust_main->collect('invoice_time'=>$time,
'batch_card' => $opt_i ? 'no' : 'yes',
);
- warn "Error collecting from customer #" . $cust_main->gcustnum. ":$error"
+ warn "Error collecting from customer #" . $cust_main->custnum. ":$error"
if $error;
#sleep 1;
@@ -123,7 +123,7 @@ customers. Otherwise, bills all customers.
=head1 VERSION
-$Id: freeside-bill,v 1.10 2001-11-05 14:04:56 ivan Exp $
+$Id: freeside-bill,v 1.11 2001-12-28 14:40:35 ivan Exp $
=head1 BUGS
diff --git a/FS/bin/freeside-overdue b/FS/bin/freeside-overdue
index 0c62b99c1..8f7f872c8 100755
--- a/FS/bin/freeside-overdue
+++ b/FS/bin/freeside-overdue
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
use strict;
use vars qw( $days_to_pay $cust_main $cust_pkg
@@ -13,12 +13,12 @@ use FS::UID qw(adminsuidsetup);
&untaint_argv;
my %opt;
-getopts('ed:qplsc', \%opt);
+getopts('ed:qplscbyoi', \%opt);
my $user = shift or die &usage;
adminsuidsetup $user;
-my $now = time;
+my $now = time; #eventually take a time option like freeside-bill
my ($sec,$min,$hour,$mday,$mon,$year) =
(localtime($now) )[0,1,2,3,4,5];
$mon++;
@@ -48,21 +48,23 @@ foreach $cust_main ( qsearch('cust_main',{} ) ) {
$cust_main->balance_date(time-$opt{d} * 86400);
}
-# if ( $opt{l} ) {
-# print "\n\tCharging late fee of \$$opt{l}" unless $opt{q};
-#
-# }
+ if ( $opt{p} && ! grep { $_ eq 'POST' } $cust_main->invoicing_list ) {
+ print "\n\tAdding postal invoicing" unless $opt{q};
+ my @invoicing_list = $cust_main->invoicing_list;
+ push @invoicing_list, 'POST';
+ $cust_main->invoicing_list(\@invoicing_list);
+ }
+
+ if ( $opt{l} ) {
+ print "\n\tCharging late fee of \$$opt{l}" unless $opt{q};
+ my $error = $cust_main->charge($opt{l}, 'Late fee');
+ # comment or plandata with info so we don't redo the same late fee every
+ # day
+ }
foreach $cust_pkg ( qsearch( 'cust_pkg',
{ 'custnum' => $cust_main->custnum } ) ) {
- if ( $opt{p} && ! grep { $_ eq 'POST' } $cust_main->invoicing_list ) {
- print "\n\tAdding postal invoicing" unless $opt{q};
- my @invoicing_list = $cust_main->invoicing_list;
- push @invoicing_list, 'POST';
- $cust_main->invoicing_list(\@invoicing_list);
- }
-
if ($opt{s}) {
print "\n\tSuspending pkgnum " . $cust_pkg->pkgnum unless $opt{q};
$cust_pkg->suspend;
@@ -72,7 +74,29 @@ foreach $cust_main ( qsearch('cust_main',{} ) ) {
print "\n\tCancelling pkgnum " . $cust_pkg->pkgnum unless $opt{q};
$cust_pkg->cancel;
}
+
+ }
+
+ if ( $opt{b} ) {
+ print "\n\tBilling" unless $opt{q};
+ my $error = $cust_main->bill('time'=>$now);
+ warn "Error billing, customer #" . $cust_main->custnum .
+ ":" . $error if $error;
+ }
+ if ( $opt{y} ) {
+ print "\n\tApplying outstanding payments and credits" unless $opt{q};
+ $cust_main->apply_payments;
+ $cust_main->apply_credits;
+ }
+
+ if ( $opt{o} ) {
+ print "\n\tCollecting" unless $opt{q};
+ my $error = $cust_main->collect( 'invoice_time'=>$now,
+ 'batch_card' => $opt{i} ? 'no' : 'yes',
+ );
+ warn "Error collecting from customer #" . $cust_main->custnum. ":$error"
+ if $error;
}
print "\n" unless $opt{q};
@@ -99,7 +123,7 @@ freeside-overdue - Perform actions on overdue and/or expired accounts.
=head1 SYNOPSIS
- freeside-overdue [ -e ] [ -d days ] [ -q ] [ -p ] [ -l amount ] [ -s ] [ -c ] user
+ freeside-overdue [ -e ] [ -d days ] [ -q ] [ -p ] [ -l amount ] [ -s ] [ -c ] [ -b ] [ -y ] [ -o [ -i ] ] user
=head1 DESCRIPTION
@@ -107,22 +131,31 @@ Performs actions on overdue and/or expired accounts.
Selection options (at least one selection option is required):
- -d: Customers with a balance due on invoices older than the supplied number
- of days. Requires an integer argument.
+ -d: Customers with a balance due on invoices older than the supplied number
+ of days. Requires an integer argument.
- -e: Customers with a billing expiration date in the past.
+ -e: Customers with a billing expiration date in the past.
Action options:
- -q: Be quiet (by default, selected accounts are printed).
+ -q: Be quiet (by default, selected accounts are printed).
+
+ -p: Add postal invoicing to the relevant customers.
+
+ -l: Add a charge of the given amount to the relevant customers.
+
+ -s: Suspend accounts.
- -p: Add postal invoicing to the relevant customers.
+ -c: Cancel accounts.
- -l: Add a charge of the given amount to the relevant customers.
+ -b: Bill customers (create invoices)
- -s: Suspend accounts.
+ -y: Apply unapplied payments and credits
- -c: Cancel accounts.
+ -o: Collect from customers (charge cards, print invoices)
+
+ -i: real-time billing (as opposed to batch billing). only relevant
+ for credit cards.
user: From the mapsecrets file - see config.html from the base documentation
@@ -146,6 +179,12 @@ Example crontab entries:
Original disable-overdue version by mw/kwh: Mark W.? and Kristian Hoffmann ?
+Ivan seems to be turning it into the "do-everything" CLI.
+
+=head1 BUGS
+
+Hell now that this is the do-everything CLI it should have --longoptions
+
=cut
1;
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index 9588dcb3a..d3251c2b9 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -1,5 +1,5 @@
<%
-#<!-- $Id: cust_main.cgi,v 1.17 2001-12-27 09:26:14 ivan Exp $ -->
+#<!-- $Id: cust_main.cgi,v 1.18 2001-12-28 14:40:35 ivan Exp $ -->
use vars qw( $cgi $custnum $action $cust_main $p1 @agents $agentnum
$last $first $ss $company $address1 $address2 $city $zip
@@ -364,12 +364,12 @@ print "<TR><TD>Billing type</TD></TR>",
%payby = (
'CARD' => qq!Credit card<BR>${r}<INPUT TYPE="text" NAME="CARD_payinfo" VALUE="" MAXLENGTH=19><BR>${r}Exp !. expselect("CARD"). qq!<BR>${r}Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="">!,
- 'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE=""><BR>${r}Exp !. expselect("BILL", "12-2037"). qq!<BR>${r}Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="Accounts Payable">!,
+ 'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE=""><BR>${r}Exp !. expselect("BILL", "12-2037"). qq!<BR>Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="">!,
'COMP' => qq!Complimentary<BR>${r}Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE=""><BR>${r}Exp !. expselect("COMP"),
);
%paybychecked = (
'CARD' => qq!Credit card<BR>${r}<INPUT TYPE="text" NAME="CARD_payinfo" VALUE="$payinfo" MAXLENGTH=19><BR>${r}Exp !. expselect("CARD", $cust_main->paydate). qq!<BR>${r}Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="$payname">!,
- 'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE="$payinfo"><BR>${r}Exp !. expselect("BILL", $cust_main->paydate). qq!<BR>${r}Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="$payname">!,
+ 'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE="$payinfo"><BR>${r}Exp !. expselect("BILL", $cust_main->paydate). qq!<BR>Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="$payname">!,
'COMP' => qq!Complimentary<BR>${r}Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE="$payinfo"><BR>${r}Exp !. expselect("COMP", $cust_main->paydate),
);
for (qw(CARD BILL COMP)) {
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index 1618c5a99..735f4f269 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -1,4 +1,4 @@
-<!-- $Id: part_pkg.cgi,v 1.7 2001-12-27 09:26:14 ivan Exp $ -->
+<!-- $Id: part_pkg.cgi,v 1.8 2001-12-28 14:40:35 ivan Exp $ -->
<%
@@ -26,6 +26,7 @@ if ( $cgi->param('clone') ) {
my $old_part_pkg =
qsearchs('part_pkg', { 'pkgpart' => $cgi->param('clone') } );
$part_pkg ||= $old_part_pkg->clone;
+ $part_pkg->disabled('Y');
} elsif ( $query && $query =~ /^(\d+)$/ ) {
$part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1});
} else {