module Logistics module Core class ServiceDeliveryUnitServiceService def delete_services(id) service = Logistics::Core::ServiceDeliveryUnitChargeableService.find(id) csuoc = Logistics::Core::ChargeableServiceUnitOfCharge.where(service_delivery_unit_id: service.service_delivery_unit_id, chargeable_service_id: service.chargeable_service_id) if csuoc.count > 0 Logistics::Core::BillOfLadingRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::ContractBillOfLadingRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::ServiceRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::ContractContainerRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::TruckRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::ContractTruckRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::BreakBulkRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::ContractFreightTonRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::BreakBulkUnitRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::ContractBreakBulkUnitRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::AirwayBillRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::ContractAirwayBillRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::ItemRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::ContractItemRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::ConvoyRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::ContractConvoyRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::TwentyFootEquivalenceUnitRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::ContractTwentyFeetEquivalenceUnitRate.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all Logistics::Core::ChargeableServiceIncrement.where(chargeable_service_unit_of_charge_id: csuoc[0].id).delete_all csuoc[0].delete end service.delete end end end end