3
Inventory
10K rowsColumns from three joined tables, plus margin and stock value computed in SQL. Sort and search work across all of them.
Sort by warehouse, then search a supplier's name.
|
Item
|
In stock
| Cost |
Price
| Margin | Stock value |
Warehouse
| Supplier |
|---|---|---|---|---|---|---|---|
|
Advanced Accessory
STK004226
|
| ₹3,563 | ₹3,755 | 5.4% | ₹16,28,291 |
Surat Warehouse
West region
|
Mahindra Industries LLP
2.6
★
|
|
Advanced Accessory
STK004508
|
| ₹2,922 | ₹4,039 | 38.2% | ₹26,59,020 |
Jaipur Warehouse
West region
|
Mahindra Global Inc
3.0
★
|
|
Advanced Accessory
STK003649
|
| ₹2,259 | ₹2,636 | 16.7% | ₹1,31,022 |
Hyderabad Warehouse
South region
|
Infosys Enterprises Ltd
3.4
★
|
|
Advanced Accessory
STK003301
|
| ₹4,926 | ₹5,500 | 11.7% | ₹3,25,116 |
Mumbai Warehouse
West region
|
Reliance Enterprises LLP
1.0
★
|
|
Advanced Accessory
STK003228
|
| ₹1,137 | ₹1,469 | 29.2% | ₹8,62,983 |
Mumbai Warehouse
West region
|
Info Technologies LLP
3.7
★
|
|
Advanced Accessory
STK004321
|
| ₹1,828 | ₹1,996 | 9.2% | ₹5,20,980 |
Patna Warehouse
East region
|
Bharti Industries Pvt
1.0
★
|
|
Advanced Accessory
STK002770
|
| ₹4,124 | ₹6,140 | 48.9% | ₹28,29,064 |
Lucknow Warehouse
North region
|
HCL Innovations India
1.1
★
|
|
Advanced Accessory
STK001447
|
| ₹2,962 | ₹3,478 | 17.4% | ₹28,99,798 |
Ghaziabad Warehouse
North region
|
Larsen Digital LLP
4.5
★
|
|
Advanced Accessory
STK001662
|
| ₹3,868 | ₹4,692 | 21.3% | ₹32,91,668 |
Jaipur Warehouse
West region
|
Cyber Ventures Ltd
1.9
★
|
|
Advanced Accessory
STK003295
|
| ₹367 | ₹433 | 17.9% | ₹58,353 |
Hyderabad Warehouse
South region
|
Tech Labs Inc
2.2
★
|
|
Advanced Accessory
STK002375
|
| ₹2,206 | ₹3,186 | 44.4% | ₹13,52,278 |
Patna Warehouse
East region
|
Reliance Industries India
1.5
★
|
|
Advanced Accessory
STK002678
|
| ₹3,422 | ₹4,482 | 31.0% | ₹24,46,730 |
Visakhapatnam Warehouse
South region
|
Cyber Technologies Ltd
1.4
★
|
|
Advanced Accessory
STK004153
|
| ₹3,924 | ₹5,106 | 30.1% | ₹1,02,024 |
Pune Warehouse
West region
|
Adani Digital Group
3.9
★
|
|
Advanced Accessory
STK002019
|
| ₹1,703 | ₹2,217 | 30.2% | ₹5,33,039 |
Kanpur Warehouse
North region
|
Cloud Systems Group
2.5
★
|
|
Advanced Accessory
STK002393
|
| ₹705 | ₹760 | 7.8% | ₹3,77,880 |
Ahmedabad Warehouse
West region
|
Cyber Networks Ltd
1.8
★
|
|
Advanced Accessory
STK001356
|
| ₹1,846 | ₹1,855 | 0.5% | ₹15,89,406 |
Ghaziabad Warehouse
North region
|
HCL Industries Pvt
4.7
★
|
|
Advanced Accessory
STK000937
|
| ₹1,563 | ₹1,896 | 21.3% | ₹2,21,946 |
Bangalore Warehouse
South region
|
HCL Labs India
2.1
★
|
|
Advanced Accessory
STK000593
|
| ₹785 | ₹1,134 | 44.5% | ₹5,14,960 |
Vadodara Warehouse
West region
|
Mahindra Industries LLP
2.6
★
|
|
Advanced Accessory
STK001108
|
| ₹4,501 | ₹6,132 | 36.2% | ₹25,70,071 |
Surat Warehouse
West region
|
Smart Systems LLP
3.7
★
|
|
Advanced Accessory
STK000139
|
| ₹4,853 | ₹7,212 | 48.6% | ₹7,81,333 |
Kolkata Warehouse
East region
|
Cloud Enterprises LLP
2.2
★
|
|
Advanced Accessory
STK000088
|
| ₹2,756 | ₹3,163 | 14.8% | ₹3,08,672 |
Bangalore Warehouse
South region
|
Cloud Enterprises Ltd
2.7
★
|
|
Advanced Accessory
STK001155
|
| ₹1,860 | ₹2,562 | 37.8% | ₹10,63,920 |
Kanpur Warehouse
North region
|
Info Services Pvt
4.2
★
|
|
Advanced Accessory
STK000568
|
| ₹331 | ₹438 | 32.5% | ₹2,51,891 |
Pune Warehouse
West region
|
Bajaj Global Ltd
4.4
★
|
|
Advanced Accessory
STK001362
|
| ₹2,532 | ₹3,262 | 28.8% | ₹15,69,840 |
Mumbai Warehouse
West region
|
Godrej Services LLP
4.5
★
|
|
Advanced Accessory
STK001765
|
| ₹4,163 | ₹5,201 | 24.9% | ₹23,97,888 |
Indore Warehouse
Central region
|
Godrej Global Inc
3.0
★
|
# In your LiveView
def mount(_params, _session, socket) do
{:ok, assign(socket, :data_provider, {__MODULE__, :stock, []})}
end
# Joined tables and computed columns, in one query. LiveTable sorts, searches and filters it.
def stock do
from s in Demo.Inventory.StockItem,
join: w in assoc(s, :warehouse),
as: :warehouse,
join: sup in assoc(s, :supplier),
as: :supplier,
select: %{
id: s.id,
sku: s.sku,
name: s.name,
quantity: s.quantity,
unit_cost: s.unit_cost,
selling_price: s.selling_price,
margin: (s.selling_price - s.unit_cost) / s.unit_cost * 100,
stock_value: s.quantity * s.unit_cost,
low: s.quantity <= s.reorder_level,
warehouse: w.name,
region: w.region,
supplier: sup.name,
supplier_rating: sup.rating
}
end
def fields do
[
id: %{label: "ID", hidden: true},
name: %{label: "Item", sortable: true, searchable: true, renderer: &item/2},
quantity: %{label: "In stock", sortable: true, renderer: &quantity/2},
unit_cost: %{label: "Cost", renderer: &cost/1},
selling_price: %{label: "Price", sortable: true, renderer: &money/1},
margin: %{label: "Margin", renderer: &margin/1},
stock_value: %{label: "Stock value", renderer: &money/1},
warehouse: %{
label: "Warehouse",
sortable: true,
assoc: {:warehouse, :name},
renderer: &warehouse/2
},
supplier: %{
label: "Supplier",
searchable: true,
assoc: {:supplier, :name},
renderer: &supplier/2
},
sku: %{label: "SKU", searchable: true, hidden: true},
region: %{label: "Region", hidden: true, assoc: {:warehouse, :region}},
supplier_rating: %{label: "Supplier rating", hidden: true}
]
end
def filters do
[
region:
Select.new({:warehouse, :region}, "region", %{
label: "Region",
mode: :tags,
options_source: {Demo.Inventory, :search_warehouses_by_region, []}
}),
quantity:
Range.new(:quantity, "quantity", %{
label: "Quantity",
min: 0,
max: 1000,
step: 50,
pips: true,
pips_mode: "values",
pips_values: [0, 250, 500, 750, 1000]
}),
low:
Boolean.new(:quantity, "low", %{
label: "Needs reorder",
condition: dynamic([s], s.quantity <= s.reorder_level)
}),
high_margin:
Boolean.new(:selling_price, "high_margin", %{
label: "Margin over 30%",
condition: dynamic([s], (s.selling_price - s.unit_cost) / s.unit_cost >= 0.3)
})
]
end
def table_options do
%{
pagination: %{sizes: [10, 25, 50], default_size: 25},
sorting: %{default_sort: [name: :asc]},
search: %{placeholder: "Search item, SKU or supplier"},
exports: %{enabled: false},
fixed_header: true
}
end