Difference between revisions of "Freeside:1.7:Documentation:Developer/FS/cust pkg"
(import from POD) |
m (Edit via perl MediaWiki framework (1.13)) |
||
Line 35: | Line 35: | ||
An FS::cust_pkg object represents a customer billing item. FS::cust_pkg inherits from FS::Record. The following fields are currently supported: | 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 [[Freeside:1.7:Documentation:Developer/FS/cust main|FS::cust_main]]); pkgpart - Billing item definition (see [[Freeside:1.7:Documentation:Developer/FS/part pkg|FS::part_pkg]]); setup - date; bill - date (next bill date); last_bill - last bill date; adjourn - date; susp - date; expire - date; cancel - date; otaker - order taker (assigned automatically if null, see [[Freeside:1.7:Documentation:Developer/FS/UID|FS::UID]]); manual_flag - If this field is set to 1, disables the automatic unsuspension of this package when using the '''unsuspendauto''' config file. | + | ; pkgnum - primary key (assigned automatically for new billing items); custnum - Customer (see [[Freeside:1.7:Documentation:Developer/FS/cust main|FS::cust_main]]); pkgpart - Billing item definition (see [[Freeside:1.7:Documentation:Developer/FS/part pkg|FS::part_pkg]]); setup - date; bill - date (next bill date); last_bill - last bill date; adjourn - date; susp - date; expire - date; cancel - date; otaker - order taker (assigned automatically if null, see [[Freeside:1.7:Documentation:Developer/FS/UID|FS::UID]]); manual_flag - If this field is set to 1, disables the automatic unsuspension of this package when using the '''unsuspendauto''' config file.; quantity - If not set, defaults to 1 |
Note: setup, bill, adjourn, susp, expire and cancel are specified as UNIX timestamps; see [[perlfunc#time|"time" in perlfunc]]. Also see [[Freeside:1.7:Documentation:Developer/Time/Local|Time::Local]] and [[Freeside:1.7:Documentation:Developer/Date/Parse|Date::Parse]] for conversion functions. | Note: setup, bill, adjourn, susp, expire and cancel are specified as UNIX timestamps; see [[perlfunc#time|"time" in perlfunc]]. Also see [[Freeside:1.7:Documentation:Developer/Time/Local|Time::Local]] and [[Freeside:1.7:Documentation:Developer/Date/Parse|Date::Parse]] for conversion functions. | ||
Line 65: | Line 65: | ||
:cancel is normally updated by the cancel method (and also the order subroutine in some cases). | :cancel is normally updated by the cancel method (and also the order subroutine in some cases). | ||
− | |||
− | |||
; check | ; 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. | :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. | ||
Line 72: | Line 70: | ||
:Cancels and removes all services (see [[Freeside:1.7:Documentation:Developer/FS/cust svc|FS::cust_svc]] and [[Freeside:1.7:Documentation:Developer/FS/part svc|FS::part_svc]]) in this package, then cancels the package itself (sets the cancel field to now). | :Cancels and removes all services (see [[Freeside:1.7:Documentation:Developer/FS/cust svc|FS::cust_svc]] and [[Freeside:1.7:Documentation:Developer/FS/part svc|FS::part_svc]]) in this package, then cancels the package itself (sets the cancel field to now). | ||
− | :Available options are: ''quiet'' | + | :Available options are: ''quiet'' ''reason'' ''date'' |
− | :''quiet'' can be set true to supress email cancellation notices. | + | :''quiet'' can be set true to supress email cancellation notices. ''reason'' can be set to a reasonnum (see [[Freeside:1.7:Documentation:Developer/FS/reason|FS::reason]]) explaining the action ''date'' can be set to a unix style timestamp to specify when to cancel (expire) |
:If there is an error, returns the error, otherwise returns false. | :If there is an error, returns the error, otherwise returns false. | ||
− | ; suspend | + | ; unexpire |
+ | :Cancels any pending expiration (sets the expire field to null). | ||
+ | |||
+ | :If there is an error, returns the error, otherwise returns false. | ||
+ | ; suspend [ OPTION => VALUE ... ] | ||
:Suspends all services (see [[Freeside:1.7:Documentation:Developer/FS/cust svc|FS::cust_svc]] and [[Freeside:1.7:Documentation:Developer/FS/part svc|FS::part_svc]]) in this package, then suspends the package itself (sets the susp field to now). | :Suspends all services (see [[Freeside:1.7:Documentation:Developer/FS/cust svc|FS::cust_svc]] and [[Freeside:1.7:Documentation:Developer/FS/part svc|FS::part_svc]]) in this package, then suspends the package itself (sets the susp field to now). | ||
+ | |||
+ | :Available options are: ''reason'' ''date'' | ||
+ | |||
+ | :''date'' can be set to a unix style timestamp to specify when to suspend (adjourn) ''reason'' can be set to a reasonnum (see [[Freeside:1.7:Documentation:Developer/FS/reason|FS::reason]]) explaining the action | ||
:If there is an error, returns the error, otherwise returns false. | :If there is an error, returns the error, otherwise returns false. | ||
Line 87: | Line 93: | ||
:''adjust_next_bill'' can be set true to adjust the next bill date forward by the amount of time the account was inactive. This was set true by default since 1.4.2 and 1.5.0pre6; however, starting with 1.7.0 this needs to be explicitly requested. Price plans for which this makes sense (anniversary-date based than prorate or subscription) could have an option to enable this behaviour? | :''adjust_next_bill'' can be set true to adjust the next bill date forward by the amount of time the account was inactive. This was set true by default since 1.4.2 and 1.5.0pre6; however, starting with 1.7.0 this needs to be explicitly requested. Price plans for which this makes sense (anniversary-date based than prorate or subscription) could have an option to enable this behaviour? | ||
+ | |||
+ | :If there is an error, returns the error, otherwise returns false. | ||
+ | ; unadjourn | ||
+ | :Cancels any pending suspension (sets the adjourn field to null). | ||
:If there is an error, returns the error, otherwise returns false. | :If there is an error, returns the error, otherwise returns false. | ||
; last_bill | ; last_bill | ||
:Returns the last bill date, or if there is no last bill date, the setup date. Useful for billing metered services. | :Returns the last bill date, or if there is no last bill date, the setup date. Useful for billing metered services. | ||
− | ; last_reason | + | ; last_cust_pkg_reason ACTION |
− | :Returns the most recent FS::reason associated with the package. | + | :Returns the most recent ACTION FS::cust_pkg_reason associated with the package. Returns false if there is no reason or the package is not currenly ACTION'd ACTION is one of adjourn, susp, cancel, or expire. |
+ | ; last_reason ACTION | ||
+ | :Returns the most recent ACTION FS::reason associated with the package. Returns false if there is no reason or the package is not currenly ACTION'd ACTION is one of adjourn, susp, cancel, or expire. | ||
; part_pkg | ; part_pkg | ||
:Returns the definition for this billing item, as an FS::part_pkg object (see [[Freeside:1.7:Documentation:Developer/FS/part pkg|FS::part_pkg]]). | :Returns the definition for this billing item, as an FS::part_pkg object (see [[Freeside:1.7:Documentation:Developer/FS/part pkg|FS::part_pkg]]). | ||
Line 107: | Line 119: | ||
; cust_bill_pkg | ; cust_bill_pkg | ||
:Returns any invoice line items for this package (see [[Freeside:1.7:Documentation:Developer/FS/cust bill pkg|FS::cust_bill_pkg]]). | :Returns any invoice line items for this package (see [[Freeside:1.7:Documentation:Developer/FS/cust bill pkg|FS::cust_bill_pkg]]). | ||
+ | ; cust_pkg_detail [ DETAILTYPE ] | ||
+ | :Returns any customer package details for this package (see [[Freeside:1.7:Documentation:Developer/FS/cust pkg detail|FS::cust_pkg_detail]]). | ||
+ | |||
+ | :DETAILTYPE can be set to "I" for invoice details or "C" for comments. | ||
+ | ; set_cust_pkg_detail DETAILTYPE [ DETAIL, DETAIL, ... ] | ||
+ | :Sets customer package details for this package (see [[Freeside:1.7:Documentation:Developer/FS/cust pkg detail|FS::cust_pkg_detail]]). | ||
+ | |||
+ | :DETAILTYPE can be set to "I" for invoice details or "C" for comments. | ||
+ | |||
+ | :If there is an error, returns the error, otherwise returns false. | ||
; cust_svc [ SVCPART ] | ; cust_svc [ SVCPART ] | ||
:Returns the services for this package, as FS::cust_svc objects (see [[Freeside:1.7:Documentation:Developer/FS/cust svc|FS::cust_svc]]). If a svcpart is specified, return only the matching services. | :Returns the services for this package, as FS::cust_svc objects (see [[Freeside:1.7:Documentation:Developer/FS/cust svc|FS::cust_svc]]). If a svcpart is specified, return only the matching services. | ||
Line 139: | Line 161: | ||
:Returns a list of lists, calling the label method for all (historical) services (see [[Freeside:1.7:Documentation:Developer/FS/h cust svc|FS::h_cust_svc]]) of this billing item. | :Returns a list of lists, calling the label method for all (historical) services (see [[Freeside:1.7:Documentation:Developer/FS/h cust svc|FS::h_cust_svc]]) of this billing item. | ||
; h_labels_short END_TIMESTAMP [ START_TIMESTAMP ] | ; h_labels_short END_TIMESTAMP [ START_TIMESTAMP ] | ||
− | :Like h_labels, except returns a simple flat list, and shortens long (currently >5) lists of identical services to one line that lists the service label and the number of individual services rather than individual items. | + | :Like h_labels, except returns a simple flat list, and shortens long (currently >5 or the cust_bill-max_same_services configuration value) lists of identical services to one line that lists the service label and the number of individual services rather than individual items. |
; cust_main | ; cust_main | ||
:Returns the parent customer object (see [[Freeside:1.7:Documentation:Developer/FS/cust main|FS::cust_main]]). | :Returns the parent customer object (see [[Freeside:1.7:Documentation:Developer/FS/cust main|FS::cust_main]]). | ||
Line 154: | Line 176: | ||
:TIMESTAMP_START and TIMESTAMP_END are specified as UNIX timestamps; see [[perlfunc#time|"time" in perlfunc]]. Also see [[Freeside:1.7:Documentation:Developer/Time/Local|Time::Local]] and [[Freeside:1.7:Documentation:Developer/Date/Parse|Date::Parse]] for conversion functions. | :TIMESTAMP_START and TIMESTAMP_END are specified as UNIX timestamps; see [[perlfunc#time|"time" in perlfunc]]. Also see [[Freeside:1.7:Documentation:Developer/Time/Local|Time::Local]] and [[Freeside:1.7:Documentation:Developer/Date/Parse|Date::Parse]] for conversion functions. | ||
− | ; transfer DEST_PKGNUM | DEST_CUST_PKG, [ OPTION => VALUE ... ] | + | ; quantity; transfer DEST_PKGNUM | DEST_CUST_PKG, [ OPTION => VALUE ... ] |
:Transfers as many services as possible from this package to another package. | :Transfers as many services as possible from this package to another package. | ||
Line 180: | Line 202: | ||
; cancel_sql =item cancelled_sql | ; cancel_sql =item cancelled_sql | ||
:Returns an SQL exprression identifying cancelled packages. | :Returns an SQL exprression identifying cancelled packages. | ||
+ | ; search_sql HASHREF | ||
+ | :(Class method) | ||
+ | |||
+ | :Returns a qsearch hash expression to search for parameters specified in HASHREF. Valid parameters are | ||
+ | :; agentnum:; magic | ||
+ | ::active, inactive, suspended, cancel (or cancelled) | ||
+ | :; status | ||
+ | ::active, inactive, suspended, one-time charge, inactive, cancel (or cancelled) | ||
+ | :; classnum:; pkgpart | ||
+ | ::list specified how? | ||
+ | :; setup | ||
+ | ::arrayref of beginning and ending epoch date | ||
+ | :; last_bill | ||
+ | ::arrayref of beginning and ending epoch date | ||
+ | :; bill | ||
+ | ::arrayref of beginning and ending epoch date | ||
+ | :; adjourn | ||
+ | ::arrayref of beginning and ending epoch date | ||
+ | :; susp | ||
+ | ::arrayref of beginning and ending epoch date | ||
+ | :; expire | ||
+ | ::arrayref of beginning and ending epoch date | ||
+ | :; cancel | ||
+ | ::arrayref of beginning and ending epoch date | ||
+ | :; query | ||
+ | ::pkgnum or APKG_pkgnum | ||
+ | :; cust_fields | ||
+ | ::a value suited to passing to FS::UI::Web::cust_header | ||
+ | :; CurrentUser | ||
+ | ::specifies the user for agent virtualization | ||
==SUBROUTINES== | ==SUBROUTINES== | ||
Line 190: | Line 242: | ||
:RETURN_CUST_PKG_ARRAYREF, if specified, will be filled in with the newly-created cust_pkg objects. | :RETURN_CUST_PKG_ARRAYREF, if specified, will be filled in with the newly-created cust_pkg objects. | ||
+ | ; bulk_change PKGPARTS_ARYREF, REMOVE_PKGNUMS_ARYREF [ RETURN_CUST_PKG_ARRAYREF ] | ||
+ | :PKGPARTS is a list of pkgparts specifying the the billing item definitions (see [[Freeside:1.7:Documentation:Developer/FS/part pkg|FS::part_pkg]]) to order for this customer. Duplicates are of course permitted. | ||
+ | |||
+ | :REMOVE_PKGNUMS is an list of pkgnums specifying the billing items to replace. The services (see [[Freeside:1.7:Documentation:Developer/FS/cust svc|FS::cust_svc]]) are moved to the new billing items. An error is returned if this is not possible (see [[Freeside:1.7:Documentation:Developer/FS/pkg svc|FS::pkg_svc]]). | ||
+ | |||
+ | :RETURN_CUST_PKG_ARRAYREF, if specified, will be filled in with the newly-created cust_pkg objects. | ||
+ | ; insert_reason | ||
+ | :Associates this package with a (suspension or cancellation) reason (see [[Freeside:1.7:Documentation:Developer/FS/cust pkg reason|FS::cust_pkg_reason]], possibly inserting a new reason on the fly (see [[Freeside:1.7:Documentation:Developer/FS/reason|FS::reason]]). | ||
+ | |||
+ | :Available options are: | ||
+ | :; reason - can be set to a cancellation reason (see FS:reason), either a reasonnum of an existing reason, or passing a hashref will create a new reason. The hashref should have the following keys: typenum - Reason type (see [[Freeside:1.7:Documentation:Developer/FS/reason type|FS::reason_type]], reason - Text of the new reason.:; otaker_reason - the access_user (see [[Freeside:1.7:Documentation:Developer/FS/access user|FS::access_user]]) providing the reason:; date - a unix timestamp:; action - the action (cancel, susp, adjourn, expire) associated with the reason | ||
+ | :If there is an error, returns the error, otherwise returns false. | ||
; set_usage USAGE_VALUE_HASHREF | ; set_usage USAGE_VALUE_HASHREF | ||
:USAGE_VALUE_HASHREF is a hashref of svc_acct usage columns and the amounts to which they should be set (see [[Freeside:1.7:Documentation:Developer/FS/svc acct|FS::svc_acct]]). Currently seconds, upbytes, downbytes, and totalbytes are appropriate keys. | :USAGE_VALUE_HASHREF is a hashref of svc_acct usage columns and the amounts to which they should be set (see [[Freeside:1.7:Documentation:Developer/FS/svc acct|FS::svc_acct]]). Currently seconds, upbytes, downbytes, and totalbytes are appropriate keys. | ||
Line 212: | Line 276: | ||
Hey! '''The above document had some coding errors, which are explained below:''' | Hey! '''The above document had some coding errors, which are explained below:''' | ||
− | ; Around line | + | ; Around line 2046: |
:You forgot a '=back' before '=head1' | :You forgot a '=back' before '=head1' |
Latest revision as of 13:01, 23 July 2009
Contents
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; $seconds = $record->seconds_since($timestamp); $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 FS::cust_main); pkgpart - Billing item definition (see FS::part_pkg); setup - date; bill - date (next bill date); last_bill - last bill date; adjourn - date; susp - date; expire - date; cancel - date; otaker - order taker (assigned automatically if null, see FS::UID); manual_flag - If this field is set to 1, disables the automatic unsuspension of this package when using the unsuspendauto config file.; quantity - If not set, defaults to 1
Note: setup, bill, adjourn, susp, expire and cancel are specified as UNIX timestamps; see "time" in perlfunc. Also see Time::Local and Date::Parse for conversion functions.
METHODS
- new HASHREF
- Create a new billing item. To add the item to the database, see "insert".
- insert [ OPTION => VALUE ... ]
- Adds this billing item to the database ("Orders" the item). If there is an error, returns the error, otherwise returns false.
- If the additional field promo_code is defined instead of pkgpart, it will be used to look up the package definition and agent restrictions will be ignored.
- The following options are available: change
- change, if set true, supresses any referral credit to a referring customer.
- delete
- This method now works but you probably shouldn't use it.
- 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, adjourn, 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 FS::cust_main).
- 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 [ OPTION => VALUE ... ]
- Cancels and removes all services (see FS::cust_svc and FS::part_svc) in this package, then cancels the package itself (sets the cancel field to now).
- Available options are: quiet reason date
- quiet can be set true to supress email cancellation notices. reason can be set to a reasonnum (see FS::reason) explaining the action date can be set to a unix style timestamp to specify when to cancel (expire)
- If there is an error, returns the error, otherwise returns false.
- unexpire
- Cancels any pending expiration (sets the expire field to null).
- If there is an error, returns the error, otherwise returns false.
- suspend [ OPTION => VALUE ... ]
- Suspends all services (see FS::cust_svc and FS::part_svc) in this package, then suspends the package itself (sets the susp field to now).
- Available options are: reason date
- date can be set to a unix style timestamp to specify when to suspend (adjourn) reason can be set to a reasonnum (see FS::reason) explaining the action
- If there is an error, returns the error, otherwise returns false.
- unsuspend [ OPTION => VALUE ... ]
- Unsuspends all services (see FS::cust_svc and FS::part_svc) in this package, then unsuspends the package itself (clears the susp field and the adjourn field if it is in the past).
- Available options are: adjust_next_bill.
- adjust_next_bill can be set true to adjust the next bill date forward by the amount of time the account was inactive. This was set true by default since 1.4.2 and 1.5.0pre6; however, starting with 1.7.0 this needs to be explicitly requested. Price plans for which this makes sense (anniversary-date based than prorate or subscription) could have an option to enable this behaviour?
- If there is an error, returns the error, otherwise returns false.
- unadjourn
- Cancels any pending suspension (sets the adjourn field to null).
- If there is an error, returns the error, otherwise returns false.
- last_bill
- Returns the last bill date, or if there is no last bill date, the setup date. Useful for billing metered services.
- last_cust_pkg_reason ACTION
- Returns the most recent ACTION FS::cust_pkg_reason associated with the package. Returns false if there is no reason or the package is not currenly ACTION'd ACTION is one of adjourn, susp, cancel, or expire.
- last_reason ACTION
- Returns the most recent ACTION FS::reason associated with the package. Returns false if there is no reason or the package is not currenly ACTION'd ACTION is one of adjourn, susp, cancel, or expire.
- part_pkg
- Returns the definition for this billing item, as an FS::part_pkg object (see FS::part_pkg).
- old_cust_pkg
- Returns the cancelled package this package was changed from, if any.
- calc_setup
- Calls the calc_setup of the FS::part_pkg object associated with this billing item.
- calc_recur
- Calls the calc_recur of the FS::part_pkg object associated with this billing item.
- calc_remain
- Calls the calc_remain of the FS::part_pkg object associated with this billing item.
- calc_cancel
- Calls the calc_cancel of the FS::part_pkg object associated with this billing item.
- cust_bill_pkg
- Returns any invoice line items for this package (see FS::cust_bill_pkg).
- cust_pkg_detail [ DETAILTYPE ]
- Returns any customer package details for this package (see FS::cust_pkg_detail).
- DETAILTYPE can be set to "I" for invoice details or "C" for comments.
- set_cust_pkg_detail DETAILTYPE [ DETAIL, DETAIL, ... ]
- Sets customer package details for this package (see FS::cust_pkg_detail).
- DETAILTYPE can be set to "I" for invoice details or "C" for comments.
- If there is an error, returns the error, otherwise returns false.
- cust_svc [ SVCPART ]
- Returns the services for this package, as FS::cust_svc objects (see FS::cust_svc). If a svcpart is specified, return only the matching services.
- overlimit [ SVCPART ]
- Returns the services for this package which have exceeded their usage limit as FS::cust_svc objects (see FS::cust_svc). If a svcpart is specified, return only the matching services.
- h_cust_svc END_TIMESTAMP [ START_TIMESTAMP ]
- Returns historical services for this package created before END TIMESTAMP and (optionally) not cancelled before START_TIMESTAMP, as FS::h_cust_svc objects (see FS::h_cust_svc).
- num_cust_svc [ SVCPART ]
- Returns the number of provisioned services for this package. If a svcpart is specified, counts only the matching services.
- available_part_svc
- Returns a list of FS::part_svc objects representing services included in this package but not yet provisioned. Each FS::part_svc object also has an extra field, num_avail, which specifies the number of available services.
- part_svc
- Returns a list of FS::part_svc objects representing provisioned and available services included in this package. Each FS::part_svc object also has the following extra fields:
- num_cust_svc (count)
- ; num_avail (quantity - count):; cust_pkg_svc (services) - array reference containing the provisioned services, as cust_svc objects
- svcnum label -> ($cust_svc->label)[1]
- extra_part_svc
- Returns a list of FS::part_svc objects corresponding to services in this package which are still provisioned but not (any longer) available in the package definition.
- status
- Returns a short status string for this package, currently:
- not yet billed
- ; one-time charge:; active:; suspended:; cancelled; statuses
- Class method that returns the list of possible status strings for pacakges (see the status method). For example:
@statuses = FS::cust_pkg->statuses();
- statuscolor
- Returns a hex triplet color string for this package's status.
- labels
- Returns a list of lists, calling the label method for all services (see FS::cust_svc) of this billing item.
- h_labels END_TIMESTAMP [ START_TIMESTAMP ]
- Like the labels method, but returns historical information on services that were active as of END_TIMESTAMP and (optionally) not cancelled before START_TIMESTAMP.
- Returns a list of lists, calling the label method for all (historical) services (see FS::h_cust_svc) of this billing item.
- h_labels_short END_TIMESTAMP [ START_TIMESTAMP ]
- Like h_labels, except returns a simple flat list, and shortens long (currently >5 or the cust_bill-max_same_services configuration value) lists of identical services to one line that lists the service label and the number of individual services rather than individual items.
- cust_main
- Returns the parent customer object (see FS::cust_main).
- seconds_since TIMESTAMP
- Returns the number of seconds all accounts (see FS::svc_acct) in this package have been online since TIMESTAMP, according to the session monitor.
- TIMESTAMP is specified as a UNIX timestamp; see "time" in perlfunc. Also see Time::Local and Date::Parse for conversion functions.
- seconds_since_sqlradacct TIMESTAMP_START TIMESTAMP_END
- Returns the numbers of seconds all accounts (see FS::svc_acct) in this package have been online between TIMESTAMP_START (inclusive) and TIMESTAMP_END (exclusive).
- TIMESTAMP_START and TIMESTAMP_END are specified as UNIX timestamps; see "time" in perlfunc. Also see Time::Local and Date::Parse for conversion functions.
- attribute_since_sqlradacct TIMESTAMP_START TIMESTAMP_END ATTRIBUTE
- Returns the sum of the given attribute for all accounts (see FS::svc_acct) in this package for sessions ending between TIMESTAMP_START (inclusive) and TIMESTAMP_END (exclusive).
- TIMESTAMP_START and TIMESTAMP_END are specified as UNIX timestamps; see "time" in perlfunc. Also see Time::Local and Date::Parse for conversion functions.
- quantity; transfer DEST_PKGNUM | DEST_CUST_PKG, [ OPTION => VALUE ... ]
- Transfers as many services as possible from this package to another package.
- The destination package can be specified by pkgnum by passing an FS::cust_pkg object. The destination package must already exist.
- Services are moved only if the destination allows services with the correct svcpart (not svcdb), unless the change_svcpart option is set true. Use this option with caution! No provision is made for export differences between the old and new service definitions. Probably only should be used when your exports for all service definitions of a given svcdb are identical. (attempt a transfer without it first, to move all possible svcpart-matching services)
- Any services that can't be moved remain in the original package.
- Returns an error, if there is one; otherwise, returns the number of services that couldn't be moved.
- reexport
- This method is deprecated. See the depend_jobnum option to the insert and order_pkgs methods in FS::cust_main for a better way to defer provisioning.
CLASS METHODS
- recurring_sql
- Returns an SQL expression identifying recurring packages.
- onetime_sql
- Returns an SQL expression identifying one-time packages.
- active_sql
- Returns an SQL expression identifying active packages.
- inactive_sql
- Returns an SQL expression identifying inactive packages (one-time packages that are otherwise unsuspended/uncancelled).
- susp_sql =item suspended_sql
- Returns an SQL expression identifying suspended packages.
- cancel_sql =item cancelled_sql
- Returns an SQL exprression identifying cancelled packages.
- search_sql HASHREF
- (Class method)
- Returns a qsearch hash expression to search for parameters specified in HASHREF. Valid parameters are
- agentnum
- ; magic
- active, inactive, suspended, cancel (or cancelled)
- status
- active, inactive, suspended, one-time charge, inactive, cancel (or cancelled)
- classnum
- ; pkgpart
- list specified how?
- setup
- arrayref of beginning and ending epoch date
- last_bill
- arrayref of beginning and ending epoch date
- bill
- arrayref of beginning and ending epoch date
- adjourn
- arrayref of beginning and ending epoch date
- susp
- arrayref of beginning and ending epoch date
- expire
- arrayref of beginning and ending epoch date
- cancel
- arrayref of beginning and ending epoch date
- query
- pkgnum or APKG_pkgnum
- cust_fields
- a value suited to passing to FS::UI::Web::cust_header
- CurrentUser
- specifies the user for agent virtualization
SUBROUTINES
- order CUSTNUM, PKGPARTS_ARYREF, [ REMOVE_PKGNUMS_ARYREF [ RETURN_CUST_PKG_ARRAYREF ] ]
- CUSTNUM is a customer (see FS::cust_main)
- PKGPARTS is a list of pkgparts specifying the the billing item definitions (see FS::part_pkg) 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 FS::cust_svc) are moved to the new billing items. An error is returned if this is not possible (see FS::pkg_svc). An empty arrayref is equivalent to not specifying this parameter.
- RETURN_CUST_PKG_ARRAYREF, if specified, will be filled in with the newly-created cust_pkg objects.
- bulk_change PKGPARTS_ARYREF, REMOVE_PKGNUMS_ARYREF [ RETURN_CUST_PKG_ARRAYREF ]
- PKGPARTS is a list of pkgparts specifying the the billing item definitions (see FS::part_pkg) to order for this customer. Duplicates are of course permitted.
- REMOVE_PKGNUMS is an list of pkgnums specifying the billing items to replace. The services (see FS::cust_svc) are moved to the new billing items. An error is returned if this is not possible (see FS::pkg_svc).
- RETURN_CUST_PKG_ARRAYREF, if specified, will be filled in with the newly-created cust_pkg objects.
- insert_reason
- Associates this package with a (suspension or cancellation) reason (see FS::cust_pkg_reason, possibly inserting a new reason on the fly (see FS::reason).
- Available options are:
- reason - can be set to a cancellation reason (see FS
- reason), either a reasonnum of an existing reason, or passing a hashref will create a new reason. The hashref should have the following keys: typenum - Reason type (see FS::reason_type, reason - Text of the new reason.:; otaker_reason - the access_user (see FS::access_user) providing the reason:; date - a unix timestamp:; action - the action (cancel, susp, adjourn, expire) associated with the reason
- If there is an error, returns the error, otherwise returns false.
- set_usage USAGE_VALUE_HASHREF
- USAGE_VALUE_HASHREF is a hashref of svc_acct usage columns and the amounts to which they should be set (see FS::svc_acct). Currently seconds, upbytes, downbytes, and totalbytes are appropriate keys.
- All svc_accts which are part of this package have their values reset.
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_domain, FS::svc_www, FS::svc_ip and FS::svc_forward 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.
Now that things are transactional should the check in the insert method be moved to check ?
SEE ALSO
FS::Record, FS::cust_main, FS::part_pkg, FS::cust_svc, FS::pkg_svc, schema.html from the base documentation
POD ERRORS
Hey! The above document had some coding errors, which are explained below:
- Around line 2046:
- You forgot a '=back' before '=head1'