fix sorting of NULL companies differently than empty companies
[freeside.git] / httemplate / docs / billing.html
1 <head>
2   <title>Billing</title>
3 </head>
4 <body>
5   <h1>Billing</h1>
6   <ul>
7     <li>You can bill individual customers by clicking on the <i>Bill now</i> link on the main customer view.
8     <li>The <a href="man/bin/freeside-daily.html"><b>freeside-daily</b></a> script should be run daily to bill customers and run invoice collection events.
9     <li>Real-time credit card processing: Install the <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> module for your processor.  Configure the <a href="../config/config-view.cgi#business-onlinepayment">business-onlinepayment</a> configuration option.  Disable the default <b>Batch card</b> <a href="../browse/part_bill_event.cgi">invoice event</a> and add one for Business::OnlinePayment.
10     <li>Optional: Credit card expiration alerts: Customize <a href="../config/config.cgi#alerter_template">alerter_template</a> configuration option and run <a href="man/bin/freeside-expiration-alerter.html">freeside-expiration-alerter</a> daily.
11     <li>Credit card decline alerts: Customize the <a href="../config/config.cgi#declinetemplate">declinetemplate</a> configuration option and set the <a href="../config/config.cgi#emaildecline">emaildecline</a> configuration option.
12     <li>Optional: Invoice template customization
13       <ul>
14         <li>See the <a href="http://search.cpan.org/~mjd/Text-Template/lib/Text/Template.pm">Text::Template</a> documentation for details on the substitution language.
15         <li>You <b>must</b> 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.  Alternatively, call invoice_lines() with no arguments, and pagination will be disabled - all invoice line items will print on one page, with no padding (recommended for email invoices).
16         <li>In addition, the following variables are available:
17           <ul>
18             <li>$invnum - invoice number
19             <li>$date - as a UNIX timestamp (see <a href="http://search.cpan.org/doc/GBARR/TimeDate-1.09/lib/Date/Format.pm">Date::Format</a> for conversion functions).
20             <li>$page - current page
21             <li>$total_pages - total pages
22             <li>@address - A six-element array containing the customer name, company, and address.
23 <!--            <li>$overdue - true if this invoice is overdue -->
24           </ul>
25       </ul>
26     <li>Batch credit card processing
27       <ul>
28         <li>After <a href="man/bin/freeside-daily.html"><b>freeside-daily</b></a> is run, a credit card batch will be in the <a href="schema.html#cust_pay_batch">cust_pay_batch</a> table.  Export this table to your credit card batching.
29         <li>When your batch completes, erase the cust_pay_batch records in that batch and add any necessary paymants to the <a href="schema.html#cust_pay">cust_pay</a> table.  Example code to add payments is:
30         <pre>use FS::cust_pay;
31
32 # loop over all records in batch
33
34 my $payment=create FS::cust_pay (
35   'invnum' => $invnum,
36   'paid' => $paid,
37   '_date' => $_date,
38   'payby' => $payby,
39   'payinfo' => $payinfo,
40   'paybatch' => $paybatch,
41 );
42
43 my $error=$payment->insert;
44 if ( $error ) {
45   #process error
46 }
47
48 # end loop
49 </pre>
50 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.
51     </ul>
52 <!--      <li>The <a href="man/bin/freeside-print-batch.html"><b>freeside-print-batch</b></a> script can print or email pending credit card batches for manual entry. -->
53   </ul>
54 </body>