Subversion Repositories SmartDukaan

Rev

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

Rev 10308 Rev 10347
Line 367... Line 367...
367
	SELECT x.itemId, ci.brand, ci.model_name as modelName, ci.model_number as modelNumber, 
367
	SELECT x.itemId, ci.brand, ci.model_name as modelName, ci.model_number as modelNumber, 
368
	ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity 
368
	ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity 
369
	FROM 
369
	FROM 
370
		(SELECT i.itemId, count(*) as inx FROM scanNew s JOIN inventoryItem i ON 
370
		(SELECT i.itemId, count(*) as inx FROM scanNew s JOIN inventoryItem i ON 
371
		(i.id = s.inventoryItemId) JOIN catalog.item c ON i.itemId = c.id 
371
		(i.id = s.inventoryItemId) JOIN catalog.item c ON i.itemId = c.id 
372
		where s.type in ('DOA_IN', 'SALE_RET_UNUSABLE') and 
372
		where s.type in ('DOA_IN', 'SALE_RET_UNUSABLE','MARKED_BAD') and 
373
		s.scannedAt < #{date} group by i.itemId ) as x 
373
		s.scannedAt < #{date} group by i.itemId ) as x 
374
		LEFT JOIN 
374
		LEFT JOIN 
375
		(SELECT i.itemId, count(*) as outx FROM scanNew s JOIN inventoryItem i ON
375
		(SELECT i.itemId, count(*) as outx FROM scanNew s JOIN inventoryItem i ON
376
		i.id = s.inventoryItemId JOIN catalog.item c ON i.itemId = c.id WHERE 
376
		i.id = s.inventoryItemId JOIN catalog.item c ON i.itemId = c.id WHERE 
377
		s.type in ('DOA_OUT') and s.scannedAt < #{date} group by i.itemId) as y 
377
		s.type in ('DOA_OUT','MARKED_GOOD') and s.scannedAt < #{date} group by i.itemId) as y 
378
		ON x.itemId = y.itemId 
378
		ON x.itemId = y.itemId 
379
		JOIN catalog.item ci ON ci.id = x.itemId 
379
		JOIN catalog.item ci ON ci.id = x.itemId 
380
	having quantity>0;
380
	having quantity>0;
381
</select>
381
</select>
382
 
382