add charge method to FS::cust_main
one-off packages default to disabled
billing payname defaults to first and last, not "Accounts Payable"
use FS::cust_bill_pay;
use FS::prepay_credit;
use FS::queue;
use FS::cust_bill_pay;
use FS::prepay_credit;
use FS::queue;
+=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;
+
+}
+
-$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 $
if ($opt_p) {
$cust_main->apply_payments;
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',
);
}
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"
-$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 $
use strict;
use vars qw( $days_to_pay $cust_main $cust_pkg
use strict;
use vars qw( $days_to_pay $cust_main $cust_pkg
-getopts('ed:qplsc', \%opt);
+getopts('ed:qplscbyoi', \%opt);
my $user = shift or die &usage;
adminsuidsetup $user;
my $user = shift or die &usage;
adminsuidsetup $user;
+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++;
my ($sec,$min,$hour,$mday,$mon,$year) =
(localtime($now) )[0,1,2,3,4,5];
$mon++;
$cust_main->balance_date(time-$opt{d} * 86400);
}
$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 } ) ) {
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;
if ($opt{s}) {
print "\n\tSuspending pkgnum " . $cust_pkg->pkgnum unless $opt{q};
$cust_pkg->suspend;
print "\n\tCancelling pkgnum " . $cust_pkg->pkgnum unless $opt{q};
$cust_pkg->cancel;
}
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};
}
print "\n" unless $opt{q};
- 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
Selection options (at least one selection option is required):
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.
- -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.
- -l: Add a charge of the given amount to the relevant customers.
+ -b: Bill customers (create invoices)
+ -y: Apply unapplied payments and credits
+ -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
user: From the mapsecrets file - see config.html from the base documentation
Original disable-overdue version by mw/kwh: Mark W.? and Kristian Hoffmann ?
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
+
-#<!-- $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
use vars qw( $cgi $custnum $action $cust_main $p1 @agents $agentnum
$last $first $ss $company $address1 $address2 $city $zip
%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="">!,
%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">!,
'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)) {
'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)) {
-<!-- $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 $ -->
my $old_part_pkg =
qsearchs('part_pkg', { 'pkgpart' => $cgi->param('clone') } );
$part_pkg ||= $old_part_pkg->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 {
} elsif ( $query && $query =~ /^(\d+)$/ ) {
$part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1});
} else {