1 package FS::inventory_item;
2 use base qw( FS::cust_main_Mixin FS::Record );
8 FS::inventory_item - Object methods for inventory_item records
12 use FS::inventory_item;
14 $record = new FS::inventory_item \%hash;
15 $record = new FS::inventory_item { 'column' => 'value' };
17 $error = $record->insert;
19 $error = $new_record->replace($old_record);
21 $error = $record->delete;
23 $error = $record->check;
27 An FS::inventory_item object represents a specific piece of (real or virtual)
28 inventory, such as a specific DID or serial number. FS::inventory_item
29 inherits from FS::Record. The following fields are currently supported:
33 =item itemnum - primary key
35 =item classnum - Inventory class (see L<FS::inventory_class>)
37 =item item - Item identifier (unique within its inventory class)
39 =item svcnum - Customer servcie (see L<FS::cust_svc>)
49 Creates a new item. To add the item to the database, see L<"insert">.
51 Note that this stores the hash reference, not a distinct copy of the hash it
52 points to. You can ask the object for a copy with the I<hash> method.
56 # the new method can be inherited from FS::Record, if a table method is defined
58 sub table { 'inventory_item'; }
62 Adds this record to the database. If there is an error, returns the error,
63 otherwise returns false.
67 # the insert method can be inherited from FS::Record
71 Delete this record from the database.
75 # the delete method can be inherited from FS::Record
77 =item replace OLD_RECORD
79 Replaces the OLD_RECORD with this one in the database. If there is an error,
80 returns the error, otherwise returns false.
84 # the replace method can be inherited from FS::Record
88 Checks all fields to make sure this is a valid item. If there is
89 an error, returns the error, otherwise returns false. Called by the insert
94 # the check method should currently be supplied - FS::Record contains some
95 # data checking routines
101 $self->ut_numbern('itemnum')
102 || $self->ut_foreign_key('classnum', 'inventory_class', 'classnum' )
103 #|| $self->ut_foreign_keyn('agentnum', 'agent', 'agentnum' )
104 || $self->ut_agentnum_acl('agentnum', ['Configuration',
105 'Edit global inventory'] )
106 || $self->ut_text('item')
107 || $self->ut_foreign_keyn('svcnum', 'cust_svc', 'svcnum' )
108 || $self->ut_alphan('svc_field')
110 return $error if $error;
117 Returns the customer service associated with this inventory item, if the
118 item has been used (see L<FS::cust_svc>).
122 Returns the associated agent for this event, if any, as an FS::agent object.
130 =item process_batch_import
134 sub process_batch_import {
137 my $opt = { 'table' => 'inventory_item',
138 #'params' => [ 'itembatch', 'classnum', ],
139 'params' => [ 'classnum', 'agentnum', ],
140 'formats' => { 'default' => [ 'item' ] },
144 FS::Record::process_batch_import( $job, $opt, @_ );
152 maybe batch_import should be a regular method in FS::inventory_class
156 L<inventory_class>, L<cust_svc>, L<FS::Record>, schema.html from the base