| Line 127... |
Line 127... |
| 127 |
group by i.itemId) as y
|
127 |
group by i.itemId) as y
|
| 128 |
ON x.itemId = y.itemId
|
128 |
ON x.itemId = y.itemId
|
| 129 |
JOIN catalog.item ci ON ci.id = x.itemId
|
129 |
JOIN catalog.item ci ON ci.id = x.itemId
|
| 130 |
where ci.type = 'SERIALIZED' having quantity>0
|
130 |
where ci.type = 'SERIALIZED' having quantity>0
|
| 131 |
</select>
|
131 |
</select>
|
| - |
|
132 |
|
| - |
|
133 |
<select id = "getHistoricSerializedInventoryByScans" resultType = "inventoryAvailability" parameterType = "date">
|
| - |
|
134 |
SELECT x.itemId, ci.brand, ci.model_name as modelName,
|
| - |
|
135 |
ci.model_number as modelNumber, ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity
|
| - |
|
136 |
from
|
| - |
|
137 |
(select i.itemId, count(*) as inx from scanNew s
|
| - |
|
138 |
JOIN inventoryItem i ON (i.id = s.inventoryItemId)
|
| - |
|
139 |
JOIN catalog.item c ON i.itemId = c.id
|
| - |
|
140 |
where s.type in ('PURCHASE','SALE_RET') and c.type = 'SERIALIZED'
|
| - |
|
141 |
and s.scannedAt < #{date}
|
| - |
|
142 |
group by i.itemId ) as x
|
| - |
|
143 |
LEFT JOIN
|
| - |
|
144 |
(select i.itemId, count(*) as outx from scanNew s
|
| - |
|
145 |
JOIN inventoryItem i on i.id = s.inventoryItemId
|
| - |
|
146 |
JOIN catalog.item c ON i.itemId = c.id
|
| - |
|
147 |
where s.type in ('SALE','LOST_IN_WAREHOUSE','PURCHASE_RETURN') and c.type = 'SERIALIZED'
|
| - |
|
148 |
and s.scannedAt < #{date}
|
| - |
|
149 |
group by i.itemId) as y
|
| - |
|
150 |
ON x.itemId = y.itemId
|
| - |
|
151 |
JOIN catalog.item ci ON ci.id = x.itemId
|
| - |
|
152 |
where ci.type = 'SERIALIZED' having quantity>0
|
| - |
|
153 |
</select>
|
| - |
|
154 |
|
| 132 |
|
155 |
|
| 133 |
<select id = "getCurrentNonSerializedInventoryByScans" resultType = "inventoryAvailability">
|
156 |
<select id = "getCurrentNonSerializedInventoryByScans" resultType = "inventoryAvailability">
|
| 134 |
SELECT x.itemId, ci.brand, ci.model_name as modelName,
|
157 |
SELECT x.itemId, ci.brand, ci.model_name as modelName,
|
| 135 |
ci.model_number as modelNumber, ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity
|
158 |
ci.model_number as modelNumber, ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity
|
| 136 |
from
|
159 |
from
|
| Line 147... |
Line 170... |
| 147 |
group by i.itemId) as y
|
170 |
group by i.itemId) as y
|
| 148 |
ON x.itemId = y.itemId
|
171 |
ON x.itemId = y.itemId
|
| 149 |
JOIN catalog.item ci ON ci.id = x.itemId
|
172 |
JOIN catalog.item ci ON ci.id = x.itemId
|
| 150 |
where ci.type = 'NON_SERIALIZED' having quantity>0
|
173 |
where ci.type = 'NON_SERIALIZED' having quantity>0
|
| 151 |
</select>
|
174 |
</select>
|
| - |
|
175 |
|
| - |
|
176 |
<select id = "getHistoricNonSerializedInventoryByScans" resultType = "inventoryAvailability" parameterType = "date">
|
| - |
|
177 |
SELECT x.itemId, ci.brand, ci.model_name as modelName,
|
| - |
|
178 |
ci.model_number as modelNumber, ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity
|
| - |
|
179 |
from
|
| - |
|
180 |
(select i.itemId, sum(quantity) as inx from scanNew s
|
| - |
|
181 |
JOIN inventoryItem i ON (i.id = s.inventoryItemId)
|
| - |
|
182 |
JOIN catalog.item c ON i.itemId = c.id
|
| - |
|
183 |
where s.type in ('PURCHASE','SALE_RET') and c.type = 'NON_SERIALIZED'
|
| - |
|
184 |
and s.scannedAt < #{date}
|
| - |
|
185 |
group by i.itemId ) as x
|
| - |
|
186 |
LEFT JOIN
|
| - |
|
187 |
(select i.itemId, sum(quantity) as outx from scanNew s
|
| - |
|
188 |
JOIN inventoryItem i on i.id = s.inventoryItemId
|
| - |
|
189 |
JOIN catalog.item c ON i.itemId = c.id
|
| - |
|
190 |
where s.type in ('SALE','LOST_IN_WAREHOUSE','PURCHASE_RETURN') and c.type = 'NON_SERIALIZED'
|
| - |
|
191 |
and s.scannedAt < #{date}
|
| - |
|
192 |
group by i.itemId) as y
|
| - |
|
193 |
ON x.itemId = y.itemId
|
| - |
|
194 |
JOIN catalog.item ci ON ci.id = x.itemId
|
| - |
|
195 |
where ci.type = 'NON_SERIALIZED' having quantity>0
|
| - |
|
196 |
</select>
|
| - |
|
197 |
|
| - |
|
198 |
<select id = "getMovementSerializedInventoryByScans" resultType = "inventoryMovement" parameterType = "map">
|
| - |
|
199 |
select itemId, brand, model_name as modelName, model_number as modelNumber, color, s.type, count(*) as quantity
|
| - |
|
200 |
FROM inventoryItem i JOIN scanNew s ON i.id = s.inventoryItemId
|
| - |
|
201 |
LEFT JOIN catalog.item c ON i.itemId = c.id
|
| - |
|
202 |
where s.scannedAt between #{startDate} and #{endDate} and c.type = 'SERIALIZED'
|
| - |
|
203 |
group by itemId, s.type
|
| - |
|
204 |
</select>
|
| - |
|
205 |
|
| - |
|
206 |
<select id = "getMovementNonSerializedInventoryByScans" resultType = "inventoryMovement" parameterType = "map">
|
| - |
|
207 |
select itemId, brand, model_name as modelName, model_number as modelNumber, color, s.type, count(*) as quantity
|
| - |
|
208 |
FROM inventoryItem i JOIN scanNew s ON i.id = s.inventoryItemId
|
| - |
|
209 |
LEFT JOIN catalog.item c ON i.itemId = c.id
|
| - |
|
210 |
where s.scannedAt between #{startDate} and #{endDate} and c.type = 'NON_SERIALIZED'
|
| - |
|
211 |
group by itemId, s.type
|
| - |
|
212 |
</select>
|
| 152 |
|
213 |
|
| 153 |
</mapper>
|
214 |
</mapper>
|