1 package FS::export_batch;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
9 FS::export_batch - Object methods for export_batch records
15 $record = new FS::export_batch \%hash;
16 $record = new FS::export_batch { 'column' => 'value' };
18 $error = $record->insert;
20 $error = $new_record->replace($old_record);
22 $error = $record->delete;
24 $error = $record->check;
28 An FS::export_batch object represents a batch of records being processed
29 by an export. This mechanism allows exports to process multiple pending
30 service changes at the end of day or some other scheduled time, rather
31 than doing everything in realtime or near-realtime (via the job queue).
33 FS::export_batch inherits from FS::Record. The following fields are
44 The L<FS::part_export> object that created this batch.
48 The time the batch was created.
52 A status string. Allowed values are "open" (for a newly created batch that
53 can receive additional items), "closed" (for a batch that is no longer
54 allowed to receive items but is still being processed), "done" (for a batch
55 that is finished processing), and "failed" (if there has been an error
60 Free-text field for any status information from the remote machine or whatever
61 else the export is doing. If status is "failed" this MUST contain a value.
71 Creates a new batch. To add the example to the database, see L<"insert">.
73 Note that this stores the hash reference, not a distinct copy of the hash it
74 points to. You can ask the object for a copy with the I<hash> method.
78 sub table { 'export_batch'; }
82 Adds this record to the database. If there is an error, returns the error,
83 otherwise returns false.
87 Delete this record from the database. Don't ever do this.
89 =item replace OLD_RECORD
91 Replaces the OLD_RECORD with this one in the database. If there is an error,
92 returns the error, otherwise returns false.
96 Checks all fields to make sure this is a valid batch. If there is
97 an error, returns the error, otherwise returns false. Called by the insert
105 $self->set('status' => 'open') unless $self->get('status');
106 $self->set('_date' => time) unless $self->get('_date');
109 $self->ut_numbern('batchnum')
110 || $self->ut_number('exportnum')
111 || $self->ut_foreign_key('exportnum', 'part_export', 'exportnum')
112 || $self->ut_number('_date')
113 || $self->ut_enum('status', [ qw(open closed done failed) ])
114 || $self->ut_textn('statustext')
116 return $error if $error;
127 L<FS::part_export>, L<FS::export_batch_item>