From: ivan Date: Sun, 10 Feb 2002 19:58:43 +0000 (+0000) Subject: update billing documentation for the new world of invoice events X-Git-Tag: freeside_1_4_0pre11~77 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=7e3eb82f87c371785544b706b7347c7edde2b593 update billing documentation for the new world of invoice events added freeside-daily replacing freeside-bill for the new world of invoice events --- diff --git a/FS/MANIFEST b/FS/MANIFEST index 0a9205c7f..85c09b465 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -4,6 +4,7 @@ MANIFEST.SKIP Makefile.PL README bin/freeside-bill +bin/freeside-daily bin/freeside-email bin/freeside-queued bin/freeside-apply-credits diff --git a/FS/bin/freeside-bill b/FS/bin/freeside-bill index 6ef344a50..49ad4a768 100755 --- a/FS/bin/freeside-bill +++ b/FS/bin/freeside-bill @@ -97,6 +97,8 @@ freeside-bill - Command line (crontab, script) interface to customer billing. =head1 DESCRIPTION +This script is deprecated in 1.4.0. You should use freeside-daily instead. + Bills customers. Searches for customers who are due for billing and calls the bill and collect methods of a cust_main object. See L. @@ -116,15 +118,11 @@ user: From the mapsecrets file - see config.html from the base documentation custnum: if one or more customer numbers are specified, only bills those customers. Otherwise, bills all customers. -=head1 VERSION - -$Id: freeside-bill,v 1.12 2002-02-10 01:48:00 ivan Exp $ - =head1 BUGS =head1 SEE ALSO -L, config.html from the base documentation +L, L, config.html from the base documentation =cut diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily new file mode 100755 index 000000000..8d839cb21 --- /dev/null +++ b/FS/bin/freeside-daily @@ -0,0 +1,90 @@ +#!/usr/bin/perl -w + +use strict; +use Fcntl qw(:flock); +use Date::Parse; +use Getopt::Std; +use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearch qsearchs); +use FS::cust_main; + +&untaint_argv; #what it sounds like (eww) +use vars qw($opt_d); +getopts("d:"); +my $user = shift or die &usage; + +adminsuidsetup $user; + +my @cust_main = @ARGV + ? map { qsearchs('cust_main', { custnum => $_ } ) } @ARGV + : qsearch('cust_main', {} ) +; + +#we're at now now (and later). +my($time)= $opt_d ? str2time($opt_d) : $^T; + +my($cust_main,%saw); +foreach $cust_main ( @cust_main ) { + + my $error; + + $error = $cust_main->bill( 'time' => $time ); + warn "Error billing, custnum ". $cust_main->custnum. ": $error" if $error; + + $cust_main->apply_payments; + $cust_main->apply_credits; + + $error=$cust_main->collect( 'invoice_time' => $time ); + warn "Error collecting, custnum". $cust_main->custnum. ": $error" if $error; + +} + +# subroutines + +sub untaint_argv { + foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV + #$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\""; + # Date::Parse + $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\""; + $ARGV[$_]=$1; + } +} + +sub usage { + die "Usage:\n\n freeside-daily [ -d 'date' ] user [ custnum custnum ... ]\n"; +} + +=head1 NAME + +freeside-daily - Run daily billing and invoice collection events. + +=head1 SYNOPSIS + + freeside-daily [ -d 'date' ] user [ custnum custnum ... ] + +=head1 DESCRIPTION + +Bills customers and runs invoice collection events. Should be run from +crontab daily. + +This script replaces freeside-bill from 1.3.1. + +Bills customers. Searches for customers who are due for billing and calls +the bill and collect methods of a cust_main object. See L. + + -d: Pretend it's 'date'. Date is in any format Date::Parse is happy with, + but be careful. + +user: From the mapsecrets file - see config.html from the base documentation + +custnum: if one or more customer numbers are specified, only bills those +customers. Otherwise, bills all customers. + +=head1 BUGS + +=head1 SEE ALSO + +L, config.html from the base documentation + +=cut + diff --git a/httemplate/docs/billing.html b/httemplate/docs/billing.html index dcb90208a..de59fc60a 100644 --- a/httemplate/docs/billing.html +++ b/httemplate/docs/billing.html @@ -4,36 +4,26 @@

Billing

    -
  • To enable billing, you must create an invoice_template configuration file. An example file is available in the conf/ directory of the distribution. You also need to create an lpr configuration file to enable postal invoices. -
      -
    • Optional: Invoice template customization -
        -
      • See the Text::Template documentation for details on the substitution language. -
      • You must call the invoice_lines() function at least once - pass it a number of lines, and it returns a list of array references, each of two elements: a service description column, and a price column. -
      • In addition, the following variables are available: -
          -
        • $invnum - invoice number -
        • $date - as a UNIX timestamp (see Date::Format for conversion functions). -
        • $page - current page -
        • $total_pages - total pages -
        • @address - A six-element array containing the customer name, company, and address. -
        • $overdue - true if this invoice is overdue -
        -
      -
  • You can bill individual customers by clicking on the Bill now link on the main customer view. -
  • The freeside-bill script can be run daily to bill all customers. (link to manpage!) Usage:
    freeside-bill [ -c [ -p ] [ -a ] [ -i ] ] [ -d date ] user
    +
  • The freeside-daily script should be run daily to bill customers and run invoice collection events. +
  • Real-time credit card processing: Install the Business::OnlinePayment module for your processor. Configure the business-onlinepayment configuration option. Disable the default Batch card invoice event and add one for Business::OnlinePayment. +
  • Optional: Invoice template customization
      -
    • -c: Turn on collecting (you probably want this). -
    • -p: Apply unapplied payments and credits before collecting (you probably want this too) -
    • -a: Call collect even if there isn't a new invoice (probably a bad idea for daily use) -
    • -i: Real-time billing (as opposed to bacth billing). Only relevant for credit cards. -
    • -d: Pretend it is date (parsed by Date::Parse) -
    • user: as setup with freeside-adduser +
    • See the Text::Template documentation for details on the substitution language. +
    • You must call the invoice_lines() function at least once - pass it a number of lines, and it returns a list of array references, each of two elements: a service description column, and a price column. +
    • In addition, the following variables are available: +
        +
      • $invnum - invoice number +
      • $date - as a UNIX timestamp (see Date::Format for conversion functions). +
      • $page - current page +
      • $total_pages - total pages +
      • @address - A six-element array containing the customer name, company, and address. +
      • $overdue - true if this invoice is overdue +
    -

    Batch credit card processing +
  • Batch credit card processing
      -
    • After this script is run, a credit card batch will be in the cust_pay_batch table. Export this table to your credit card batching. +
    • After freeside-daily is run, a credit card batch will be in the cust_pay_batch table. Export this table to your credit card batching.
    • When your batch completes, erase the cust_pay_batch records in that batch and add any necessary paymants to the cust_pay table. Example code to add payments is:
      use FS::cust_pay;
       
      @@ -55,16 +45,8 @@ if ( $error ) {
       
       # end loop
       
      -All fields except paybatch are contained in the cust_pay_batch table. You can use paybatch field to track particular batches and/or particular transactions within a batch.

      -
    • The freeside-print-batch script can print or email pending credit card batches for manual entry. Usage: freeside-print-batch [-v] [-p] [-e] [-a] [-d] user -
        -
      • -v: Verbose - Prints records to STDOUT. -
      • -p: Print to printer lpr as found in the conf directory. -
      • -e: Email output to user found in the Conf email file. -
      • -a: Automatically pays all records in cust_pay_batch. Use -d with this option usually. -
      • -d: Delete - Pays account and deletes record from cust_pay_batch. -
      -
    -
  • The freeside-overdue script can list, add postal invoicing, suspend or cancel overdue and/or expired accounts (link to manpage!). +All fields except paybatch are contained in the cust_pay_batch table. You can use paybatch field to track particular batches and/or particular transactions within a batch. +
+
  • The freeside-print-batch script can print or email pending credit card batches for manual entry. diff --git a/httemplate/docs/upgrade8.html b/httemplate/docs/upgrade8.html index 2c7008a6c..61d956ce8 100644 --- a/httemplate/docs/upgrade8.html +++ b/httemplate/docs/upgrade8.html @@ -303,5 +303,6 @@ ALTER TABLE cust_refund DROP COLUMN crednum; (ownded by the freeside user).
  • freeside-queued was installed with the Perl modules. Start it now and ensure that is run upon system startup.
  • Set appropriate invoice events for your site. At the very least, you'll want to set some invoice events "After 0 days": a BILL invoice event to print invoices, a CARD invoice event to batch or run cards real-time, and a COMP invoice event to "pay" complimentary customers. If you were using the -i option to freeside-bill it should be removed. +
  • Use freeside-daily instead of freeside-bill. diff --git a/httemplate/edit/process/part_bill_event.cgi b/httemplate/edit/process/part_bill_event.cgi index 1716c71b9..4049ade80 100755 --- a/httemplate/edit/process/part_bill_event.cgi +++ b/httemplate/edit/process/part_bill_event.cgi @@ -12,7 +12,7 @@ if ( ! $cgi->param('plan_weight_eventcode') ) { $error = "Must select an action"; } else { - $cgi->param('plan_weight_eventcode') =~ /^(\w+):(\d+):(.*)$/ + $cgi->param('plan_weight_eventcode') =~ /^([\w\-]+):(\d+):(.*)$/ or die "illegal plan_weight_eventcode:". $cgi->param('plan_weight_eventcode'); $cgi->param('plan', $1);