| Line 233... |
Line 233... |
| 233 |
int quantityToReduce = itemQtyEntry.getValue() - ourSale;
|
233 |
int quantityToReduce = itemQtyEntry.getValue() - ourSale;
|
| 234 |
List<InventoryItem> itemIis = itemIdInventoryMap.get(itemQtyEntry.getKey());
|
234 |
List<InventoryItem> itemIis = itemIdInventoryMap.get(itemQtyEntry.getKey());
|
| 235 |
if (itemIdInventoryMap != null) {
|
235 |
if (itemIdInventoryMap != null) {
|
| 236 |
for (InventoryItem ii : itemIis) {
|
236 |
for (InventoryItem ii : itemIis) {
|
| 237 |
if (quantityToReduce > 0 && ii.getGoodQuantity() > 0) {
|
237 |
if (quantityToReduce > 0 && ii.getGoodQuantity() > 0) {
|
| 238 |
LOGGER.info("Changed in inventoryItems {}, {}, {}, {}, {}, {}, {}",
|
238 |
LOGGER.info("Changed in inventoryItems {}, {}, {}, {}, {}, {}",
|
| 239 |
purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
|
239 |
purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
|
| 240 |
ii.getInitialQuantity(), ii.getGoodQuantity(), ii.getBadQuantity(),
|
240 |
ii.getInitialQuantity(), ii.getGoodQuantity(), quantityToReduce);
|
| 241 |
quantityToReduce);
|
- |
|
| 242 |
if (ii.getGoodQuantity() > 0) {
|
241 |
if (ii.getGoodQuantity() > 0) {
|
| 243 |
List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
|
242 |
List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
|
| 244 |
for (ScanRecord scanRecord : scanRecords) {
|
243 |
for (ScanRecord scanRecord : scanRecords) {
|
| 245 |
if (scanRecord.getType().equals(ScanType.PURCHASE)) {
|
244 |
if (scanRecord.getType().equals(ScanType.PURCHASE)) {
|
| 246 |
CurrentInventorySnapshot cis = currentInventorySnapshotRepository
|
245 |
CurrentInventorySnapshot cis = currentInventorySnapshotRepository
|
| Line 249... |
Line 248... |
| 249 |
ii.setInitialQuantity(ii.getInitialQuantity() - ii.getBadQuantity());
|
248 |
ii.setInitialQuantity(ii.getInitialQuantity() - ii.getBadQuantity());
|
| 250 |
ii.setGoodQuantity(0);
|
249 |
ii.setGoodQuantity(0);
|
| 251 |
cis.setAvailability(cis.getAvailability() - ii.getGoodQuantity());
|
250 |
cis.setAvailability(cis.getAvailability() - ii.getGoodQuantity());
|
| 252 |
purchase.setUnfullfilledNonSerializedQuantity(
|
251 |
purchase.setUnfullfilledNonSerializedQuantity(
|
| 253 |
purchase.getUnfullfilledNonSerializedQuantity() + quantityToReduce);
|
252 |
purchase.getUnfullfilledNonSerializedQuantity() + quantityToReduce);
|
| - |
|
253 |
quantityToReduce = quantityToReduce - ii.getGoodQuantity();
|
| 254 |
LOGGER.info("Rectified {}, {}, {}, {}, {}, {}, {}",
|
254 |
LOGGER.info("Rectified {}, {}, {}, {}, {}, {}",
|
| 255 |
purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
|
255 |
purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
|
| 256 |
ii.getInitialQuantity(), ii.getGoodQuantity(), ii.getBadQuantity(),
|
256 |
ii.getInitialQuantity(), ii.getGoodQuantity(),
|
| 257 |
quantityToReduce);
|
257 |
quantityToReduce);
|
| 258 |
quantityToReduce = quantityToReduce - ii.getGoodQuantity();
|
- |
|
| 259 |
break;
|
258 |
break;
|
| 260 |
}
|
259 |
}
|
| 261 |
}
|
260 |
}
|
| 262 |
}
|
261 |
}
|
| 263 |
}
|
262 |
}
|