| Line 278... |
Line 278... |
| 278 |
public void reconcileExpiredFixedSchemes() throws Exception {
|
278 |
public void reconcileExpiredFixedSchemes() throws Exception {
|
| 279 |
List<Scheme> allSchemes = schemeRepository.selectAll();
|
279 |
List<Scheme> allSchemes = schemeRepository.selectAll();
|
| 280 |
// .stream().filter(x ->
|
280 |
// .stream().filter(x ->
|
| 281 |
// x.getAmountType().equals(AmountType.FIXED)).collect(Collectors.toList());
|
281 |
// x.getAmountType().equals(AmountType.FIXED)).collect(Collectors.toList());
|
| 282 |
|
282 |
|
| 283 |
System.out.println("InventoryId\tSerialNumber\tItem Id\tScheme Id\tScheme Name\tScheme Type\tAmount Type\tScheme Amount\tAmount Paid\tReference\tTransaction Time");
|
283 |
System.out.println("InventoryId\tSerialNumber\tItem Id\tScheme Id\tScheme Name\tScheme Type\tAmount Type\tScheme Amount\tAmount Paid\tReference\tTransaction Time\tScheme Start\tScheme End\tScheme Expiry");
|
| 284 |
for (Scheme scheme : allSchemes) {
|
284 |
for (Scheme scheme : allSchemes) {
|
| 285 |
if (scheme.getExpireTimestamp() != null) {
|
285 |
if (scheme.getExpireTimestamp() != null) {
|
| 286 |
if (scheme.getExpireTimestamp().isBefore(scheme.getEndDateTime())) {
|
286 |
if (scheme.getExpireTimestamp().isBefore(scheme.getEndDateTime())) {
|
| 287 |
List<SchemeInOut> inOuts = schemeInOutRepository
|
287 |
List<SchemeInOut> inOuts = schemeInOutRepository
|
| 288 |
.selectBySchemeIds(Sets.newHashSet(scheme.getId()));
|
288 |
.selectBySchemeIds(Sets.newHashSet(scheme.getId()));
|
| Line 293... |
Line 293... |
| 293 |
.filter(x -> x.getType().equals(ScanType.PURCHASE)).collect(Collectors.toList())
|
293 |
.filter(x -> x.getType().equals(ScanType.PURCHASE)).collect(Collectors.toList())
|
| 294 |
.get(0);
|
294 |
.get(0);
|
| 295 |
if (inRecord.getCreateTimestamp().isAfter(scheme.getExpireTimestamp())) {
|
295 |
if (inRecord.getCreateTimestamp().isAfter(scheme.getExpireTimestamp())) {
|
| 296 |
InventoryItem ii = inventoryItemRepository.selectById(inRecord.getInventoryItemId());
|
296 |
InventoryItem ii = inventoryItemRepository.selectById(inRecord.getInventoryItemId());
|
| 297 |
Purchase purchase = purchaseRepository.selectByIdAndFofoId(ii.getPurchaseId(), ii.getFofoId());
|
297 |
Purchase purchase = purchaseRepository.selectByIdAndFofoId(ii.getPurchaseId(), ii.getFofoId());
|
| 298 |
System.out.println(String.format("%d\t%s\t%d\t%d\t%s\t%s\t%f\t%f\t%d\t%s",
|
298 |
System.out.println(String.format("%d\t%s\t%d\t%d\t%s\t%s\t%f\t%f\t%d\t%s\t%s\t%s\t%s",
|
| 299 |
ii.getId(), ii.getSerialNumber(), ii.getItemId(), schemeInOut.getSchemeId(), scheme.getName(), scheme.getType(),
|
299 |
ii.getId(), ii.getSerialNumber(), ii.getItemId(), schemeInOut.getSchemeId(), scheme.getName(), scheme.getType(),
|
| 300 |
scheme.getAmount(), schemeInOut.getAmount(), purchase.getId(), inRecord.getCreateTimestamp()));
|
300 |
scheme.getAmount(), schemeInOut.getAmount(), purchase.getId(), inRecord.getCreateTimestamp(), scheme.getStartDateTime(), scheme.getEndDateTime(), scheme.getExpireTimestamp()));
|
| 301 |
}
|
301 |
}
|
| 302 |
|
302 |
|
| 303 |
}
|
303 |
}
|
| 304 |
}
|
304 |
}
|
| 305 |
if (scheme.getType().equals(SchemeType.OUT)) {
|
305 |
if (scheme.getType().equals(SchemeType.OUT)) {
|
| Line 309... |
Line 309... |
| 309 |
.filter(x -> x.getType().equals(ScanType.SALE)).sorted((x1,x2)->x1.getId() - x2.getId()).collect(Collectors.toList()).get(0);
|
309 |
.filter(x -> x.getType().equals(ScanType.SALE)).sorted((x1,x2)->x1.getId() - x2.getId()).collect(Collectors.toList()).get(0);
|
| 310 |
if (outRecord.getCreateTimestamp().isAfter(scheme.getExpireTimestamp())) {
|
310 |
if (outRecord.getCreateTimestamp().isAfter(scheme.getExpireTimestamp())) {
|
| 311 |
InventoryItem ii = inventoryItemRepository.selectById(outRecord.getInventoryItemId());
|
311 |
InventoryItem ii = inventoryItemRepository.selectById(outRecord.getInventoryItemId());
|
| 312 |
FofoOrder fofoOrder;
|
312 |
FofoOrder fofoOrder;
|
| 313 |
if(outRecord.getOrderId()==0) {
|
313 |
if(outRecord.getOrderId()==0) {
|
| - |
|
314 |
LOGGER.info("Order Id found 0 {}", outRecord.getCreateTimestamp());
|
| 314 |
continue;
|
315 |
continue;
|
| 315 |
} else {
|
316 |
} else {
|
| 316 |
fofoOrder = fofoOrderRepository.selectByOrderId(outRecord.getOrderId());
|
317 |
fofoOrder = fofoOrderRepository.selectByOrderId(outRecord.getOrderId());
|
| 317 |
if(fofoOrder==null) {
|
318 |
if(fofoOrder==null) {
|
| 318 |
LOGGER.info("Order id does not exits - {}", outRecord.getOrderId());
|
319 |
LOGGER.info("Order id does not exits - {}", outRecord.getOrderId());
|
| 319 |
continue;
|
320 |
continue;
|
| 320 |
}
|
321 |
}
|
| 321 |
}
|
322 |
}
|
| 322 |
System.out.println(String.format("%d\t%s\t%d\t%d\t%s\t%s\t%f\t%f\t%d\t%s",
|
323 |
System.out.println(String.format("%d\t%s\t%d\t%d\t%s\t%s\t%f\t%f\t%d\t%s\t%s\t%s\t%s",
|
| 323 |
ii.getId(), ii.getSerialNumber(), ii.getItemId(), schemeInOut.getSchemeId(), scheme.getName(), scheme.getType(),
|
324 |
ii.getId(), ii.getSerialNumber(), ii.getItemId(), schemeInOut.getSchemeId(), scheme.getName(), scheme.getType(),
|
| 324 |
scheme.getAmount(), schemeInOut.getAmount(), fofoOrder.getId(), outRecord.getCreateTimestamp()));
|
325 |
scheme.getAmount(), schemeInOut.getAmount(), fofoOrder.getId(), outRecord.getCreateTimestamp(), scheme.getStartDateTime(), scheme.getEndDateTime(), scheme.getExpireTimestamp()));
|
| 325 |
|
326 |
|
| 326 |
}
|
327 |
}
|
| 327 |
|
328 |
|
| 328 |
}
|
329 |
}
|
| 329 |
}
|
330 |
}
|