| 1 | 2 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | |||||||||||
| 3 | package Interchange6::Schema::Result::OrderlinesShipping; | ||||||||||
| 4 | |||||||||||
| 5 | =head1 NAME | ||||||||||
| 6 | |||||||||||
| 7 | Interchange6::Schema::Result::OrderlinesShipping | ||||||||||
| 8 | |||||||||||
| 9 | =cut | ||||||||||
| 10 | |||||||||||
| 11 | 2 | ▶ | use Interchange6::Schema::Candy; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | =head1 ACCESSORS | ||||||||||
| 14 | |||||||||||
| 15 | =head2 orderlines_id | ||||||||||
| 16 | |||||||||||
| 17 | Foreign key constraint on L<Interchange6::Schema::Result::Orderline/orderlines_id> | ||||||||||
| 18 | via L</orderline> relationship. | ||||||||||
| 19 | |||||||||||
| 20 | =cut | ||||||||||
| 21 | |||||||||||
| 22 | 2 | column orderlines_id => { data_type => "integer" }; | |||||||||
| 23 | |||||||||||
| 24 | =head2 addresses_id | ||||||||||
| 25 | |||||||||||
| 26 | Foreign key constraint on L<Interchange6::Schema::Result::Address/addresses_id> | ||||||||||
| 27 | via L</address> relationship. | ||||||||||
| 28 | |||||||||||
| 29 | =cut | ||||||||||
| 30 | |||||||||||
| 31 | 2 | column addresses_id => { data_type => "integer" }; | |||||||||
| 32 | |||||||||||
| 33 | =head2 shipments_id | ||||||||||
| 34 | |||||||||||
| 35 | Foreign key constraint on L<Interchange6::Schema::Result::Shipment/shipments_id> | ||||||||||
| 36 | via L</shipment> relationship. | ||||||||||
| 37 | |||||||||||
| 38 | =cut | ||||||||||
| 39 | |||||||||||
| 40 | 2 | column shipments_id => { data_type => "integer" }; | |||||||||
| 41 | |||||||||||
| 42 | =head2 quantity | ||||||||||
| 43 | |||||||||||
| 44 | The partial or full quantity shipped for the related | ||||||||||
| 45 | L<Interchange6::Schema::Result::Orderline> in this shipment. | ||||||||||
| 46 | |||||||||||
| 47 | =cut | ||||||||||
| 48 | |||||||||||
| 49 | 2 | column quantity => { data_type => "integer" }; | |||||||||
| 50 | |||||||||||
| 51 | =head1 PRIMARY KEY | ||||||||||
| 52 | |||||||||||
| 53 | Each unique combination of L</orderline> and L</address> can have multiple | ||||||||||
| 54 | related L</shipments> in case an L</orderline> needs to be shipped in more | ||||||||||
| 55 | than one consignment. | ||||||||||
| 56 | |||||||||||
| 57 | =over 4 | ||||||||||
| 58 | |||||||||||
| 59 | =item * L</orderlines_id> | ||||||||||
| 60 | |||||||||||
| 61 | =item * L</addresses_id> | ||||||||||
| 62 | |||||||||||
| 63 | =item * L</shipments_id> | ||||||||||
| 64 | |||||||||||
| 65 | =back | ||||||||||
| 66 | |||||||||||
| 67 | =cut | ||||||||||
| 68 | |||||||||||
| 69 | 2 | primary_key "orderlines_id", "addresses_id", "shipments_id"; | |||||||||
| 70 | |||||||||||
| 71 | =head1 RELATIONS | ||||||||||
| 72 | |||||||||||
| 73 | =head2 address | ||||||||||
| 74 | |||||||||||
| 75 | Type: belongs_to | ||||||||||
| 76 | |||||||||||
| 77 | Related object: L<Interchange6::Schema::Result::Address> | ||||||||||
| 78 | |||||||||||
| 79 | =cut | ||||||||||
| 80 | |||||||||||
| 81 | 2 | belongs_to | |||||||||
| 82 | address => "Interchange6::Schema::Result::Address", | ||||||||||
| 83 | "addresses_id"; | ||||||||||
| 84 | |||||||||||
| 85 | =head2 orderline | ||||||||||
| 86 | |||||||||||
| 87 | Type: belongs_to | ||||||||||
| 88 | |||||||||||
| 89 | Related object: L<Interchange6::Schema::Result::Orderline> | ||||||||||
| 90 | |||||||||||
| 91 | =cut | ||||||||||
| 92 | |||||||||||
| 93 | 2 | belongs_to | |||||||||
| 94 | orderline => "Interchange6::Schema::Result::Orderline", | ||||||||||
| 95 | "orderlines_id"; | ||||||||||
| 96 | |||||||||||
| 97 | =head2 shipment | ||||||||||
| 98 | |||||||||||
| 99 | Type: belongs_to | ||||||||||
| 100 | |||||||||||
| 101 | Related object: L<Interchange6::Schema::Result::Shipment> | ||||||||||
| 102 | |||||||||||
| 103 | =cut | ||||||||||
| 104 | |||||||||||
| 105 | 2 | belongs_to | |||||||||
| 106 | shipment => "Interchange6::Schema::Result::Shipment", | ||||||||||
| 107 | "shipments_id"; | ||||||||||
| 108 | |||||||||||
| 109 | =head1 METHODS | ||||||||||
| 110 | |||||||||||
| 111 | =head2 delete | ||||||||||
| 112 | |||||||||||
| 113 | Rows in this table should not be deleted so we overload | ||||||||||
| 114 | L<DBIx::Class::Row/delete> to throw an exception. | ||||||||||
| 115 | |||||||||||
| 116 | NOTE: if L<DBIx::Class::ResultSet/delete> is called on a result set then this | ||||||||||
| 117 | overloaded method is bypassed. Please consider using | ||||||||||
| 118 | L<DBIx::Class::ResultSet/delete_all> instead. Of course we also cannot prevent | ||||||||||
| 119 | deletes performed outside DBIx::Class control. | ||||||||||
| 120 | |||||||||||
| 121 | =cut | ||||||||||
| 122 | |||||||||||
| 123 | sub delete { | ||||||||||
| 124 | shift->result_source->schema->throw_exception( | ||||||||||
| 125 | 1 | ▶ | "OrderlinesShipping rows cannot be deleted"); | ||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 126 | } | ||||||||||
| 127 | |||||||||||
| 128 | =head2 partial_shipment | ||||||||||
| 129 | |||||||||||
| 130 | If L<Interchange6::Schema::Result::Orderline/quantity> is greater than | ||||||||||
| 131 | L</quantity> then return 1. Otherwise returns 0. | ||||||||||
| 132 | |||||||||||
| 133 | =cut | ||||||||||
| 134 | |||||||||||
| 135 | sub partial_shipment { | ||||||||||
| 136 | 3 | ▶ | my $self = shift; | ||||||||
|
Subroutine
partial_shipment: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 137 | 3 | ▶ | return $self->orderline->quantity > $self->quantity ? 1 : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 138 | } | ||||||||||
| 139 | |||||||||||
| 140 | 2 | 1; | |||||||||