2 FS::cust_main - Object methods for cust_main records
7 $record = create FS::cust_main \%hash;
8 $record = create FS::cust_main { 'column' => 'value' };
10 $error = $record->insert;
12 $error = $new_record->replace($old_record);
14 $error = $record->delete;
16 $error = $record->check;
18 @cust_pkg = $record->all_pkgs;
20 @cust_pkg = $record->ncancelled_pkgs;
22 $error = $record->bill;
23 $error = $record->bill %options;
24 $error = $record->bill 'time' => $time;
26 $error = $record->collect;
27 $error = $record->collect %options;
28 $error = $record->collect 'invoice_time' => $time,
29 'batch_card' => 'yes',
30 'report_badcard' => 'yes',
34 An FS::cust_main object represents a customer. FS::cust_main
35 inherits from FS::Record. The following fields are currently
38 custnum - primary key (assigned automatically for new customers)
39 agentnum - agent (see the FS::agent manpage)
40 refnum - referral (see the FS::part_referral manpage)
43 ss - social security number (optional)
48 county - (optional, see the FS::cust_main_county manpage)
49 state - (see the FS::cust_main_county manpage)
51 country - (see the FS::cust_main_county manpage)
52 daytime - phone (optional)
53 night - phone (optional)
54 payby - `CARD' (credit cards), `BILL' (billing), or `COMP' (free)
55 payinfo - card number, P.O.#, or comp issuer (4-8 lowercase alphanumerics; think username)
56 paydate - expiration date, mm/yyyy, m/yyyy, mm/yy or m/yy
57 payname - name on card or billing name
58 tax - tax exempt, empty or `Y'
59 otaker - order taker (assigned automatically, see the FS::UID manpage)
62 Creates a new customer. To add the customer to the database,
63 see the section on "insert".
65 Note that this stores the hash reference, not a distinct
66 copy of the hash it points to. You can ask the object for a
67 copy with the *hash* method.
70 Adds this customer to the database. If there is an error,
71 returns the error, otherwise returns false.
74 Currently unimplemented. Maybe cancel all of this customer's
77 I don't remove the customer record in the database because
78 there would then be no record the customer ever existed
82 Replaces the OLD_RECORD with this one in the database. If
83 there is an error, returns the error, otherwise returns
87 Checks all fields to make sure this is a valid customer
88 record. If there is an error, returns the error, otherwise
89 returns false. Called by the insert and repalce methods.
92 Returns all packages (see the FS::cust_pkg manpage) for this
96 Returns all non-cancelled packages (see the FS::cust_pkg
97 manpage) for this customer.
100 Generates invoices (see the FS::cust_bill manpage) for this
101 customer. Usually used in conjunction with the collect
104 The only currently available option is `time', which bills
105 the customer as if it were that time. It is specified as a
106 UNIX timestamp; see the section on "time" in the perlfunc
107 manpage). Also see the Time::Local manpage and the
108 Date::Parse manpage for conversion functions.
110 If there is an error, returns the error, otherwise returns
114 (Attempt to) collect money for this customer's outstanding
115 invoices (see the FS::cust_bill manpage). Usually used after
118 Depending on the value of `payby', this may print an invoice
119 (`BILL'), charge a credit card (`CARD'), or just add any
120 necessary (pseudo-)payment (`COMP').
122 If there is an error, returns the error, otherwise returns
125 Currently available options are:
127 invoice_time - Use this time when deciding when to print
128 invoices and late notices on those invoices. The default is
129 now. It is specified as a UNIX timestamp; see the section on
130 "time" in the perlfunc manpage). Also see the Time::Local
131 manpage and the Date::Parse manpage for conversion
134 batch_card - Set this true to batch cards (see the
135 cust_pay_batch manpage). By default, cards are processed
136 immediately, which will generate an error if CyberCash is
139 report_badcard - Set this true if you want bad card
140 transactions to return an error. By default, they don't.
143 Returns the total owed for this customer on all invoices
144 (see the FS::cust_bill manpage).
147 Returns the total credits (see the FS::cust_credit manpage)
151 Returns the balance for this customer (total owed minus
157 It doesn't properly override FS::Record yet.
159 hfields should be removed.
161 Bill and collect options should probably be passed as references
164 CyberCash v2 forces us to define some variables in package main.
167 the FS::Record manpage, the FS::cust_pkg manpage, the
168 FS::cust_bill manpage, the FS::cust_credit manpage the
169 FS::cust_pay_batch manpage, the FS::agent manpage, the
170 FS::part_referral manpage, the FS::cust_main_county manpage, the
171 FS::UID manpage, schema.html from the base documentation.
174 ivan@voicenet.com 97-jul-28
176 Changed to standard Business::CreditCard no more TableUtil
177 EXPORT_OK FS::Record's hfields removed unique calls and locking
178 (not needed here now) wrapped the (now) optional fields in if
179 statements in sub check (notyetdone!) ivan@sisd.com 97-nov-12
181 updated paydate with SQL-type date info ivan@sisd.com 98-mar-5
183 Added export of datasrc from UID.pm for Pg6.3 changed 'day' to
184 'daytime' because Pg6.3 reserves the day word
185 bmccane@maxbaud.net 98-apr-3
187 in ->create, s/svc_acct/cust_main/, now it should actually
188 eliminate the warnings it was meant to ivan@sisd.com 98-jul-16
190 don't require a phone number and allow '/' in company names
191 ivan@sisd.com 98-jul-18
193 use ut_ and rewrite &check, &*_pkgs ivan@sisd.com 98-sep-5
195 pod, merge with FS::Bill (about time!), total_owed,
196 total_credited and balance methods, cleaned collect method,
197 source modifications no longer necessary to enable cybercash,
198 cybercash v3 support, don't need to import
199 FS::UID::{datasrc,checkruid} ivan@sisd.com 98-sep-19-21