erp_inventory 3.1.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/controllers/erp_inventory/erp_app/organizer/asset_management/facilities_controller.rb +78 -0
- data/app/controllers/erp_inventory/erp_app/organizer/asset_management/fixed_assets_controller.rb +16 -0
- data/app/controllers/erp_inventory/erp_app/organizer/inventory_mgt/base_controller.rb +15 -0
- data/app/controllers/erp_inventory/erp_app/organizer/inventory_mgt/inventory_entries_controller.rb +126 -0
- data/app/controllers/erp_inventory/erp_app/organizer/inventory_mgt/inventory_entry_locations_controller.rb +47 -0
- data/app/controllers/erp_inventory/erp_app/organizer/inventory_mgt/inventory_txns_controller.rb +37 -0
- data/app/models/facility.rb +23 -0
- data/app/models/inventory_entry.rb +69 -6
- data/app/models/inventory_entry_location.rb +13 -0
- data/app/views/erp_inventory/erp_app/organizer/asset_management/facilities/show_summary.html.erb +64 -0
- data/app/views/erp_inventory/erp_app/organizer/inventory_mgt/base/show_summary.html.erb +7 -0
- data/app/views/erp_inventory/erp_app/organizer/inventory_mgt/inventory_entries/show_summary.html.erb +50 -0
- data/config/routes.rb +21 -0
- data/db/data_migrations/20131206033154_create_inv_txn_types.rb +21 -0
- data/db/migrate/20130925202059_create_inventory_entry_locations.rb +13 -0
- data/db/migrate/20130925222100_create_inventory_pickup_txns.rb +17 -0
- data/db/migrate/20130925222150_create_inventory_dropoff_txns.rb +18 -0
- data/db/migrate/20131206035027_add_inv_entry_to_inventory_txns.rb +15 -0
- data/db/migrate/20131211170059_change_fixed_asset_to_facility_for_inventory_locations.rb +8 -0
- data/db/migrate/20140103183635_add_uom_to_inventory_entry.rb +5 -0
- data/db/migrate/20140104182403_add_number_in_stock_inventory.rb +9 -0
- data/lib/erp_inventory/engine.rb +1 -1
- data/lib/erp_inventory/version.rb +6 -2
- metadata +43 -139
- data/app/assets/javascripts/erp_inventory/application.js +0 -9
- data/app/assets/stylesheets/erp_inventory/application.css +0 -7
- data/app/helpers/erp_inventory/application_helper.rb +0 -4
- data/app/views/layouts/erp_inventory/application.html.erb +0 -14
- data/lib/erp_inventory/extensions/compass_ae/erp_products/erp_app/desktop/product_manager/base_controller.rb +0 -64
- data/public/javascripts/extensions/compass_ae/erp_app/desktop/applications/product_manager/inventory_form_panel.js +0 -83
- data/spec/dummy/db/data_migrations/20101011152441_payment_gateway_actions.erp_commerce.rb +0 -28
- data/spec/dummy/db/data_migrations/20101014142230_financial_txn_types.erp_txns_and_accts.rb +0 -16
- data/spec/dummy/db/data_migrations/20110109173616_create_capability_scope_types.erp_tech_svcs.rb +0 -15
- data/spec/dummy/db/data_migrations/20110324010232_product_role_types.erp_products.rb +0 -24
- data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +0 -12
- data/spec/dummy/db/data_migrations/20110527160807_add_default_prod_avail_types.erp_products.rb +0 -27
- data/spec/dummy/db/data_migrations/20110605231556_create_order_party_roles.erp_orders.rb +0 -24
- data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +0 -19
- data/spec/dummy/db/data_migrations/20110728201729_erp_app_setup.erp_app.rb +0 -252
- data/spec/dummy/db/data_migrations/20110728201730_create_desktop_app_product_manager.erp_products.rb +0 -26
- data/spec/dummy/db/data_migrations/20110728201731_create_desktop_app_order_manager.erp_orders.rb +0 -26
- data/spec/dummy/db/data_migrations/20110728201732_create_organizer_app_order_management.erp_orders.rb +0 -15
- data/spec/dummy/db/data_migrations/20110728201733_update_preferences.erp_app.rb +0 -53
- data/spec/dummy/db/data_migrations/20110802200222_schedule_delete_expired_sessions_job.erp_tech_svcs.rb +0 -16
- data/spec/dummy/db/data_migrations/20110816161238_create_desktop_app_audit_log_viewer.erp_app.rb +0 -21
- data/spec/dummy/db/data_migrations/20110817160743_add_file_manager_application.erp_app.rb +0 -32
- data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +0 -12
- data/spec/dummy/db/data_migrations/20111108183739_add_default_capabilities.erp_app.rb +0 -23
- data/spec/dummy/db/data_migrations/20111108183740_add_new_contact_widgets.erp_app.rb +0 -42
- data/spec/dummy/db/data_migrations/20111111144706_setup_audit_log_types.erp_tech_svcs.rb +0 -22
- data/spec/dummy/db/data_migrations/20120109173616_create_download_capability_type.erp_tech_svcs.rb +0 -14
- data/spec/dummy/db/data_migrations/20120229160222_add_userinfo_widget.erp_app.rb +0 -29
- data/spec/dummy/db/data_migrations/20120229174343_add_orders_widget.erp_orders.rb +0 -29
- data/spec/dummy/db/data_migrations/20120405193721_create_party_and_role_type_for_communication_events.erp_app.rb +0 -11
- data/spec/dummy/db/data_migrations/20120411180756_create_user_management_mobile_application.erp_app.rb +0 -19
- data/spec/dummy/db/data_migrations/20120418164215_create_configuration_management_desktop_application.erp_app.rb +0 -23
- data/spec/dummy/db/data_migrations/20121116155018_create_group_relationship_and_role_types.erp_tech_svcs.rb +0 -20
- data/spec/dummy/db/data_migrations/20121130201859_upgrade_remove_system_mgmt_app.erp_app.rb +0 -16
- data/spec/dummy/db/data_migrations/20121130212146_note_capabilities.erp_tech_svcs.rb +0 -24
- data/spec/dummy/db/data_migrations/20121218175028_create_security_management_desktop_application.erp_app.rb +0 -23
- data/spec/dummy/db/migrate/20121213235616_base_erp_services.erp_base_erp_svcs.rb +0 -461
- data/spec/dummy/db/migrate/20121213235617_base_inventory.erp_inventory.rb +0 -91
- data/spec/dummy/db/migrate/20121213235618_base_inventory_indexes.erp_inventory.rb +0 -48
- data/spec/dummy/db/migrate/20121213235619_base_tech_services.erp_tech_svcs.rb +0 -255
- data/spec/dummy/db/migrate/20121213235620_create_has_attribute_tables.erp_tech_svcs.rb +0 -39
- data/spec/dummy/db/migrate/20121213235621_base_orders.erp_orders.rb +0 -178
- data/spec/dummy/db/migrate/20121213235622_base_products.erp_products.rb +0 -234
- data/spec/dummy/db/migrate/20121213235623_base_products_indexes.erp_products.rb +0 -59
- data/spec/dummy/db/migrate/20121213235624_base_txns_and_accts.erp_txns_and_accts.rb +0 -364
- data/spec/dummy/db/migrate/20121213235625_agreements_services.erp_agreements.rb +0 -160
- data/spec/dummy/db/migrate/20121213235626_agreements_services_indexes.erp_agreements.rb +0 -52
- data/spec/dummy/db/migrate/20121213235627_base_app_framework.erp_app.rb +0 -276
- data/spec/dummy/db/migrate/20121213235628_erp_commerce_base.erp_commerce.rb +0 -442
- data/spec/dummy/db/migrate/20130107180714_create_groups.erp_tech_svcs.rb +0 -19
- data/spec/dummy/db/migrate/20130107180715_upgrade_security.erp_tech_svcs.rb +0 -54
- data/spec/dummy/db/migrate/20130107180716_upgrade_security2.erp_tech_svcs.rb +0 -270
- data/spec/dummy/db/schema.rb +0 -1879
- data/spec/dummy/db/spec.sqlite3 +0 -0
- data/spec/dummy/log/spec.log +0 -9949
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1638c2774d64dc7ed63045210a81eb744a6ae1ae
|
4
|
+
data.tar.gz: a5322287991cb59a81325728dfb91705639e733c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 26d4ccfe361cf001c191a730ebe7a808d7f5c95bde625562e237e3e6ef67e64bed9ef7bd57efec034dde6e3bea2c7944d84048063e0cd303be14eaf65e5d38b3
|
7
|
+
data.tar.gz: b7225b9252a044cb0ff127407b727e9f35592717dfc5afbceb5ddb9c3bdb12c630ff840b3c6902972ce9149488b4b22325921279aca4c99d272dd30eb121c7c7
|
data/app/controllers/erp_inventory/erp_app/organizer/asset_management/facilities_controller.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
module ErpInventory
|
2
|
+
module ErpApp
|
3
|
+
module Organizer
|
4
|
+
module AssetManagement
|
5
|
+
class FacilitiesController < ::ErpApp::Organizer::BaseController
|
6
|
+
|
7
|
+
def index
|
8
|
+
offset = params[:start] || 0
|
9
|
+
limit = params[:limit] || 25
|
10
|
+
query_filter = params[:query_filter].blank? ? nil : params[:query_filter].strip
|
11
|
+
|
12
|
+
factility_tbl = Facility.arel_table
|
13
|
+
statement = Facility.order('created_at asc')
|
14
|
+
|
15
|
+
unless query_filter.blank?
|
16
|
+
statement = statement.where(factility_tbl[:description].matches(query_filter + '%'))
|
17
|
+
end
|
18
|
+
|
19
|
+
# Get total count of records
|
20
|
+
total = statement.count
|
21
|
+
|
22
|
+
# Apply limit and offset
|
23
|
+
facilities = statement.offset(offset).limit(limit)
|
24
|
+
|
25
|
+
render :json => {:success => true, :total => total, :facilities => facilities.collect { |facility| facility.to_hash(:only => [:id, :description, :created_at, :updated_at]) }}
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def show_summary
|
30
|
+
|
31
|
+
@facility = Facility.find(params[:id]) rescue nil
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def show
|
36
|
+
|
37
|
+
facility = Facility.find(params[:facility_id])
|
38
|
+
render :json => {:success => true, :data => facility.to_hash(:only => [:id, :description, :created_at, :updated_at])}
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
def new
|
43
|
+
end
|
44
|
+
|
45
|
+
def create
|
46
|
+
|
47
|
+
facility = Facility.new
|
48
|
+
facility.description=params[:description]
|
49
|
+
facility.save
|
50
|
+
|
51
|
+
render :json => {:success => true, :data => facility.to_hash(:only => [:id, :description, :created_at, :updated_at])}
|
52
|
+
end
|
53
|
+
|
54
|
+
def edit
|
55
|
+
end
|
56
|
+
|
57
|
+
def update
|
58
|
+
|
59
|
+
facility = Facility.find(params[:facility_id])
|
60
|
+
facility.description=params[:description]
|
61
|
+
facility.save
|
62
|
+
|
63
|
+
render :json => {:success => true, :data => facility.to_hash(:only => [:id, :description, :created_at, :updated_at])}
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
def destroy
|
68
|
+
|
69
|
+
facility = Facility.find(params[:facility_id]).destroy
|
70
|
+
render :json => {:success => true}
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end #AssetManagement
|
76
|
+
end #Organizer
|
77
|
+
end #ErpApp
|
78
|
+
end #ErpInventory
|
data/app/controllers/erp_inventory/erp_app/organizer/asset_management/fixed_assets_controller.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module ErpInventory
|
2
|
+
module ErpApp
|
3
|
+
module Organizer
|
4
|
+
module AssetManagement
|
5
|
+
class FixedAssetsController < ::ErpApp::Organizer::BaseController
|
6
|
+
|
7
|
+
def index
|
8
|
+
fixed_assets = FixedAsset.all
|
9
|
+
render :json => {:success => true, :fixed_assets => fixed_assets.collect { |fixed_asset| fixed_asset.to_hash(:only => [:id, :description, :created_at, :updated_at]) }}
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end #AssetManagement
|
14
|
+
end #Organizer
|
15
|
+
end #ErpApp
|
16
|
+
end #ErpInventory
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module ErpInventory
|
2
|
+
module ErpApp
|
3
|
+
module Organizer
|
4
|
+
module InventoryMgt
|
5
|
+
class BaseController < ::ErpApp::Organizer::BaseController
|
6
|
+
|
7
|
+
def menu
|
8
|
+
render :json => [{:text => 'Menu Item', :leaf => true, :iconCls => 'icon-tasks', :applicationCardId => "inventory_mgt_example_panel"}]
|
9
|
+
end
|
10
|
+
|
11
|
+
end #BaseController
|
12
|
+
end #InventoryMgt
|
13
|
+
end #Organizer
|
14
|
+
end #ErpApp
|
15
|
+
end #ErpInventory
|
data/app/controllers/erp_inventory/erp_app/organizer/inventory_mgt/inventory_entries_controller.rb
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
module ErpInventory
|
2
|
+
module ErpApp
|
3
|
+
module Organizer
|
4
|
+
module InventoryMgt
|
5
|
+
class InventoryEntriesController < ::ErpApp::Organizer::BaseController
|
6
|
+
|
7
|
+
def index
|
8
|
+
offset = params[:start] || 0
|
9
|
+
limit = params[:limit] || 25
|
10
|
+
query_filter = params[:query_filter].blank? ? nil : params[:query_filter].strip
|
11
|
+
facility_id = params[:facility_id].blank? ? nil : params[:facility_id].strip
|
12
|
+
party_id = params[:party_id]
|
13
|
+
|
14
|
+
inventory_entry_tbl = InventoryEntry.arel_table
|
15
|
+
|
16
|
+
# scope by party if have party id
|
17
|
+
if party_id.blank?
|
18
|
+
statement = InventoryEntry.order('created_at asc')
|
19
|
+
else
|
20
|
+
statement = InventoryEntry.joins(product_type: :product_type_pty_roles).where('product_type_pty_roles.party_id = ?', party_id).order('created_at asc')
|
21
|
+
end
|
22
|
+
|
23
|
+
# apply filters if present
|
24
|
+
statement = statement.where(inventory_entry_tbl[:description].matches(query_filter + '%')) if query_filter
|
25
|
+
|
26
|
+
# apply facility if present
|
27
|
+
statement = statement.joins(:inventory_entry_locations).where('facility_id = ?', facility_id) if facility_id
|
28
|
+
|
29
|
+
# Get total count of records
|
30
|
+
total = statement.count
|
31
|
+
|
32
|
+
# Apply limit and offset
|
33
|
+
inventory_entries = statement.offset(offset).limit(limit)
|
34
|
+
|
35
|
+
render :json => {:success => true, :total => total, :inventory_entries => inventory_entries.collect { |entry| entry.to_data_hash }}
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def show_summary
|
40
|
+
|
41
|
+
@inventory_entry = InventoryEntry.find(params[:id]) rescue nil
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def show
|
46
|
+
|
47
|
+
entry = InventoryEntry.find(params[:inventory_entry_id])
|
48
|
+
render :json => {:success => true, :data => entry.to_data_hash}
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
def new
|
53
|
+
end
|
54
|
+
|
55
|
+
def create
|
56
|
+
|
57
|
+
begin
|
58
|
+
ActiveRecord::Base.transaction do
|
59
|
+
entry = InventoryEntry.new
|
60
|
+
entry.description=params[:description]
|
61
|
+
entry.sku=params[:sku]
|
62
|
+
entry.unit_of_measurement_id=params[:unit_of_measurement]
|
63
|
+
entry.number_in_stock=params[:number_in_stock]
|
64
|
+
entry.number_available=params[:number_available]
|
65
|
+
entry.product_type_id=params[:product_type_id]
|
66
|
+
entry.save
|
67
|
+
|
68
|
+
location_assignment = InventoryEntryLocation.new
|
69
|
+
location_assignment.inventory_entry = entry
|
70
|
+
location_assignment.facility_id = params[:inventory_facility]
|
71
|
+
location_assignment.save
|
72
|
+
|
73
|
+
render :json => {:success => true, :data => entry.to_hash(:only => [:id, :description, :created_at, :updated_at], :model => 'InventoryEntry')}
|
74
|
+
end
|
75
|
+
rescue => ex
|
76
|
+
Rails.logger.error ex.message
|
77
|
+
Rails.logger.error ex.backtrace.join("\n")
|
78
|
+
render :json => {:success => false, :message => ex.message}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def edit
|
83
|
+
puts "edit called"
|
84
|
+
end
|
85
|
+
|
86
|
+
def update
|
87
|
+
begin
|
88
|
+
ActiveRecord::Base.transaction do
|
89
|
+
entry = InventoryEntry.find(params[:inventory_entry_id])
|
90
|
+
current_facility = entry.current_storage_facility
|
91
|
+
entry.description=params[:description]
|
92
|
+
entry.sku=params[:sku]
|
93
|
+
entry.unit_of_measurement_id=params[:unit_of_measurement]
|
94
|
+
entry.number_available=params[:number_available]
|
95
|
+
entry.number_in_stock=params[:number_in_stock]
|
96
|
+
entry.product_type_id=params[:product_type_id]
|
97
|
+
entry.save
|
98
|
+
|
99
|
+
if current_facility.id != params[:inventory_facility].to_i
|
100
|
+
location_assignment = InventoryEntryLocation.new
|
101
|
+
location_assignment.inventory_entry = entry
|
102
|
+
location_assignment.facility_id = params[:inventory_facility]
|
103
|
+
location_assignment.save
|
104
|
+
end
|
105
|
+
|
106
|
+
render :json => {:success => true, :data => entry.to_hash(:only => [:id, :description, :created_at, :updated_at], :model => 'InventoryEntry')}
|
107
|
+
end
|
108
|
+
rescue Exception => e
|
109
|
+
Rails.logger.error e.message
|
110
|
+
Rails.logger.error e.backtrace.join("\n")
|
111
|
+
render :json => {:success => false, :message => e.message}
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def destroy
|
116
|
+
|
117
|
+
entry = InventoryEntry.find(params[:inventory_entry_id])
|
118
|
+
render :json => {:success => entry.destroy}
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
end #InventoryMgt
|
124
|
+
end #Organizer
|
125
|
+
end #ErpApp
|
126
|
+
end #ErpInventory
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module ErpInventory
|
2
|
+
module ErpApp
|
3
|
+
module Organizer
|
4
|
+
module InventoryMgt
|
5
|
+
class InventoryEntryLocationsController < ::ErpApp::Organizer::BaseController
|
6
|
+
|
7
|
+
def show
|
8
|
+
end
|
9
|
+
|
10
|
+
def new
|
11
|
+
end
|
12
|
+
|
13
|
+
def create
|
14
|
+
|
15
|
+
location_assignment = InventoryEntryLocation.new
|
16
|
+
location_assignment.inventory_entry_id = params[:inventory_entry_id]
|
17
|
+
location_assignment.facility_id = params[:facility_id]
|
18
|
+
location_assignment.save
|
19
|
+
|
20
|
+
render :json => {:success => true }
|
21
|
+
end
|
22
|
+
|
23
|
+
def edit
|
24
|
+
end
|
25
|
+
|
26
|
+
def update
|
27
|
+
|
28
|
+
location_assignment = InventoryEntryLocation.find(params[:inventory_entry_location_id])
|
29
|
+
location_assignment.fixed_asset_id = params[:fixed_asset_id]
|
30
|
+
location_assignment.save
|
31
|
+
|
32
|
+
render :json => {:success => true }
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
|
38
|
+
entry = InventoryEntryLocation.find(params[:inventory_entry_location_id]).destroy
|
39
|
+
render :json => { :success => true }
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end #InventoryMgt
|
45
|
+
end #Organizer
|
46
|
+
end #ErpApp
|
47
|
+
end #ErpInventory
|
data/app/controllers/erp_inventory/erp_app/organizer/inventory_mgt/inventory_txns_controller.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module ErpInventory
|
2
|
+
module ErpApp
|
3
|
+
module Organizer
|
4
|
+
module InventoryMgt
|
5
|
+
class InventoryTxnsController < ::ErpApp::Organizer::BaseController
|
6
|
+
|
7
|
+
def index
|
8
|
+
offset = params[:start] || 0
|
9
|
+
limit = params[:limit] || 25
|
10
|
+
|
11
|
+
statement = BizTxnEvent.joins("left outer join inventory_pickup_txns ipt on biz_txn_events.biz_txn_record_id = ipt.id
|
12
|
+
and biz_txn_events.biz_txn_record_type = 'InventoryPickupTxn'")
|
13
|
+
.joins("left outer join inventory_dropoff_txns idt on biz_txn_events.biz_txn_record_id = idt.id
|
14
|
+
and biz_txn_events.biz_txn_record_type = 'InventoryDropoffTxn'")
|
15
|
+
.where("idt.inventory_entry_id = ? or ipt.inventory_entry_id = ?", params[:inventory_entry_id], params[:inventory_entry_id])
|
16
|
+
.order('updated_at ASC')
|
17
|
+
.uniq
|
18
|
+
|
19
|
+
# Get total count of records
|
20
|
+
total = statement.count
|
21
|
+
|
22
|
+
# apply limit and offset
|
23
|
+
inventory_txns = statement.offset(offset).limit(limit)
|
24
|
+
|
25
|
+
render :json => {:success => true, :total => total, :inventory_txns => inventory_txns.collect { |txn| txn.to_hash(:only => [:id, :description, :created_at, :updated_at], :model => txn.biz_txn_record_type) }}
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def show
|
30
|
+
@inventory_entry = InventoryEntry.find(params[:id]) rescue nil
|
31
|
+
end
|
32
|
+
|
33
|
+
end #InventoryTxnsController
|
34
|
+
end #InventoryMgt
|
35
|
+
end #Organizer
|
36
|
+
end #ErpApp
|
37
|
+
end #ErpInventory
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Facility < ActiveRecord::Base
|
2
|
+
|
3
|
+
has_many :inventory_entry_locations
|
4
|
+
has_many :inventory_entries, :through => :inventory_entry_locations
|
5
|
+
|
6
|
+
belongs_to :postal_address
|
7
|
+
|
8
|
+
def to_data_hash
|
9
|
+
{
|
10
|
+
:id => self.id,
|
11
|
+
:description => self.description,
|
12
|
+
:postal_address_id => self.postal_address_id,
|
13
|
+
:address_line_1 => (self.postal_address.address_line_1 rescue nil),
|
14
|
+
:address_line_2 => (self.postal_address.address_line_2 rescue nil),
|
15
|
+
:city => (self.postal_address.city rescue nil),
|
16
|
+
:state => (self.postal_address.state rescue nil),
|
17
|
+
:zip => (self.postal_address.zip rescue nil),
|
18
|
+
:created_at => self.created_at,
|
19
|
+
:updated_at => self.updated_at,
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class InventoryEntry < ActiveRecord::Base
|
2
2
|
attr_protected :created_at, :updated_at
|
3
3
|
|
4
|
-
belongs_to
|
5
|
-
belongs_to
|
6
|
-
has_one
|
7
|
-
has_many
|
8
|
-
has_many
|
4
|
+
belongs_to :inventory_entry_record, :polymorphic => true
|
5
|
+
belongs_to :product_type
|
6
|
+
has_one :classification, :as => :classification, :class_name => 'CategoryClassification'
|
7
|
+
has_many :prod_instance_inv_entries
|
8
|
+
has_many :product_instances, :through => :prod_instance_inv_entries do
|
9
9
|
def available
|
10
10
|
includes([:prod_availability_status_type]).where('prod_availability_status_types.internal_identifier = ?', 'available')
|
11
11
|
end
|
@@ -14,9 +14,72 @@ class InventoryEntry < ActiveRecord::Base
|
|
14
14
|
includes([:prod_availability_status_type]).where('prod_availability_status_types.internal_identifier = ?', 'sold')
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
has_many :inventory_entry_locations
|
18
|
+
has_many :facilities, :through => :inventory_entry_locations
|
19
|
+
belongs_to :unit_of_measurement
|
20
|
+
|
21
|
+
alias_method :storage_facilities, :facilities
|
22
|
+
|
23
|
+
delegate :description, :sku, :unit_of_measurement, :to => :product_type, :prefix => true
|
24
|
+
|
25
|
+
def current_location
|
26
|
+
self.inventory_entry_locations
|
27
|
+
end
|
28
|
+
|
29
|
+
def current_storage_facility
|
30
|
+
inventory_entry_locations.last.facility
|
31
|
+
end
|
32
|
+
|
33
|
+
def current_storage_facility=(facility)
|
34
|
+
location = InventoryEntryLocation.new
|
35
|
+
location.facility = facility
|
36
|
+
location.inventory_entry = self
|
37
|
+
location.save
|
38
|
+
end
|
39
|
+
|
40
|
+
def current_storage_facility_id=(facility_id)
|
41
|
+
location = InventoryEntryLocation.new
|
42
|
+
location.facility_id = facility_id
|
43
|
+
location.inventory_entry = self
|
44
|
+
location.save
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_data_hash
|
48
|
+
{
|
49
|
+
:id => self.id,
|
50
|
+
:description => self.description,
|
51
|
+
:number_available => self.number_available,
|
52
|
+
:number_in_stock => self.number_in_stock,
|
53
|
+
:sku => self.get_sku,
|
54
|
+
:unit_of_measurement_id => (self.get_uom.id rescue nil),
|
55
|
+
:unit_of_measurement_description => (self.get_uom.description rescue nil),
|
56
|
+
:inventory_storage_facility_id => (self.current_storage_facility.id rescue nil),
|
57
|
+
:inventory_storage_facility_description => (self.current_storage_facility.description rescue nil),
|
58
|
+
:created_at => self.created_at,
|
59
|
+
:updated_at => self.updated_at,
|
60
|
+
:product_type_id =>self.product_type_id,
|
61
|
+
:product_type_description => (self.product_type_description rescue nil)
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
18
65
|
def to_label
|
19
66
|
"#{description}"
|
20
67
|
end
|
21
68
|
|
69
|
+
def get_sku
|
70
|
+
if self.sku.blank?
|
71
|
+
self.product_type_sku
|
72
|
+
else
|
73
|
+
self.sku
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_uom
|
78
|
+
if self.unit_of_measurement.nil?
|
79
|
+
self.product_type_unit_of_measurement
|
80
|
+
else
|
81
|
+
self.unit_of_measurement
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
22
85
|
end
|