show credit balance on invoices, #11564
[freeside.git] / FS / FS / did_order.pm
1 package FS::did_order;
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 - Object methods for did_order records
10
11 =head1 SYNOPSIS
12
13   use FS::did_order;
14
15   $record = new FS::did_order \%hash;
16   $record = new FS::did_order { '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 object represents a bulk DID order.  FS::did_order inherits from
29 FS::Record.  The following fields are currently supported:
30
31 =over 4
32
33 =item ordernum
34
35 primary key
36
37 =item vendornum
38
39 vendornum
40
41 =item vendor_order_id
42
43 vendor_order_id
44
45 =item msa
46
47 msa
48
49 =item latanum
50
51 latanum
52
53 =item rate_center
54
55 rate_center
56
57 =item state
58
59 state
60
61 =item quantity
62
63 quantity
64
65 =item submitted
66
67 submitted
68
69 =item confirmed
70
71 confirmed
72
73 =item received
74
75 received
76
77
78 =back
79
80 =head1 METHODS
81
82 =over 4
83
84 =item new HASHREF
85
86 Creates a new bulk DID order.  To add it to the database, see L<"insert">.
87
88 Note that this stores the hash reference, not a distinct copy of the hash it
89 points to.  You can ask the object for a copy with the I<hash> method.
90
91 =cut
92
93 # the new method can be inherited from FS::Record, if a table method is defined
94
95 sub table { 'did_order'; }
96
97 =item insert
98
99 Adds this record to the database.  If there is an error, returns the error,
100 otherwise returns false.
101
102 =cut
103
104 # the insert method can be inherited from FS::Record
105
106 =item delete
107
108 Delete this record from the database.
109
110 =cut
111
112 # the delete method can be inherited from FS::Record
113
114 =item replace OLD_RECORD
115
116 Replaces the OLD_RECORD with this one in the database.  If there is an error,
117 returns the error, otherwise returns false.
118
119 =cut
120
121 # the replace method can be inherited from FS::Record
122
123 =item check
124
125 Checks all fields to make sure this is a valid bulk DID order.  If there is
126 an error, returns the error, otherwise returns false.  Called by the insert
127 and replace methods.
128
129 =cut
130
131 # the check method should currently be supplied - FS::Record contains some
132 # data checking routines
133
134 sub check {
135   my $self = shift;
136
137   my $error = 
138     $self->ut_numbern('ordernum')
139     || $self->ut_foreign_key('vendornum', 'did_vendor', 'vendornum' )
140     || $self->ut_text('vendor_order_id')
141     || $self->ut_textn('msa')
142     || $self->ut_foreign_keyn('latanum', 'lata', 'latanum')
143     || $self->ut_textn('rate_center')
144     || $self->ut_textn('state')
145     || $self->ut_number('quantity')
146     || $self->ut_number('submitted')
147     || $self->ut_numbern('confirmed')
148     || $self->ut_numbern('received')
149   ;
150   return $error if $error;
151
152   $self->SUPER::check;
153 }
154
155 =back
156
157 =head1 BUGS
158
159 =head1 SEE ALSO
160
161 L<FS::Record>, schema.html from the base documentation.
162
163 =cut
164
165 1;
166