Freeside:4:Documentation:Developer/FS/part export/batch Common

From Freeside
Jump to: navigation, search

DESCRIPTION

FS::part_export::batch_Common should be inherited by any export that stores pending service changes and processes them all at once. It provides the external interface, and has an internal interface that the subclass must implement.

INTERFACE

ACTION in all of these methods is one of 'insert', 'delete', 'replace', 'suspend', 'unsuspend', 'pkg_change', or 'relocate'.

ARGUMENTS is the arguments to the export_* method:

- for insert, the new service

- for suspend, unsuspend, or delete, the service to act on

- for replace, the new service, followed by the old service

- for pkg_change, the service, followed by the new and old packages (as FS::cust_pkg objects)

- for relocate, the service, followed by the new location and old location (as FS::cust_location objects)

immediate ACTION, ARGUMENTS
This is called immediately from the export_* method, and does anything that needs to happen right then, except for inserting the FS::export_batch_item record. Optional. If it exists, it can return a non-empty error string to cause the export to fail.
data ACTION, ARGUMENTS
This is called just before inserting the batch item, and returns a scalar to store in the item's data field. If the export needs to remember anything about the service for the later batch-processing stage, it goes here. Remember that if the service is being deleted, the export will need to remember enough information to unprovision it when it's no longer in the database.
If this returns a reference, it will be frozen down with Base64-Storable.
process BATCH
This is called from freeside-daily, once for each batch still in the 'open' or 'closed' state. It's expected to do whatever needs to be done with the batch, and report failure via die().

METHODS

create_item ACTION, ARGUMENTS
Creates and inserts the FS::export_batch_item record for the action.
add_to_batch ITEM
Actually inserts ITEM into the appropriate open batch. All fields in ITEM will be populated except for 'batchnum'. By default, all items for a single export will go into the same batch, but subclass exports may override this method.
open_batch
Returns the current open batch for this export. If there isn't one yet, this will create one.