Add unitsLeft field to SearchResult type
This commit is contained in:
parent
29888851e7
commit
2a51eec1c8
@ -38,6 +38,7 @@ type alias SearchResult =
|
|||||||
, groupName : String
|
, groupName : String
|
||||||
, groupId : Int
|
, groupId : Int
|
||||||
, taxGroupId : Int
|
, taxGroupId : Int
|
||||||
|
, unitsLeft : Int
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResultDecoder =
|
searchResultDecoder =
|
||||||
@ -53,6 +54,7 @@ searchResultDecoder =
|
|||||||
|> P.required "group_name" D.string
|
|> P.required "group_name" D.string
|
||||||
|> P.required "group_id" D.int
|
|> P.required "group_id" D.int
|
||||||
|> P.required "tax_group_id" D.int
|
|> P.required "tax_group_id" D.int
|
||||||
|
|> P.required "units_left" D.int
|
||||||
|
|
||||||
type alias Location =
|
type alias Location =
|
||||||
{ id : Int
|
{ id : Int
|
||||||
|
@ -11,6 +11,7 @@ SELECT
|
|||||||
inventory_items.available,
|
inventory_items.available,
|
||||||
inventory_items.item_group,
|
inventory_items.item_group,
|
||||||
inventory_items.location,
|
inventory_items.location,
|
||||||
|
inventory_items.tax_group,
|
||||||
inventory_item_groups.group_name,
|
inventory_item_groups.group_name,
|
||||||
COALESCE(b.sales::numeric, 0::numeric) - COALESCE(cancel.count::numeric, 0::numeric) AS sales,
|
COALESCE(b.sales::numeric, 0::numeric) - COALESCE(cancel.count::numeric, 0::numeric) AS sales,
|
||||||
inventory_items.sales_units::numeric - COALESCE(b.sales, 0::bigint)::numeric + COALESCE(c.delta, 0::numeric) + COALESCE(cancel.count::numeric, 0::numeric) AS units_left,
|
inventory_items.sales_units::numeric - COALESCE(b.sales, 0::bigint)::numeric + COALESCE(c.delta, 0::numeric) + COALESCE(cancel.count::numeric, 0::numeric) AS units_left,
|
||||||
|
@ -6,13 +6,12 @@ SELECT
|
|||||||
sales_units,
|
sales_units,
|
||||||
available,
|
available,
|
||||||
location_name,
|
location_name,
|
||||||
location_id,
|
location as location_id,
|
||||||
group_name,
|
group_name,
|
||||||
item_group AS group_id,
|
item_group AS group_id,
|
||||||
tax_group AS tax_group_id
|
tax_group AS tax_group_id,
|
||||||
FROM garfield.inventory_items
|
units_left :: integer
|
||||||
LEFT JOIN garfield.locations ON location = location_id
|
FROM all_inventory_item_overview
|
||||||
LEFT JOIN garfield.inventory_item_groups ON item_group = group_id
|
|
||||||
WHERE (%(location_id)s IS NULL OR location = %(location_id)s)
|
WHERE (%(location_id)s IS NULL OR location = %(location_id)s)
|
||||||
AND (name ILIKE CONCAT('%%', %(search_term)s, '%%') OR item_barcode = %(search_term)s)
|
AND (name ILIKE CONCAT('%%', %(search_term)s, '%%') OR item_barcode = %(search_term)s)
|
||||||
ORDER BY bought DESC
|
ORDER BY bought DESC
|
||||||
|
Loading…
x
Reference in New Issue
Block a user