3 <TITLE>FS::cust_pkg - Object methods for cust_pkg objects</TITLE>
4 <LINK REV="made" HREF="mailto:ivan@rootwood.sisd.com">
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>
26 <H1><A NAME="NAME">NAME</A></H1>
28 FS::cust_pkg - Object methods for cust_pkg objects
32 <H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
34 <PRE> use FS::cust_pkg;
37 <PRE> $record = new FS::cust_pkg \%hash;
38 $record = new FS::cust_pkg { 'column' => 'value' };
41 <PRE> $error = $record->insert;
44 <PRE> $error = $new_record->replace($old_record);
47 <PRE> $error = $record->delete;
50 <PRE> $error = $record->check;
53 <PRE> $error = $record->cancel;
56 <PRE> $error = $record->suspend;
59 <PRE> $error = $record->unsuspend;
62 <PRE> $part_pkg = $record->part_pkg;
65 <PRE> @labels = $record->labels;
68 <PRE> $error = FS::cust_pkg::order( $custnum, \@pkgparts );
69 $error = FS::cust_pkg::order( $custnum, \@pkgparts, \@remove_pkgnums ] );
73 <H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
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:
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>
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.
95 <H1><A NAME="METHODS">METHODS</A></H1>
97 <DT><STRONG><A NAME="item_new">new HASHREF</A></STRONG><DD>
99 Create a new billing item. To add the item to the database, see <A HREF="#insert">insert</A>.
101 <DT><STRONG><A NAME="item_insert">insert</A></STRONG><DD>
103 Adds this billing item to the database (``Orders'' the item). If there is
104 an error, returns the error, otherwise returns false.
107 sub insert { my <CODE>$self</CODE> = shift;
110 <PRE> # custnum might not have have been defined in sub check (for one-shot new
111 # customers), so check it here instead
114 <PRE> my $error = $self->ut_number('custnum');
115 return $error if $error
118 <PRE> return "Unknown customer"
119 unless qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
122 <PRE> $self->SUPER::insert;
127 <DT><STRONG><A NAME="item_delete">delete</A></STRONG><DD>
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.
133 <DT><STRONG><A NAME="item_replace">replace OLD_RECORD</A></STRONG><DD>
135 Replaces the OLD_RECORD with this one in the database. If there is an
136 error, returns the error, otherwise returns false.
139 Currently, custnum, setup, bill, susp, expire, and cancel may be changed.
142 Changing pkgpart may have disasterous effects. See the order subroutine.
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>).
149 suspend is normally updated by the suspend and unsuspend methods.
152 cancel is normally updated by the cancel method (and also the order
153 subroutine in some cases).
155 <DT><STRONG><A NAME="item_check">check</A></STRONG><DD>
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
161 <DT><STRONG>cancel</STRONG><DD>
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
167 If there is an error, returns the error, otherwise returns false.
169 <DT><STRONG><A NAME="item_suspend">suspend</A></STRONG><DD>
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
175 If there is an error, returns the error, otherwise returns false.
177 <DT><STRONG><A NAME="item_unsuspend">unsuspend</A></STRONG><DD>
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
183 If there is an error, returns the error, otherwise returns false.
185 <DT><STRONG><A NAME="item_part_pkg">part_pkg</A></STRONG><DD>
187 Returns the definition for this billing item, as an FS::part_pkg object
189 <A HREF="../FS/part_pkg.html">FS::part_pkg</A>).
191 <DT><STRONG><A NAME="item_labels">labels</A></STRONG><DD>
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.
198 <H1><A NAME="SUBROUTINES">SUBROUTINES</A></H1>
200 <DT><STRONG><A NAME="item_order">order CUSTNUM, PKGPARTS_ARYREF, [ REMOVE_PKGNUMS_ARYREF ]</A></STRONG><DD>
202 CUSTNUM is a customer (see <A HREF="../FS/cust_main.html">FS::cust_main</A>)
205 PKGPARTS is a list of pkgparts specifying the the billing item definitions
207 <A HREF="../FS/part_pkg.html">FS::part_pkg</A>) to order for this customer. Duplicates are of course permitted.
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
213 <A HREF="../FS/pkg_svc.html">FS::pkg_svc</A>).
218 <H1><A NAME="VERSION">VERSION</A></H1>
220 $Id: cust_pkg.html,v 1.1 1999-08-04 12:13:27 ivan Exp $
224 <H1><A NAME="BUGS">BUGS</A></H1>
226 sub order is not OO. Perhaps it should be moved to FS::cust_main and made
230 In sub order, the <CODE>@pkgparts</CODE> array (passed by reference) is
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
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.
247 <H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
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