1 package FS::export_batch;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
7 use FS::export_batch_item;
11 FS::export_batch - Object methods for export_batch records
17 $record = new FS::export_batch \%hash;
18 $record = new FS::export_batch { 'column' => 'value' };
20 $error = $record->insert;
22 $error = $new_record->replace($old_record);
24 $error = $record->delete;
26 $error = $record->check;
30 An FS::export_batch object represents a batch of records being processed
31 by an export. This mechanism allows exports to process multiple pending
32 service changes at the end of day or some other scheduled time, rather
33 than doing everything in realtime or near-realtime (via the job queue).
35 FS::export_batch inherits from FS::Record. The following fields are
46 The L<FS::part_export> object that created this batch.
50 The time the batch was created.
54 A status string. Allowed values are "open" (for a newly created batch that
55 can receive additional items), "closed" (for a batch that is no longer
56 allowed to receive items but is still being processed), "done" (for a batch
57 that is finished processing), and "failed" (if there has been an error
62 Free-text field for any status information from the remote machine or whatever
63 else the export is doing. If status is "failed" this MUST contain a value.
73 Creates a new batch. To add the example to the database, see L<"insert">.
75 Note that this stores the hash reference, not a distinct copy of the hash it
76 points to. You can ask the object for a copy with the I<hash> method.
80 sub table { 'export_batch'; }
84 Adds this record to the database. If there is an error, returns the error,
85 otherwise returns false.
89 Delete this record from the database. Don't ever do this.
91 =item replace OLD_RECORD
93 Replaces the OLD_RECORD with this one in the database. If there is an error,
94 returns the error, otherwise returns false.
98 Checks all fields to make sure this is a valid batch. If there is
99 an error, returns the error, otherwise returns false. Called by the insert
107 $self->set('status' => 'open') unless $self->get('status');
108 $self->set('_date' => time) unless $self->get('_date');
111 $self->ut_numbern('batchnum')
112 || $self->ut_number('exportnum')
113 || $self->ut_foreign_key('exportnum', 'part_export', 'exportnum')
114 || $self->ut_number('_date')
115 || $self->ut_enum('status', [ qw(open closed done failed) ])
116 || $self->ut_textn('statustext')
118 return $error if $error;
123 # stubs, removed in 4.x
125 sub export_batch_item {
127 qsearch('export_batch_item', { batchnum => $self->batchnum });
132 FS::part_export->by_key($self->exportnum);
141 L<FS::part_export>, L<FS::export_batch_item>