| Line 13... |
Line 13... |
| 13 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
13 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 14 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
14 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
| 15 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
15 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 16 |
import com.spice.profitmandi.dao.repository.fofo.FofoOpeningStockRepository;
|
16 |
import com.spice.profitmandi.dao.repository.fofo.FofoOpeningStockRepository;
|
| 17 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
17 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 18 |
import com.spice.profitmandi.model.WarehouseItemQtyModel;
|
- |
|
| 19 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
18 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
| 20 |
import org.apache.logging.log4j.LogManager;
|
19 |
import org.apache.logging.log4j.LogManager;
|
| 21 |
import org.apache.logging.log4j.Logger;
|
20 |
import org.apache.logging.log4j.Logger;
|
| 22 |
import org.hibernate.Session;
|
21 |
import org.hibernate.Session;
|
| 23 |
import org.hibernate.SessionFactory;
|
22 |
import org.hibernate.SessionFactory;
|
| Line 112... |
Line 111... |
| 112 |
@Override
|
111 |
@Override
|
| 113 |
public void minusOpeningStock(int itemId, int fofoId, int quantity) throws ProfitMandiBusinessException{
|
112 |
public void minusOpeningStock(int itemId, int fofoId, int quantity) throws ProfitMandiBusinessException{
|
| 114 |
int catalogId = itemRepository.selectById(itemId).getCatalogItemId();
|
113 |
int catalogId = itemRepository.selectById(itemId).getCatalogItemId();
|
| 115 |
FofoOpeningStock fofoOpeningStock = fofoOpeningStockRepository.findByFofoIdAndCatalogId(fofoId,catalogId);
|
114 |
FofoOpeningStock fofoOpeningStock = fofoOpeningStockRepository.findByFofoIdAndCatalogId(fofoId,catalogId);
|
| 116 |
if(fofoOpeningStock !=null){
|
115 |
if(fofoOpeningStock !=null){
|
| 117 |
int updatedQty = fofoOpeningStock.getCurrentQty() - quantity;
|
116 |
int updatedQty = Math.max(fofoOpeningStock.getCurrentQty() - quantity, 0);
|
| 118 |
fofoOpeningStock.setCurrentQty(updatedQty);
|
117 |
fofoOpeningStock.setCurrentQty(updatedQty);
|
| 119 |
}
|
118 |
}
|
| 120 |
}
|
119 |
}
|
| 121 |
|
120 |
|
| 122 |
@Override
|
121 |
@Override
|
| Line 147... |
Line 146... |
| 147 |
|
146 |
|
| 148 |
// Update each opening stock
|
147 |
// Update each opening stock
|
| 149 |
for (FofoOpeningStock openingStock : openingStocks) {
|
148 |
for (FofoOpeningStock openingStock : openingStocks) {
|
| 150 |
Integer quantityToSubtract = catalogQuantityMap.get(openingStock.getCatalogId());
|
149 |
Integer quantityToSubtract = catalogQuantityMap.get(openingStock.getCatalogId());
|
| 151 |
if (quantityToSubtract != null) {
|
150 |
if (quantityToSubtract != null) {
|
| 152 |
openingStock.setCurrentQty(openingStock.getCurrentQty() - quantityToSubtract);
|
151 |
openingStock.setCurrentQty(Math.max(openingStock.getCurrentQty() - quantityToSubtract, 0));
|
| 153 |
}
|
152 |
}
|
| 154 |
}
|
153 |
}
|
| 155 |
}
|
154 |
}
|
| 156 |
|
155 |
|
| 157 |
@Override
|
156 |
@Override
|