| Line 528... |
Line 528... |
| 528 |
partnerType, new ArrayList<>(catalogInventoryItemMap.keySet()), billingDate);
|
528 |
partnerType, new ArrayList<>(catalogInventoryItemMap.keySet()), billingDate);
|
| 529 |
|
529 |
|
| 530 |
|
530 |
|
| 531 |
int itemsCount = 0;
|
531 |
int itemsCount = 0;
|
| 532 |
float totalCashback = 0;
|
532 |
float totalCashback = 0;
|
| - |
|
533 |
//LOGGER.info("catalogSchemeSummaryMap - {}", catalogSchemeSummaryMap);
|
| 533 |
for (Map.Entry<CatalogSummaryModel, List<SchemeSummaryModel>> catalogSummaryModelListEntry : catalogSchemeSummaryMap.entrySet()) {
|
534 |
for (Map.Entry<CatalogSummaryModel, List<SchemeSummaryModel>> catalogSummaryModelListEntry : catalogSchemeSummaryMap.entrySet()) {
|
| 534 |
CatalogSummaryModel catalogSummaryModel = catalogSummaryModelListEntry.getKey();
|
535 |
CatalogSummaryModel catalogSummaryModel = catalogSummaryModelListEntry.getKey();
|
| 535 |
List<SchemeSummaryModel> schemeSummaryModels = catalogSummaryModelListEntry.getValue().stream().filter(Objects::nonNull).collect(Collectors.toList());
|
536 |
List<SchemeSummaryModel> schemeSummaryModels = catalogSummaryModelListEntry.getValue().stream().filter(Objects::nonNull).collect(Collectors.toList());
|
| 536 |
schemeSummaryModels.stream().filter(x -> x != null && x.getSchemeType().getTransactionType().equals(StockTransactionType.IN)).forEach(x -> x.setProcess(true));
|
537 |
schemeSummaryModels.stream().filter(x -> x != null && x.getSchemeType().getTransactionType().equals(StockTransactionType.IN)).forEach(x -> x.setProcess(true));
|
| 537 |
if (schemeSummaryModels.stream().filter(x -> x.isProcess()).count() == 0) continue;
|
538 |
if (schemeSummaryModels.stream().filter(x -> x.isProcess()).count() == 0) continue;
|
| Line 599... |
Line 600... |
| 599 |
private float createSchemeInOut(List<SchemeSummaryModel> schemeSummaryModels, InventoryItem inventoryItem) throws ProfitMandiBusinessException {
|
600 |
private float createSchemeInOut(List<SchemeSummaryModel> schemeSummaryModels, InventoryItem inventoryItem) throws ProfitMandiBusinessException {
|
| 600 |
LOGGER.info("schemeSummaryModels - {}", schemeSummaryModels);
|
601 |
LOGGER.info("schemeSummaryModels - {}", schemeSummaryModels);
|
| 601 |
InventoryPayoutModel inventoryPayoutModel = priceCircularService.getPayouts(inventoryItem);
|
602 |
InventoryPayoutModel inventoryPayoutModel = priceCircularService.getPayouts(inventoryItem);
|
| 602 |
//Get all schemes
|
603 |
//Get all schemes
|
| 603 |
List<SchemeSummaryModel> inventoryPayoutModelToProcess = schemeSummaryModels.stream().filter(x -> x.isProcess()).collect(Collectors.toList());
|
604 |
List<SchemeSummaryModel> inventoryPayoutModelToProcess = schemeSummaryModels.stream().filter(x -> x.isProcess()).collect(Collectors.toList());
|
| 604 |
|
- |
|
| - |
|
605 |
LOGGER.info("inventoryPayoutModel - {}", inventoryPayoutModel);
|
| 605 |
List<SchemeInOut> paidSios = inventoryPayoutModel.getPaidSios();
|
606 |
List<SchemeInOut> paidSios = inventoryPayoutModel.getPaidSios();
|
| 606 |
List<SchemeInOut> pendingSios = inventoryPayoutModel.getPendingSios();
|
607 |
List<SchemeInOut> pendingSios = inventoryPayoutModel.getPendingSios();
|
| 607 |
Map<SchemeType, List<SchemeInOut>> paidSchemeTypesMap = inventoryPayoutModel.getPaidSios().stream().collect(Collectors.groupingBy(x -> x.getScheme().getType()));
|
608 |
Map<SchemeType, List<SchemeInOut>> paidSchemeTypesMap = inventoryPayoutModel.getPaidSios().stream().collect(Collectors.groupingBy(x -> x.getScheme().getType()));
|
| 608 |
Map<Integer, SchemeInOut> paidSchemesMap = paidSios.stream().collect(Collectors.toMap(x -> x.getSchemeId(), x -> x));
|
609 |
Map<Integer, SchemeInOut> paidSchemesMap = paidSios.stream().collect(Collectors.toMap(x -> x.getSchemeId(), x -> x));
|
| 609 |
Map<Integer, SchemeInOut> pendingSchemesMap = pendingSios.stream().collect(Collectors.toMap(x -> x.getSchemeId(), x -> x));
|
610 |
Map<Integer, SchemeInOut> pendingSchemesMap = pendingSios.stream().collect(Collectors.toMap(x -> x.getSchemeId(), x -> x));
|
| Line 804... |
Line 805... |
| 804 |
schemeSummaryModels.stream().filter(x -> x.getSchemeType().getTransactionType().equals(StockTransactionType.OUT)).forEach(x -> x.setProcess(true));
|
805 |
schemeSummaryModels.stream().filter(x -> x.getSchemeType().getTransactionType().equals(StockTransactionType.OUT)).forEach(x -> x.setProcess(true));
|
| 805 |
if (schemeSummaryModels.stream().filter(x -> x.isProcess()).count() == 0) continue;
|
806 |
if (schemeSummaryModels.stream().filter(x -> x.isProcess()).count() == 0) continue;
|
| 806 |
|
807 |
|
| 807 |
List<InventoryItem> modelInventoryItems = catalogInventoryItemMap.get(catalogSummaryModel.getCatalogId());
|
808 |
List<InventoryItem> modelInventoryItems = catalogInventoryItemMap.get(catalogSummaryModel.getCatalogId());
|
| 808 |
for (InventoryItem inventoryItem : modelInventoryItems) {
|
809 |
for (InventoryItem inventoryItem : modelInventoryItems) {
|
| - |
|
810 |
Map<Integer, SchemeSummaryModel> schemeSummaryModelMap = schemeSummaryModels.stream().collect(Collectors.toMap(x -> x.getSchemeId(), x -> x));
|
| - |
|
811 |
List<SchemeInOut> siosToReject = schemeInOutRepository.selectAll(inventoryItem.getId())
|
| - |
|
812 |
.stream().filter(x -> x.getStatus().equals(SchemePayoutStatus.CREDITED))
|
| - |
|
813 |
.filter(x -> !schemeSummaryModelMap.containsKey(x.getSchemeId())).collect(Collectors.toList());
|
| - |
|
814 |
|
| - |
|
815 |
//Reject invalid scheme payouts due to upgrade in Category or any change in schemes historically
|
| - |
|
816 |
for (SchemeInOut sioToReject : siosToReject) {
|
| - |
|
817 |
sioToReject.setStatusDescription("Rolledback due to Category upgrade/invalid scheme");
|
| - |
|
818 |
sioToReject.setStatus(SchemePayoutStatus.REJECTED);
|
| - |
|
819 |
sioToReject.setRolledBackTimestamp(LocalDateTime.now());
|
| - |
|
820 |
totalCashback -= sioToReject.getAmount();
|
| - |
|
821 |
}
|
| 809 |
float inventoryItemCashback = this.createSchemeInOut(schemeSummaryModels, inventoryItem);
|
822 |
float inventoryItemCashback = this.createSchemeInOut(schemeSummaryModels, inventoryItem);
|
| 810 |
if (inventoryItemCashback > 0) {
|
823 |
if (inventoryItemCashback > 0) {
|
| 811 |
count++;
|
824 |
count++;
|
| 812 |
totalCashback += inventoryItemCashback;
|
825 |
totalCashback += inventoryItemCashback;
|
| 813 |
}
|
826 |
}
|
| Line 1130... |
Line 1143... |
| 1130 |
int retailerId = purchaseIdInventoryItemEntry.getValue().get(0).getFofoId();
|
1143 |
int retailerId = purchaseIdInventoryItemEntry.getValue().get(0).getFofoId();
|
| 1131 |
this.processSchemeIn(purchaseIdInventoryItemEntry.getKey(), retailerId);
|
1144 |
this.processSchemeIn(purchaseIdInventoryItemEntry.getKey(), retailerId);
|
| 1132 |
}
|
1145 |
}
|
| 1133 |
}
|
1146 |
}
|
| 1134 |
|
1147 |
|
| - |
|
1148 |
/*@Override
|
| - |
|
1149 |
public void processFullCD(String invoiceNumber) throws ProfitMandiBusinessException {
|
| - |
|
1150 |
Purchase purchase = purchaseRepository.selectByPurchaseReference(invoiceNumber);
|
| - |
|
1151 |
this.processSchemeIn(purchase.getId(), purchase.getFofoId(), SchemeType.CDS);
|
| - |
|
1152 |
}
|
| - |
|
1153 |
|
| - |
|
1154 |
@Override
|
| - |
|
1155 |
public void processPartialCD(String invoiceNumber) throws ProfitMandiBusinessException {
|
| - |
|
1156 |
Purchase purchase = purchaseRepository.selectByPurchaseReference(invoiceNumber);
|
| - |
|
1157 |
this.processSchemeIn(purchase.getId(), purchase.getFofoId(), Arrays.asList(SchemeType.CASH_DISCOUNT));
|
| - |
|
1158 |
}
|
| - |
|
1159 |
|
| - |
|
1160 |
@Override
|
| - |
|
1161 |
public void processNoCD(String invoiceNumber) throws ProfitMandiBusinessException {
|
| - |
|
1162 |
Purchase purchase = purchaseRepository.selectByPurchaseReference(invoiceNumber);
|
| - |
|
1163 |
this.processSchemeIn(purchase.getId(), purchase.getFofoId(), Arrays.asList());
|
| - |
|
1164 |
}*/
|
| - |
|
1165 |
|
| 1135 |
@Autowired
|
1166 |
@Autowired
|
| 1136 |
FofoStoreRepository fofoStoreRepository;
|
1167 |
FofoStoreRepository fofoStoreRepository;
|
| 1137 |
|
1168 |
|
| 1138 |
|
1169 |
|
| 1139 |
@Override
|
1170 |
@Override
|