Sha256: 57652f433cde6f4a414dbc80b67f51d1938286394ed6248ffa4e093950ff54e6
Contents?: true
Size: 1.5 KB
Versions: 9
Compression:
Stored size: 1.5 KB
Contents
module Logistics module Core class TruckRate < ApplicationRecord belongs_to :transaction_type belongs_to :chargeable_service_unit_of_charge def self.get_chargeable_services(service_delivery_unit_id) unit_of_charge_id = UnitOfCharge.select(:id).where('code' => 'TRUCK') csuocs = ChargeableServiceUnitOfCharge.where('service_delivery_unit_id' => service_delivery_unit_id, 'unit_of_charge_id' => unit_of_charge_id) return csuocs end def self.generate_rate_for_truck_rate(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| truck_rate = TruckRate.where('transaction_type_id' => transaction_type.id, 'chargeable_service_unit_of_charge_id' => chargeable_service.id) if truck_rate.count == 0 TruckRate.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 end end end
Version data entries
9 entries across 9 versions & 1 rubygems