| Line 308... |
Line 308... |
| 308 |
this.processPreviousSales(scheme);
|
308 |
this.processPreviousSales(scheme);
|
| 309 |
}
|
309 |
}
|
| 310 |
}
|
310 |
}
|
| 311 |
|
311 |
|
| 312 |
private void processPreviousPurchases(Scheme scheme) throws ProfitMandiBusinessException{
|
312 |
private void processPreviousPurchases(Scheme scheme) throws ProfitMandiBusinessException{
|
| 313 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectBetweenDates(scheme.getStartDateTime(), LocalDateTime.now());
|
313 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectBetweenDates(scheme.getStartDateTime(), scheme.getEndDateTime());
|
| 314 |
if(inventoryItems.isEmpty()) {
|
314 |
if(inventoryItems.isEmpty()) {
|
| 315 |
return;
|
315 |
return;
|
| 316 |
}
|
316 |
}
|
| 317 |
List<Integer> itemIds = schemeItemRepository.selectItemIdsBySchemeId(scheme.getId());
|
317 |
List<Integer> itemIds = schemeItemRepository.selectItemIdsBySchemeId(scheme.getId());
|
| 318 |
if(itemIds.isEmpty()) {
|
318 |
if(itemIds.isEmpty()) {
|
| Line 353... |
Line 353... |
| 353 |
}
|
353 |
}
|
| 354 |
return inventoryItemIdFofoOrderIdMap;
|
354 |
return inventoryItemIdFofoOrderIdMap;
|
| 355 |
}
|
355 |
}
|
| 356 |
|
356 |
|
| 357 |
private void processPreviousSales(Scheme scheme) throws ProfitMandiBusinessException{
|
357 |
private void processPreviousSales(Scheme scheme) throws ProfitMandiBusinessException{
|
| 358 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectBetweenDates(scheme.getStartDateTime(), LocalDateTime.now());
|
358 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectBetweenDates(scheme.getStartDateTime(), scheme.getEndDateTime());
|
| 359 |
|
359 |
|
| 360 |
if(fofoOrderItems.isEmpty()){
|
360 |
if(fofoOrderItems.isEmpty()){
|
| 361 |
return;
|
361 |
return;
|
| 362 |
}
|
362 |
}
|
| 363 |
|
363 |
|
| Line 538... |
Line 538... |
| 538 |
LOGGER.info("Trying to process SchemeIn with purchaseId [{}] and retailerId [{}]", purchaseId, retailerId);
|
538 |
LOGGER.info("Trying to process SchemeIn with purchaseId [{}] and retailerId [{}]", purchaseId, retailerId);
|
| 539 |
Purchase purchase = purchaseRepository.selectByIdAndFofoId(purchaseId, retailerId);
|
539 |
Purchase purchase = purchaseRepository.selectByIdAndFofoId(purchaseId, retailerId);
|
| 540 |
LOGGER.info("purchase is completed = {}", (purchase.getCompleteTimestamp() != null));
|
540 |
LOGGER.info("purchase is completed = {}", (purchase.getCompleteTimestamp() != null));
|
| 541 |
if(purchase.getCompleteTimestamp() != null) {
|
541 |
if(purchase.getCompleteTimestamp() != null) {
|
| 542 |
List<Order> orders = orderRepository.selectByAirwayBillOrInvoiceNumber(purchase.getPurchaseReference(), retailerId);
|
542 |
List<Order> orders = orderRepository.selectByAirwayBillOrInvoiceNumber(purchase.getPurchaseReference(), retailerId);
|
| 543 |
LocalDateTime billingTimestamp = LocalDateTime.now();
|
543 |
LocalDateTime billingTimestamp = purchase.getCreateTimestamp();
|
| 544 |
if(!orders.isEmpty()){
|
544 |
if(!orders.isEmpty()){
|
| 545 |
billingTimestamp = orders.get(0).getBillingTimestamp();
|
545 |
billingTimestamp = orders.get(0).getBillingTimestamp();
|
| 546 |
}
|
546 |
}
|
| 547 |
List<Scheme> schemes = schemeRepository.selectActiveAll(SchemeType.IN, billingTimestamp);
|
547 |
List<Scheme> schemes = schemeRepository.selectActiveAll(SchemeType.IN, billingTimestamp);
|
| 548 |
float totalCashback = 0;
|
548 |
float totalCashback = 0;
|