| Line 5069... |
Line 5069... |
| 5069 |
existingStock.setCurrentQty(partnerCurrentQty);
|
5069 |
existingStock.setCurrentQty(partnerCurrentQty);
|
| 5070 |
existingStock.setOpeningDate(openingDate);
|
5070 |
existingStock.setOpeningDate(openingDate);
|
| 5071 |
LOGGER.info("if condition exist {}");
|
5071 |
LOGGER.info("if condition exist {}");
|
| 5072 |
}else if(existingStock.getCurrentQty() >= existingStock.getOpeningQty()){
|
5072 |
}else if(existingStock.getCurrentQty() >= existingStock.getOpeningQty()){
|
| 5073 |
existingStock.setOpeningQty(existingStock.getCurrentQty());
|
5073 |
existingStock.setOpeningQty(existingStock.getCurrentQty());
|
| - |
|
5074 |
existingStock.setCurrentQty(partnerCurrentQty);
|
| 5074 |
existingStock.setOpeningDate(LocalDate.now());
|
5075 |
existingStock.setOpeningDate(LocalDate.now());
|
| 5075 |
} else if (existingStock.getOpeningDate().isBefore(LocalDate.now().minusDays(7))) {
|
5076 |
} else if (existingStock.getOpeningDate().isBefore(LocalDate.now().minusDays(7))) {
|
| 5076 |
int averageQty = Math.round((existingStock.getCurrentQty() + existingStock.getOpeningQty()) / 2.0f);
|
5077 |
int averageQty = Math.round((existingStock.getCurrentQty() + existingStock.getOpeningQty()) / 2.0f);
|
| 5077 |
|
5078 |
|
| 5078 |
if (averageQty == 1 && existingStock.getOpeningQty() == 1 && existingStock.getCurrentQty() == 0) {
|
5079 |
if (averageQty == 1 && existingStock.getOpeningQty() == 1 && existingStock.getCurrentQty() == 0) {
|
| Line 5080... |
Line 5081... |
| 5080 |
fofoOpeningStockRepository.delete(existingStock);
|
5081 |
fofoOpeningStockRepository.delete(existingStock);
|
| 5081 |
LOGGER.info("Deleted record with fofoId: {}, catalogId: {} because averageQty, openingQty, and currentQty meet deletion criteria", fofoId, catalogId);
|
5082 |
LOGGER.info("Deleted record with fofoId: {}, catalogId: {} because averageQty, openingQty, and currentQty meet deletion criteria", fofoId, catalogId);
|
| 5082 |
} else {
|
5083 |
} else {
|
| 5083 |
// Update the existing stock with the new average quantity
|
5084 |
// Update the existing stock with the new average quantity
|
| 5084 |
existingStock.setOpeningQty(averageQty);
|
5085 |
existingStock.setOpeningQty(averageQty);
|
| - |
|
5086 |
existingStock.setCurrentQty(partnerCurrentQty);
|
| 5085 |
existingStock.setOpeningDate(LocalDate.now());
|
5087 |
existingStock.setOpeningDate(LocalDate.now());
|
| 5086 |
LOGGER.info("Updated due to date being older than 7 days with average quantity: {}", averageQty);
|
5088 |
LOGGER.info("Updated due to date being older than 7 days with average quantity: {}", averageQty);
|
| 5087 |
}
|
5089 |
}
|
| - |
|
5090 |
}else {
|
| - |
|
5091 |
existingStock.setCurrentQty(partnerCurrentQty);
|
| 5088 |
}
|
5092 |
}
|
| 5089 |
} else {
|
5093 |
} else {
|
| 5090 |
LOGGER.info("else condition exist");
|
5094 |
LOGGER.info("else condition exist");
|
| 5091 |
FofoOpeningStock newStock = new FofoOpeningStock();
|
5095 |
FofoOpeningStock newStock = new FofoOpeningStock();
|
| 5092 |
newStock.setFofoId(fofoId);
|
5096 |
newStock.setFofoId(fofoId);
|