Bug 32894: Koha::Item->last_returned_by
[koha.git] / Koha / Schema / Result / Item.pm
1 use utf8;
2 package Koha::Schema::Result::Item;
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::Item
10
11 =cut
12
13 use strict;
14 use warnings;
15
16 use base 'DBIx::Class::Core';
17
18 =head1 TABLE: C<items>
19
20 =cut
21
22 __PACKAGE__->table("items");
23
24 =head1 ACCESSORS
25
26 =head2 itemnumber
27
28   data_type: 'integer'
29   is_auto_increment: 1
30   is_nullable: 0
31
32 primary key and unique identifier added by Koha
33
34 =head2 biblionumber
35
36   data_type: 'integer'
37   default_value: 0
38   is_foreign_key: 1
39   is_nullable: 0
40
41 foreign key from biblio table used to link this item to the right bib record
42
43 =head2 biblioitemnumber
44
45   data_type: 'integer'
46   default_value: 0
47   is_foreign_key: 1
48   is_nullable: 0
49
50 foreign key from the biblioitems table to link to item to additional information
51
52 =head2 barcode
53
54   data_type: 'varchar'
55   is_nullable: 1
56   size: 20
57
58 item barcode (MARC21 952$p)
59
60 =head2 dateaccessioned
61
62   data_type: 'date'
63   datetime_undef_if_invalid: 1
64   is_nullable: 1
65
66 date the item was acquired or added to Koha (MARC21 952$d)
67
68 =head2 booksellerid
69
70   data_type: 'longtext'
71   is_nullable: 1
72
73 where the item was purchased (MARC21 952$e)
74
75 =head2 homebranch
76
77   data_type: 'varchar'
78   is_foreign_key: 1
79   is_nullable: 1
80   size: 10
81
82 foreign key from the branches table for the library that owns this item (MARC21 952$a)
83
84 =head2 price
85
86   data_type: 'decimal'
87   is_nullable: 1
88   size: [8,2]
89
90 purchase price (MARC21 952$g)
91
92 =head2 replacementprice
93
94   data_type: 'decimal'
95   is_nullable: 1
96   size: [8,2]
97
98 cost the library charges to replace the item if it has been marked lost (MARC21 952$v)
99
100 =head2 replacementpricedate
101
102   data_type: 'date'
103   datetime_undef_if_invalid: 1
104   is_nullable: 1
105
106 the date the price is effective from (MARC21 952$w)
107
108 =head2 datelastborrowed
109
110   data_type: 'date'
111   datetime_undef_if_invalid: 1
112   is_nullable: 1
113
114 the date the item was last checked out/issued
115
116 =head2 datelastseen
117
118   data_type: 'datetime'
119   datetime_undef_if_invalid: 1
120   is_nullable: 1
121
122 the date the item was last see (usually the last time the barcode was scanned or inventory was done)
123
124 =head2 stack
125
126   data_type: 'tinyint'
127   is_nullable: 1
128
129 =head2 notforloan
130
131   data_type: 'tinyint'
132   default_value: 0
133   is_nullable: 0
134
135 authorized value defining why this item is not for loan (MARC21 952$7)
136
137 =head2 damaged
138
139   data_type: 'tinyint'
140   default_value: 0
141   is_nullable: 0
142
143 authorized value defining this item as damaged (MARC21 952$4)
144
145 =head2 damaged_on
146
147   data_type: 'datetime'
148   datetime_undef_if_invalid: 1
149   is_nullable: 1
150
151 the date and time an item was last marked as damaged, NULL if not damaged
152
153 =head2 itemlost
154
155   data_type: 'tinyint'
156   default_value: 0
157   is_nullable: 0
158
159 authorized value defining this item as lost (MARC21 952$1)
160
161 =head2 itemlost_on
162
163   data_type: 'datetime'
164   datetime_undef_if_invalid: 1
165   is_nullable: 1
166
167 the date and time an item was last marked as lost, NULL if not lost
168
169 =head2 withdrawn
170
171   data_type: 'tinyint'
172   default_value: 0
173   is_nullable: 0
174
175 authorized value defining this item as withdrawn (MARC21 952$0)
176
177 =head2 withdrawn_on
178
179   data_type: 'datetime'
180   datetime_undef_if_invalid: 1
181   is_nullable: 1
182
183 the date and time an item was last marked as withdrawn, NULL if not withdrawn
184
185 =head2 itemcallnumber
186
187   data_type: 'varchar'
188   is_nullable: 1
189   size: 255
190
191 call number for this item (MARC21 952$o)
192
193 =head2 coded_location_qualifier
194
195   data_type: 'varchar'
196   is_nullable: 1
197   size: 10
198
199 coded location qualifier(MARC21 952$f)
200
201 =head2 issues
202
203   data_type: 'smallint'
204   default_value: 0
205   is_nullable: 1
206
207 number of times this item has been checked out/issued
208
209 =head2 renewals
210
211   data_type: 'smallint'
212   is_nullable: 1
213
214 number of times this item has been renewed
215
216 =head2 reserves
217
218   data_type: 'smallint'
219   is_nullable: 1
220
221 number of times this item has been placed on hold/reserved
222
223 =head2 restricted
224
225   data_type: 'tinyint'
226   is_nullable: 1
227
228 authorized value defining use restrictions for this item (MARC21 952$5)
229
230 =head2 itemnotes
231
232   data_type: 'longtext'
233   is_nullable: 1
234
235 public notes on this item (MARC21 952$z)
236
237 =head2 itemnotes_nonpublic
238
239   data_type: 'longtext'
240   is_nullable: 1
241
242 non-public notes on this item (MARC21 952$x)
243
244 =head2 holdingbranch
245
246   data_type: 'varchar'
247   is_foreign_key: 1
248   is_nullable: 1
249   size: 10
250
251 foreign key from the branches table for the library that is currently in possession item (MARC21 952$b)
252
253 =head2 timestamp
254
255   data_type: 'timestamp'
256   datetime_undef_if_invalid: 1
257   default_value: current_timestamp
258   is_nullable: 0
259
260 date and time this item was last altered
261
262 =head2 deleted_on
263
264   data_type: 'datetime'
265   datetime_undef_if_invalid: 1
266   is_nullable: 1
267
268 date/time of deletion
269
270 =head2 location
271
272   data_type: 'varchar'
273   is_nullable: 1
274   size: 80
275
276 authorized value for the shelving location for this item (MARC21 952$c)
277
278 =head2 permanent_location
279
280   data_type: 'varchar'
281   is_nullable: 1
282   size: 80
283
284 linked to the CART and PROC temporary locations feature, stores the permanent shelving location
285
286 =head2 onloan
287
288   data_type: 'date'
289   datetime_undef_if_invalid: 1
290   is_nullable: 1
291
292 defines if item is checked out (NULL for not checked out, and due date for checked out)
293
294 =head2 cn_source
295
296   data_type: 'varchar'
297   is_nullable: 1
298   size: 10
299
300 classification source used on this item (MARC21 952$2)
301
302 =head2 cn_sort
303
304   data_type: 'varchar'
305   is_nullable: 1
306   size: 255
307
308 normalized form of the call number (MARC21 952$o) used for sorting
309
310 =head2 ccode
311
312   data_type: 'varchar'
313   is_nullable: 1
314   size: 80
315
316 authorized value for the collection code associated with this item (MARC21 952$8)
317
318 =head2 materials
319
320   data_type: 'mediumtext'
321   is_nullable: 1
322
323 materials specified (MARC21 952$3)
324
325 =head2 uri
326
327   data_type: 'mediumtext'
328   is_nullable: 1
329
330 URL for the item (MARC21 952$u)
331
332 =head2 itype
333
334   data_type: 'varchar'
335   is_nullable: 1
336   size: 10
337
338 foreign key from the itemtypes table defining the type for this item (MARC21 952$y)
339
340 =head2 more_subfields_xml
341
342   data_type: 'longtext'
343   is_nullable: 1
344
345 additional 952 subfields in XML format
346
347 =head2 enumchron
348
349   data_type: 'mediumtext'
350   is_nullable: 1
351
352 serial enumeration/chronology for the item (MARC21 952$h)
353
354 =head2 copynumber
355
356   data_type: 'varchar'
357   is_nullable: 1
358   size: 32
359
360 copy number (MARC21 952$t)
361
362 =head2 stocknumber
363
364   data_type: 'varchar'
365   is_nullable: 1
366   size: 32
367
368 inventory number (MARC21 952$i)
369
370 =head2 new_status
371
372   data_type: 'varchar'
373   is_nullable: 1
374   size: 32
375
376 'new' value, you can put whatever free-text information. This field is intented to be managed by the automatic_item_modification_by_age cronjob.
377
378 =head2 exclude_from_local_holds_priority
379
380   data_type: 'tinyint'
381   is_nullable: 1
382
383 Exclude this item from local holds priority
384
385 =cut
386
387 __PACKAGE__->add_columns(
388   "itemnumber",
389   { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
390   "biblionumber",
391   {
392     data_type      => "integer",
393     default_value  => 0,
394     is_foreign_key => 1,
395     is_nullable    => 0,
396   },
397   "biblioitemnumber",
398   {
399     data_type      => "integer",
400     default_value  => 0,
401     is_foreign_key => 1,
402     is_nullable    => 0,
403   },
404   "barcode",
405   { data_type => "varchar", is_nullable => 1, size => 20 },
406   "dateaccessioned",
407   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
408   "booksellerid",
409   { data_type => "longtext", is_nullable => 1 },
410   "homebranch",
411   { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
412   "price",
413   { data_type => "decimal", is_nullable => 1, size => [8, 2] },
414   "replacementprice",
415   { data_type => "decimal", is_nullable => 1, size => [8, 2] },
416   "replacementpricedate",
417   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
418   "datelastborrowed",
419   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
420   "datelastseen",
421   {
422     data_type => "datetime",
423     datetime_undef_if_invalid => 1,
424     is_nullable => 1,
425   },
426   "stack",
427   { data_type => "tinyint", is_nullable => 1 },
428   "notforloan",
429   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
430   "damaged",
431   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
432   "damaged_on",
433   {
434     data_type => "datetime",
435     datetime_undef_if_invalid => 1,
436     is_nullable => 1,
437   },
438   "itemlost",
439   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
440   "itemlost_on",
441   {
442     data_type => "datetime",
443     datetime_undef_if_invalid => 1,
444     is_nullable => 1,
445   },
446   "withdrawn",
447   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
448   "withdrawn_on",
449   {
450     data_type => "datetime",
451     datetime_undef_if_invalid => 1,
452     is_nullable => 1,
453   },
454   "itemcallnumber",
455   { data_type => "varchar", is_nullable => 1, size => 255 },
456   "coded_location_qualifier",
457   { data_type => "varchar", is_nullable => 1, size => 10 },
458   "issues",
459   { data_type => "smallint", default_value => 0, is_nullable => 1 },
460   "renewals",
461   { data_type => "smallint", is_nullable => 1 },
462   "reserves",
463   { data_type => "smallint", is_nullable => 1 },
464   "restricted",
465   { data_type => "tinyint", is_nullable => 1 },
466   "itemnotes",
467   { data_type => "longtext", is_nullable => 1 },
468   "itemnotes_nonpublic",
469   { data_type => "longtext", is_nullable => 1 },
470   "holdingbranch",
471   { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
472   "timestamp",
473   {
474     data_type => "timestamp",
475     datetime_undef_if_invalid => 1,
476     default_value => \"current_timestamp",
477     is_nullable => 0,
478   },
479   "deleted_on",
480   {
481     data_type => "datetime",
482     datetime_undef_if_invalid => 1,
483     is_nullable => 1,
484   },
485   "location",
486   { data_type => "varchar", is_nullable => 1, size => 80 },
487   "permanent_location",
488   { data_type => "varchar", is_nullable => 1, size => 80 },
489   "onloan",
490   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
491   "cn_source",
492   { data_type => "varchar", is_nullable => 1, size => 10 },
493   "cn_sort",
494   { data_type => "varchar", is_nullable => 1, size => 255 },
495   "ccode",
496   { data_type => "varchar", is_nullable => 1, size => 80 },
497   "materials",
498   { data_type => "mediumtext", is_nullable => 1 },
499   "uri",
500   { data_type => "mediumtext", is_nullable => 1 },
501   "itype",
502   { data_type => "varchar", is_nullable => 1, size => 10 },
503   "more_subfields_xml",
504   { data_type => "longtext", is_nullable => 1 },
505   "enumchron",
506   { data_type => "mediumtext", is_nullable => 1 },
507   "copynumber",
508   { data_type => "varchar", is_nullable => 1, size => 32 },
509   "stocknumber",
510   { data_type => "varchar", is_nullable => 1, size => 32 },
511   "new_status",
512   { data_type => "varchar", is_nullable => 1, size => 32 },
513   "exclude_from_local_holds_priority",
514   { data_type => "tinyint", is_nullable => 1 },
515 );
516
517 =head1 PRIMARY KEY
518
519 =over 4
520
521 =item * L</itemnumber>
522
523 =back
524
525 =cut
526
527 __PACKAGE__->set_primary_key("itemnumber");
528
529 =head1 UNIQUE CONSTRAINTS
530
531 =head2 C<itembarcodeidx>
532
533 =over 4
534
535 =item * L</barcode>
536
537 =back
538
539 =cut
540
541 __PACKAGE__->add_unique_constraint("itembarcodeidx", ["barcode"]);
542
543 =head1 RELATIONS
544
545 =head2 accountlines
546
547 Type: has_many
548
549 Related object: L<Koha::Schema::Result::Accountline>
550
551 =cut
552
553 __PACKAGE__->has_many(
554   "accountlines",
555   "Koha::Schema::Result::Accountline",
556   { "foreign.itemnumber" => "self.itemnumber" },
557   { cascade_copy => 0, cascade_delete => 0 },
558 );
559
560 =head2 article_requests
561
562 Type: has_many
563
564 Related object: L<Koha::Schema::Result::ArticleRequest>
565
566 =cut
567
568 __PACKAGE__->has_many(
569   "article_requests",
570   "Koha::Schema::Result::ArticleRequest",
571   { "foreign.itemnumber" => "self.itemnumber" },
572   { cascade_copy => 0, cascade_delete => 0 },
573 );
574
575 =head2 biblioitemnumber
576
577 Type: belongs_to
578
579 Related object: L<Koha::Schema::Result::Biblioitem>
580
581 =cut
582
583 __PACKAGE__->belongs_to(
584   "biblioitemnumber",
585   "Koha::Schema::Result::Biblioitem",
586   { biblioitemnumber => "biblioitemnumber" },
587   { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
588 );
589
590 =head2 biblionumber
591
592 Type: belongs_to
593
594 Related object: L<Koha::Schema::Result::Biblio>
595
596 =cut
597
598 __PACKAGE__->belongs_to(
599   "biblionumber",
600   "Koha::Schema::Result::Biblio",
601   { biblionumber => "biblionumber" },
602   { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
603 );
604
605 =head2 branchtransfers
606
607 Type: has_many
608
609 Related object: L<Koha::Schema::Result::Branchtransfer>
610
611 =cut
612
613 __PACKAGE__->has_many(
614   "branchtransfers",
615   "Koha::Schema::Result::Branchtransfer",
616   { "foreign.itemnumber" => "self.itemnumber" },
617   { cascade_copy => 0, cascade_delete => 0 },
618 );
619
620 =head2 club_holds
621
622 Type: has_many
623
624 Related object: L<Koha::Schema::Result::ClubHold>
625
626 =cut
627
628 __PACKAGE__->has_many(
629   "club_holds",
630   "Koha::Schema::Result::ClubHold",
631   { "foreign.item_id" => "self.itemnumber" },
632   { cascade_copy => 0, cascade_delete => 0 },
633 );
634
635 =head2 course_item
636
637 Type: might_have
638
639 Related object: L<Koha::Schema::Result::CourseItem>
640
641 =cut
642
643 __PACKAGE__->might_have(
644   "course_item",
645   "Koha::Schema::Result::CourseItem",
646   { "foreign.itemnumber" => "self.itemnumber" },
647   { cascade_copy => 0, cascade_delete => 0 },
648 );
649
650 =head2 cover_images
651
652 Type: has_many
653
654 Related object: L<Koha::Schema::Result::CoverImage>
655
656 =cut
657
658 __PACKAGE__->has_many(
659   "cover_images",
660   "Koha::Schema::Result::CoverImage",
661   { "foreign.itemnumber" => "self.itemnumber" },
662   { cascade_copy => 0, cascade_delete => 0 },
663 );
664
665 =head2 creator_batches
666
667 Type: has_many
668
669 Related object: L<Koha::Schema::Result::CreatorBatch>
670
671 =cut
672
673 __PACKAGE__->has_many(
674   "creator_batches",
675   "Koha::Schema::Result::CreatorBatch",
676   { "foreign.item_number" => "self.itemnumber" },
677   { cascade_copy => 0, cascade_delete => 0 },
678 );
679
680 =head2 hold_fill_target
681
682 Type: might_have
683
684 Related object: L<Koha::Schema::Result::HoldFillTarget>
685
686 =cut
687
688 __PACKAGE__->might_have(
689   "hold_fill_target",
690   "Koha::Schema::Result::HoldFillTarget",
691   { "foreign.itemnumber" => "self.itemnumber" },
692   { cascade_copy => 0, cascade_delete => 0 },
693 );
694
695 =head2 holdingbranch
696
697 Type: belongs_to
698
699 Related object: L<Koha::Schema::Result::Branch>
700
701 =cut
702
703 __PACKAGE__->belongs_to(
704   "holdingbranch",
705   "Koha::Schema::Result::Branch",
706   { branchcode => "holdingbranch" },
707   {
708     is_deferrable => 1,
709     join_type     => "LEFT",
710     on_delete     => "RESTRICT",
711     on_update     => "CASCADE",
712   },
713 );
714
715 =head2 homebranch
716
717 Type: belongs_to
718
719 Related object: L<Koha::Schema::Result::Branch>
720
721 =cut
722
723 __PACKAGE__->belongs_to(
724   "homebranch",
725   "Koha::Schema::Result::Branch",
726   { branchcode => "homebranch" },
727   {
728     is_deferrable => 1,
729     join_type     => "LEFT",
730     on_delete     => "RESTRICT",
731     on_update     => "CASCADE",
732   },
733 );
734
735 =head2 issue
736
737 Type: might_have
738
739 Related object: L<Koha::Schema::Result::Issue>
740
741 =cut
742
743 __PACKAGE__->might_have(
744   "issue",
745   "Koha::Schema::Result::Issue",
746   { "foreign.itemnumber" => "self.itemnumber" },
747   { cascade_copy => 0, cascade_delete => 0 },
748 );
749
750 =head2 item_bundles_hosts
751
752 Type: has_many
753
754 Related object: L<Koha::Schema::Result::ItemBundle>
755
756 =cut
757
758 __PACKAGE__->has_many(
759   "item_bundles_hosts",
760   "Koha::Schema::Result::ItemBundle",
761   { "foreign.host" => "self.itemnumber" },
762   { cascade_copy => 0, cascade_delete => 0 },
763 );
764
765 =head2 item_bundles_item
766
767 Type: might_have
768
769 Related object: L<Koha::Schema::Result::ItemBundle>
770
771 =cut
772
773 __PACKAGE__->might_have(
774   "item_bundles_item",
775   "Koha::Schema::Result::ItemBundle",
776   { "foreign.item" => "self.itemnumber" },
777   { cascade_copy => 0, cascade_delete => 0 },
778 );
779
780 =head2 item_group_item
781
782 Type: might_have
783
784 Related object: L<Koha::Schema::Result::ItemGroupItem>
785
786 =cut
787
788 __PACKAGE__->might_have(
789   "item_group_item",
790   "Koha::Schema::Result::ItemGroupItem",
791   { "foreign.item_id" => "self.itemnumber" },
792   { cascade_copy => 0, cascade_delete => 0 },
793 );
794
795 =head2 items_last_borrower
796
797 Type: might_have
798
799 Related object: L<Koha::Schema::Result::ItemsLastBorrower>
800
801 =cut
802
803 __PACKAGE__->might_have(
804   "items_last_borrower",
805   "Koha::Schema::Result::ItemsLastBorrower",
806   { "foreign.itemnumber" => "self.itemnumber" },
807   { cascade_copy => 0, cascade_delete => 0 },
808 );
809
810 =head2 linktrackers
811
812 Type: has_many
813
814 Related object: L<Koha::Schema::Result::Linktracker>
815
816 =cut
817
818 __PACKAGE__->has_many(
819   "linktrackers",
820   "Koha::Schema::Result::Linktracker",
821   { "foreign.itemnumber" => "self.itemnumber" },
822   { cascade_copy => 0, cascade_delete => 0 },
823 );
824
825 =head2 old_issues
826
827 Type: has_many
828
829 Related object: L<Koha::Schema::Result::OldIssue>
830
831 =cut
832
833 __PACKAGE__->has_many(
834   "old_issues",
835   "Koha::Schema::Result::OldIssue",
836   { "foreign.itemnumber" => "self.itemnumber" },
837   { cascade_copy => 0, cascade_delete => 0 },
838 );
839
840 =head2 old_reserves
841
842 Type: has_many
843
844 Related object: L<Koha::Schema::Result::OldReserve>
845
846 =cut
847
848 __PACKAGE__->has_many(
849   "old_reserves",
850   "Koha::Schema::Result::OldReserve",
851   { "foreign.itemnumber" => "self.itemnumber" },
852   { cascade_copy => 0, cascade_delete => 0 },
853 );
854
855 =head2 recalls
856
857 Type: has_many
858
859 Related object: L<Koha::Schema::Result::Recall>
860
861 =cut
862
863 __PACKAGE__->has_many(
864   "recalls",
865   "Koha::Schema::Result::Recall",
866   { "foreign.item_id" => "self.itemnumber" },
867   { cascade_copy => 0, cascade_delete => 0 },
868 );
869
870 =head2 reserves
871
872 Type: has_many
873
874 Related object: L<Koha::Schema::Result::Reserve>
875
876 =cut
877
878 __PACKAGE__->has_many(
879   "reserves",
880   "Koha::Schema::Result::Reserve",
881   { "foreign.itemnumber" => "self.itemnumber" },
882   { cascade_copy => 0, cascade_delete => 0 },
883 );
884
885 =head2 return_claims
886
887 Type: has_many
888
889 Related object: L<Koha::Schema::Result::ReturnClaim>
890
891 =cut
892
893 __PACKAGE__->has_many(
894   "return_claims",
895   "Koha::Schema::Result::ReturnClaim",
896   { "foreign.itemnumber" => "self.itemnumber" },
897   { cascade_copy => 0, cascade_delete => 0 },
898 );
899
900 =head2 serialitem
901
902 Type: might_have
903
904 Related object: L<Koha::Schema::Result::Serialitem>
905
906 =cut
907
908 __PACKAGE__->might_have(
909   "serialitem",
910   "Koha::Schema::Result::Serialitem",
911   { "foreign.itemnumber" => "self.itemnumber" },
912   { cascade_copy => 0, cascade_delete => 0 },
913 );
914
915 =head2 stockrotationitem
916
917 Type: might_have
918
919 Related object: L<Koha::Schema::Result::Stockrotationitem>
920
921 =cut
922
923 __PACKAGE__->might_have(
924   "stockrotationitem",
925   "Koha::Schema::Result::Stockrotationitem",
926   { "foreign.itemnumber_id" => "self.itemnumber" },
927   { cascade_copy => 0, cascade_delete => 0 },
928 );
929
930 =head2 tmp_holdsqueues
931
932 Type: has_many
933
934 Related object: L<Koha::Schema::Result::TmpHoldsqueue>
935
936 =cut
937
938 __PACKAGE__->has_many(
939   "tmp_holdsqueues",
940   "Koha::Schema::Result::TmpHoldsqueue",
941   { "foreign.itemnumber" => "self.itemnumber" },
942   { cascade_copy => 0, cascade_delete => 0 },
943 );
944
945
946 # Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-05-12 18:18:47
947 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:HMU2tnuIRypuatz/J5683A
948
949 __PACKAGE__->belongs_to( biblioitem => "Koha::Schema::Result::Biblioitem", "biblioitemnumber" );
950
951 __PACKAGE__->belongs_to(
952   "biblio",
953   "Koha::Schema::Result::Biblio",
954   { biblionumber => "biblionumber" },
955   { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
956 );
957
958 __PACKAGE__->add_columns(
959     '+exclude_from_local_holds_priority' => { is_boolean => 1 },
960 );
961
962 # Relationship with orders via the aqorders_item table that not have foreign keys
963 __PACKAGE__->has_many(
964   "aqorders_item",
965   "Koha::Schema::Result::AqordersItem",
966   { "foreign.itemnumber" => "self.itemnumber" },
967   { cascade_copy => 0, cascade_delete => 0 },
968 );
969 __PACKAGE__->many_to_many(
970   "item_orders",
971   "aqorders_item",
972   "ordernumber",
973 );
974
975 __PACKAGE__->has_many(
976   "current_branchtransfers",
977   "Koha::Schema::Result::Branchtransfer",
978   { 'foreign.itemnumber' => 'self.itemnumber' },
979   {
980       where => { datearrived => undef, datecancelled => undef },
981       order_by => [ { -desc => 'datesent' }, { -asc => 'daterequested' } ]
982   }
983 );
984
985 __PACKAGE__->might_have(
986   "last_returned_by",
987   "Koha::Schema::Result::ItemsLastBorrower",
988   { "foreign.itemnumber" => "self.itemnumber" },
989   { cascade_copy => 0, cascade_delete => 0 },
990 );
991
992 use C4::Context;
993 sub effective_itemtype {
994     my ( $self ) = @_;
995
996     my $pref = C4::Context->preference('item-level_itypes');
997     if ( $pref && $self->itype() ) {
998         return $self->itype();
999     } else {
1000         warn "item-level_itypes set but no itemtype set for item (".$self->itemnumber.")"
1001           if $pref;
1002         return $self->biblioitemnumber()->itemtype();
1003     }
1004 }
1005
1006 1;