Class: Logistics::Core::ConvoyRate
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Logistics::Core::ConvoyRate
- Defined in:
- app/models/logistics/core/convoy_rate.rb
Class Method Summary collapse
- .generate_rate_for_convoy_services(effective_date) ⇒ Object
- .get_chargeable_services(service_delivery_unit_id) ⇒ Object
Methods inherited from ApplicationRecord
Class Method Details
.generate_rate_for_convoy_services(effective_date) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/models/logistics/core/convoy_rate.rb', line 13 def self.generate_rate_for_convoy_services(effective_date) transaction_types = TransactionType.all service_delivery_units = ServiceDeliveryUnit.all service_delivery_units.each { |sdu| transaction_types.each { |transaction_type| chargeable_services = get_chargeable_services(sdu.id) chargeable_services.each { |chargeable_service| convoy_rate = ConvoyRate.where('transaction_type_id' =>transaction_type.id, 'chargeable_service_unit_of_charge_id' => chargeable_service.id) if convoy_rate.count == 0 ConvoyRate.create('transaction_type_id' => transaction_type.id,'chargeable_service_unit_of_charge_id' => chargeable_service.id, 'low' => 0, 'medium' => 0,'high' => 0, 'margin' => 0,'effective_date' => effective_date) end } } } end |
.get_chargeable_services(service_delivery_unit_id) ⇒ Object
7 8 9 10 11 |
# File 'app/models/logistics/core/convoy_rate.rb', line 7 def self.get_chargeable_services(service_delivery_unit_id) unit_of_charge_id = UnitOfCharge.select(:id).where('code' => 'CONVOY') csuocs = ChargeableServiceUnitOfCharge.where('service_delivery_unit_id' => service_delivery_unit_id, 'unit_of_charge_id' => unit_of_charge_id ) return csuocs end |