Compare commits
	
		
			No commits in common. "61cf7696a5527f11c22781dc8d0996f52db10b24" and "1b6d0c40f371058479ce1177fd034bc6477b2732" have entirely different histories.
		
	
	
		
			61cf7696a5
			...
			1b6d0c40f3
		
	
		
| @ -58,19 +58,3 @@ FROM garfield.inventory_items | ||||
|   ) m USING (item_id) | ||||
| ORDER BY inventory_items.name; | ||||
| 
 | ||||
| -- How many *other* active inventory lines exist with the same barcode in the same location that are newer? | ||||
| 
 | ||||
| CREATE TEMPORARY VIEW more_recent_inventory_lines_with_same_barcode AS | ||||
| SELECT | ||||
|   a.item_id, | ||||
|   -- It's important not to count(*) here because item_id is NULL | ||||
|   -- when no other inventory lines exist. | ||||
|   count(b.item_id) AS other_lines_count | ||||
| FROM garfield.inventory_items AS a | ||||
| LEFT JOIN garfield.inventory_items AS b | ||||
|        ON a.item_barcode = b.item_barcode | ||||
|       AND a.item_id != b.item_id | ||||
|       AND a.location = b.location | ||||
|       AND b.available | ||||
|       AND b.bought > a.bought | ||||
| GROUP BY a.item_id; | ||||
|  | ||||
| @ -1,7 +1,6 @@ | ||||
| SELECT | ||||
|   * | ||||
| FROM all_inventory_item_overview | ||||
| LEFT JOIN more_recent_inventory_lines_with_same_barcode USING (item_id) | ||||
| WHERE (%(location_id)s IS NULL OR location = %(location_id)s) | ||||
|   AND available | ||||
| ORDER BY | ||||
|  | ||||
| @ -3,7 +3,6 @@ | ||||
| {% block content %} | ||||
| <table> | ||||
|   <tr> | ||||
|     <th>Stat</th> | ||||
|     <th>ID</th> | ||||
|     <th>Barcode</th> | ||||
|     <th>Name</th> | ||||
| @ -18,10 +17,6 @@ | ||||
|   </tr> | ||||
| {% for item in items %} | ||||
|   <tr> | ||||
|     <td> | ||||
|       {% if item.units_left == 0 %}<span title="Leerer aktiver Inventareintrag">🅾️</span>{% endif %} | ||||
|       {% if item.other_lines_count != 0 %}<span title="{% if item.other_lines_count == 1 %}Neuerer Eintrag mit demselben Barcode ist aktiv{% else %}{{ item.other_lines_count }} Einträge mit demselben Barcode sind aktiv{% endif %}">🔄</span>{% endif %} | ||||
|     </td> | ||||
|     <td><a href="/inventory/item/{{ item.item_id }}">{{ item.item_id }}</a></td> | ||||
|     <td><code>{{ item.item_barcode }}</code></td> | ||||
|     <td>{{ item.name }}</td> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user