| Line 179... |
Line 179... |
| 179 |
|
179 |
|
| 180 |
|
180 |
|
| 181 |
@PostMapping(value = "/wallet/upload")
|
181 |
@PostMapping(value = "/wallet/upload")
|
| 182 |
public String uploadWalletBulk(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model) throws Exception {
|
182 |
public String uploadWalletBulk(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model) throws Exception {
|
| 183 |
List<WalletHistoryModel> walletHistoryModelList = ExcelUtils.parseWalletBulkCredit(file.getInputStream());
|
183 |
List<WalletHistoryModel> walletHistoryModelList = ExcelUtils.parseWalletBulkCredit(file.getInputStream());
|
| - |
|
184 |
// Scheme/CN-backed reference types (CN_WALLET_REFERENCES) must flow through the scheme/offer code
|
| - |
|
185 |
// paths that also reject the offer_payout / scheme_in_out, so the month-end MARGINS credit note
|
| - |
|
186 |
// reverses with them. Posting one manually from this sheet leaves the payout un-rejected -> the CN
|
| - |
|
187 |
// is over-issued and the account-statement scheme-adjustment line breaks (see the Jul-2026 re-tag
|
| - |
|
188 |
// fix). Reject the whole sheet up-front (this endpoint is not transactional, so validate before any
|
| - |
|
189 |
// row posts); manual scheme recoveries must be posted as OTHERS.
|
| - |
|
190 |
List<WalletHistoryModel> blockedRows = walletHistoryModelList.stream()
|
| - |
|
191 |
.filter(x -> WalletService.CN_WALLET_REFERENCES.contains(x.getWalletReferenceType()))
|
| - |
|
192 |
.collect(Collectors.toList());
|
| - |
|
193 |
if (!blockedRows.isEmpty()) {
|
| - |
|
194 |
String offending = blockedRows.stream()
|
| - |
|
195 |
.map(x -> "fofoId " + x.getFofoId() + " => " + x.getWalletReferenceType())
|
| - |
|
196 |
.collect(Collectors.joining(", "));
|
| - |
|
197 |
throw new ProfitMandiBusinessException("Wallet", "Wallet",
|
| - |
|
198 |
"Scheme/CN-backed reference types cannot be posted from the wallet bulk sheet - they must go "
|
| - |
|
199 |
+ "through the scheme/offer flow so the credit note reverses. Post manual scheme recoveries as OTHERS. "
|
| - |
|
200 |
+ "Offending rows: " + offending);
|
| - |
|
201 |
}
|
| 184 |
for (WalletHistoryModel walletHistoryModel : walletHistoryModelList) {
|
202 |
for (WalletHistoryModel walletHistoryModel : walletHistoryModelList) {
|
| 185 |
if (walletHistoryModel.getReference() == 0) {
|
203 |
if (walletHistoryModel.getReference() == 0) {
|
| 186 |
ManualPaymentType paymentType = manualPaymentRequestRepository.selectByReferenceType(walletHistoryModel.getWalletReferenceType());
|
204 |
ManualPaymentType paymentType = manualPaymentRequestRepository.selectByReferenceType(walletHistoryModel.getWalletReferenceType());
|
| 187 |
if (paymentType == null) {
|
205 |
if (paymentType == null) {
|
| 188 |
paymentType = new ManualPaymentType();
|
206 |
paymentType = new ManualPaymentType();
|