Subversion Repositories SmartDukaan

Rev

Rev 10348 | Rev 10407 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10348 Rev 10402
Line 185... Line 185...
185
	ci.model_number as modelNumber, ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity
185
	ci.model_number as modelNumber, ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity
186
	from 
186
	from 
187
	(select i.itemId, count(*) as inx from scanNew s 
187
	(select i.itemId, count(*) as inx from scanNew s 
188
		JOIN inventoryItem i ON (i.id = s.inventoryItemId) 
188
		JOIN inventoryItem i ON (i.id = s.inventoryItemId) 
189
		JOIN catalog.item c ON i.itemId = c.id 
189
		JOIN catalog.item c ON i.itemId = c.id 
-
 
190
		JOIN inventory.warehouse w ON w.id = s.warehouseId  
190
		where s.type in ('PURCHASE','SALE_RET', 'MARKED_GOOD','WAREHOUSE_TRANSFER_IN') and c.type = 'SERIALIZED' 
191
		where s.type in ('PURCHASE','SALE_RET', 'MARKED_GOOD','WAREHOUSE_TRANSFER_IN') and c.type = 'SERIALIZED' 
191
		and i.physicalWarehouseId = #{physicalWarehouseId} 
192
		and w.billingWarehouseId = #{physicalWarehouseId} 
192
		group by i.itemId ) as x 
193
		group by i.itemId ) as x 
193
	LEFT JOIN 
194
	LEFT JOIN 
194
	(select i.itemId, count(*) as outx from scanNew s 
195
	(select i.itemId, count(*) as outx from scanNew s 
195
		JOIN inventoryItem i on i.id = s.inventoryItemId 
196
		JOIN inventoryItem i on i.id = s.inventoryItemId 
196
		JOIN catalog.item c ON i.itemId = c.id 
197
		JOIN catalog.item c ON i.itemId = c.id 
-
 
198
		JOIN inventory.warehouse w ON w.id = s.warehouseId 
197
		where s.type in ('SALE','LOST_IN_WAREHOUSE','PURCHASE_RETURN','MARKED_USED','MARKED_BAD','WAREHOUSE_TRANSFER_OUT') and c.type = 'SERIALIZED'
199
		where s.type in ('SALE','LOST_IN_WAREHOUSE','PURCHASE_RETURN','MARKED_USED','MARKED_BAD','WAREHOUSE_TRANSFER_OUT') and c.type = 'SERIALIZED'
198
		and i.physicalWarehouseId = #{physicalWarehouseId} 
200
		and w.billingWarehouseId = #{physicalWarehouseId} 
199
		group by i.itemId) as y 
201
		group by i.itemId) as y 
200
	ON x.itemId = y.itemId 
202
	ON x.itemId = y.itemId 
201
	JOIN catalog.item ci ON ci.id = x.itemId 
203
	JOIN catalog.item ci ON ci.id = x.itemId 
202
	where ci.type = 'SERIALIZED' having quantity>0  
204
	where ci.type = 'SERIALIZED' having quantity>0  
203
  </select>
205
  </select>