| Line 774... |
Line 774... |
| 774 |
List<SchemeType> schemeTypes) throws ProfitMandiBusinessException {
|
774 |
List<SchemeType> schemeTypes) throws ProfitMandiBusinessException {
|
| 775 |
Map<Integer, InventoryItem> inventoryItemsMap = inventoryItems.stream()
|
775 |
Map<Integer, InventoryItem> inventoryItemsMap = inventoryItems.stream()
|
| 776 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
776 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 777 |
LOGGER.info("inventoryItems" + inventoryItems);
|
777 |
LOGGER.info("inventoryItems" + inventoryItems);
|
| 778 |
|
778 |
|
| - |
|
779 |
Map<SchemeType, SchemeInOut> schemeTypeMap = new HashMap<>();
|
| - |
|
780 |
|
| 779 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByInventoryItemIds(inventoryItemsMap.keySet());
|
781 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByInventoryItemIds(inventoryItemsMap.keySet());
|
| 780 |
LOGGER.info("schemeInOuts" + schemeInOuts);
|
782 |
LOGGER.info("schemeInOuts" + schemeInOuts);
|
| 781 |
float amountToRollback = 0;
|
783 |
float amountToRollback = 0;
|
| 782 |
|
784 |
|
| 783 |
if (!schemeInOuts.isEmpty()) {
|
785 |
if (!schemeInOuts.isEmpty()) {
|
| Line 787... |
Line 789... |
| 787 |
Map<Integer, Scheme> schemesMap = schemeRepository.selectBySchemeIds(schemeIds, 0, schemeIds.size())
|
789 |
Map<Integer, Scheme> schemesMap = schemeRepository.selectBySchemeIds(schemeIds, 0, schemeIds.size())
|
| 788 |
.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
790 |
.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 789 |
for (SchemeInOut schemeInOut : schemeInOuts) {
|
791 |
for (SchemeInOut schemeInOut : schemeInOuts) {
|
| 790 |
Scheme scheme = schemesMap.get(schemeInOut.getSchemeId());
|
792 |
Scheme scheme = schemesMap.get(schemeInOut.getSchemeId());
|
| 791 |
if (schemeTypes.contains(scheme.getType())) {
|
793 |
if (schemeTypes.contains(scheme.getType())) {
|
| - |
|
794 |
schemeTypeMap.put(scheme.getType(), schemeInOut);
|
| 792 |
if (schemeInOut.getRolledBackTimestamp() == null) {
|
795 |
if (schemeInOut.getRolledBackTimestamp() == null) {
|
| 793 |
schemeInOut.setRolledBackTimestamp(LocalDateTime.now());
|
796 |
schemeInOut.setRolledBackTimestamp(LocalDateTime.now());
|
| 794 |
if (schemeInOut.getStatus().equals(SchemePayoutStatus.CREDITED)) {
|
797 |
if (schemeInOut.getStatus().equals(SchemePayoutStatus.CREDITED)) {
|
| 795 |
amountToRollback += schemeInOut.getAmount();
|
798 |
amountToRollback += schemeInOut.getAmount();
|
| 796 |
}
|
799 |
}
|
| Line 808... |
Line 811... |
| 808 |
: WalletReferenceType.INVESTMENT_PAYOUT);
|
811 |
: WalletReferenceType.INVESTMENT_PAYOUT);
|
| 809 |
if (amountToRollback > 0) {
|
812 |
if (amountToRollback > 0) {
|
| 810 |
// Mark appropriate reference of rollback investment margin
|
813 |
// Mark appropriate reference of rollback investment margin
|
| 811 |
if (schemeTypes.contains(SchemeType.INVESTMENT)) {
|
814 |
if (schemeTypes.contains(SchemeType.INVESTMENT)) {
|
| 812 |
reversalReference = Integer
|
815 |
reversalReference = Integer
|
| 813 |
.parseInt(FormattingUtils.getYearMonth(schemeInOuts.get(0).getCreditTimestamp().minusMonths(1)));
|
816 |
.parseInt(FormattingUtils.getYearMonth(schemeTypeMap.get(SchemeType.INVESTMENT).getCreditTimestamp().minusMonths(1)));
|
| 814 |
}
|
817 |
}
|
| 815 |
walletService.rollbackAmountFromWallet(fofoId, amountToRollback, reversalReference, walletReferenceType,
|
818 |
walletService.rollbackAmountFromWallet(fofoId, amountToRollback, reversalReference, walletReferenceType,
|
| 816 |
reversalReason, LocalDateTime.now());
|
819 |
reversalReason, LocalDateTime.now());
|
| 817 |
}
|
820 |
}
|
| 818 |
}
|
821 |
}
|