Subversion Repositories SmartDukaan

Rev

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

Rev 7672 Rev 7676
Line 179... Line 179...
179
	from 
179
	from 
180
	(select i.itemId, count(*) as inx from scanNew s 
180
	(select i.itemId, count(*) as inx from scanNew s 
181
		JOIN inventoryItem i ON (i.id = s.inventoryItemId) 
181
		JOIN inventoryItem i ON (i.id = s.inventoryItemId) 
182
		JOIN catalog.item c ON i.itemId = c.id 
182
		JOIN catalog.item c ON i.itemId = c.id 
183
		where s.type in ('PURCHASE','SALE_RET') and c.type = 'SERIALIZED' 
183
		where s.type in ('PURCHASE','SALE_RET') and c.type = 'SERIALIZED' 
-
 
184
		and i.physicalWarehouseId = #{physicalWarehouseId} 
184
		group by i.itemId ) as x 
185
		group by i.itemId ) as x 
185
	LEFT JOIN 
186
	LEFT JOIN 
186
	(select i.itemId, count(*) as outx from scanNew s 
187
	(select i.itemId, count(*) as outx from scanNew s 
187
		JOIN inventoryItem i on i.id = s.inventoryItemId 
188
		JOIN inventoryItem i on i.id = s.inventoryItemId 
188
		JOIN catalog.item c ON i.itemId = c.id 
189
		JOIN catalog.item c ON i.itemId = c.id 
189
		where s.type in ('SALE','LOST_IN_WAREHOUSE','PURCHASE_RETURN') and c.type = 'SERIALIZED' 
190
		where s.type in ('SALE','LOST_IN_WAREHOUSE','PURCHASE_RETURN') and c.type = 'SERIALIZED'
-
 
191
		and i.physicalWarehouseId = #{physicalWarehouseId} 
190
		group by i.itemId) as y 
192
		group by i.itemId) as y 
191
	ON x.itemId = y.itemId 
193
	ON x.itemId = y.itemId 
192
	JOIN catalog.item ci ON ci.id = x.itemId 
194
	JOIN catalog.item ci ON ci.id = x.itemId 
193
	where ci.type = 'SERIALIZED' having quantity>0  
195
	where ci.type = 'SERIALIZED' having quantity>0  
194
  </select>
196
  </select>
Line 221... Line 223...
221
	ci.model_number as modelNumber, ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity
223
	ci.model_number as modelNumber, ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity
222
	from 
224
	from 
223
	(select i.itemId, sum(quantity) as inx from scanNew s 
225
	(select i.itemId, sum(quantity) as inx from scanNew s 
224
		JOIN inventoryItem i ON (i.id = s.inventoryItemId) 
226
		JOIN inventoryItem i ON (i.id = s.inventoryItemId) 
225
		JOIN catalog.item c ON i.itemId = c.id 
227
		JOIN catalog.item c ON i.itemId = c.id 
226
		where s.type in ('PURCHASE','SALE_RET') and c.type = 'NON_SERIALIZED' 
228
		where s.type in ('PURCHASE','SALE_RET') and c.type = 'NON_SERIALIZED'
-
 
229
		and i.physicalWarehouseId = #{physicalWarehouseId} 
227
		group by i.itemId ) as x 
230
		group by i.itemId ) as x 
228
	LEFT JOIN 
231
	LEFT JOIN 
229
	(select i.itemId, sum(quantity) as outx from scanNew s 
232
	(select i.itemId, sum(quantity) as outx from scanNew s 
230
		JOIN inventoryItem i on i.id = s.inventoryItemId 
233
		JOIN inventoryItem i on i.id = s.inventoryItemId 
231
		JOIN catalog.item c ON i.itemId = c.id 
234
		JOIN catalog.item c ON i.itemId = c.id 
232
		where s.type in ('SALE','LOST_IN_WAREHOUSE','PURCHASE_RETURN') and c.type = 'NON_SERIALIZED' 
235
		where s.type in ('SALE','LOST_IN_WAREHOUSE','PURCHASE_RETURN') and c.type = 'NON_SERIALIZED'
-
 
236
		and i.physicalWarehouseId = #{physicalWarehouseId} 
233
		group by i.itemId) as y 
237
		group by i.itemId) as y 
234
	ON x.itemId = y.itemId 
238
	ON x.itemId = y.itemId 
235
	JOIN catalog.item ci ON ci.id = x.itemId 
239
	JOIN catalog.item ci ON ci.id = x.itemId 
236
	where ci.type = 'NON_SERIALIZED' having quantity>0  
240
	where ci.type = 'NON_SERIALIZED' having quantity>0  
237
  </select>
241
  </select>