d7659f0ceb989b4641d622fd2803aec16551567b
[freeside.git] / htdocs / 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:none">
5 </HEAD>
6
7 <BODY>
8
9 <!-- INDEX BEGIN -->
10
11 <UL>
12
13         <LI><A HREF="#NAME">NAME</A>
14         <LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
15         <LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
16         <LI><A HREF="#METHODS">METHODS</A>
17         <LI><A HREF="#SUBROUTINES">SUBROUTINES</A>
18         <LI><A HREF="#VERSION">VERSION</A>
19         <LI><A HREF="#BUGS">BUGS</A>
20         <LI><A HREF="#SEE_ALSO">SEE ALSO</A>
21 </UL>
22 <!-- INDEX END -->
23
24 <HR>
25 <P>
26 <H1><A NAME="NAME">NAME</A></H1>
27 <P>
28 FS::cust_pkg - Object methods for cust_pkg objects
29
30 <P>
31 <HR>
32 <H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
33 <P>
34 <PRE>  use FS::cust_pkg;
35 </PRE>
36 <P>
37 <PRE>  $record = new FS::cust_pkg \%hash;
38   $record = new FS::cust_pkg { 'column' =&gt; 'value' };
39 </PRE>
40 <P>
41 <PRE>  $error = $record-&gt;insert;
42 </PRE>
43 <P>
44 <PRE>  $error = $new_record-&gt;replace($old_record);
45 </PRE>
46 <P>
47 <PRE>  $error = $record-&gt;delete;
48 </PRE>
49 <P>
50 <PRE>  $error = $record-&gt;check;
51 </PRE>
52 <P>
53 <PRE>  $error = $record-&gt;cancel;
54 </PRE>
55 <P>
56 <PRE>  $error = $record-&gt;suspend;
57 </PRE>
58 <P>
59 <PRE>  $error = $record-&gt;unsuspend;
60 </PRE>
61 <P>
62 <PRE>  $part_pkg = $record-&gt;part_pkg;
63 </PRE>
64 <P>
65 <PRE>  @labels = $record-&gt;labels;
66 </PRE>
67 <P>
68 <PRE>  $error = FS::cust_pkg::order( $custnum, \@pkgparts );
69   $error = FS::cust_pkg::order( $custnum, \@pkgparts, \@remove_pkgnums ] );
70 </PRE>
71 <P>
72 <HR>
73 <H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
74 <P>
75 An FS::cust_pkg object represents a customer billing item. FS::cust_pkg
76 inherits from FS::Record. The following fields are currently supported:
77
78 <DL>
79 <DT><STRONG><A NAME="item_pkgnum">pkgnum - primary key (assigned automatically for new billing items)</A></STRONG><DD>
80 <DT><STRONG><A NAME="item_custnum">custnum - Customer (see FS::cust_main)</A></STRONG><DD>
81 <DT><STRONG><A NAME="item_pkgpart">pkgpart - Billing item definition (see FS::part_pkg)</A></STRONG><DD>
82 <DT><STRONG><A NAME="item_setup">setup - date</A></STRONG><DD>
83 <DT><STRONG><A NAME="item_bill">bill - date</A></STRONG><DD>
84 <DT><STRONG><A NAME="item_susp">susp - date</A></STRONG><DD>
85 <DT><STRONG><A NAME="item_expire">expire - date</A></STRONG><DD>
86 <DT><STRONG><A NAME="item_cancel">cancel - date</A></STRONG><DD>
87 <DT><STRONG><A NAME="item_otaker">otaker - order taker (assigned automatically if null, see FS::UID)</A></STRONG><DD>
88 </DL>
89 <P>
90 Note: setup, bill, susp, expire and cancel are specified as UNIX
91 timestamps; see <EM>perlfunc</EM>. Also see <A HREF="../Time/Local.html">Time::Local</A> and <A HREF="../Date/Parse.html">Date::Parse</A> for conversion functions.
92
93 <P>
94 <HR>
95 <H1><A NAME="METHODS">METHODS</A></H1>
96 <DL>
97 <DT><STRONG><A NAME="item_new">new HASHREF</A></STRONG><DD>
98 <P>
99 Create a new billing item. To add the item to the database, see <A HREF="#insert">insert</A>.
100
101 <DT><STRONG><A NAME="item_insert">insert</A></STRONG><DD>
102 <P>
103 Adds this billing item to the database (``Orders'' the item). If there is
104 an error, returns the error, otherwise returns false.
105
106 <P>
107 sub insert { my <CODE>$self</CODE> = shift;
108
109 <P>
110 <PRE>  # custnum might not have have been defined in sub check (for one-shot new
111   # customers), so check it here instead
112 </PRE>
113 <P>
114 <PRE>  my $error = $self-&gt;ut_number('custnum');
115   return $error if $error
116 </PRE>
117 <P>
118 <PRE>  return &quot;Unknown customer&quot;
119     unless qsearchs( 'cust_main', { 'custnum' =&gt; $self-&gt;custnum } );
120 </PRE>
121 <P>
122 <PRE>  $self-&gt;SUPER::insert;
123 </PRE>
124 <P>
125 }
126
127 <DT><STRONG><A NAME="item_delete">delete</A></STRONG><DD>
128 <P>
129 Currently unimplemented. You don't want to delete billing items, because
130 there would then be no record the customer ever purchased the item.
131 Instead, see the cancel method.
132
133 <DT><STRONG><A NAME="item_replace">replace OLD_RECORD</A></STRONG><DD>
134 <P>
135 Replaces the OLD_RECORD with this one in the database. If there is an
136 error, returns the error, otherwise returns false.
137
138 <P>
139 Currently, custnum, setup, bill, susp, expire, and cancel may be changed.
140
141 <P>
142 Changing pkgpart may have disasterous effects. See the order subroutine.
143
144 <P>
145 setup and bill are normally updated by calling the bill method of a
146 customer object (see <A HREF="../FS/cust_main.html">FS::cust_main</A>).
147
148 <P>
149 suspend is normally updated by the suspend and unsuspend methods.
150
151 <P>
152 cancel is normally updated by the cancel method (and also the order
153 subroutine in some cases).
154
155 <DT><STRONG><A NAME="item_check">check</A></STRONG><DD>
156 <P>
157 Checks all fields to make sure this is a valid billing item. If there is an
158 error, returns the error, otherwise returns false. Called by the insert and
159 replace methods.
160
161 <DT><STRONG>cancel</STRONG><DD>
162 <P>
163 Cancels and removes all services (see <A HREF="../FS/cust_svc.html">FS::cust_svc</A> and <A HREF="../FS/part_svc.html">FS::part_svc</A>) in this package, then cancels the package itself (sets the cancel field
164 to now).
165
166 <P>
167 If there is an error, returns the error, otherwise returns false.
168
169 <DT><STRONG><A NAME="item_suspend">suspend</A></STRONG><DD>
170 <P>
171 Suspends all services (see <A HREF="../FS/cust_svc.html">FS::cust_svc</A> and <A HREF="../FS/part_svc.html">FS::part_svc</A>) in this package, then suspends the package itself (sets the susp field to
172 now).
173
174 <P>
175 If there is an error, returns the error, otherwise returns false.
176
177 <DT><STRONG><A NAME="item_unsuspend">unsuspend</A></STRONG><DD>
178 <P>
179 Unsuspends all services (see <A HREF="../FS/cust_svc.html">FS::cust_svc</A> and <A HREF="../FS/part_svc.html">FS::part_svc</A>) in this package, then unsuspends the package itself (clears the susp
180 field).
181
182 <P>
183 If there is an error, returns the error, otherwise returns false.
184
185 <DT><STRONG><A NAME="item_part_pkg">part_pkg</A></STRONG><DD>
186 <P>
187 Returns the definition for this billing item, as an FS::part_pkg object
188 (see
189 <A HREF="../FS/part_pkg.html">FS::part_pkg</A>).
190
191 <DT><STRONG><A NAME="item_labels">labels</A></STRONG><DD>
192 <P>
193 Returns a list of lists, calling the label method for all services (see <A HREF="../FS/cust_svc.html">FS::cust_svc</A>) of this billing item.
194
195 </DL>
196 <P>
197 <HR>
198 <H1><A NAME="SUBROUTINES">SUBROUTINES</A></H1>
199 <DL>
200 <DT><STRONG><A NAME="item_order">order CUSTNUM, PKGPARTS_ARYREF, [ REMOVE_PKGNUMS_ARYREF ]</A></STRONG><DD>
201 <P>
202 CUSTNUM is a customer (see <A HREF="../FS/cust_main.html">FS::cust_main</A>)
203
204 <P>
205 PKGPARTS is a list of pkgparts specifying the the billing item definitions
206 (see
207 <A HREF="../FS/part_pkg.html">FS::part_pkg</A>) to order for this customer. Duplicates are of course permitted.
208
209 <P>
210 REMOVE_PKGNUMS is an optional list of pkgnums specifying the billing items
211 to remove for this customer. The services (see <A HREF="../FS/cust_svc.html">FS::cust_svc</A>) are moved to the new billing items. An error is returned if this is not
212 possible (see
213 <A HREF="../FS/pkg_svc.html">FS::pkg_svc</A>).
214
215 </DL>
216 <P>
217 <HR>
218 <H1><A NAME="VERSION">VERSION</A></H1>
219 <P>
220 $Id: cust_pkg.html,v 1.2 2000-03-03 18:22:43 ivan Exp $
221
222 <P>
223 <HR>
224 <H1><A NAME="BUGS">BUGS</A></H1>
225 <P>
226 sub order is not OO. Perhaps it should be moved to FS::cust_main and made
227 so?
228
229 <P>
230 In sub order, the <CODE>@pkgparts</CODE> array (passed by reference) is
231 clobbered.
232
233 <P>
234 Also in sub order, no money is adjusted. Once FS::part_pkg defines a
235 standard method to pass dates to the recur_prog expression, it should do
236 so.
237
238 <P>
239 FS::svc_acct, FS::svc_acct_sm, and FS::svc_domain are loaded via 'use' at
240 compile time, rather than via 'require' in sub { setup, suspend, unsuspend,
241 cancel } because they use %FS::UID::callback to load configuration values.
242 Probably need a subroutine which decides what to do based on whether or not
243 we've fetched the user yet, rather than a hash. See FS::UID and the TODO.
244
245 <P>
246 <HR>
247 <H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
248 <P>
249 <A HREF="../FS/Record.html">FS::Record</A>, <A HREF="../FS/cust_main.html">FS::cust_main</A>, <A HREF="../FS/part_pkg.html">FS::part_pkg</A>, <A HREF="../FS/cust_svc.html">FS::cust_svc</A>
250 , <A HREF="../FS/pkg_svc.html">FS::pkg_svc</A>, schema.html from the base documentation
251
252 </BODY>
253
254 </HTML>