| Line 377... |
Line 377... |
| 377 |
continue;
|
377 |
continue;
|
| 378 |
}
|
378 |
}
|
| 379 |
int ourSale = ourSaleItemQtyMap.get(itemQtyEntry.getKey());
|
379 |
int ourSale = ourSaleItemQtyMap.get(itemQtyEntry.getKey());
|
| 380 |
int quantityToReduce = itemQtyEntry.getValue() - ourSale;
|
380 |
int quantityToReduce = itemQtyEntry.getValue() - ourSale;
|
| 381 |
List<InventoryItem> itemIis = itemIdInventoryMap.get(itemQtyEntry.getKey());
|
381 |
List<InventoryItem> itemIis = itemIdInventoryMap.get(itemQtyEntry.getKey());
|
| - |
|
382 |
if (quantityToReduce > 0) {
|
| - |
|
383 |
LOGGER.info("Invoice {}, Item {}, Quantity to reduce {}", purchase.getPurchaseReference(), itemQtyEntry.getKey(), quantityToReduce);
|
| 382 |
if (itemIdInventoryMap != null) {
|
384 |
if (itemIdInventoryMap != null) {
|
| 383 |
for (InventoryItem ii : itemIis) {
|
385 |
for (InventoryItem ii : itemIis) {
|
| 384 |
if (ii.getSerialNumber() == null && ii.getGoodQuantity() == ii.getInitialQuantity()
|
386 |
if (ii.getSerialNumber() == null && ii.getGoodQuantity() == ii.getInitialQuantity()
|
| 385 |
&& quantityToReduce >= ii.getInitialQuantity()) {
|
387 |
&& quantityToReduce >= ii.getInitialQuantity()) {
|
| 386 |
LOGGER.info("Changed in inventoryItems {}, {}, {}, {}, {}, {}",
|
388 |
LOGGER.info("Changed in inventoryItems {}, {}, {}, {}, {}, {}",
|
| 387 |
purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
|
389 |
purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
|
| 388 |
ii.getInitialQuantity(), ii.getGoodQuantity(), quantityToReduce);
|
390 |
ii.getInitialQuantity(), ii.getGoodQuantity(), quantityToReduce);
|
| 389 |
List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
|
391 |
List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
|
| 390 |
for (ScanRecord scanRecord : scanRecords) {
|
392 |
for (ScanRecord scanRecord : scanRecords) {
|
| 391 |
CurrentInventorySnapshot cis = currentInventorySnapshotRepository
|
393 |
CurrentInventorySnapshot cis = currentInventorySnapshotRepository
|
| 392 |
.selectByItemIdAndFofoId(itemQtyEntry.getKey(), purchase.getFofoId());
|
394 |
.selectByItemIdAndFofoId(itemQtyEntry.getKey(), purchase.getFofoId());
|
| - |
|
395 |
|
| 393 |
scanRecord.setQuantity(0);
|
396 |
cis.setAvailability(cis.getAvailability() - ii.getInitialQuantity());
|
| 394 |
ii.setGoodQuantity(0);
|
397 |
purchase.setUnfullfilledNonSerializedQuantity(
|
| 395 |
quantityToReduce = quantityToReduce - ii.getInitialQuantity();
|
398 |
purchase.getUnfullfilledNonSerializedQuantity() + quantityToReduce);
|
| - |
|
399 |
|
| 396 |
cis.setAvailability(cis.getAvailability() - ii.getInitialQuantity());
|
400 |
quantityToReduce = quantityToReduce - ii.getInitialQuantity();
|
| 397 |
purchase.setUnfullfilledNonSerializedQuantity(
|
401 |
inventoryItemRepository.delete(ii);
|
| 398 |
purchase.getUnfullfilledNonSerializedQuantity() + quantityToReduce);
|
402 |
scanRecordRepository.delete(scanRecord);
|
| 399 |
LOGGER.info("Rectified {}, {}, {}, {}, {}, {}", purchase.getPurchaseReference(),
|
403 |
LOGGER.info("Rectified {}, {}, {}, {}, {}, {}", purchase.getPurchaseReference(),
|
| 400 |
ii.getId(), ii.getItemId(), ii.getInitialQuantity(), ii.getGoodQuantity(),
|
404 |
ii.getId(), ii.getItemId(), ii.getInitialQuantity(), ii.getGoodQuantity(),
|
| 401 |
quantityToReduce);
|
405 |
quantityToReduce);
|
| - |
|
406 |
|
| - |
|
407 |
}
|
| 402 |
}
|
408 |
}
|
| 403 |
}
|
409 |
}
|
| 404 |
}
|
410 |
}
|
| 405 |
}
|
411 |
}
|
| 406 |
}
|
412 |
}
|
| 407 |
}
|
413 |
}
|
| 408 |
// throw new Exception();
|
414 |
//throw new Exception();
|
| 409 |
}
|
415 |
}
|
| 410 |
|
416 |
|
| 411 |
public void migrateChallansToInvoices() throws Exception {
|
417 |
public void migrateChallansToInvoices() throws Exception {
|
| 412 |
Map<String, List<Order>> invoiceOrdersMap = orderRepository.selectAllChallans().stream()
|
418 |
Map<String, List<Order>> invoiceOrdersMap = orderRepository.selectAllChallans().stream()
|
| 413 |
.filter(x -> !x.getLineItem().getHsnCode().equals("NOGST"))
|
419 |
.filter(x -> !x.getLineItem().getHsnCode().equals("NOGST"))
|