| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.dao.service;
|
1 |
package com.spice.profitmandi.dao.service;
|
| 2 |
|
2 |
|
| - |
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 3 |
import com.spice.profitmandi.common.util.Utils;
|
4 |
import com.spice.profitmandi.common.util.Utils;
|
| 4 |
import com.spice.profitmandi.dao.entity.transaction.FofoSidbiSanction;
|
5 |
import com.spice.profitmandi.dao.entity.transaction.FofoSidbiSanction;
|
| 5 |
import com.spice.profitmandi.dao.repository.dtr.CreditAccountRepository;
|
6 |
import com.spice.profitmandi.dao.repository.dtr.CreditAccountRepository;
|
| 6 |
import com.spice.profitmandi.dao.repository.transaction.FofoSidbiSanctionRepository;
|
7 |
import com.spice.profitmandi.dao.repository.transaction.FofoSidbiSanctionRepository;
|
| - |
|
8 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| - |
|
9 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
| 7 |
import org.apache.logging.log4j.LogManager;
|
10 |
import org.apache.logging.log4j.LogManager;
|
| 8 |
import org.springframework.beans.factory.annotation.Autowired;
|
11 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 9 |
import org.springframework.stereotype.Component;
|
12 |
import org.springframework.stereotype.Component;
|
| 10 |
|
13 |
|
| 11 |
import java.math.BigDecimal;
|
14 |
import java.math.BigDecimal;
|
| Line 112... |
Line 115... |
| 112 |
fofoSidbiSanction.setLoanAmount(this.getActualLoan(receivedAmount));
|
115 |
fofoSidbiSanction.setLoanAmount(this.getActualLoan(receivedAmount));
|
| 113 |
fofoSidbiSanction.setAdvanceInterestAmount(this.getAdvancePaid(fofoSidbiSanction));
|
116 |
fofoSidbiSanction.setAdvanceInterestAmount(this.getAdvancePaid(fofoSidbiSanction));
|
| 114 |
fofoSidbiSanctionRepository.persist(fofoSidbiSanction);
|
117 |
fofoSidbiSanctionRepository.persist(fofoSidbiSanction);
|
| 115 |
}
|
118 |
}
|
| 116 |
|
119 |
|
| 117 |
public void migrateSanctions() {
|
120 |
public void migrateSanctions() throws ProfitMandiBusinessException {
|
| 118 |
List<FofoSidbiSanction> fofoSidbiSanctions = fofoSidbiSanctionRepository.selectAll(Optional.empty());
|
121 |
List<FofoSidbiSanction> fofoSidbiSanctions = fofoSidbiSanctionRepository.selectAll(Optional.empty());
|
| 119 |
for (FofoSidbiSanction fofoSidbiSanction : fofoSidbiSanctions) {
|
122 |
for (FofoSidbiSanction fofoSidbiSanction : fofoSidbiSanctions) {
|
| 120 |
fofoSidbiSanction.setLoanAmount(this.getActualLoan(fofoSidbiSanction.getSanctionAmount()));
|
123 |
fofoSidbiSanction.setLoanAmount(this.getActualLoan(fofoSidbiSanction.getSanctionAmount()));
|
| 121 |
fofoSidbiSanction.setAdvanceInterestAmount(this.getAdvancePaid(fofoSidbiSanction));
|
124 |
fofoSidbiSanction.setAdvanceInterestAmount(this.getAdvancePaid(fofoSidbiSanction));
|
| 122 |
fofoSidbiSanction.setIssuedOn(fofoSidbiSanction.getCreatedOn().plusDays(2));
|
125 |
if (!Arrays.asList(175139259, 175139638).contains(fofoSidbiSanction.getFofoId())) {
|
| - |
|
126 |
issueLimit(fofoSidbiSanction);
|
| - |
|
127 |
}
|
| 123 |
}
|
128 |
}
|
| 124 |
}
|
129 |
}
|
| - |
|
130 |
|
| - |
|
131 |
@Autowired
|
| - |
|
132 |
WalletService walletService;
|
| - |
|
133 |
|
| - |
|
134 |
public void issueLimit(FofoSidbiSanction fofoSidbiSanction) throws ProfitMandiBusinessException {
|
| - |
|
135 |
if (fofoSidbiSanction.getIssuedOn() != null) {
|
| - |
|
136 |
throw new ProfitMandiBusinessException("Sidbi Sanction Issue",
|
| - |
|
137 |
"Party - " + fofoSidbiSanction.getFofoId() + " - " + fofoSidbiSanction.getLoanAmount(), "");
|
| - |
|
138 |
}
|
| - |
|
139 |
fofoSidbiSanction.setIssuedOn(fofoSidbiSanction.getCreatedOn().plusDays(2));
|
| - |
|
140 |
double deductions = this.getProcessingDeductions(fofoSidbiSanction);
|
| - |
|
141 |
walletService.consumeAmountFromWallet(fofoSidbiSanction.getFofoId(), fofoSidbiSanction.getId(), WalletReferenceType.ADVANCE_SECURITY, "Deducted to fund advance", (float)deductions, fofoSidbiSanction.getCreatedOn(), true);
|
| - |
|
142 |
}
|
| 125 |
}
|
143 |
}
|