| Line 23... |
Line 23... |
| 23 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
23 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 24 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
24 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 25 |
import com.spice.profitmandi.dao.entity.transaction.LineItem;
|
25 |
import com.spice.profitmandi.dao.entity.transaction.LineItem;
|
| 26 |
import com.spice.profitmandi.dao.entity.transaction.LineItemImei;
|
26 |
import com.spice.profitmandi.dao.entity.transaction.LineItemImei;
|
| 27 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
27 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| - |
|
28 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| 28 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
29 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
30 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
31 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 31 |
import com.spice.profitmandi.dao.repository.fofo.DebitNoteRepository;
|
32 |
import com.spice.profitmandi.dao.repository.fofo.DebitNoteRepository;
|
| 32 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
33 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| Line 207... |
Line 208... |
| 207 |
|
208 |
|
| 208 |
public void cancelOrder(List<String> invoiceNumbers) throws Exception {
|
209 |
public void cancelOrder(List<String> invoiceNumbers) throws Exception {
|
| 209 |
orderService.cancelOrder(invoiceNumbers);
|
210 |
orderService.cancelOrder(invoiceNumbers);
|
| 210 |
}
|
211 |
}
|
| 211 |
|
212 |
|
| 212 |
public void migratePurchase() throws Exception{
|
213 |
public void migratePurchase() throws Exception {
|
| 213 |
List<Purchase> purchases = purchaseRepository.selectPurchaseAllPurchasesLessThanZero();
|
214 |
List<Purchase> purchases = purchaseRepository.selectPurchaseAllPurchasesLessThanZero();
|
| 214 |
System.out.printf("Total Purchases count is %s", purchases.size());
|
215 |
System.out.printf("Total Purchases count is %s", purchases.size());
|
| 215 |
for (Purchase purchase : purchases) {
|
216 |
for (Purchase purchase : purchases) {
|
| 216 |
System.out.printf("Got purchase id %d\n", purchase.getId());
|
217 |
System.out.printf("Got purchase id %d\n", purchase.getId());
|
| 217 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchase.getId());
|
218 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchase.getId());
|
| Line 239... |
Line 240... |
| 239 |
purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
|
240 |
purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
|
| 240 |
ii.getInitialQuantity(), ii.getGoodQuantity(), ii.getBadQuantity(),
|
241 |
ii.getInitialQuantity(), ii.getGoodQuantity(), ii.getBadQuantity(),
|
| 241 |
quantityToReduce);
|
242 |
quantityToReduce);
|
| 242 |
if (ii.getGoodQuantity() == quantityToReduce) {
|
243 |
if (ii.getGoodQuantity() == quantityToReduce) {
|
| 243 |
List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
|
244 |
List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
|
| 244 |
if (scanRecords.size() == 1) {
|
245 |
for (ScanRecord scanRecord : scanRecords) {
|
| - |
|
246 |
if (scanRecord.getType().equals(ScanType.PURCHASE)) {
|
| 245 |
CurrentInventorySnapshot cis = currentInventorySnapshotRepository
|
247 |
CurrentInventorySnapshot cis = currentInventorySnapshotRepository
|
| 246 |
.selectByItemIdAndFofoId(itemQtyEntry.getKey(), purchase.getFofoId());
|
248 |
.selectByItemIdAndFofoId(itemQtyEntry.getKey(), purchase.getFofoId());
|
| 247 |
if (cis.getAvailability() - quantityToReduce >= 0) {
|
249 |
if (cis.getAvailability() - quantityToReduce >= 0) {
|
| 248 |
scanRecordRepository.delete(scanRecords.get(0));
|
250 |
scanRecord.setQuantity(scanRecord.getQuantity() - quantityToReduce);
|
| 249 |
genericRepository.delete(ii);
|
251 |
genericRepository.delete(ii);
|
| 250 |
cis.setAvailability(cis.getAvailability() - quantityToReduce);
|
252 |
cis.setAvailability(cis.getAvailability() - quantityToReduce);
|
| - |
|
253 |
purchase.setUnfullfilledNonSerializedQuantity(
|
| 251 |
purchase.setUnfullfilledNonSerializedQuantity(purchase.getUnfullfilledNonSerializedQuantity() + quantityToReduce);
|
254 |
purchase.getUnfullfilledNonSerializedQuantity() + quantityToReduce);
|
| 252 |
LOGGER.info("Rectified {}, {}, {}, {}, {}, {}, {}",
|
255 |
LOGGER.info("Rectified {}, {}, {}, {}, {}, {}, {}",
|
| 253 |
purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
|
256 |
purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
|
| 254 |
ii.getInitialQuantity(), ii.getGoodQuantity(), ii.getBadQuantity(),
|
257 |
ii.getInitialQuantity(), ii.getGoodQuantity(), ii.getBadQuantity(),
|
| 255 |
quantityToReduce);
|
258 |
quantityToReduce);
|
| 256 |
break;
|
259 |
break;
|
| - |
|
260 |
}
|
| 257 |
}
|
261 |
}
|
| 258 |
} else if (scanRecords.size() != 1) {
|
- |
|
| 259 |
LOGGER.info("Skipped {}, {}, {}, {}, {}, {}, {}", purchase.getPurchaseReference(),
|
- |
|
| 260 |
ii.getId(), ii.getItemId(), ii.getInitialQuantity(), ii.getGoodQuantity(),
|
- |
|
| 261 |
ii.getBadQuantity(), quantityToReduce);
|
- |
|
| 262 |
}
|
262 |
}
|
| 263 |
// Delete it immediately and make changes.
|
- |
|
| 264 |
}
|
263 |
}
|
| 265 |
}
|
264 |
}
|
| 266 |
}
|
265 |
}
|
| 267 |
}
|
266 |
}
|
| 268 |
}
|
267 |
}
|