more schema changes: part_bill_event and cust_bill_event tables
[freeside.git] / httemplate / docs / schema.html
1 <head>
2   <title>Schema reference</title>
3 </head>
4 <body>
5   <h1>Schema reference</h1>
6   <ul>
7     <li><a name="agent" href="man/FS/agent.html">agent</a> - Agents are resellers of your service.  Agents may be limited to a subset of your full offerings (via their agent type).
8       <ul>
9         <li>agentnum - primary key
10         <li>agent - name of this agent
11         <li>typenum - <a href="#agent_type">agent type</a>
12         <li>prog - (unimplemented)
13         <li>freq - (unimplemented)
14       </ul>
15     <li><a name="agent_type" href="man/FS/agent_type.html">agent_type</a> - Agent types define groups of packages that you can then assign to particular agents.
16       <ul>
17         <li>typenum - primary key
18         <li>atype - name of this agent type
19       </ul>
20     <li><a name="cust_bill" href="man/FS/cust_bill.html">cust_bill</a> - Invoices.  Declarations that a customer owes you money.  The specific charges are itemized in <a href="#cust_bill_pkg">cust_bill_pkg</a>.
21       <ul>
22         <li>invnum - primary key
23         <li>custnum - <a href="#cust_main">customer</a>
24         <li>_date
25         <li>charged - amount of this invoice
26         <li>printed - how many times this invoice has been printed automatically
27       </ul>
28     <li><a name="cust_bill_event" href="man/FS/cust_bill_event.html">cust_bill_event</a> - Invoice event history
29       <ul>
30         <li>eventnum - primary key
31         <li>invnum - <a href="#cust_bill">invoice</a>
32         <li>eventpart - <a href="#part_bill_event">event definition</a>
33         <li>_date
34       </ul>
35     <li><a name="part_bill_event" href="man/FS/part_bill_event.html">part_bill_event</a> - Invoice event definitions
36       <ul>
37         <li>eventpart - primary key
38         <li>payby - CARD, BILL, or COMP
39         <li>event - event name
40         <li>eventcode - event action
41         <li>seconds - how long after the invoice date (<a href="#cust_bill">cust_bill</a>._date) events of this type are triggered
42         <li>disabled - Disabled flag, empty or `Y'
43       </ul>
44     <li><a name="cust_bill_pkg" href="man/FS/cust_bill_pkg.html">cust_bill_pkg</a> - Invoice line items
45       <ul>
46         <li>invnum - (multiple) key
47         <li>pkgnum - <a href="#cust_pkg">package</a> or 0 for the special virtual sales tax package
48         <li>setup - setup fee 
49         <li>recur - recurring fee
50         <li>sdate - starting date
51         <li>edate - ending date
52       </ul>
53     <li><a name="cust_credit" href="man/FS/cust_credit.html">cust_credit</a> - Credits.  The equivalent of a negative <a href="#cust_bill">cust_bill</a> record.
54       <ul>
55         <li>crednum - primary key
56         <li>custnum - <a href="#cust_main">customer</a>
57         <li>amount - amount credited
58         <li>_date
59         <li>otaker - order taker
60         <li>reason
61       </ul>
62     <li><a name="cust_credit_bill" href="man/FS/cust_credit_bill.html">cust_credit_bill</a> - Credit invoice application.  Links a credit to an invoice.
63       <ul>
64         <li>creditbillnum - primary key
65         <li>crednum - <a href="#cust_credit">credit</a> being applied
66         <li>invnum - <a href="#cust_bill">invoice</a> to which credit is applied
67         <li>amount - amount applied
68         <li>_date
69       </ul>
70     <li><a name="cust_main" href="man/FS/cust_main.html">cust_main</a> - Customers
71       <ul>
72         <li>custnum - primary key
73         <li>agentnum - <a href="#agent">agent</a>
74         <li>refnum - <a href="#part_referral">referral</a>
75         <li>first - name
76         <li>last - name
77         <li>ss - social security number
78         <li>company
79         <li>address1
80         <li>address2
81         <li>city
82         <li>county
83         <li>state
84         <li>zip
85         <li>country
86         <li>daytime - phone
87         <li>night - phone
88         <li>fax - phone
89         <li><i>ship_first</i>
90         <li><i>ship_last</i>
91         <li><i>ship_company</i>
92         <li><i>ship_address1</i>
93         <li><i>ship_address2</i>
94         <li><i>ship_city</i>
95         <li><i>ship_county</i>
96         <li><i>ship_state</i>
97         <li><i>ship_zip</i>
98         <li><i>ship_country</i>
99         <li><i>ship_daytime</i>
100         <li><i>ship_night</i>
101         <li><i>ship_fax</i>
102         <li>payby - CARD, BILL, or COMP
103         <li>payinfo - card number, P.O.#, or comp issuer
104         <li>paydate - expiration date
105         <li>payname - billing name (name on card)
106         <li>tax - tax exempt, Y or null
107         <li>otaker - order taker
108         <li>referral_custnum
109         <li>comments
110       </ul>
111       (columns in <i>italics</i> are optional)
112     <li><a name="cust_main_invoice" href="man/FS/cust_main_invoice.html">cust_main_invoice</a> - Invoice destinations for email invoices.  Note that a customer can have many email destinations for their invoice (either literal or via svcnum), but only one postal destination.
113       <ul>
114         <li>destnum - primary key
115         <li>custnum - <a href="#cust_main">customer</a>
116         <li>dest - Invoice destination.  Freeside supports three types of invoice delivery: send directly to a service defined in Freeside, send to an arbitrary email address, or print the invoice to a printer and have someone send it out via snail mail.  Freeside determines which method to use based on the contents of the dest field.  If the contents are numeric, a <a href="#svc_acct">svcnum</a> pointing to a valid service is expected in the field.  If the contents are a string, a literal email address is expected to be in the field.  If the special keyword `POST' is present, the snail mail method is used (which is the default if no cust_main_invoice records exist).  Snail mail invoices get their address information from <A name="#cust_main">cust_main</A> and are printed with the printer defined in the configuration files.
117       </ul>
118     <li><a name="cust_main_county" href="man/FS/cust_main_county.html">cust_main_county</a> - Tax rates
119       <ul>
120         <li>taxnum - primary key
121         <li>state
122         <li>county
123         <li>country
124         <li>tax - % rate
125       </ul>
126     <li><a name="cust_pay" href="man/FS/cust_pay.html">cust_pay</a> - Payments.  Money being transferred from a customer.
127       <ul>
128         <li>paynum - primary key
129         <li>custnum - <a href="#cust_main">customer</a>
130         <li>paid - amount
131         <li>_date
132         <li>payby - CARD, BILL, or COMP
133         <li>payinfo - card number, P.O.#, or comp issuer
134         <li>paybatch - text field for tracking card processor batches
135       </ul>
136     <li><a name="cust_bill_pay" href="man/FS/cust_bill_pay.html">cust_bill_pay</a> - Applicaton of a payment to a specific invoice.
137       <ul>
138         <li>billpaynum
139         <li>invnum - <a href="#cust_bill">invoice</a>
140         <li>paynum - <a href="#cust_pay">payment</a>
141         <li>amount
142         <li>_date
143       </ul>
144     <li><a name="cust_pay_batch" href="man/FS/cust_pay_batch.html">cust_pay_batch</a> - Pending batch
145       <ul>
146         <li>paybatchnum
147         <li>cardnum
148         <li>exp - card expiration
149         <li>amount
150         <li>invnum - <a href="#cust_bill">invoice</a>
151         <li>custnum - <a href="#cust_main">customer</a>
152         <li>payname - name on card
153         <li>first - name
154         <li>last - name
155         <li>address1
156         <li>address2
157         <li>city
158         <li>state
159         <li>zip
160         <li>country
161       </ul>
162     <li><a name="cust_pkg" href="man/FS/cust_pkg.html">cust_pkg</a> - Customer billing items
163       <ul>
164         <li>pkgnum - primary key
165         <li>custnum - <a href="#cust_main">customer</a>
166         <li>pkgpart - <a href="#part_pkg">Package definition</a>
167         <li>setup - date
168         <li>bill - next bill date
169         <li>susp - (past) suspension date
170         <li>expire - (future) cancellation date
171         <li>cancel - (past) cancellation date
172         <li>otaker - order taker
173         <li>manual_flag - If this field is set to 1, disables the automatic unsuspensiond of this package when using the <a href="config.html#unsuspendauto">unsuspendauto</a> config file.
174       </ul>
175     <li><a name="cust_refund" href="man/FS/cust_refund.html">cust_refund</a> - Refunds.  The transfer of money to a customer; equivalent to a negative <a href="#cust_pay">cust_pay</a> record.
176       <ul>
177         <li>refundnum - primary key
178         <li>custnum - <a href="#cust_main">customer</a>
179         <li>refund - amount
180         <li>_date
181         <li>payby - CARD, BILL or COMP
182         <li>payinfo - card number, P.O.#, or comp issuer
183         <li>otaker - order taker
184       </ul>
185     <li><a name="cust_credit_refund" href="man/FS/cust_credit_refund.html">cust_credit_refund</a> - Applicaton of a refund to a specific credit.
186       <ul>
187         <li>creditrefundnum - primary key
188         <li>crednum - <a href="#cust_credit">credit</a>
189         <li>refundnum - <a href="#cust_refund">refund</a>
190         <li>amount
191         <li>_date
192       </ul>
193     <li><a name="cust_svc" href="man/FS/cust_svc.html">cust_svc</a> - Customer services
194       <ul>
195         <li>svcnum - primary key
196         <li>pkgnum - <a href="#cust_pkg">package</a>
197         <li>svcpart - <a href="#part_svc">Service definition</a>
198       </ul>
199     <li><a name="nas" href="man/FS/nas.html">nas</a> - Network Access Server (terminal server)
200       <ul>
201         <li>nasnum - primary key
202         <li>nas - NAS name
203         <li>nasip - NAS ip address
204         <li>nasfqdn - NAS fully-qualified domain name
205         <li>last - timestamp indicating the last instant the NAS was in a known state (used by the session monitoring).
206       </ul>
207     <li><a name="part_pkg" href="man/FS/part_pkg.html">part_pkg</a> - Package definitions
208       <ul>
209         <li>pkgpart - primary key
210         <li>pkg - package name
211         <li>comment - non-customer visable package comment
212         <li>setup - setup fee expression
213         <li>freq - recurring frequency (months)
214         <li>recur - recurring fee expression
215         <li>setuptax - Setup fee tax exempt flag, empty or `Y'
216         <li>recurtax - Recurring fee tax exempt flag, empty or `Y'
217         <li>plan - price plan
218         <li>plandata - additional price plan data
219         <li>disabled - Disabled flag, empty or `Y'
220       </ul>
221     <li><a name="part_referral" href="man/FS/part_referral.html">part_referral</a> - Referral listing
222       <ul>
223         <li>refnum - primary key
224         <li>referral - referral
225       </ul>
226     <li><a name="part_svc" href="man/FS/part_svc.html">part_svc</a> - Service definitions
227       <ul>
228         <li>svcpart - primary key
229         <li>svc - name of this service
230         <li>svcdb - table used for this service: svc_acct, svc_acct_sm, svc_forward, svc_domain, svc_charge or svc_wo
231         <li>disabled - Disabled flag, empty or `Y'
232 <!--        <li><i>table</i>__<i>field</i> - Default or fixed value for <i>field</i> in <i>table</i>
233         <li><i>table</i>__<i>field</i>_flag - null, D or F
234 -->
235       </ul>
236     <li><a name="part_svc_column" href="man/FS/part_svc_column.html">part_svc_column</a>
237       <ul>
238         <li>columnnum - primary key
239         <li>svcpart - <a href="#part_svc">Service definition</a>
240         <li>columnname - column name in part_svc.svcdb table
241         <li>columnvalue - default or fixed value for the column
242         <li>columnflag - null, D or F
243       </ul>
244     <li><a name="pkg_svc" href="man/FS/pkg_svc.html">pkg_svc</a>
245       <ul>
246         <li>pkgpart - <a href="#part_pkg">Package definition</a>
247         <li>svcpart - <a href="#part_svc">Service definition</a>
248         <li>quantity - quantity of this service that this package includes
249       </ul>
250     <li><a name="port" href="man/FS/port.html">port</a> - individual port on a <a href="#nas">nas</a>
251       <ul>
252         <li>portnum - primary key
253         <li>ip - IP address of this port
254         <li>nasport - port number on the NAS
255         <li>nasnum - <a href="#nas">NAS</a>
256       </ul>
257     <li><a name="prepay_credit" href="man/FS/prepay_credit.html">prepay_credit</a>
258       <ul>
259         <li>prepaynum - primary key
260         <li>identifier - text or numeric string used to receive this credit
261         <li>amount - amount of credit
262       </ul>
263     <li><a name="session" href="man/FS/session.html">session</a>
264       <ul>
265         <li>sessionnum - primary key
266         <li>portnum - <a href="#port">Port</a>
267         <li>svcnum - <a href="#svc_acct">Account</a>
268         <li>login - timestamp indicating the beginning of this user session.
269         <li>logout - timestamp indicating the end of this user session.  May be null, which indicates a currently open session.
270       </ul>
271
272     <li><a name="svc_acct" href="man/FS/svc_acct.html">svc_acct</a> - Accounts
273       <ul>
274         <li>svcnum - <a href="#cust_svc">primary key</a>
275         <li>username
276         <li>_password
277         <li>popnum - <a href="#svc_acct_pop">Point of Presence</a>
278         <li>uid
279         <li>gid
280         <li>finger - GECOS
281         <li>dir
282         <li>shell
283         <li>quota - (unimplementd)
284         <li>slipip - IP address
285         <li>seconds
286         <li>domsvc
287         <li>radius_<i>Radius_Reply_Attribute</i> - Radius-Reply-Attribute
288         <li>rc_<i>Radius_Check_Attribute</i> - Radius-Check-Attribute
289       </ul>
290     <li><a name="svc_acct_pop" href="man/FS/svc_acct_pop.html">svc_acct_pop</a> - Points of Presence
291       <ul>
292         <li>popnum - primary key
293         <li>city
294         <li>state
295         <li>ac - area code
296         <li>exch - exchange
297         <li>loc - rest of number
298       </ul>
299     <li><a name="part_pop_local" href="man/FS/part_pop_local.html">part_pop_local</a> - Local calling areas
300       <ul>
301         <li>localnum - primary key
302         <li>popnum - primary key
303         <li>city
304         <li>state
305         <li>npa - area code
306         <li>nxx - exchange
307       </ul>
308     <li><a name="svc_acct_sm" href="man/FS/svc_acct_sm.html">svc_acct_sm</a> - <b>DEPRECIATED</b> Domain mail aliases
309       <ul>
310         <li>svcnum - <a href="#cust_svc">primary key</a>
311         <li>domsvc - <a href="#svc_domain">Domain</a> (by svcnum)
312         <li>domuid - <a href="#svc_acct">Account</a> (by uid)
313         <li>domuser - domuser @ <a href="#svc_domain">Domain</a> forwards to <a href="#svc_acct">Account</a>
314       </ul>
315     <li><a name="svc_domain" href="man/FS/svc_domain.html">svc_domain</a> - Domains
316       <ul>
317         <li>svcnum - <a href="#cust_svc">primary key</a>
318         <li>domain
319       </ul>
320     <li><a name="svc_forward" href="man/FS/svc_forward.html">svc_forward</a> - Mail forwarding aliases
321       <ul>
322         <li>svcnum - <a href="#cust_svc">primary key</a>
323         <li>srcsvc - <a href="#svc_acct">svcnum of the source of this forward</a>
324         <li>dstsvc - <a href="#svc_acct">svcnum of the destination of this forward</a>
325         <li>dst - foreign destination (email address) - forward not local to freeside
326       </ul>
327     <li><a name="domain_record" href="man/FS/domain_record.html">domain_record</a> - Domain zone detail
328       <ul>
329         <li>recnum - primary key
330         <li>svcnum - <a href="#svc_domain">Domain</a> (by svcnum)
331         <li>reczone - zone for this line
332         <li>recaf - address family, usually <b>IN</b>
333         <li>rectype - type for this record (<b>A</b>, <b>MX</b>, etc.)
334         <li>recdata - data for this record
335       </ul>
336     <li><a name="svc_www" href="man/FS/svc_www.html">svc_www</a>
337       <ul>
338        <li>svcnum - <a href="#cust-svc">primary key</a>
339        <li>recnum - <a href="#domain_record">host</a>
340        <li>usersvc - <a href="#svc_acct">account</a>
341       </ul>
342     <li><a name="type_pkgs" href="man/FS/type_pkgs.html">type_pkgs</a>
343       <ul>
344         <li>typenum - <a href="#agent_type">agent type</a>
345         <li>pkgpart - <a href="#part_pkg">Package definition</a>
346       </ul>
347     <li><a name="queue" href="man/FS/queue.html">queue</a> - job queue
348       <ul>
349         <li>jobnum - primary key
350         <li>job
351         <li>_date
352         <li>status
353       </ul>
354     <li><a name="queue_arg" href="man/FS/queue_arg.html">queue_arg</a> - job arguments
355       <ul>
356         <li>argnum - primary key
357         <li>jobnum - <a href="#queue">job</a>
358         <li>arg - argument
359       </ul>
360   </ul>
361 </body>