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