bulk DID order/inventory improvements, RT11291
[freeside.git] / FS / FS / did_order_item.pm
1 package FS::did_order_item;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::did_order_item - Object methods for did_order_item records
10
11 =head1 SYNOPSIS
12
13   use FS::did_order_item;
14
15   $record = new FS::did_order_item \%hash;
16   $record = new FS::did_order_item { 'column' => 'value' };
17
18   $error = $record->insert;
19
20   $error = $new_record->replace($old_record);
21
22   $error = $record->delete;
23
24   $error = $record->check;
25
26 =head1 DESCRIPTION
27
28 An FS::did_order_item object represents an item in a bulk DID order.
29 FS::did_order_item inherits from FS::Record.  
30 The following fields are currently supported:
31
32 =over 4
33
34 =item orderitemnum
35
36 primary key
37
38 =item ordernum
39
40 ordernum
41
42 =item msa
43
44 msa
45
46 =item npa
47
48 npa
49
50 =item latanum
51
52 latanum
53
54 =item rate_center
55
56 rate_center
57
58 =item state
59
60 state
61
62 =item quantity
63
64 quantity
65
66
67 =back
68
69 =head1 METHODS
70
71 =over 4
72
73 =item new HASHREF
74
75 Creates a new DID order item.  To add it to the database, see L<"insert">.
76
77 Note that this stores the hash reference, not a distinct copy of the hash it
78 points to.  You can ask the object for a copy with the I<hash> method.
79
80 =cut
81
82 # the new method can be inherited from FS::Record, if a table method is defined
83
84 sub table { 'did_order_item'; }
85
86 =item insert
87
88 Adds this record to the database.  If there is an error, returns the error,
89 otherwise returns false.
90
91 =cut
92
93 # the insert method can be inherited from FS::Record
94
95 =item delete
96
97 Delete this record from the database.
98
99 =cut
100
101 # the delete method can be inherited from FS::Record
102
103 =item replace OLD_RECORD
104
105 Replaces the OLD_RECORD with this one in the database.  If there is an error,
106 returns the error, otherwise returns false.
107
108 =cut
109
110 # the replace method can be inherited from FS::Record
111
112 =item check
113
114 Checks all fields to make sure this is a valid DID order item.  If there is
115 an error, returns the error, otherwise returns false.  Called by the insert
116 and replace methods.
117
118 =cut
119
120 # the check method should currently be supplied - FS::Record contains some
121 # data checking routines
122
123 sub check {
124   my $self = shift;
125
126   my $error = 
127     $self->ut_numbern('orderitemnum')
128     || $self->ut_number('ordernum')
129     || $self->ut_textn('msa')
130     || $self->ut_numbern('npa')
131     || $self->ut_foreign_keyn('latanum', 'lata', 'latanum')
132     || $self->ut_textn('rate_center')
133     || $self->ut_textn('state')
134     || $self->ut_number('quantity')
135   ;
136   return $error if $error;
137
138   $self->SUPER::check;
139 }
140
141 =back
142
143 =head1 SEE ALSO
144
145 L<FS::Record>, schema.html from the base documentation.
146
147 =cut
148
149 1;
150