2 package Koha::Schema::Result::Aqorder;
4 # Created by DBIx::Class::Schema::Loader
5 # DO NOT MODIFY THE FIRST PART OF THIS FILE
9 Koha::Schema::Result::Aqorder
16 use base 'DBIx::Class::Core';
18 =head1 TABLE: C<aqorders>
22 __PACKAGE__->table("aqorders");
32 primary key and unique identifier assigned by Koha to each line
40 links the order to the biblio being ordered (biblio.biblionumber)
42 =head2 deleted_biblionumber
47 links the order to the deleted bibliographic record (deletedbiblio.biblionumber)
52 datetime_undef_if_invalid: 1
55 the date the bib was added to the basket
71 the currency used for the purchase
79 the vendor price for this line item
84 datetime_undef_if_invalid: 1
87 the date this order was received
103 shipping costs (not used)
111 the actual cost entered when receiving this line item
113 =head2 unitprice_tax_excluded
119 the unit price excluding tax (on receiving)
121 =head2 unitprice_tax_included
127 the unit price including tax (on receiving)
129 =head2 quantityreceived
131 data_type: 'smallint'
135 the quantity that have been received so far
143 the borrowernumber of order line's creator
145 =head2 datecancellationprinted
148 datetime_undef_if_invalid: 1
151 the date the line item was deleted
153 =head2 cancellationreason
155 data_type: 'mediumtext'
158 reason of cancellation
160 =head2 order_internalnote
162 data_type: 'longtext'
165 notes related to this order line, made for staff
167 =head2 order_vendornote
169 data_type: 'longtext'
172 notes related to this order line, made for vendor
174 =head2 purchaseordernumber
176 data_type: 'longtext'
179 not used? always NULL
187 links this order line to a specific basket (aqbasket.basketno)
191 data_type: 'timestamp'
192 datetime_undef_if_invalid: 1
193 default_value: current_timestamp
196 the date and time this order line was last modified
204 the retail cost for this line item
206 =head2 replacementprice
212 the replacement cost for this line item
214 =head2 rrp_tax_excluded
220 the replacement cost excluding tax
222 =head2 rrp_tax_included
228 the replacement cost including tax
236 the replacement cost for this line item
238 =head2 ecost_tax_excluded
244 the estimated cost excluding tax
246 =head2 ecost_tax_included
252 the estimated cost including tax
260 the tax rate for this line item (%)
262 =head2 tax_rate_on_ordering
268 the tax rate on ordering for this line item (%)
270 =head2 tax_rate_on_receiving
276 the tax rate on receiving for this line item (%)
284 the tax value for this line item
286 =head2 tax_value_on_ordering
292 the tax value on ordering for this line item
294 =head2 tax_value_on_receiving
300 the tax value on receiving for this line item
308 the discount for this line item (%)
316 the fund this order goes against (aqbudgets.budget_id)
321 datetime_undef_if_invalid: 1
324 not used? always NULL
340 second statistical field
354 =head2 uncertainprice
359 was this price uncertain (1 for yes, 0 for no)
361 =head2 subscriptionid
367 links this order line to a subscription (subscription.subscriptionid)
369 =head2 parent_ordernumber
374 ordernumber of parent order line, or same as ordernumber if no parent
383 the current status for this line item. Can be 'new', 'ordered', 'partial', 'complete' or 'cancelled'
391 Supplier's article id for Edifact orderline
393 =head2 suppliers_reference_number
399 Suppliers unique edifact quote ref
401 =head2 suppliers_reference_qualifier
407 Type of number above usually 'QLI'
409 =head2 suppliers_report
411 data_type: 'mediumtext'
414 reports received from suppliers
416 =head2 estimated_delivery_date
419 datetime_undef_if_invalid: 1
422 Estimated delivery date
424 =head2 invoice_unitprice
430 the unit price in foreign currency
432 =head2 invoice_currency
439 the currency of the invoice_unitprice
443 __PACKAGE__->add_columns(
445 { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
447 { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
448 "deleted_biblionumber",
449 { data_type => "integer", is_nullable => 1 },
451 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
453 { data_type => "smallint", is_nullable => 1 },
455 { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
457 { data_type => "decimal", is_nullable => 1, size => [28, 6] },
459 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
461 { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
463 { data_type => "decimal", is_nullable => 1, size => [28, 6] },
465 { data_type => "decimal", is_nullable => 1, size => [28, 6] },
466 "unitprice_tax_excluded",
467 { data_type => "decimal", is_nullable => 1, size => [28, 6] },
468 "unitprice_tax_included",
469 { data_type => "decimal", is_nullable => 1, size => [28, 6] },
471 { data_type => "smallint", default_value => 0, is_nullable => 0 },
473 { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
474 "datecancellationprinted",
475 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
476 "cancellationreason",
477 { data_type => "mediumtext", is_nullable => 1 },
478 "order_internalnote",
479 { data_type => "longtext", is_nullable => 1 },
481 { data_type => "longtext", is_nullable => 1 },
482 "purchaseordernumber",
483 { data_type => "longtext", is_nullable => 1 },
485 { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
488 data_type => "timestamp",
489 datetime_undef_if_invalid => 1,
490 default_value => \"current_timestamp",
494 { data_type => "decimal", is_nullable => 1, size => [13, 2] },
496 { data_type => "decimal", is_nullable => 1, size => [28, 6] },
498 { data_type => "decimal", is_nullable => 1, size => [28, 6] },
500 { data_type => "decimal", is_nullable => 1, size => [28, 6] },
502 { data_type => "decimal", is_nullable => 1, size => [13, 2] },
503 "ecost_tax_excluded",
504 { data_type => "decimal", is_nullable => 1, size => [28, 6] },
505 "ecost_tax_included",
506 { data_type => "decimal", is_nullable => 1, size => [28, 6] },
508 { data_type => "decimal", is_nullable => 1, size => [6, 4] },
509 "tax_rate_on_ordering",
510 { data_type => "decimal", is_nullable => 1, size => [6, 4] },
511 "tax_rate_on_receiving",
512 { data_type => "decimal", is_nullable => 1, size => [6, 4] },
514 { data_type => "decimal", is_nullable => 1, size => [28, 6] },
515 "tax_value_on_ordering",
516 { data_type => "decimal", is_nullable => 1, size => [28, 6] },
517 "tax_value_on_receiving",
518 { data_type => "decimal", is_nullable => 1, size => [28, 6] },
520 { data_type => "float", is_nullable => 1, size => [6, 4] },
522 { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
524 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
526 { data_type => "varchar", is_nullable => 1, size => 80 },
528 { data_type => "varchar", is_nullable => 1, size => 80 },
530 { data_type => "varchar", is_nullable => 1, size => 10 },
532 { data_type => "varchar", is_nullable => 1, size => 10 },
534 { data_type => "tinyint", is_nullable => 1 },
536 { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
537 "parent_ordernumber",
538 { data_type => "integer", is_nullable => 1 },
541 data_type => "varchar",
542 default_value => "new",
547 { data_type => "varchar", is_nullable => 1, size => 35 },
548 "suppliers_reference_number",
549 { data_type => "varchar", is_nullable => 1, size => 35 },
550 "suppliers_reference_qualifier",
551 { data_type => "varchar", is_nullable => 1, size => 3 },
553 { data_type => "mediumtext", is_nullable => 1 },
554 "estimated_delivery_date",
555 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
557 { data_type => "decimal", is_nullable => 1, size => [28, 6] },
559 { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
566 =item * L</ordernumber>
572 __PACKAGE__->set_primary_key("ordernumber");
580 Related object: L<Koha::Schema::Result::AqorderUser>
584 __PACKAGE__->has_many(
586 "Koha::Schema::Result::AqorderUser",
587 { "foreign.ordernumber" => "self.ordernumber" },
588 { cascade_copy => 0, cascade_delete => 0 },
591 =head2 aqorders_claims
595 Related object: L<Koha::Schema::Result::AqordersClaim>
599 __PACKAGE__->has_many(
601 "Koha::Schema::Result::AqordersClaim",
602 { "foreign.ordernumber" => "self.ordernumber" },
603 { cascade_copy => 0, cascade_delete => 0 },
606 =head2 aqorders_items
610 Related object: L<Koha::Schema::Result::AqordersItem>
614 __PACKAGE__->has_many(
616 "Koha::Schema::Result::AqordersItem",
617 { "foreign.ordernumber" => "self.ordernumber" },
618 { cascade_copy => 0, cascade_delete => 0 },
621 =head2 aqorders_transfers_ordernumber_from
625 Related object: L<Koha::Schema::Result::AqordersTransfer>
629 __PACKAGE__->might_have(
630 "aqorders_transfers_ordernumber_from",
631 "Koha::Schema::Result::AqordersTransfer",
632 { "foreign.ordernumber_from" => "self.ordernumber" },
633 { cascade_copy => 0, cascade_delete => 0 },
636 =head2 aqorders_transfers_ordernumber_to
640 Related object: L<Koha::Schema::Result::AqordersTransfer>
644 __PACKAGE__->might_have(
645 "aqorders_transfers_ordernumber_to",
646 "Koha::Schema::Result::AqordersTransfer",
647 { "foreign.ordernumber_to" => "self.ordernumber" },
648 { cascade_copy => 0, cascade_delete => 0 },
655 Related object: L<Koha::Schema::Result::Aqbasket>
659 __PACKAGE__->belongs_to(
661 "Koha::Schema::Result::Aqbasket",
662 { basketno => "basketno" },
666 on_delete => "CASCADE",
667 on_update => "CASCADE",
675 Related object: L<Koha::Schema::Result::Biblio>
679 __PACKAGE__->belongs_to(
681 "Koha::Schema::Result::Biblio",
682 { biblionumber => "biblionumber" },
686 on_delete => "SET NULL",
687 on_update => "CASCADE",
695 Related object: L<Koha::Schema::Result::Aqbudget>
699 __PACKAGE__->belongs_to(
701 "Koha::Schema::Result::Aqbudget",
702 { budget_id => "budget_id" },
703 { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
710 Related object: L<Koha::Schema::Result::Borrower>
714 __PACKAGE__->belongs_to(
716 "Koha::Schema::Result::Borrower",
717 { borrowernumber => "created_by" },
721 on_delete => "SET NULL",
722 on_update => "CASCADE",
730 Related object: L<Koha::Schema::Result::Currency>
734 __PACKAGE__->belongs_to(
736 "Koha::Schema::Result::Currency",
737 { currency => "currency" },
741 on_delete => "SET NULL",
742 on_update => "SET NULL",
746 =head2 invoice_currency
750 Related object: L<Koha::Schema::Result::Currency>
754 __PACKAGE__->belongs_to(
756 "Koha::Schema::Result::Currency",
757 { currency => "invoice_currency" },
761 on_delete => "SET NULL",
762 on_update => "SET NULL",
770 Related object: L<Koha::Schema::Result::Aqinvoice>
774 __PACKAGE__->belongs_to(
776 "Koha::Schema::Result::Aqinvoice",
777 { invoiceid => "invoiceid" },
781 on_delete => "SET NULL",
782 on_update => "CASCADE",
786 =head2 subscriptionid
790 Related object: L<Koha::Schema::Result::Subscription>
794 __PACKAGE__->belongs_to(
796 "Koha::Schema::Result::Subscription",
797 { subscriptionid => "subscriptionid" },
801 on_delete => "CASCADE",
802 on_update => "CASCADE",
806 =head2 borrowernumbers
810 Composing rels: L</aqorder_users> -> borrowernumber
814 __PACKAGE__->many_to_many("borrowernumbers", "aqorder_users", "borrowernumber");
817 # Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-05-05 12:31:38
818 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Bt8GMBWcWja5oa7r+8Vbig
820 __PACKAGE__->belongs_to(
822 "Koha::Schema::Result::Aqbasket",
823 { "foreign.basketno" => "self.basketno" },
827 on_delete => "CASCADE",
828 on_update => "CASCADE",
832 __PACKAGE__->belongs_to(
834 "Koha::Schema::Result::Biblio",
835 { 'foreign.biblionumber' => "self.biblionumber" },
839 on_delete => "SET NULL",
840 on_update => "CASCADE",
844 __PACKAGE__->belongs_to(
846 "Koha::Schema::Result::Aqbudget",
847 { "foreign.budget_id" => "self.budget_id" },
848 { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
851 __PACKAGE__->belongs_to(
853 "Koha::Schema::Result::Aqinvoice",
854 { "foreign.invoiceid" => "self.invoiceid" },
858 on_delete => "SET NULL",
859 on_update => "CASCADE",
867 Related object: L<Koha::Schema::Result::Borrower>
871 __PACKAGE__->belongs_to(
873 "Koha::Schema::Result::Borrower",
874 { borrowernumber => "created_by" },
878 on_delete => "SET NULL",
879 on_update => "CASCADE",
883 __PACKAGE__->belongs_to(
885 "Koha::Schema::Result::Subscription",
886 { "foreign.subscriptionid" => "self.subscriptionid" },
890 on_delete => "CASCADE",
891 on_update => "CASCADE",
895 __PACKAGE__->has_many(
896 "additional_field_values",
897 "Koha::Schema::Result::AdditionalFieldValue",
902 "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.ordernumber" },
904 # TODO Add column additional_field_values.tablename to avoid subquery ?
905 "$args->{foreign_alias}.field_id" =>
906 { -in => \'(SELECT id FROM additional_fields WHERE tablename = "aqorders")' },
909 { cascade_copy => 0, cascade_delete => 0 },
912 sub koha_objects_class {
913 'Koha::Acquisition::Orders';
916 sub koha_object_class {
917 'Koha::Acquisition::Order';
920 __PACKAGE__->add_columns(
921 '+uncertainprice' => { is_boolean => 1 }