Initial revision
[freeside.git] / htdocs / docs / man / cust_pkg.txt
1 NAME
2     FS::cust_pkg - Object methods for cust_pkg objects
3
4 SYNOPSIS
5       use FS::cust_pkg;
6
7       $record = create FS::cust_pkg \%hash;
8       $record = create FS::cust_pkg { 'column' => 'value' };
9
10       $error = $record->insert;
11
12       $error = $new_record->replace($old_record);
13
14       $error = $record->delete;
15
16       $error = $record->check;
17
18       $error = $record->cancel;
19
20       $error = $record->suspend;
21
22       $error = $record->unsuspend;
23
24       $error = FS::cust_pkg::order( $custnum, \@pkgparts );
25       $error = FS::cust_pkg::order( $custnum, \@pkgparts, \@remove_pkgnums ] );
26
27 DESCRIPTION
28     An FS::cust_pkg object represents a customer billing item.
29     FS::cust_pkg inherits from FS::Record. The following fields are
30     currently supported:
31
32     pkgnum - primary key (assigned automatically for new billing items)
33     custnum - Customer (see the FS::cust_main manpage)
34     pkgpart - Billing item definition (see the FS::part_pkg manpage)
35     setup - date
36     bill - date
37     susp - date
38     expire - date
39     cancel - date
40     otaker - order taker (assigned automatically if null, see the FS::UID manpage)
41     Note: setup, bill, susp, expire and cancel are specified as UNIX
42     timestamps; see the section on "time" in the perlfunc manpage.
43     Also see the Time::Local manpage and the Date::Parse manpage for
44     conversion functions.
45
46 METHODS
47     create HASHREF
48         Create a new billing item. To add the item to the database,
49         see the section on "insert".
50
51     insert
52         Adds this billing item to the database ("Orders" the item).
53         If there is an error, returns the error, otherwise returns
54         false.
55
56     delete
57         Currently unimplemented. You don't want to delete billing
58         items, because there would then be no record the customer
59         ever purchased the item. Instead, see the cancel method.
60
61         sub delete { return "Can't delete cust_pkg records!"; }
62
63     replace OLD_RECORD
64         Replaces the OLD_RECORD with this one in the database. If
65         there is an error, returns the error, otherwise returns
66         false.
67
68         Currently, custnum, setup, bill, susp, expire, and cancel
69         may be changed.
70
71         pkgpart may not be changed, but see the order subroutine.
72
73         setup and bill are normally updated by calling the bill
74         method of a customer object (see the FS::cust_main manpage).
75
76         suspend is normally updated by the suspend and unsuspend
77         methods.
78
79         cancel is normally updated by the cancel method (and also
80         the order subroutine in some cases).
81
82     check
83         Checks all fields to make sure this is a valid billing item.
84         If there is an error, returns the error, otherwise returns
85         false. Called by the insert and replace methods.
86
87     cancel
88         Cancels and removes all services (see the FS::cust_svc
89         manpage and the FS::part_svc manpage) in this package, then
90         cancels the package itself (sets the cancel field to now).
91
92         If there is an error, returns the error, otherwise returns
93         false.
94
95     suspend
96         Suspends all services (see the FS::cust_svc manpage and the
97         FS::part_svc manpage) in this package, then suspends the
98         package itself (sets the susp field to now).
99
100         If there is an error, returns the error, otherwise returns
101         false.
102
103     unsuspend
104         Unsuspends all services (see the FS::cust_svc manpage and
105         the FS::part_svc manpage) in this package, then unsuspends
106         the package itself (clears the susp field).
107
108         If there is an error, returns the error, otherwise returns
109         false.
110
111 SUBROUTINES
112     order CUSTNUM, PKGPARTS_ARYREF, [ REMOVE_PKGNUMS_ARYREF ]
113         CUSTNUM is a customer (see the FS::cust_main manpage)
114
115         PKGPARTS is a list of pkgparts specifying the the billing
116         item definitions (see the FS::part_pkg manpage) to order for
117         this customer. Duplicates are of course permitted.
118
119         REMOVE_PKGNUMS is an optional list of pkgnums specifying the
120         billing items to remove for this customer. The services (see
121         the FS::cust_svc manpage) are moved to the new billing
122         items. An error is returned if this is not possible (see the
123         FS::pkg_svc manpage).
124
125 BUGS
126     It doesn't properly override FS::Record yet.
127
128     sub order is not OO. Perhaps it should be moved to FS::cust_main
129     and made so?
130
131     In sub order, the @pkgparts array (passed by reference) is
132     clobbered.
133
134     Also in sub order, no money is adjusted. Once FS::part_pkg
135     defines a standard method to pass dates to the recur_prog
136     expression, it should do so.
137
138 SEE ALSO
139     the FS::Record manpage, the FS::cust_main manpage, the
140     FS::part_pkg manpage, the FS::cust_svc manpage , the FS::pkg_svc
141     manpage, schema.html from the base documentation
142
143 HISTORY
144     ivan@voicenet.com 97-jul-1 - 21
145
146     fixed for new agent->agent_type->type_pkgs in &order
147     ivan@sisd.com 98-mar-7
148
149     pod ivan@sisd.com 98-sep-21
150