line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
1555
|
use utf8; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
32
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Interchange6::Schema::Result::Order; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Interchange6::Schema::Result::Order |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
136
|
use Interchange6::Schema::Candy -components => [qw(InflateColumn::DateTime)]; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
15
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 ACCESSORS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head2 orders_id |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Primary key. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
primary_column orders_id => { |
22
|
|
|
|
|
|
|
data_type => "integer", |
23
|
|
|
|
|
|
|
is_auto_increment => 1, |
24
|
|
|
|
|
|
|
sequence => "orders_orders_id_seq", |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 order_number |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Unique representation of the order. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
unique_column order_number => { |
34
|
|
|
|
|
|
|
data_type => "varchar", |
35
|
|
|
|
|
|
|
size => 24 |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 order_date |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Timestamp of when the order was placed. Is nullable. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
column order_date => { |
45
|
|
|
|
|
|
|
data_type => "timestamp", |
46
|
|
|
|
|
|
|
is_nullable => 1 |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 users_id |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Foreign key constraint on L<Interchange6::Schema::Result::User/users_id> |
52
|
|
|
|
|
|
|
via L</user> relationship. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
column users_id => { |
57
|
|
|
|
|
|
|
data_type => "integer", |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 email |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Email address used for the order. Default is empty string |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
column email => { |
67
|
|
|
|
|
|
|
data_type => "varchar", |
68
|
|
|
|
|
|
|
default_value => "", |
69
|
|
|
|
|
|
|
size => 255 |
70
|
|
|
|
|
|
|
}; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 shipping_addresses_id |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Foreign key constraint on L<Interchange6::Schema::Result::Address/addresses_id> |
75
|
|
|
|
|
|
|
via L</shipping_address> relationship. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
column shipping_addresses_id => { |
80
|
|
|
|
|
|
|
data_type => "integer", |
81
|
|
|
|
|
|
|
}; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 billing_addresses_id |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Foreign key constraint on L<Interchange6::Schema::Result::Address/addresses_id> |
86
|
|
|
|
|
|
|
via L</billing_address> relationship. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
column billing_addresses_id => { |
91
|
|
|
|
|
|
|
data_type => "integer", |
92
|
|
|
|
|
|
|
}; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 weight |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Total numeric weight of the order. Default is 0 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
column weight => { |
101
|
|
|
|
|
|
|
data_type => "numeric", |
102
|
|
|
|
|
|
|
default_value => 0, |
103
|
|
|
|
|
|
|
size => [ 11, 3 ] |
104
|
|
|
|
|
|
|
}; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 payment_method |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This is the type of payment used for the order. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
column payment_method => { |
113
|
|
|
|
|
|
|
data_type => "varchar", |
114
|
|
|
|
|
|
|
default_value => "", |
115
|
|
|
|
|
|
|
size => 255 |
116
|
|
|
|
|
|
|
}; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 payment_number |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
A validation record for the payment. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
column payment_number => { |
125
|
|
|
|
|
|
|
data_type => "varchar", |
126
|
|
|
|
|
|
|
default_value => "", |
127
|
|
|
|
|
|
|
size => 255 |
128
|
|
|
|
|
|
|
}; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 payment_status |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
The status of the payment for the current order. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
column payment_status => { |
137
|
|
|
|
|
|
|
data_type => "varchar", |
138
|
|
|
|
|
|
|
default_value => "", |
139
|
|
|
|
|
|
|
size => 255 |
140
|
|
|
|
|
|
|
}; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 shipping_method |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
What shipping method was used for the order. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
column shipping_method => { |
149
|
|
|
|
|
|
|
data_type => "varchar", |
150
|
|
|
|
|
|
|
default_value => "", |
151
|
|
|
|
|
|
|
size => 255 |
152
|
|
|
|
|
|
|
}; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 subtotal |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
The sum of all items in the cart before tax and shipping costs. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Defaults to 0. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
column subtotal => { |
163
|
|
|
|
|
|
|
data_type => "numeric", |
164
|
|
|
|
|
|
|
default_value => 0, |
165
|
|
|
|
|
|
|
size => [ 21, 3 ], |
166
|
|
|
|
|
|
|
}; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 shipping |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
The numeric cost associated with shipping the order. Default is 0 |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
column shipping => { |
175
|
|
|
|
|
|
|
data_type => "numeric", |
176
|
|
|
|
|
|
|
default_value => 0, |
177
|
|
|
|
|
|
|
size => [ 21, 3 ], |
178
|
|
|
|
|
|
|
}; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 handling |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
The numeric cost associated with handling the order. Default is 0. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
column handling => { |
187
|
|
|
|
|
|
|
data_type => "numeric", |
188
|
|
|
|
|
|
|
default_value => 0, |
189
|
|
|
|
|
|
|
size => [ 21, 3 ], |
190
|
|
|
|
|
|
|
}; |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head2 salestax |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
The total tax applied to the order. Default is 0 |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
column salestax => { |
199
|
|
|
|
|
|
|
data_type => "numeric", |
200
|
|
|
|
|
|
|
default_value => 0, |
201
|
|
|
|
|
|
|
size => [ 21, 3 ], |
202
|
|
|
|
|
|
|
}; |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head2 total_cost |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
The total cost of all items shipping handling and tax for the order. |
207
|
|
|
|
|
|
|
Default is 0. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=cut |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
column total_cost => { |
212
|
|
|
|
|
|
|
data_type => "numeric", |
213
|
|
|
|
|
|
|
default_value => 0, |
214
|
|
|
|
|
|
|
size => [ 21, 3 ], |
215
|
|
|
|
|
|
|
}; |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 RELATIONS |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head2 shipping_address |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Type: belongs_to |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Related object: L<Interchange6::Schema::Result::Address> |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=cut |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
belongs_to |
228
|
|
|
|
|
|
|
shipping_address => "Interchange6::Schema::Result::Address", |
229
|
|
|
|
|
|
|
{ addresses_id => "shipping_addresses_id" }; |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head2 billing_address |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Type: belongs_to |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Related object: L<Interchange6::Schema::Result::Address> |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=cut |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
belongs_to |
240
|
|
|
|
|
|
|
billing_address => "Interchange6::Schema::Result::Address", |
241
|
|
|
|
|
|
|
{ addresses_id => "billing_addresses_id" }; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 orderlines |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Type: has_many |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
Related object: L<Interchange6::Schema::Result::Orderline> |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=cut |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
has_many |
252
|
|
|
|
|
|
|
orderlines => "Interchange6::Schema::Result::Orderline", |
253
|
|
|
|
|
|
|
"orders_id", |
254
|
|
|
|
|
|
|
{ cascade_copy => 0, cascade_delete => 0 }; |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head2 payment_orders |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Type: has_many |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
Related object: L<Interchange6::Schema::Result::PaymentOrder> |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=cut |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
has_many |
265
|
|
|
|
|
|
|
payment_orders => "Interchange6::Schema::Result::PaymentOrder", |
266
|
|
|
|
|
|
|
"orders_id", |
267
|
|
|
|
|
|
|
{ cascade_copy => 0, cascade_delete => 0 }; |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head2 user |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
Type: belongs_to |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
Related object: L<Interchange6::Schema::Result::User> |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=cut |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
belongs_to |
278
|
|
|
|
|
|
|
user => "Interchange6::Schema::Result::User", |
279
|
|
|
|
|
|
|
"users_id", |
280
|
|
|
|
|
|
|
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }; |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head2 order_comments |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Type: has_many |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Related object: L<Interchange6::Schema::Result::OrderComment> |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=cut |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
has_many |
291
|
|
|
|
|
|
|
order_comments => 'Interchange6::Schema::Result::OrderComment', |
292
|
|
|
|
|
|
|
'orders_id'; |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=head2 _comments |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
Type: many_to_many |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
This is considered a private method. Please see public L</comments> and L</add_to_comments> methods. |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=cut |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
many_to_many _comments => "order_comments", "message"; |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=head2 statuses |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
Type: has_many |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
Related object: L<Interchange6::Schema::Result::OrderStatus> |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=cut |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
has_many |
313
|
|
|
|
|
|
|
statuses => 'Interchange6::Schema::Result::OrderStatus', |
314
|
|
|
|
|
|
|
'orders_id'; |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=head1 METHODS |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
=head2 comments |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
=over 4 |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
=item Arguments: none |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=item Return Value: L<Interchange6::Schema::Result::Message> resultset. |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
=back |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
=cut |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
sub comments { |
332
|
3
|
|
|
3
|
1
|
54810
|
return shift->_comments(@_); |
333
|
|
|
|
|
|
|
} |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
=head2 add_to_comments |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
=over 4 |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=item Arguments: \%col_data |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=item Return Value: L<Interchange6::Schema::Result::Message> |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
=back |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
See L<DBIx::Class::Relationship::Base/add_to_$rel> many_to_many for further details. |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
=cut |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
# much of this was cargo-culted from DBIx::Class::Relationship::ManyToMany |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
sub add_to_comments { |
352
|
12
|
|
|
12
|
1
|
56305
|
my $self = shift; |
353
|
12
|
100
|
|
|
|
67
|
@_ > 0 |
354
|
|
|
|
|
|
|
or $self->throw_exception("add_to_comments needs an object or hashref"); |
355
|
11
|
|
|
|
|
53
|
my $rset_message = $self->result_source->schema->resultset("Message"); |
356
|
11
|
|
|
|
|
4351
|
my $obj; |
357
|
11
|
100
|
|
|
|
52
|
if ( ref $_[0] ) { |
358
|
10
|
100
|
|
|
|
49
|
if ( ref $_[0] eq 'HASH' ) { |
359
|
7
|
|
|
|
|
31
|
$_[0]->{type} = "order_comment"; |
360
|
7
|
|
|
|
|
28
|
$obj = $rset_message->create( $_[0] ); |
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
else { |
363
|
3
|
|
|
|
|
9
|
$obj = $_[0]; |
364
|
3
|
100
|
|
|
|
71
|
unless ( my $type = $obj->message_type->name eq "order_comment" ) { |
365
|
1
|
|
|
|
|
3892
|
$self->throw_exception( |
366
|
|
|
|
|
|
|
"cannot add message type $type to comments"); |
367
|
|
|
|
|
|
|
} |
368
|
|
|
|
|
|
|
} |
369
|
|
|
|
|
|
|
} |
370
|
|
|
|
|
|
|
else { |
371
|
1
|
|
|
|
|
11
|
push @_, type => "order_comment"; |
372
|
1
|
|
|
|
|
8
|
$obj = $rset_message->create( {@_} ); |
373
|
|
|
|
|
|
|
} |
374
|
9
|
|
|
|
|
43177
|
$self->create_related( 'order_comments', { messages_id => $obj->id } ); |
375
|
9
|
|
|
|
|
28894
|
return $obj; |
376
|
|
|
|
|
|
|
} |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
=head2 set_comments |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
=over 4 |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
=item Arguments: (\@hashrefs_of_col_data | \@result_objs) |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
=item Return Value: not defined |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
=back |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
Similar to L<DBIx::Class::Relationship::Base/set_$rel> except that this method D |
389
|
|
|
|
|
|
|
OES delete objects in the table on the right side of the relation. |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
=cut |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
sub set_comments { |
394
|
5
|
|
|
5
|
1
|
36652
|
my $self = shift; |
395
|
5
|
100
|
|
|
|
50
|
@_ > 0 |
396
|
|
|
|
|
|
|
or $self->throw_exception( |
397
|
|
|
|
|
|
|
"set_comments needs a list of objects or hashrefs"); |
398
|
4
|
100
|
|
|
|
21
|
my @to_set = ( ref( $_[0] ) eq 'ARRAY' ? @{ $_[0] } : @_ ); |
|
2
|
|
|
|
|
5
|
|
399
|
4
|
|
|
|
|
103
|
$self->order_comments->delete_all; |
400
|
4
|
|
|
|
|
105722
|
$self->add_to_comments( $_ ) for (@to_set); |
401
|
|
|
|
|
|
|
} |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
=head2 delete |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
Overload delete to force removal of any order comments. |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
=cut |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
# FIXME: (SysPete) There ought to be a way to force this with cascade delete. |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
sub delete { |
412
|
2
|
|
|
2
|
1
|
33761
|
my ( $self, @args ) = @_; |
413
|
2
|
|
|
|
|
13
|
my $guard = $self->result_source->schema->txn_scope_guard; |
414
|
2
|
|
|
|
|
1084
|
$self->order_comments->delete_all; |
415
|
2
|
|
|
|
|
135876
|
$self->next::method(@args); |
416
|
2
|
|
|
|
|
14558
|
$guard->commit; |
417
|
|
|
|
|
|
|
} |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
=head2 insert |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
Override insert so that if no L<Interchange6::Schema::Result::OrderStatus> has |
422
|
|
|
|
|
|
|
been provided via multicreate then create a single status named C<new>. |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
=cut |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
sub insert { |
427
|
12
|
|
|
12
|
1
|
128890
|
my ( $self, @args ) = @_; |
428
|
12
|
|
|
|
|
64
|
my $guard = $self->result_source->schema->txn_scope_guard; |
429
|
12
|
|
|
|
|
6365
|
my $ret = $self->next::method(@args); |
430
|
12
|
100
|
|
|
|
149658
|
if ( $self->statuses->count == 0 ) { |
431
|
11
|
|
|
|
|
58974
|
$self->create_related('statuses', { status => 'new' }); |
432
|
|
|
|
|
|
|
} |
433
|
12
|
|
|
|
|
45968
|
$guard->commit; |
434
|
12
|
|
|
|
|
4398
|
return $ret; |
435
|
|
|
|
|
|
|
} |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
=head2 status |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
Option argument C<$status> will cause creation of a new related entry in |
440
|
|
|
|
|
|
|
L<Interchange6::Schema::Result::OrderStatus>. |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
Returns the most recent L<Interchange6::Schema::Result::OrderStatus/status> or |
443
|
|
|
|
|
|
|
undef if none are found. |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
If initial result set was created using |
446
|
|
|
|
|
|
|
L<Interchange6::Schema::ResultSet::Order/with_status> then the status added |
447
|
|
|
|
|
|
|
by that method will be returned so that a new query is not required. |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
=cut |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
sub status { |
452
|
6
|
|
|
6
|
1
|
46235
|
my $self = shift; |
453
|
6
|
100
|
|
|
|
26
|
if ( @_ ) { |
454
|
1
|
|
|
|
|
34
|
return $self->statuses->create( { status => shift } )->status; |
455
|
|
|
|
|
|
|
} |
456
|
5
|
100
|
|
|
|
322
|
if ( $self->has_column_loaded('status')) { |
457
|
1
|
|
|
|
|
17
|
return $self->get_column('status'); |
458
|
|
|
|
|
|
|
} |
459
|
|
|
|
|
|
|
else { |
460
|
4
|
|
|
|
|
165
|
my $status = |
461
|
|
|
|
|
|
|
$self->statuses->order_by('!created,!order_status_id')->rows(1) |
462
|
|
|
|
|
|
|
->single; |
463
|
4
|
100
|
|
|
|
14575
|
return $status ? $status->status : undef; |
464
|
|
|
|
|
|
|
} |
465
|
|
|
|
|
|
|
} |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
1; |