weight, plan and plandata fields in part_bill_event
[freeside.git] / httemplate / docs / man / FS / cust_pkg.html
1 <HTML>
2 <HEAD>
3 <TITLE>FS::cust_pkg - Object methods for cust_pkg objects</TITLE>
4 <LINK REV="made" HREF="mailto:perl@packages.debian.org">
5 </HEAD>
6
7 <BODY>
8
9 <A NAME="__index__"></A>
10 <!-- INDEX BEGIN -->
11
12 <UL>
13
14         <LI><A HREF="#name">NAME</A></LI>
15         <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
16         <LI><A HREF="#description">DESCRIPTION</A></LI>
17         <LI><A HREF="#methods">METHODS</A></LI>
18         <LI><A HREF="#subroutines">SUBROUTINES</A></LI>
19         <LI><A HREF="#version">VERSION</A></LI>
20         <LI><A HREF="#bugs">BUGS</A></LI>
21         <LI><A HREF="#see also">SEE ALSO</A></LI>
22 </UL>
23 <!-- INDEX END -->
24
25 <HR>
26 <P>
27 <H1><A NAME="name">NAME</A></H1>
28 <P>FS::cust_pkg - Object methods for cust_pkg objects</P>
29 <P>
30 <HR>
31 <H1><A NAME="synopsis">SYNOPSIS</A></H1>
32 <PRE>
33   use FS::cust_pkg;</PRE>
34 <PRE>
35   $record = new FS::cust_pkg \%hash;
36   $record = new FS::cust_pkg { 'column' =&gt; 'value' };</PRE>
37 <PRE>
38   $error = $record-&gt;insert;</PRE>
39 <PRE>
40   $error = $new_record-&gt;replace($old_record);</PRE>
41 <PRE>
42   $error = $record-&gt;delete;</PRE>
43 <PRE>
44   $error = $record-&gt;check;</PRE>
45 <PRE>
46   $error = $record-&gt;cancel;</PRE>
47 <PRE>
48   $error = $record-&gt;suspend;</PRE>
49 <PRE>
50   $error = $record-&gt;unsuspend;</PRE>
51 <PRE>
52   $part_pkg = $record-&gt;part_pkg;</PRE>
53 <PRE>
54   @labels = $record-&gt;labels;</PRE>
55 <PRE>
56   $seconds = $record-&gt;seconds_since($timestamp);</PRE>
57 <PRE>
58   $error = FS::cust_pkg::order( $custnum, \@pkgparts );
59   $error = FS::cust_pkg::order( $custnum, \@pkgparts, \@remove_pkgnums ] );</PRE>
60 <P>
61 <HR>
62 <H1><A NAME="description">DESCRIPTION</A></H1>
63 <P>An FS::cust_pkg object represents a customer billing item.  FS::cust_pkg
64 inherits from FS::Record.  The following fields are currently supported:</P>
65 <DL>
66 <DT><STRONG><A NAME="item_key">pkgnum - primary key (assigned automatically for new billing items)</A></STRONG><BR>
67 <DD>
68 <DT><STRONG><A NAME="item_Customer">custnum - Customer (see <A HREF=".././FS/cust_main.html">the FS::cust_main manpage</A>)</A></STRONG><BR>
69 <DD>
70 <DT><STRONG><A NAME="item_definition">pkgpart - Billing item definition (see <A HREF=".././FS/part_pkg.html">the FS::part_pkg manpage</A>)</A></STRONG><BR>
71 <DD>
72 <DT><STRONG><A NAME="item_setup_%2D_date">setup - date</A></STRONG><BR>
73 <DD>
74 <DT><STRONG><A NAME="item_bill_%2D_date">bill - date</A></STRONG><BR>
75 <DD>
76 <DT><STRONG><A NAME="item_susp_%2D_date">susp - date</A></STRONG><BR>
77 <DD>
78 <DT><STRONG><A NAME="item_expire_%2D_date">expire - date</A></STRONG><BR>
79 <DD>
80 <DT><STRONG><A NAME="item_cancel_%2D_date">cancel - date</A></STRONG><BR>
81 <DD>
82 <DT><STRONG><A NAME="item_taker">otaker - order taker (assigned automatically if null, see <A HREF=".././FS/UID.html">the FS::UID manpage</A>)</A></STRONG><BR>
83 <DD>
84 <DT><STRONG><A NAME="item_manual_flag_%2D_If_this_field_is_set_to_1%2C_disab">manual_flag - If this field is set to 1, disables the automatic
85 unsuspension of this package when using the <STRONG>unsuspendauto</STRONG> config file.</A></STRONG><BR>
86 <DD>
87 </DL>
88 <P>Note: setup, bill, susp, expire and cancel are specified as UNIX timestamps;
89 see <EM>perlfunc/``time''</EM>.  Also see <A HREF="../Time/Local.html">the Time::Local manpage</A> and <A HREF="../Date/Parse.html">the Date::Parse manpage</A> for
90 conversion functions.</P>
91 <P>
92 <HR>
93 <H1><A NAME="methods">METHODS</A></H1>
94 <DL>
95 <DT><STRONG><A NAME="item_new">new HASHREF</A></STRONG><BR>
96 <DD>
97 Create a new billing item.  To add the item to the database, see <A HREF="#insert">insert</A>.
98 <P></P>
99 <DT><STRONG><A NAME="item_insert">insert</A></STRONG><BR>
100 <DD>
101 Adds this billing item to the database (``Orders'' the item).  If there is an
102 error, returns the error, otherwise returns false.
103 <P></P>
104 <DT><STRONG><A NAME="item_delete">delete</A></STRONG><BR>
105 <DD>
106 This method now works but you probably shouldn't use it.
107 <P>You don't want to delete billing items, because there would then be no record
108 the customer ever purchased the item.  Instead, see the cancel method.</P>
109 <P></P>
110 <DT><STRONG><A NAME="item_replace_OLD_RECORD">replace OLD_RECORD</A></STRONG><BR>
111 <DD>
112 Replaces the OLD_RECORD with this one in the database.  If there is an error,
113 returns the error, otherwise returns false.
114 <P>Currently, custnum, setup, bill, susp, expire, and cancel may be changed.</P>
115 <P>Changing pkgpart may have disasterous effects.  See the order subroutine.</P>
116 <P>setup and bill are normally updated by calling the bill method of a customer
117 object (see <A HREF=".././FS/cust_main.html">the FS::cust_main manpage</A>).</P>
118 <P>suspend is normally updated by the suspend and unsuspend methods.</P>
119 <P>cancel is normally updated by the cancel method (and also the order subroutine
120 in some cases).</P>
121 <P></P>
122 <DT><STRONG><A NAME="item_check">check</A></STRONG><BR>
123 <DD>
124 Checks all fields to make sure this is a valid billing item.  If there is an
125 error, returns the error, otherwise returns false.  Called by the insert and
126 replace methods.
127 <P></P>
128 <DT><STRONG><A NAME="item_cancel">cancel</A></STRONG><BR>
129 <DD>
130 Cancels and removes all services (see <A HREF=".././FS/cust_svc.html">the FS::cust_svc manpage</A> and <A HREF=".././FS/part_svc.html">the FS::part_svc manpage</A>)
131 in this package, then cancels the package itself (sets the cancel field to
132 now).
133 <P>If there is an error, returns the error, otherwise returns false.</P>
134 <P></P>
135 <DT><STRONG><A NAME="item_suspend">suspend</A></STRONG><BR>
136 <DD>
137 Suspends all services (see <A HREF=".././FS/cust_svc.html">the FS::cust_svc manpage</A> and <A HREF=".././FS/part_svc.html">the FS::part_svc manpage</A>) in this
138 package, then suspends the package itself (sets the susp field to now).
139 <P>If there is an error, returns the error, otherwise returns false.</P>
140 <P></P>
141 <DT><STRONG><A NAME="item_unsuspend">unsuspend</A></STRONG><BR>
142 <DD>
143 Unsuspends all services (see <A HREF=".././FS/cust_svc.html">the FS::cust_svc manpage</A> and <A HREF=".././FS/part_svc.html">the FS::part_svc manpage</A>) in this
144 package, then unsuspends the package itself (clears the susp field).
145 <P>If there is an error, returns the error, otherwise returns false.</P>
146 <P></P>
147 <DT><STRONG><A NAME="item_part_pkg">part_pkg</A></STRONG><BR>
148 <DD>
149 Returns the definition for this billing item, as an FS::part_pkg object (see
150 <A HREF=".././FS/part_pkg.html">the FS::part_pkg manpage</A>).
151 <P></P>
152 <DT><STRONG><A NAME="item_cust_svc">cust_svc</A></STRONG><BR>
153 <DD>
154 Returns the services for this package, as FS::cust_svc objects (see
155 <A HREF=".././FS/cust_svc.html">the FS::cust_svc manpage</A>)
156 <P></P>
157 <DT><STRONG><A NAME="item_labels">labels</A></STRONG><BR>
158 <DD>
159 Returns a list of lists, calling the label method for all services
160 (see <A HREF=".././FS/cust_svc.html">the FS::cust_svc manpage</A>) of this billing item.
161 <P></P>
162 <DT><STRONG><A NAME="item_cust_main">cust_main</A></STRONG><BR>
163 <DD>
164 Returns the parent customer object (see <A HREF=".././FS/cust_main.html">the FS::cust_main manpage</A>).
165 <P></P>
166 <DT><STRONG><A NAME="item_seconds_since_TIMESTAMP">seconds_since TIMESTAMP</A></STRONG><BR>
167 <DD>
168 Returns the number of seconds all accounts (see <A HREF=".././FS/svc_acct.html">the FS::svc_acct manpage</A>) in this
169 package have been online since TIMESTAMP.
170 <P>TIMESTAMP is specified as a UNIX timestamp; see <EM>perlfunc/``time''</EM>.  Also see
171 <A HREF="../Time/Local.html">the Time::Local manpage</A> and <A HREF="../Date/Parse.html">the Date::Parse manpage</A> for conversion functions.</P>
172 <P></P></DL>
173 <P>
174 <HR>
175 <H1><A NAME="subroutines">SUBROUTINES</A></H1>
176 <DL>
177 <DT><STRONG><A NAME="item_order_CUSTNUM%2C_PKGPARTS_ARYREF%2C_%5B_REMOVE_PKG">order CUSTNUM, PKGPARTS_ARYREF, [ REMOVE_PKGNUMS_ARYREF [ RETURN_CUST_PKG_ARRAYREF ] ]</A></STRONG><BR>
178 <DD>
179 CUSTNUM is a customer (see <A HREF=".././FS/cust_main.html">the FS::cust_main manpage</A>)
180 <P>PKGPARTS is a list of pkgparts specifying the the billing item definitions (see
181 <A HREF=".././FS/part_pkg.html">the FS::part_pkg manpage</A>) to order for this customer.  Duplicates are of course
182 permitted.</P>
183 <P>REMOVE_PKGNUMS is an optional list of pkgnums specifying the billing items to
184 remove for this customer.  The services (see <A HREF=".././FS/cust_svc.html">the FS::cust_svc manpage</A>) are moved to the
185 new billing items.  An error is returned if this is not possible (see
186 <A HREF=".././FS/pkg_svc.html">the FS::pkg_svc manpage</A>).  An empty arrayref is equivalent to not specifying this
187 parameter.</P>
188 <P>RETURN_CUST_PKG_ARRAYREF, if specified, will be filled in with the
189 newly-created cust_pkg objects.</P>
190 <P></P></DL>
191 <P>
192 <HR>
193 <H1><A NAME="version">VERSION</A></H1>
194 <P>$Id: cust_pkg.html,v 1.3 2002-01-29 17:42:46 ivan Exp $</P>
195 <P>
196 <HR>
197 <H1><A NAME="bugs">BUGS</A></H1>
198 <P>sub order is not OO.  Perhaps it should be moved to FS::cust_main and made so?</P>
199 <P>In sub order, the @pkgparts array (passed by reference) is clobbered.</P>
200 <P>Also in sub order, no money is adjusted.  Once FS::part_pkg defines a standard
201 method to pass dates to the recur_prog expression, it should do so.</P>
202 <P>FS::svc_acct, FS::svc_acct_sm, and FS::svc_domain are loaded via 'use' at 
203 compile time, rather than via 'require' in sub { setup, suspend, unsuspend,
204 cancel } because they use %FS::UID::callback to load configuration values.
205 Probably need a subroutine which decides what to do based on whether or not
206 we've fetched the user yet, rather than a hash.  See FS::UID and the TODO.</P>
207 <P>Now that things are transactional should the check in the insert method be
208 moved to check ?</P>
209 <P>
210 <HR>
211 <H1><A NAME="see also">SEE ALSO</A></H1>
212 <P><A HREF=".././FS/Record.html">the FS::Record manpage</A>, <A HREF=".././FS/cust_main.html">the FS::cust_main manpage</A>, <A HREF=".././FS/part_pkg.html">the FS::part_pkg manpage</A>, <A HREF=".././FS/cust_svc.html">the FS::cust_svc manpage</A>,
213 <A HREF=".././FS/pkg_svc.html">the FS::pkg_svc manpage</A>, schema.html from the base documentation</P>
214
215 </BODY>
216
217 </HTML>