Bug 33606: (QA follow-up) Cosmetic changes
[koha.git] / Koha / Schema / Result / Subscription.pm
1 use utf8;
2 package Koha::Schema::Result::Subscription;
3
4 # Created by DBIx::Class::Schema::Loader
5 # DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7 =head1 NAME
8
9 Koha::Schema::Result::Subscription
10
11 =cut
12
13 use strict;
14 use warnings;
15
16 use base 'DBIx::Class::Core';
17
18 =head1 TABLE: C<subscription>
19
20 =cut
21
22 __PACKAGE__->table("subscription");
23
24 =head1 ACCESSORS
25
26 =head2 biblionumber
27
28   data_type: 'integer'
29   is_foreign_key: 1
30   is_nullable: 0
31
32 foreign key for biblio.biblionumber that this subscription is attached to
33
34 =head2 subscriptionid
35
36   data_type: 'integer'
37   is_auto_increment: 1
38   is_nullable: 0
39
40 unique key for this subscription
41
42 =head2 librarian
43
44   data_type: 'varchar'
45   default_value: (empty string)
46   is_nullable: 1
47   size: 100
48
49 the librarian's username from borrowers.userid
50
51 =head2 startdate
52
53   data_type: 'date'
54   datetime_undef_if_invalid: 1
55   is_nullable: 1
56
57 start date for this subscription
58
59 =head2 aqbooksellerid
60
61   data_type: 'integer'
62   default_value: 0
63   is_nullable: 1
64
65 foreign key for aqbooksellers.id to link to the vendor
66
67 =head2 cost
68
69   data_type: 'integer'
70   default_value: 0
71   is_nullable: 1
72
73 =head2 aqbudgetid
74
75   data_type: 'integer'
76   default_value: 0
77   is_nullable: 1
78
79 =head2 weeklength
80
81   data_type: 'integer'
82   default_value: 0
83   is_nullable: 1
84
85 subscription length in weeks (will not be filled in if monthlength or numberlength is set)
86
87 =head2 monthlength
88
89   data_type: 'integer'
90   default_value: 0
91   is_nullable: 1
92
93 subscription length in weeks (will not be filled in if weeklength or numberlength is set)
94
95 =head2 numberlength
96
97   data_type: 'integer'
98   default_value: 0
99   is_nullable: 1
100
101 subscription length in weeks (will not be filled in if monthlength or weeklength is set)
102
103 =head2 periodicity
104
105   data_type: 'integer'
106   is_foreign_key: 1
107   is_nullable: 1
108
109 frequency type links to subscription_frequencies.id
110
111 =head2 countissuesperunit
112
113   data_type: 'integer'
114   default_value: 1
115   is_nullable: 0
116
117 =head2 notes
118
119   data_type: 'longtext'
120   is_nullable: 1
121
122 notes
123
124 =head2 status
125
126   data_type: 'varchar'
127   default_value: (empty string)
128   is_nullable: 0
129   size: 100
130
131 status of this subscription
132
133 =head2 lastvalue1
134
135   data_type: 'integer'
136   is_nullable: 1
137
138 =head2 innerloop1
139
140   data_type: 'integer'
141   default_value: 0
142   is_nullable: 1
143
144 =head2 lastvalue2
145
146   data_type: 'integer'
147   is_nullable: 1
148
149 =head2 innerloop2
150
151   data_type: 'integer'
152   default_value: 0
153   is_nullable: 1
154
155 =head2 lastvalue3
156
157   data_type: 'integer'
158   is_nullable: 1
159
160 =head2 innerloop3
161
162   data_type: 'integer'
163   default_value: 0
164   is_nullable: 1
165
166 =head2 firstacquidate
167
168   data_type: 'date'
169   datetime_undef_if_invalid: 1
170   is_nullable: 1
171
172 first issue received date
173
174 =head2 manualhistory
175
176   data_type: 'tinyint'
177   default_value: 0
178   is_nullable: 0
179
180 yes or no to managing the history manually
181
182 =head2 irregularity
183
184   data_type: 'mediumtext'
185   is_nullable: 1
186
187 any irregularities in the subscription
188
189 =head2 skip_serialseq
190
191   data_type: 'tinyint'
192   default_value: 0
193   is_nullable: 0
194
195 =head2 letter
196
197   data_type: 'varchar'
198   is_nullable: 1
199   size: 20
200
201 =head2 numberpattern
202
203   data_type: 'integer'
204   is_foreign_key: 1
205   is_nullable: 1
206
207 the numbering pattern used links to subscription_numberpatterns.id
208
209 =head2 locale
210
211   data_type: 'varchar'
212   is_nullable: 1
213   size: 80
214
215 for foreign language subscriptions to display months, seasons, etc correctly
216
217 =head2 distributedto
218
219   data_type: 'mediumtext'
220   is_nullable: 1
221
222 =head2 internalnotes
223
224   data_type: 'longtext'
225   is_nullable: 1
226
227 =head2 callnumber
228
229   data_type: 'mediumtext'
230   is_nullable: 1
231
232 default call number
233
234 =head2 location
235
236   data_type: 'varchar'
237   default_value: (empty string)
238   is_nullable: 1
239   size: 80
240
241 default shelving location (items.location)
242
243 =head2 branchcode
244
245   data_type: 'varchar'
246   default_value: (empty string)
247   is_nullable: 0
248   size: 10
249
250 default branches (items.homebranch)
251
252 =head2 lastbranch
253
254   data_type: 'varchar'
255   is_nullable: 1
256   size: 10
257
258 =head2 serialsadditems
259
260   data_type: 'tinyint'
261   default_value: 0
262   is_nullable: 0
263
264 does receiving this serial create an item record
265
266 =head2 staffdisplaycount
267
268   data_type: 'integer'
269   is_nullable: 1
270
271 how many issues to show to the staff
272
273 =head2 opacdisplaycount
274
275   data_type: 'integer'
276   is_nullable: 1
277
278 how many issues to show to the public
279
280 =head2 graceperiod
281
282   data_type: 'integer'
283   default_value: 0
284   is_nullable: 0
285
286 grace period in days
287
288 =head2 enddate
289
290   data_type: 'date'
291   datetime_undef_if_invalid: 1
292   is_nullable: 1
293
294 subscription end date
295
296 =head2 closed
297
298   data_type: 'tinyint'
299   default_value: 0
300   is_nullable: 0
301
302 yes / no if the subscription is closed
303
304 =head2 reneweddate
305
306   data_type: 'date'
307   datetime_undef_if_invalid: 1
308   is_nullable: 1
309
310 date of last renewal for the subscription
311
312 =head2 itemtype
313
314   data_type: 'varchar'
315   is_nullable: 1
316   size: 10
317
318 =head2 previousitemtype
319
320   data_type: 'varchar'
321   is_nullable: 1
322   size: 10
323
324 =head2 mana_id
325
326   data_type: 'integer'
327   is_nullable: 1
328
329 =head2 ccode
330
331   data_type: 'varchar'
332   is_nullable: 1
333   size: 80
334
335 collection code to assign to serial items
336
337 =cut
338
339 __PACKAGE__->add_columns(
340   "biblionumber",
341   { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
342   "subscriptionid",
343   { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
344   "librarian",
345   { data_type => "varchar", default_value => "", is_nullable => 1, size => 100 },
346   "startdate",
347   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
348   "aqbooksellerid",
349   { data_type => "integer", default_value => 0, is_nullable => 1 },
350   "cost",
351   { data_type => "integer", default_value => 0, is_nullable => 1 },
352   "aqbudgetid",
353   { data_type => "integer", default_value => 0, is_nullable => 1 },
354   "weeklength",
355   { data_type => "integer", default_value => 0, is_nullable => 1 },
356   "monthlength",
357   { data_type => "integer", default_value => 0, is_nullable => 1 },
358   "numberlength",
359   { data_type => "integer", default_value => 0, is_nullable => 1 },
360   "periodicity",
361   { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
362   "countissuesperunit",
363   { data_type => "integer", default_value => 1, is_nullable => 0 },
364   "notes",
365   { data_type => "longtext", is_nullable => 1 },
366   "status",
367   { data_type => "varchar", default_value => "", is_nullable => 0, size => 100 },
368   "lastvalue1",
369   { data_type => "integer", is_nullable => 1 },
370   "innerloop1",
371   { data_type => "integer", default_value => 0, is_nullable => 1 },
372   "lastvalue2",
373   { data_type => "integer", is_nullable => 1 },
374   "innerloop2",
375   { data_type => "integer", default_value => 0, is_nullable => 1 },
376   "lastvalue3",
377   { data_type => "integer", is_nullable => 1 },
378   "innerloop3",
379   { data_type => "integer", default_value => 0, is_nullable => 1 },
380   "firstacquidate",
381   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
382   "manualhistory",
383   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
384   "irregularity",
385   { data_type => "mediumtext", is_nullable => 1 },
386   "skip_serialseq",
387   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
388   "letter",
389   { data_type => "varchar", is_nullable => 1, size => 20 },
390   "numberpattern",
391   { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
392   "locale",
393   { data_type => "varchar", is_nullable => 1, size => 80 },
394   "distributedto",
395   { data_type => "mediumtext", is_nullable => 1 },
396   "internalnotes",
397   { data_type => "longtext", is_nullable => 1 },
398   "callnumber",
399   { data_type => "mediumtext", is_nullable => 1 },
400   "location",
401   { data_type => "varchar", default_value => "", is_nullable => 1, size => 80 },
402   "branchcode",
403   { data_type => "varchar", default_value => "", is_nullable => 0, size => 10 },
404   "lastbranch",
405   { data_type => "varchar", is_nullable => 1, size => 10 },
406   "serialsadditems",
407   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
408   "staffdisplaycount",
409   { data_type => "integer", is_nullable => 1 },
410   "opacdisplaycount",
411   { data_type => "integer", is_nullable => 1 },
412   "graceperiod",
413   { data_type => "integer", default_value => 0, is_nullable => 0 },
414   "enddate",
415   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
416   "closed",
417   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
418   "reneweddate",
419   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
420   "itemtype",
421   { data_type => "varchar", is_nullable => 1, size => 10 },
422   "previousitemtype",
423   { data_type => "varchar", is_nullable => 1, size => 10 },
424   "mana_id",
425   { data_type => "integer", is_nullable => 1 },
426   "ccode",
427   { data_type => "varchar", is_nullable => 1, size => 80 },
428 );
429
430 =head1 PRIMARY KEY
431
432 =over 4
433
434 =item * L</subscriptionid>
435
436 =back
437
438 =cut
439
440 __PACKAGE__->set_primary_key("subscriptionid");
441
442 =head1 RELATIONS
443
444 =head2 aqorders
445
446 Type: has_many
447
448 Related object: L<Koha::Schema::Result::Aqorder>
449
450 =cut
451
452 __PACKAGE__->has_many(
453   "aqorders",
454   "Koha::Schema::Result::Aqorder",
455   { "foreign.subscriptionid" => "self.subscriptionid" },
456   { cascade_copy => 0, cascade_delete => 0 },
457 );
458
459 =head2 biblionumber
460
461 Type: belongs_to
462
463 Related object: L<Koha::Schema::Result::Biblio>
464
465 =cut
466
467 __PACKAGE__->belongs_to(
468   "biblionumber",
469   "Koha::Schema::Result::Biblio",
470   { biblionumber => "biblionumber" },
471   { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
472 );
473
474 =head2 numberpattern
475
476 Type: belongs_to
477
478 Related object: L<Koha::Schema::Result::SubscriptionNumberpattern>
479
480 =cut
481
482 __PACKAGE__->belongs_to(
483   "numberpattern",
484   "Koha::Schema::Result::SubscriptionNumberpattern",
485   { id => "numberpattern" },
486   {
487     is_deferrable => 1,
488     join_type     => "LEFT",
489     on_delete     => "SET NULL",
490     on_update     => "CASCADE",
491   },
492 );
493
494 =head2 periodicity
495
496 Type: belongs_to
497
498 Related object: L<Koha::Schema::Result::SubscriptionFrequency>
499
500 =cut
501
502 __PACKAGE__->belongs_to(
503   "periodicity",
504   "Koha::Schema::Result::SubscriptionFrequency",
505   { id => "periodicity" },
506   {
507     is_deferrable => 1,
508     join_type     => "LEFT",
509     on_delete     => "SET NULL",
510     on_update     => "CASCADE",
511   },
512 );
513
514 =head2 serials
515
516 Type: has_many
517
518 Related object: L<Koha::Schema::Result::Serial>
519
520 =cut
521
522 __PACKAGE__->has_many(
523   "serials",
524   "Koha::Schema::Result::Serial",
525   { "foreign.subscriptionid" => "self.subscriptionid" },
526   { cascade_copy => 0, cascade_delete => 0 },
527 );
528
529 =head2 subscriptionhistory
530
531 Type: might_have
532
533 Related object: L<Koha::Schema::Result::Subscriptionhistory>
534
535 =cut
536
537 __PACKAGE__->might_have(
538   "subscriptionhistory",
539   "Koha::Schema::Result::Subscriptionhistory",
540   { "foreign.subscriptionid" => "self.subscriptionid" },
541   { cascade_copy => 0, cascade_delete => 0 },
542 );
543
544 =head2 subscriptionroutinglists
545
546 Type: has_many
547
548 Related object: L<Koha::Schema::Result::Subscriptionroutinglist>
549
550 =cut
551
552 __PACKAGE__->has_many(
553   "subscriptionroutinglists",
554   "Koha::Schema::Result::Subscriptionroutinglist",
555   { "foreign.subscriptionid" => "self.subscriptionid" },
556   { cascade_copy => 0, cascade_delete => 0 },
557 );
558
559
560 # Created by DBIx::Class::Schema::Loader v0.07046 @ 2022-07-05 17:45:12
561 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:MFOz3AKUVSPuQv6kMb1EbA
562
563 __PACKAGE__->has_many(
564   "additional_field_values",
565   "Koha::Schema::Result::AdditionalFieldValue",
566   sub {
567     my ($args) = @_;
568
569     return {
570         "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.subscriptionid" },
571
572         "$args->{foreign_alias}.field_id" =>
573             { -in => \'(SELECT id FROM additional_fields WHERE tablename = "subscription")' },
574     };
575   },
576   { cascade_copy => 0, cascade_delete => 0 },
577 );
578
579 __PACKAGE__->add_columns(
580     '+closed'         => { is_boolean => 1 },
581     '+skip_serialseq' => { is_boolean => 1 },
582 );
583
584 # You can replace this text with custom content, and it will be preserved on regeneration
585 1;