9762dd3cacebb891c3b80002b4bf559ad347c1c5
[freeside.git] / htdocs / docs / man / cust_bill.txt
1 NAME
2     FS::cust_bill - Object methods for cust_bill records
3
4 SYNOPSIS
5       use FS::cust_bill;
6
7       $record = create FS::cust_bill \%hash;
8       $record = create FS::cust_bill { 'column' => 'value' };
9
10       $error = $record->insert;
11
12       $error = $new_record->replace($old_record);
13
14       $error = $record->delete;
15
16       $error = $record->check;
17
18       ( $total_previous_balance, @previous_cust_bill ) = $record->previous;
19
20       @cust_bill_pkg_objects = $cust_bill->cust_bill_pkg;
21
22       ( $total_previous_credits, @previous_cust_credit ) = $record->cust_credit;
23
24       @cust_pay_objects = $cust_bill->cust_pay;
25
26       @lines = $cust_bill->print_text;
27       @lines = $cust_bill->print_text $time;
28
29 DESCRIPTION
30     An FS::cust_bill object represents an invoice. FS::cust_bill
31     inherits from FS::Record. The following fields are currently
32     supported:
33
34     invnum - primary key (assigned automatically for new invoices)
35     custnum - customer (see the FS::cust_main manpage)
36     _date - specified as a UNIX timestamp; see the section on "time" in the perlfunc manpage.  Also see
37     the Time::Local manpage and the Date::Parse manpage for conversion functions.
38     charged - amount of this invoice
39     owed - amount still outstanding on this invoice, which is charged minus
40     all payments (see the FS::cust_pay manpage).
41     printed - how many times this invoice has been printed automatically
42     (see the section on "collect" in the FS::cust_main manpage).
43 METHODS
44     create HASHREF
45         Creates a new invoice. To add the invoice to the database,
46         see the section on "insert". Invoices are normally created
47         by calling the bill method of a customer object (see the
48         FS::cust_main manpage).
49
50     insert
51         Adds this invoice to the database ("Posts" the invoice). If
52         there is an error, returns the error, otherwise returns
53         false.
54
55         When adding new invoices, owed must be charged (or null, in
56         which case it is automatically set to charged).
57
58     delete
59         Currently unimplemented. I don't remove invoices because
60         there would then be no record you ever posted this invoice
61         (which is bad, no?)
62
63     replace OLD_RECORD
64         Replaces the OLD_RECORD with this one in the database. If
65         there is an error, returns the error, otherwise returns
66         false.
67
68         Only owed and printed may be changed. Owed is normally
69         updated by creating and inserting a payment (see the
70         FS::cust_pay manpage). Printed is normally updated by
71         calling the collect method of a customer object (see the
72         FS::cust_main manpage).
73
74     check
75         Checks all fields to make sure this is a valid invoice. If
76         there is an error, returns the error, otherwise returns
77         false. Called by the insert and replace methods.
78
79     previous
80         Returns a list consisting of the total previous balance for
81         this customer, followed by the previous outstanding invoices
82         (as FS::cust_bill objects also).
83
84     cust_bill_pkg
85         Returns the line items (see the FS::cust_bill_pkg manpage)
86         for this invoice.
87
88     cust_credit
89         Returns a list consisting of the total previous credited
90         (see the FS::cust_credit manpage) for this customer,
91         followed by the previous outstanding credits
92         (FS::cust_credit objects).
93
94     cust_pay
95         Returns all payments (see the FS::cust_pay manpage) for this
96         invoice.
97
98     print_text [TIME];
99         Returns an ASCII invoice, as a list of lines.
100
101         TIME an optional value used to control the printing of
102         overdue messages. The default is now. It isn't the date of
103         the invoice; that's the `_date' field. It is specified as a
104         UNIX timestamp; see the section on "time" in the perlfunc
105         manpage. Also see the Time::Local manpage and the
106         Date::Parse manpage for conversion functions.
107
108 BUGS
109     The delete method.
110
111     It doesn't properly override FS::Record yet.
112
113     print_text formatting (and some logic :/) is in source as a
114     format declaration, which needs to be slurped in from a file.
115     the fork is rather kludgy as well. It could be cleaned with
116     swrite from man perlform, and the picture could be put in a
117     /var/spool/freeside/conf file. Also number of lines ($=).
118
119     missing print_ps for a nice postscript copy (maybe HylaFAX-
120     cover-page-style or something similar so the look can be
121     completely customized?)
122
123     There is an off-by-one error in print_text which causes a visual
124     error: "Page 1 of 2" printed on some single-page invoices?
125
126 SEE ALSO
127     the FS::Record manpage, the FS::cust_main manpage, the
128     FS::cust_pay manpage, the FS::cust_bill_pkg manpage, the
129     FS::cust_credit manpage, schema.html from the base
130     documentation.
131
132 HISTORY
133     ivan@voicenet.com 97-jul-1
134
135     small fix for new API ivan@sisd.com 98-mar-14
136
137     charges can be negative ivan@sisd.com 98-jul-13
138
139     pod, ingegrate with FS::Invoice ivan@sisd.com 98-sep-20
140