summaryrefslogtreecommitdiff
path: root/htdocs/docs/man/cust_pkg.txt
blob: 3954031927b5cacaf7fe06f6b6a0cb8bea1f487a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
NAME
    FS::cust_pkg - Object methods for cust_pkg objects

SYNOPSIS
      use FS::cust_pkg;

      $record = new FS::cust_pkg \%hash;
      $record = new FS::cust_pkg { 'column' => 'value' };

      $error = $record->insert;

      $error = $new_record->replace($old_record);

      $error = $record->delete;

      $error = $record->check;

      $error = $record->cancel;

      $error = $record->suspend;

      $error = $record->unsuspend;

      $part_pkg = $record->part_pkg;

      @labels = $record->labels;

      $error = FS::cust_pkg::order( $custnum, \@pkgparts );
      $error = FS::cust_pkg::order( $custnum, \@pkgparts, \@remove_pkgnums ] );

DESCRIPTION
    An FS::cust_pkg object represents a customer billing item.
    FS::cust_pkg inherits from FS::Record. The following fields are
    currently supported:

    pkgnum - primary key (assigned automatically for new billing items)
    custnum - Customer (see the FS::cust_main manpage)
    pkgpart - Billing item definition (see the FS::part_pkg manpage)
    setup - date
    bill - date
    susp - date
    expire - date
    cancel - date
    otaker - order taker (assigned automatically if null, see the FS::UID manpage)
    Note: setup, bill, susp, expire and cancel are specified as UNIX
    timestamps; see the section on "time" in the perlfunc manpage.
    Also see the Time::Local manpage and the Date::Parse manpage for
    conversion functions.

METHODS
    new HASHREF
        Create a new billing item. To add the item to the database,
        see the section on "insert".

    insert
        Adds this billing item to the database ("Orders" the item).
        If there is an error, returns the error, otherwise returns
        false.

        sub insert { my $self = shift;

          # custnum might not have have been defined in sub check (for one-shot new
          # customers), so check it here instead

          my $error = $self->ut_number('custnum');
          return $error if $error

          return "Unknown customer"
            unless qsearchs( 'cust_main', { 'custnum' => $self->custnum } );

          $self->SUPER::insert;

        }

    delete
        Currently unimplemented. You don't want to delete billing
        items, because there would then be no record the customer
        ever purchased the item. Instead, see the cancel method.

    replace OLD_RECORD
        Replaces the OLD_RECORD with this one in the database. If
        there is an error, returns the error, otherwise returns
        false.

        Currently, custnum, setup, bill, susp, expire, and cancel
        may be changed.

        Changing pkgpart may have disasterous effects. See the order
        subroutine.

        setup and bill are normally updated by calling the bill
        method of a customer object (see the FS::cust_main manpage).

        suspend is normally updated by the suspend and unsuspend
        methods.

        cancel is normally updated by the cancel method (and also
        the order subroutine in some cases).

    check
        Checks all fields to make sure this is a valid billing item.
        If there is an error, returns the error, otherwise returns
        false. Called by the insert and replace methods.

    cancel
        Cancels and removes all services (see the FS::cust_svc
        manpage and the FS::part_svc manpage) in this package, then
        cancels the package itself (sets the cancel field to now).

        If there is an error, returns the error, otherwise returns
        false.

    suspend
        Suspends all services (see the FS::cust_svc manpage and the
        FS::part_svc manpage) in this package, then suspends the
        package itself (sets the susp field to now).

        If there is an error, returns the error, otherwise returns
        false.

    unsuspend
        Unsuspends all services (see the FS::cust_svc manpage and
        the FS::part_svc manpage) in this package, then unsuspends
        the package itself (clears the susp field).

        If there is an error, returns the error, otherwise returns
        false.

    part_pkg
        Returns the definition for this billing item, as an
        FS::part_pkg object (see L<FS::part_pkg).

    labels
        Returns a list of lists, calling the label method for all
        services (see the FS::cust_svc manpage) of this billing
        item.

SUBROUTINES
    order CUSTNUM, PKGPARTS_ARYREF, [ REMOVE_PKGNUMS_ARYREF ]
        CUSTNUM is a customer (see the FS::cust_main manpage)

        PKGPARTS is a list of pkgparts specifying the the billing
        item definitions (see the FS::part_pkg manpage) to order for
        this customer. Duplicates are of course permitted.

        REMOVE_PKGNUMS is an optional list of pkgnums specifying the
        billing items to remove for this customer. The services (see
        the FS::cust_svc manpage) are moved to the new billing
        items. An error is returned if this is not possible (see the
        FS::pkg_svc manpage).

VERSION
    $Id: cust_pkg.txt,v 1.4 1999-04-08 13:39:32 ivan Exp $

BUGS
    sub order is not OO. Perhaps it should be moved to FS::cust_main
    and made so?

    In sub order, the @pkgparts array (passed by reference) is
    clobbered.

    Also in sub order, no money is adjusted. Once FS::part_pkg
    defines a standard method to pass dates to the recur_prog
    expression, it should do so.

    FS::svc_acct, FS::svc_acct_sm, and FS::svc_domain are loaded via
    'use' at compile time, rather than via 'require' in sub { setup,
    suspend, unsuspend, cancel } because they use %FS::UID::callback
    to load configuration values. Probably need a subroutine which
    decides what to do based on whether or not we've fetched the
    user yet, rather than a hash. See FS::UID and the TODO.

SEE ALSO
    the FS::Record manpage, the FS::cust_main manpage, the
    FS::part_pkg manpage, the FS::cust_svc manpage , the FS::pkg_svc
    manpage, schema.html from the base documentation

HISTORY
    ivan@voicenet.com 97-jul-1 - 21

    fixed for new agent->agent_type->type_pkgs in &order
    ivan@sisd.com 98-mar-7

    pod ivan@sisd.com 98-sep-21

    $Log: cust_pkg.txt,v $
    Revision 1.4  1999-04-08 13:39:32  ivan
    convert from pod for 1.2.0 release
 Revision 1.9 1999/03/29 01:11:51 ivan use
    FS::type_pkgs

    Revision 1.8 1999/03/25 13:48:14 ivan allow empty custnum in sub
    check (but call that an error in sub insert), for one-screen new
    customer entry

    Revision 1.7 1999/02/09 09:55:06 ivan invoices show line items
    for each service in a package (see the label method of
    FS::cust_svc)

    Revision 1.6 1999/01/25 12:26:12 ivan yet more mod_perl stuff

    Revision 1.5 1999/01/18 21:58:07 ivan esthetic: eq and ne were
    used in a few places instead of == and !=

    Revision 1.4 1998/12/29 11:59:45 ivan mostly properly OO, some
    work still to be done with svc_ stuff

    Revision 1.3 1998/11/15 13:01:35 ivan allow pkgpart changing
    (for per-customer custom pricing). warn about it in doc

    Revision 1.2 1998/11/12 03:42:45 ivan added label method