| Line 35... |
Line 35... |
| 35 |
import com.spice.profitmandi.common.model.SchemeModel;
|
35 |
import com.spice.profitmandi.common.model.SchemeModel;
|
| 36 |
import com.spice.profitmandi.common.services.ReporticoService;
|
36 |
import com.spice.profitmandi.common.services.ReporticoService;
|
| 37 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
37 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 38 |
import com.spice.profitmandi.common.util.StringUtils;
|
38 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 39 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
39 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| - |
|
40 |
import com.spice.profitmandi.dao.entity.catalog.RetailerScheme;
|
| 40 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
41 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 41 |
import com.spice.profitmandi.dao.entity.fofo.ActivatedImei;
|
42 |
import com.spice.profitmandi.dao.entity.fofo.ActivatedImei;
|
| 42 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
43 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 43 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
44 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 44 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
45 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| Line 59... |
Line 60... |
| 59 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
60 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
| 60 |
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
|
61 |
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
|
| 61 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
62 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 62 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
63 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 63 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
64 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 64 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
- |
|
| 65 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
65 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 66 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
66 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| 67 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
67 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
| 68 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
68 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
| 69 |
import com.spice.profitmandi.dao.repository.fofo.SchemeItemRepository;
|
69 |
import com.spice.profitmandi.dao.repository.fofo.SchemeItemRepository;
|
| Line 92... |
Line 92... |
| 92 |
@Autowired
|
92 |
@Autowired
|
| 93 |
private PurchaseService purchaseService;
|
93 |
private PurchaseService purchaseService;
|
| 94 |
|
94 |
|
| 95 |
@Autowired
|
95 |
@Autowired
|
| 96 |
private ScanRecordRepository scanRecordRepository;
|
96 |
private ScanRecordRepository scanRecordRepository;
|
| 97 |
|
- |
|
| 98 |
@Autowired
|
- |
|
| 99 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
- |
|
| 100 |
|
- |
|
| 101 |
|
- |
|
| 102 |
|
97 |
|
| 103 |
@Autowired
|
98 |
@Autowired
|
| 104 |
private SessionFactory sessionFactory;
|
99 |
private SessionFactory sessionFactory;
|
| 105 |
|
100 |
|
| 106 |
private Set<Integer> tagIds = new HashSet<Integer>(Arrays.asList(4));
|
101 |
private Set<Integer> tagIds = new HashSet<Integer>(Arrays.asList(4));
|
| Line 488... |
Line 483... |
| 488 |
purchase.getPurchaseReference(), itemsCount);
|
483 |
purchase.getPurchaseReference(), itemsCount);
|
| 489 |
purchase.setCashback(purchase.getCashback() + totalCashback);
|
484 |
purchase.setCashback(purchase.getCashback() + totalCashback);
|
| 490 |
purchaseRepository.persist(purchase);
|
485 |
purchaseRepository.persist(purchase);
|
| 491 |
}
|
486 |
}
|
| 492 |
}
|
487 |
}
|
| 493 |
|
- |
|
| - |
|
488 |
//Only in and activation margins are allowed to be rolled out more than twice
|
| 494 |
private float createSchemeInOut(Scheme scheme, InventoryItem inventoryItem) {
|
489 |
private float createSchemeInOut(Scheme scheme, InventoryItem inventoryItem) {
|
| 495 |
LOGGER.info("Scheme === {}", scheme);
|
490 |
LOGGER.info("Scheme === {}", scheme);
|
| 496 |
List<SchemeInOut> sios = schemeInOutRepository.selectAllByType(scheme.getType(), inventoryItem.getId());
|
491 |
List<SchemeInOut> sios = schemeInOutRepository.selectAllByType(scheme.getType(), inventoryItem.getId());
|
| 497 |
float actualCredit = 0;
|
492 |
float actualCredit = 0;
|
| 498 |
if (sios.stream().filter(x -> x.getRolledBackTimestamp() == null && x.getSchemeId() == scheme.getId())
|
493 |
if (sios.stream().filter(x -> x.getRolledBackTimestamp() == null && x.getSchemeId() == scheme.getId())
|
| Line 501... |
Line 496... |
| 501 |
//Rejected Scheme for types INVESTMENT and ACTIVATION are considered rolledback only if the item billing is cancelled.
|
496 |
//Rejected Scheme for types INVESTMENT and ACTIVATION are considered rolledback only if the item billing is cancelled.
|
| 502 |
float amountCredited = (float) sios.stream().mapToDouble(e -> e.getAmount()).sum();
|
497 |
float amountCredited = (float) sios.stream().mapToDouble(e -> e.getAmount()).sum();
|
| 503 |
|
498 |
|
| 504 |
LOGGER.info("SIOS ===== {}", sios);
|
499 |
LOGGER.info("SIOS ===== {}", sios);
|
| 505 |
float amountToCredit = this.getAmount(inventoryItem, scheme);
|
500 |
float amountToCredit = this.getAmount(inventoryItem, scheme);
|
| 506 |
|
501 |
//Activation and in scheme
|
| 507 |
if (!scheme.getType().equals(SchemeType.IN) && sios.size() > 0) {
|
502 |
if (!scheme.getType().equals(SchemeType.IN) && !scheme.getType().equals(SchemeType.ACTIVATION) && sios.size() > 0) {
|
| 508 |
|
503 |
|
| 509 |
if(sios.size() > 1) {
|
504 |
if(sios.size() > 1) {
|
| 510 |
LOGGER.info("SAMESCHEMETYPE has already been credited twice for inventoryItem - {}", inventoryItem.getId());
|
505 |
LOGGER.info("SAMESCHEMETYPE has already been credited twice for inventoryItem - {}", inventoryItem.getId());
|
| 511 |
return 0;
|
506 |
return 0;
|
| 512 |
}
|
507 |
}
|
| Line 795... |
Line 790... |
| 795 |
}
|
790 |
}
|
| 796 |
}
|
791 |
}
|
| 797 |
}
|
792 |
}
|
| 798 |
|
793 |
|
| 799 |
@Override
|
794 |
@Override
|
| 800 |
// Always being called from cancel order means no SCHEME IN is considered
|
795 |
// Always being called from cancel order/bad return means no SCHEME IN is considered
|
| 801 |
public void reverseSchemes(List<InventoryItem> inventoryItems, int reversalReference, String reversalReason,
|
796 |
public void reverseSchemes(List<InventoryItem> inventoryItems, int reversalReference, String reversalReason,
|
| 802 |
List<SchemeType> schemeTypes) throws ProfitMandiBusinessException {
|
797 |
List<SchemeType> schemeTypes) throws ProfitMandiBusinessException {
|
| 803 |
Map<Integer, InventoryItem> inventoryItemsMap = inventoryItems.stream()
|
798 |
Map<Integer, InventoryItem> inventoryItemsMap = inventoryItems.stream()
|
| 804 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
799 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 805 |
LOGGER.info("inventoryItems" + inventoryItems);
|
800 |
LOGGER.info("inventoryItems" + inventoryItems);
|