| Line 8... |
Line 8... |
| 8 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
8 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| 9 |
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
|
9 |
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
|
| 10 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
10 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 11 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
11 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 12 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
12 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
| - |
|
13 |
import com.spice.profitmandi.dao.repository.transaction.TransactionRepository;
|
| 13 |
import com.spice.profitmandi.service.user.RetailerService;
|
14 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 14 |
import com.spice.profitmandi.service.wallet.WalletService;
|
15 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 15 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
16 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
| 16 |
import org.apache.logging.log4j.LogManager;
|
17 |
import org.apache.logging.log4j.LogManager;
|
| 17 |
import org.apache.logging.log4j.Logger;
|
18 |
import org.apache.logging.log4j.Logger;
|
| Line 41... |
Line 42... |
| 41 |
@Autowired
|
42 |
@Autowired
|
| 42 |
InventoryItemRepository inventoryItemRepository;
|
43 |
InventoryItemRepository inventoryItemRepository;
|
| 43 |
|
44 |
|
| 44 |
@Autowired
|
45 |
@Autowired
|
| 45 |
PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
46 |
PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| - |
|
47 |
|
| - |
|
48 |
|
| - |
|
49 |
@Autowired
|
| - |
|
50 |
TransactionRepository transactionRepository;
|
| 46 |
|
51 |
|
| 47 |
@Autowired
|
52 |
@Autowired
|
| 48 |
WalletService walletService;
|
53 |
WalletService walletService;
|
| 49 |
|
54 |
|
| 50 |
public void payMonthlyInvestment() throws ProfitMandiBusinessException {
|
55 |
public void payMonthlyInvestment() throws ProfitMandiBusinessException {
|
| 51 |
LocalDate firstDateOfCurrentMonth = LocalDateTime.now().withDayOfMonth(1).toLocalDate();
|
56 |
LocalDate firstDateOfCurrentMonth = LocalDateTime.now().withDayOfMonth(1).toLocalDate();
|
| Line 72... |
Line 77... |
| 72 |
: investmentMaintainedDaysMap.get(fofoId);
|
77 |
: investmentMaintainedDaysMap.get(fofoId);
|
| 73 |
|
78 |
|
| 74 |
List<SchemeInOut> schemeInouts = retailerEntry.getValue().stream().map(x -> inventoryItemIdSchemeMap.get(x))
|
79 |
List<SchemeInOut> schemeInouts = retailerEntry.getValue().stream().map(x -> inventoryItemIdSchemeMap.get(x))
|
| 75 |
.flatMap(List::stream).filter(x -> x.getRolledBackTimestamp() == null).collect(Collectors.toList());
|
80 |
.flatMap(List::stream).filter(x -> x.getRolledBackTimestamp() == null).collect(Collectors.toList());
|
| 76 |
float totalAmount = 0;
|
81 |
float totalAmount = 0;
|
| - |
|
82 |
LocalDateTime firstBillingDate = transactionRepository.getFirstBillingDate(fofoId);
|
| - |
|
83 |
boolean sameYearMonth = firstBillingDate.getMonth() == startOfPreviousMonth.getMonth() && firstBillingDate.getYear() == startOfPreviousMonth.getYear();
|
| 77 |
for(SchemeInOut sio : schemeInouts) {
|
84 |
for (SchemeInOut sio : schemeInouts) {
|
| 78 |
|
- |
|
| 79 |
if (investmentMaintainedDays < 8) {
|
85 |
if (sameYearMonth) {
|
| 80 |
sio.setStatus(SchemePayoutStatus.REJECTED);
|
- |
|
| 81 |
//sio.setRolledBackTimestamp(LocalDateTime.now());
|
- |
|
| 82 |
sio.setStatusDescription("Investment maintained for " + investmentMaintainedDays + "(< 8) days");
|
86 |
sio.setStatusDescription("Investment payout fully disbursed for first month");
|
| 83 |
} else if (investmentMaintainedDays < 12) {
|
- |
|
| 84 |
sio.setStatus(SchemePayoutStatus.CREDITED);
|
87 |
sio.setStatus(SchemePayoutStatus.CREDITED);
|
| 85 |
sio.setAmount(sio.getAmount()/2);
|
- |
|
| 86 |
sio.setCreditTimestamp(LocalDateTime.now());
|
88 |
sio.setCreditTimestamp(LocalDateTime.now());
|
| 87 |
sio.setStatusDescription("Investment maintained for " + investmentMaintainedDays + "(< 12) days");
|
- |
|
| 88 |
totalAmount += sio.getAmount();
|
89 |
totalAmount += sio.getAmount();
|
| 89 |
} else {
|
90 |
} else {
|
| - |
|
91 |
if (investmentMaintainedDays < 8) {
|
| - |
|
92 |
sio.setStatus(SchemePayoutStatus.REJECTED);
|
| - |
|
93 |
//sio.setRolledBackTimestamp(LocalDateTime.now());
|
| - |
|
94 |
sio.setStatusDescription("Investment maintained for " + investmentMaintainedDays + "(< 8) days");
|
| - |
|
95 |
} else if (investmentMaintainedDays < 12) {
|
| 90 |
sio.setStatus(SchemePayoutStatus.CREDITED);
|
96 |
sio.setStatus(SchemePayoutStatus.CREDITED);
|
| - |
|
97 |
sio.setAmount(sio.getAmount() / 2);
|
| - |
|
98 |
sio.setCreditTimestamp(LocalDateTime.now());
|
| - |
|
99 |
sio.setStatusDescription("Investment maintained for " + investmentMaintainedDays + "(< 12) days");
|
| - |
|
100 |
totalAmount += sio.getAmount();
|
| - |
|
101 |
} else {
|
| - |
|
102 |
sio.setStatus(SchemePayoutStatus.CREDITED);
|
| 91 |
sio.setCreditTimestamp(LocalDateTime.now());
|
103 |
sio.setCreditTimestamp(LocalDateTime.now());
|
| 92 |
totalAmount += sio.getAmount();
|
104 |
totalAmount += sio.getAmount();
|
| - |
|
105 |
}
|
| 93 |
}
|
106 |
}
|
| 94 |
}
|
107 |
}
|
| 95 |
if(totalAmount > 0) {
|
108 |
if (totalAmount > 0) {
|
| 96 |
String description = "Investment margin paid for " + FormattingUtils.formatYearMonth(startOfPreviousMonth.atStartOfDay());
|
109 |
String description = "Investment margin paid for " + FormattingUtils.formatYearMonth(startOfPreviousMonth.atStartOfDay());
|
| 97 |
if(investmentMaintainedDays < 12) {
|
110 |
if (investmentMaintainedDays < 12) {
|
| 98 |
description += ", as maintained for " + investmentMaintainedDays + "(< 12) days";
|
111 |
description += ", as maintained for " + investmentMaintainedDays + "(< 12) days";
|
| 99 |
}
|
112 |
}
|
| 100 |
walletService.addAmountToWallet(fofoId,referenceId, WalletReferenceType.INVESTMENT_PAYOUT, description, totalAmount, lastOfPreviousMonth.atTime(LocalTime.MAX));
|
113 |
walletService.addAmountToWallet(fofoId, referenceId, WalletReferenceType.INVESTMENT_PAYOUT, description, totalAmount, lastOfPreviousMonth.atTime(LocalTime.MAX));
|
| 101 |
}
|
114 |
}
|
| 102 |
System.out.printf("%d\t%d\t%f%n", fofoId, investmentMaintainedDays, totalAmount);
|
115 |
System.out.printf("%d\t%d\t%f%n", fofoId, investmentMaintainedDays, totalAmount);
|
| 103 |
}
|
116 |
}
|
| 104 |
}
|
117 |
}
|
| 105 |
|
118 |
|