Class: Delivery

Inherits:
Ekylibre::Record::Base show all
Includes:
Attachable, Customizable
Defined in:
app/models/delivery.rb

Overview

Informations

License

Ekylibre - Simple agricultural ERP Copyright (C) 2008-2009 Brice Texier, Thibaud Merigon Copyright (C) 2010-2012 Brice Texier Copyright (C) 2012-2016 Brice Texier, David Joulin

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see www.gnu.org/licenses.

Table: deliveries

annotation              :text
created_at              :datetime         not null
creator_id              :integer
custom_fields           :jsonb
driver_id               :integer
id                      :integer          not null, primary key
lock_version            :integer          default(0), not null
mode                    :string
number                  :string
reference_number        :string
responsible_id          :integer
started_at              :datetime
state                   :string           not null
stopped_at              :datetime
transporter_id          :integer
transporter_purchase_id :integer
updated_at              :datetime         not null
updater_id              :integer

Instance Method Summary collapse

Methods included from Customizable

#custom_value, #set_custom_value, #validate_custom_fields

Methods inherited from Ekylibre::Record::Base

#already_updated?, attr_readonly_with_conditions, #check_if_destroyable?, #check_if_updateable?, columns_definition, complex_scopes, customizable?, #customizable?, #customized?, #destroyable?, #editable?, has_picture, #human_attribute_name, human_attribute_name_with_id, nomenclature_reflections, #old_record, #others, refers_to, scope_with_registration, simple_scopes, #updateable?

Instance Method Details

#all_parcels_in_preparation?Boolean

Returns:

  • (Boolean)

130
131
132
# File 'app/models/delivery.rb', line 130

def all_parcels_in_preparation?
  parcels.all?(&:in_preparation?)
end

#all_parcels_prepared?Boolean

Returns:

  • (Boolean)

134
135
136
# File 'app/models/delivery.rb', line 134

def all_parcels_prepared?
  parcels.all?(&:prepared?)
end

#checkObject


113
114
115
116
117
118
119
120
# File 'app/models/delivery.rb', line 113

def check
  return false unless can_check?
  parcels.find_each do |parcel|
    # parcel.prepare if parcel.can_prepare?
    parcel.check if parcel.can_check?
  end
  super
end

#finishObject


122
123
124
125
126
127
128
# File 'app/models/delivery.rb', line 122

def finish
  return false unless can_finish?
  parcels.each do |parcel|
    parcel.give! if parcel.prepared?
  end
  super
end

#human_delivery_modeObject


109
110
111
# File 'app/models/delivery.rb', line 109

def human_delivery_mode
  mode.text
end

#statusObject


105
106
107
# File 'app/models/delivery.rb', line 105

def status
  draft? ? :stop : finished? ? :go : :caution
end