Class: Cats::Core::LocationService

Inherits:
Object
  • Object
show all
Defined in:
app/services/cats/core/location_service.rb

Instance Method Summary collapse

Instance Method Details

#create_fdp(code, name, parent_id, description = nil) ⇒ Object

This method creates FDP from location params, but also creates the related dummy warehouse and store for the FDP



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/cats/core/location_service.rb', line 6

def create_fdp(code, name, parent_id, description = nil)
  ActiveRecord::Base.transaction do
    fdp = Location.create!(
      code: code, name: name, description: description, location_type: Location::FDP, parent_id: parent_id
    )
    wh_code = "FDP-WH-#{fdp.code}"
    st_code = "FDP-ST-#{fdp.code}"

    warehouse = Location.create!(
      code: wh_code, name: wh_code, location_type: Location::WAREHOUSE, parent: fdp
    )
    Store.create!(
      code: st_code, name: st_code, length: 200, width: 200, height: 200, warehouse: warehouse
    )
    fdp
  end
end