Class: ErpInventory::ErpApp::Organizer::InventoryMgt::InventoryTxnsController

Inherits:
ErpApp::Organizer::BaseController
  • Object
show all
Defined in:
app/controllers/erp_inventory/erp_app/organizer/inventory_mgt/inventory_txns_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/erp_inventory/erp_app/organizer/inventory_mgt/inventory_txns_controller.rb', line 7

def index
  offset = params[:start] || 0
  limit = params[:limit] || 25

  statement = BizTxnEvent.joins("left outer join inventory_pickup_txns ipt on biz_txn_events.biz_txn_record_id = ipt.id
                     and biz_txn_events.biz_txn_record_type = 'InventoryPickupTxn'")
  .joins("left outer join inventory_dropoff_txns idt on biz_txn_events.biz_txn_record_id = idt.id
                     and biz_txn_events.biz_txn_record_type = 'InventoryDropoffTxn'")
  .where("idt.inventory_entry_id = ? or ipt.inventory_entry_id = ?", params[:inventory_entry_id], params[:inventory_entry_id])
  .order('updated_at ASC')
  .uniq

  # Get total count of records
  total = statement.count

  # apply limit and offset
  inventory_txns = statement.offset(offset).limit(limit)

  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) }}

end

#showObject



29
30
31
# File 'app/controllers/erp_inventory/erp_app/organizer/inventory_mgt/inventory_txns_controller.rb', line 29

def show
  @inventory_entry = InventoryEntry.find(params[:id]) rescue nil
end