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