| Line 122... |
Line 122... |
| 122 |
@Autowired
|
122 |
@Autowired
|
| 123 |
PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
|
123 |
PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
|
| 124 |
|
124 |
|
| 125 |
List<String> agreedBrandFeeChangerEmail = Arrays.asList("sm@smartdukaan.com");
|
125 |
List<String> agreedBrandFeeChangerEmail = Arrays.asList("sm@smartdukaan.com");
|
| 126 |
|
126 |
|
| 127 |
// OnBoarding Form
|
127 |
// Loi Form
|
| 128 |
@RequestMapping(value = "/onboardingForm", method = RequestMethod.GET)
|
128 |
@RequestMapping(value = "/loiForm", method = RequestMethod.GET)
|
| 129 |
public String loiForm(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
129 |
public String loiForm(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| 130 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 131 |
List<AuthUser> authUsersList = loiFormService.getReferalAuthList();
|
130 |
List<AuthUser> authUsersList = loiFormService.getReferalAuthList();
|
| 132 |
List<BrandFee> brandFee = brandFeeRepository.selectFeeOnDate(LocalDateTime.now());
|
131 |
List<BrandFee> brandFee = brandFeeRepository.selectFeeOnDate(LocalDateTime.now());
|
| 133 |
Set<Pair<StoreType, BrandFee>> storeTypeFeePairs = new HashSet<>();
|
132 |
Set<Pair<StoreType, BrandFee>> storeTypeFeePairs = new HashSet<>();
|
| 134 |
for (BrandFee fee : brandFee) {
|
133 |
for (BrandFee fee : brandFee) {
|
| 135 |
for (StoreType storeType : StoreType.values()) {
|
134 |
for (StoreType storeType : StoreType.values()) {
|
| Line 140... |
Line 139... |
| 140 |
List<BusinessType> businessTypes = Arrays.asList(BusinessType.Proprietorship, BusinessType.Partnership, BusinessType.Company);
|
139 |
List<BusinessType> businessTypes = Arrays.asList(BusinessType.Proprietorship, BusinessType.Partnership, BusinessType.Company);
|
| 141 |
model.addAttribute("businessTypes", businessTypes);
|
140 |
model.addAttribute("businessTypes", businessTypes);
|
| 142 |
model.addAttribute("brandCommits", brandCommits);
|
141 |
model.addAttribute("brandCommits", brandCommits);
|
| 143 |
model.addAttribute("storeTypeFeePairs", storeTypeFeePairs);
|
142 |
model.addAttribute("storeTypeFeePairs", storeTypeFeePairs);
|
| 144 |
model.addAttribute("authUsersList", authUsersList);
|
143 |
model.addAttribute("authUsersList", authUsersList);
|
| 145 |
return "partner-onboarding-form";
|
144 |
return "loi-form";
|
| 146 |
}
|
145 |
}
|
| 147 |
|
146 |
|
| 148 |
// use to validate GSTIN
|
147 |
// use to validate GSTIN
|
| 149 |
@RequestMapping(value = "/gstValidate", method = RequestMethod.GET)
|
148 |
@RequestMapping(value = "/gstValidate", method = RequestMethod.GET)
|
| 150 |
public ResponseEntity<?> gstValidate(HttpServletRequest request, @RequestParam String gstNo) throws Exception {
|
149 |
public ResponseEntity<?> gstValidate(HttpServletRequest request, @RequestParam String gstNo) throws Exception {
|
| Line 183... |
Line 182... |
| 183 |
@RequestMapping(value = "/pendingLoiForm", method = RequestMethod.GET)
|
182 |
@RequestMapping(value = "/pendingLoiForm", method = RequestMethod.GET)
|
| 184 |
public String pendingLoiForm(HttpServletRequest request, Model model) throws Exception {
|
183 |
public String pendingLoiForm(HttpServletRequest request, Model model) throws Exception {
|
| 185 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
184 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 186 |
String email = loginDetails.getEmailId();
|
185 |
String email = loginDetails.getEmailId();
|
| 187 |
boolean isDocApprover = false;
|
186 |
boolean isDocApprover = false;
|
| 188 |
//todo:replace
|
- |
|
| 189 |
String approverEmail = "gaurav.sharma@smartdukaan.com";
|
187 |
String approverEmail = "gaurav.sharma@smartdukaan.com";
|
| 190 |
if (email.equals(approverEmail)) {
|
188 |
if (email.equals(approverEmail)) {
|
| 191 |
isDocApprover = true;
|
189 |
isDocApprover = true;
|
| 192 |
}
|
190 |
}
|
| 193 |
boolean isAgreedBrandFeeChanger = agreedBrandFeeChangerEmail.stream().anyMatch(x -> x.equals(email));
|
191 |
boolean isAgreedBrandFeeChanger = agreedBrandFeeChangerEmail.stream().anyMatch(x -> x.equals(email));
|
| Line 201... |
Line 199... |
| 201 |
return "pendingForm";
|
199 |
return "pendingForm";
|
| 202 |
}
|
200 |
}
|
| 203 |
|
201 |
|
| 204 |
// generate LOI for specific Form data
|
202 |
// generate LOI for specific Form data
|
| 205 |
@RequestMapping(value = "/generateLoi", method = RequestMethod.GET)
|
203 |
@RequestMapping(value = "/generateLoi", method = RequestMethod.GET)
|
| 206 |
public String generateLoi(@RequestParam int loiId, Model model) throws ProfitMandiBusinessException {
|
204 |
public String generateLoi(HttpServletRequest request, @RequestParam int loiId, Model model) throws ProfitMandiBusinessException {
|
| 207 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
205 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 208 |
String filledBy = authRepository.selectByEmailOrMobile(loiForm.getFilledBy()).getFullName();
|
206 |
String filledBy = authRepository.selectByEmailOrMobile(loiForm.getFilledBy()).getFullName();
|
| 209 |
loiForm.setLoiGeneratedOn(LocalDateTime.now());
|
207 |
loiForm.setLoiGeneratedOn(LocalDateTime.now());
|
| 210 |
loiForm.setStatus(LoiStatus.LOI_GENERATED);
|
- |
|
| 211 |
BrandFee brandFee = brandFeeRepository.selectById(1);
|
208 |
BrandFee brandFee = brandFeeRepository.selectById(1);
|
| 212 |
BrandFee givenFee = brandFeeRepository.selectById(loiForm.getBrandFeeId());
|
- |
|
| 213 |
BillingAddress address = billingAddressRepository.selectByLoiFormId(loiId);
|
209 |
BillingAddress address = billingAddressRepository.selectByLoiFormId(loiId);
|
| 214 |
List<BrandFeeCollection> brandFeeCollections = brandFeeCollectionRepository.selectAllByLoiFormId(loiId);
|
- |
|
| 215 |
List<LoiBrandCommitment> loiBrandCommitments = brandCommitmentRepository.selectByLoiId(loiId).stream().filter(x -> x.getAmount() > 0).collect(Collectors.toList());
|
210 |
List<LoiBrandCommitment> loiBrandCommitments = brandCommitmentRepository.selectByLoiId(loiId).stream().filter(x -> x.getAmount() > 0).collect(Collectors.toList());
|
| 216 |
double totalCommitment = loiBrandCommitments.stream().mapToDouble(x -> x.getAmount()).sum();
|
211 |
double totalCommitment = loiBrandCommitments.stream().mapToDouble(x -> x.getAmount()).sum();
|
| - |
|
212 |
List<BrandFeeCollection> brandFeeCollections = brandFeeCollectionRepository.selectAllConfirmPaymetByLoiId(loiId);
|
| 217 |
double brandFeeAmount = brandFeeCollections.stream().filter(x -> x.getPaymentStatus().equals(FeePaymentStatus.CONFIRM)).mapToDouble(x -> x.getCollectedAmount()).sum();
|
213 |
double brandFeeAmount = brandFeeCollections.stream().mapToDouble(x -> x.getCollectedAmount()).sum();
|
| 218 |
BrandFeeCollection brandFeeCollection = brandFeeCollections.get(0);
|
214 |
BrandFeeCollection brandFeeCollection = brandFeeCollections.get(0);
|
| 219 |
model.addAttribute("totalCommitment", totalCommitment);
|
215 |
model.addAttribute("totalCommitment", totalCommitment);
|
| 220 |
model.addAttribute("loiBrandCommitments", loiBrandCommitments);
|
216 |
model.addAttribute("loiBrandCommitments", loiBrandCommitments);
|
| 221 |
model.addAttribute("brandFeeAmount", brandFeeAmount);
|
217 |
model.addAttribute("brandFeeAmount", brandFeeAmount);
|
| 222 |
model.addAttribute("brandFee", brandFee);
|
218 |
model.addAttribute("brandFee", brandFee);
|
| 223 |
model.addAttribute("givenFee", givenFee);
|
- |
|
| 224 |
model.addAttribute("brandFeeCollection", brandFeeCollection);
|
219 |
model.addAttribute("brandFeeCollection", brandFeeCollection);
|
| 225 |
model.addAttribute("address", address);
|
220 |
model.addAttribute("address", address);
|
| 226 |
model.addAttribute("loiForm", loiForm);
|
221 |
model.addAttribute("loiForm", loiForm);
|
| 227 |
model.addAttribute("filledBy", filledBy);
|
222 |
model.addAttribute("filledBy", filledBy);
|
| 228 |
return "auto-Loi";
|
223 |
return "auto-Loi";
|
| 229 |
|
224 |
|
| 230 |
}
|
225 |
}
|
| 231 |
|
226 |
|
| 232 |
@RequestMapping(value = "/saveLoiDoc", method = RequestMethod.POST)
|
- |
|
| 233 |
public String saveLoiDoc(@RequestParam int loiId, @RequestParam int loiDocId, Model model) throws Exception {
|
- |
|
| 234 |
LOGGER.info("loi_docId-" + loiDocId);
|
- |
|
| 235 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
- |
|
| 236 |
int loiDoc = loiForm.getLoiDoc();
|
- |
|
| 237 |
if (loiDoc == 0) {
|
- |
|
| 238 |
loiForm.setLoiDoc(loiDocId);
|
- |
|
| 239 |
loiFormService.sendSignedLoiPdfToPartner(loiForm);
|
- |
|
| 240 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 241 |
} else {
|
- |
|
| 242 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
- |
|
| 243 |
}
|
- |
|
| 244 |
if (loiForm.getOnBoardingId() > 0) {
|
- |
|
| 245 |
partnerOnBoardingPanelRepository.selectById(loiForm.getOnBoardingId()).setLOI(loiDocId);
|
- |
|
| 246 |
}
|
- |
|
| 247 |
return "response";
|
- |
|
| 248 |
|
- |
|
| 249 |
}
|
- |
|
| 250 |
|
227 |
|
| 251 |
// send Filled form for update purpose
|
228 |
// send Filled form for update purpose
|
| 252 |
@RequestMapping(value = "/updateLoiForm", method = RequestMethod.GET)
|
229 |
@RequestMapping(value = "/updateLoiForm", method = RequestMethod.GET)
|
| 253 |
public String UpdateLoiForm(HttpServletRequest request,
|
230 |
public String UpdateLoiForm(HttpServletRequest request,
|
| 254 |
@RequestParam int loiId,
|
231 |
@RequestParam int loiId,
|
| Line 267... |
Line 244... |
| 267 |
loiFormService.updateLoiForm(loiFormData, loiId);
|
244 |
loiFormService.updateLoiForm(loiFormData, loiId);
|
| 268 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
245 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 269 |
return "response";
|
246 |
return "response";
|
| 270 |
}
|
247 |
}
|
| 271 |
|
248 |
|
| 272 |
// TODO , add paymnet if brand fee due
|
- |
|
| 273 |
@RequestMapping(value = "/brandfeeCollection", method = RequestMethod.POST)
|
249 |
@RequestMapping(value = "/brandfeeCollection", method = RequestMethod.POST)
|
| 274 |
public String addBrandFee(HttpServletRequest request, @RequestBody BrandFeeCollection brandFeeCollection, @RequestParam int loiId, Model model) throws Exception {
|
250 |
public String addBrandFee(HttpServletRequest request, @RequestBody BrandFeeCollection brandFeeCollection, @RequestParam int loiId, Model model) throws Exception {
|
| 275 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
251 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 276 |
List<BrandFeeCollection> brandFeeCollections = brandFeeCollectionRepository.selectAllByLoiFormId(loiId);
|
- |
|
| 277 |
double totatcollectedfee = brandFeeCollections.stream().filter(x -> x.getPaymentStatus().equals(FeePaymentStatus.CONFIRM) || x.getPaymentStatus().equals(FeePaymentStatus.PENDING)).mapToDouble(x -> x.getCollectedAmount()).sum();
|
252 |
double totatcollectedfee = brandFeeCollectionRepository.selectAllByLoiFormId(loiId).stream().mapToDouble(x -> x.getCollectedAmount()).sum();
|
| 278 |
double brandFee = loiForm.getAgreedBrandFees();
|
253 |
double brandFee = loiForm.getAgreedBrandFees();
|
| 279 |
double differanceAmount = brandFee - totatcollectedfee;
|
254 |
double differanceAmount = brandFee - totatcollectedfee;
|
| 280 |
if (totatcollectedfee + brandFeeCollection.getCollectedAmount() <= brandFee) {
|
255 |
if (totatcollectedfee + brandFeeCollection.getCollectedAmount() <= brandFee) {
|
| 281 |
brandFeeCollection.setPaymentStatus(FeePaymentStatus.PENDING);
|
256 |
brandFeeCollection.setPaymentStatus(FeePaymentStatus.PENDING);
|
| 282 |
brandFeeCollection.setLoiFormId(loiId);
|
257 |
brandFeeCollection.setLoiFormId(loiId);
|
| 283 |
brandFeeCollectionRepository.persist(brandFeeCollection);
|
258 |
brandFeeCollectionRepository.persist(brandFeeCollection);
|
| 284 |
loiFormService.sentMailToPaymentApprover(brandFeeCollection);
|
259 |
loiFormService.sentMailToPaymentApprover(brandFeeCollection, loiForm);
|
| 285 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
260 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 286 |
return "response";
|
261 |
return "response";
|
| 287 |
} else {
|
262 |
} else {
|
| 288 |
throw new ProfitMandiBusinessException("You need to add only due brand fee that is Only, " + differanceAmount + " INR", null, "Pay differance amount or less then differance amount");
|
263 |
throw new ProfitMandiBusinessException("You need to add only due brand fee that is Only, " + differanceAmount + " INR", null, "Pay differance amount or less then differance amount");
|
| 289 |
}
|
264 |
}
|
| Line 310... |
Line 285... |
| 310 |
public String feePaymentApproval(HttpServletRequest request, @RequestParam int bfcId, @RequestParam FeePaymentStatus feePaymentStatus, @RequestParam String description,
|
285 |
public String feePaymentApproval(HttpServletRequest request, @RequestParam int bfcId, @RequestParam FeePaymentStatus feePaymentStatus, @RequestParam String description,
|
| 311 |
Model model) throws Exception {
|
286 |
Model model) throws Exception {
|
| 312 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
287 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 313 |
String authEmail = loginDetails.getEmailId();
|
288 |
String authEmail = loginDetails.getEmailId();
|
| 314 |
BrandFeeCollection brandFeeCollection = brandFeeCollectionRepository.selectById(bfcId);
|
289 |
BrandFeeCollection brandFeeCollection = brandFeeCollectionRepository.selectById(bfcId);
|
| 315 |
LoiForm loiForm = loiFormRepository.selectById(brandFeeCollection.getLoiFormId());
|
- |
|
| 316 |
List<BrandFeeCollection> brandFeeCollections = brandFeeCollectionRepository.selectAllConfirmPaymetByLoiId(brandFeeCollection.getLoiFormId());
|
- |
|
| 317 |
brandFeeCollection.setApproverEmail(authEmail);
|
290 |
brandFeeCollection.setApproverEmail(authEmail);
|
| 318 |
brandFeeCollection.setPaymentStatus(feePaymentStatus);
|
291 |
brandFeeCollection.setPaymentStatus(feePaymentStatus);
|
| 319 |
brandFeeCollection.setDescription(description);
|
292 |
brandFeeCollection.setDescription(description);
|
| 320 |
double agreedBrandFee = loiForm.getAgreedBrandFees();
|
- |
|
| 321 |
double totalBrandFeeCollection = brandFeeCollections.stream().mapToDouble(x -> x.getCollectedAmount()).sum() + brandFeeCollection.getCollectedAmount();
|
- |
|
| 322 |
if (brandFeeCollection.getPaymentStatus().equals(FeePaymentStatus.REJECT)) {
|
- |
|
| 323 |
loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
|
293 |
loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
|
| 324 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
- |
|
| 325 |
} else {
|
- |
|
| 326 |
loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
|
- |
|
| 327 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
294 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 328 |
}
|
- |
|
| 329 |
if (agreedBrandFee == totalBrandFeeCollection && loiForm.getLoiSignOtp() != null) {
|
- |
|
| 330 |
loiForm.setStatus(LoiStatus.PRE_ONBOARDING_DONE);
|
- |
|
| 331 |
loiFormService.createPartnerOnboardingPanel(loiForm.getId());
|
- |
|
| 332 |
}
|
- |
|
| 333 |
return "response";
|
295 |
return "response";
|
| 334 |
|
296 |
|
| 335 |
}
|
297 |
}
|
| 336 |
|
298 |
|
| 337 |
|
299 |
|
| 338 |
@RequestMapping(value = "/uploadDocumentForm", method = RequestMethod.GET)
|
300 |
@RequestMapping(value = "/uploadDocumentForm", method = RequestMethod.GET)
|
| 339 |
public String uploadDocumentForm(HttpServletRequest request, @RequestParam int loiId, Model model) throws ProfitMandiBusinessException {
|
301 |
public String uploadDocumentForm(HttpServletRequest request, @RequestParam int loiId, Model model) throws ProfitMandiBusinessException {
|
| 340 |
List<LoiDocMaster> activeDocMasterList = loiDocMasterList.getAllActiveDoc();
|
302 |
List<LoiDocMaster> activeDocMasterList = loiDocMasterList.getAllActiveDoc();
|
| 341 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
- |
|
| 342 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
303 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 343 |
String authEmail = authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getEmailId();
|
304 |
String authEmail = authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getEmailId();
|
| 344 |
String approverEmail = "gaurav.sharma@smartdukaan.com";
|
305 |
String approverEmail = "gaurav.sharma@smartdukaan.com";
|
| 345 |
boolean isApprover = false;
|
306 |
boolean isApprover = false;
|
| 346 |
if (authEmail.equals(approverEmail)) {
|
307 |
if (authEmail.equals(approverEmail)) {
|
| 347 |
isApprover = true;
|
308 |
isApprover = true;
|
| 348 |
}
|
309 |
}
|
| 349 |
Map<Integer, LoiDoc> masterDocIdLoiDocMap = loiDocRepository.selectLoiFormId(loiId).stream().collect(Collectors.toMap(x -> x.getMasterDocId(), x -> x));
|
310 |
Map<Integer, LoiDoc> masterDocIdLoiDocMap = loiDocRepository.selectByLoiFormId(loiId).stream().collect(Collectors.toMap(x -> x.getMasterDocId(), x -> x));
|
| 350 |
model.addAttribute("isApprover", isApprover);
|
311 |
model.addAttribute("isApprover", isApprover);
|
| 351 |
model.addAttribute("loiId", loiId);
|
312 |
model.addAttribute("loiId", loiId);
|
| 352 |
model.addAttribute("activeDocMasterList", activeDocMasterList);
|
313 |
model.addAttribute("activeDocMasterList", activeDocMasterList);
|
| 353 |
model.addAttribute("masterDocIdLoiDocMap", masterDocIdLoiDocMap);
|
314 |
model.addAttribute("masterDocIdLoiDocMap", masterDocIdLoiDocMap);
|
| 354 |
return "loiForm/document-upload";
|
315 |
return "loiForm/document-upload";
|
| Line 400... |
Line 361... |
| 400 |
}
|
361 |
}
|
| 401 |
|
362 |
|
| 402 |
@RequestMapping(value = "/validateLoiOtp", method = RequestMethod.PUT)
|
363 |
@RequestMapping(value = "/validateLoiOtp", method = RequestMethod.PUT)
|
| 403 |
public String validateLoiAcceptanceOtp(@RequestParam int loiId, @RequestParam String provideOtp, Model model) throws Exception {
|
364 |
public String validateLoiAcceptanceOtp(@RequestParam int loiId, @RequestParam String provideOtp, Model model) throws Exception {
|
| 404 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
365 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 405 |
double agreedBrandFees = loiForm.getAgreedBrandFees();
|
- |
|
| 406 |
double totalCollectfee = brandFeeCollectionRepository.selectAllByLoiFormId(loiId).stream().filter(x -> x.getPaymentStatus().equals(FeePaymentStatus.CONFIRM)).mapToDouble(x -> x.getCollectedAmount()).sum();
|
- |
|
| 407 |
String mobile = String.valueOf(loiForm.getMobile());
|
366 |
String mobile = String.valueOf(loiForm.getMobile());
|
| 408 |
Otp otp = otpRepository.selectAllByMobileWithTime(mobile).get(0);
|
367 |
Otp otp = otpRepository.selectAllByMobileWithTime(mobile).get(0);
|
| 409 |
OTPResponse otpResponse = otpProcessor.validateOtp(otp.getId(), mobile, provideOtp);
|
368 |
OTPResponse otpResponse = otpProcessor.validateOtp(otp.getId(), mobile, provideOtp);
|
| 410 |
if (!otpResponse.isResult()) {
|
- |
|
| 411 |
throw new ProfitMandiBusinessException("Wrong OTP", provideOtp, "Your given Otp ->" + provideOtp + " is wrong , please check OTP and try again");
|
- |
|
| 412 |
}
|
- |
|
| 413 |
if (otpResponse.isResult()) {
|
369 |
if (otpResponse.isResult()) {
|
| 414 |
loiForm.setLoiSignOtp(provideOtp);
|
370 |
loiForm.setLoiSignOtp(provideOtp);
|
| 415 |
loiForm.setLoiSignedOn(LocalDateTime.now());
|
371 |
loiForm.setLoiSignedOn(LocalDateTime.now());
|
| 416 |
if (agreedBrandFees == totalCollectfee && loiForm.getLoiSignOtp() != null) {
|
- |
|
| 417 |
loiForm.setStatus(LoiStatus.PRE_ONBOARDING_DONE);
|
- |
|
| 418 |
loiFormService.createPartnerOnboardingPanel(loiId);
|
- |
|
| 419 |
} else {
|
- |
|
| 420 |
loiForm.setStatus(LoiStatus.LOI_SIGNED);
|
- |
|
| 421 |
}
|
- |
|
| 422 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
372 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
373 |
} else {
|
| - |
|
374 |
throw new ProfitMandiBusinessException("Wrong OTP", "", "Your given Otp ->" + provideOtp + " is wrong , please check OTP and try again");
|
| - |
|
375 |
|
| 423 |
}
|
376 |
}
|
| 424 |
return "response";
|
377 |
return "response";
|
| 425 |
}
|
378 |
}
|
| 426 |
|
379 |
|
| - |
|
380 |
@RequestMapping(value = "/saveLoiDoc", method = RequestMethod.POST)
|
| - |
|
381 |
public String saveLoiDoc(@RequestParam int loiId, @RequestParam int loiDocId, Model model) throws Exception {
|
| - |
|
382 |
LOGGER.info("loi_docId-" + loiDocId);
|
| - |
|
383 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| - |
|
384 |
if (loiDocId > 0) {
|
| - |
|
385 |
loiForm.setLoiDoc(loiDocId);
|
| - |
|
386 |
loiFormService.sendSignedLoiPdfToPartner(loiForm);
|
| - |
|
387 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
388 |
} else {
|
| - |
|
389 |
loiForm.setLoiSignOtp("");
|
| - |
|
390 |
loiForm.setLoiGeneratedOn(null);
|
| - |
|
391 |
loiForm.setLoiSignedOn(null);
|
| - |
|
392 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
| - |
|
393 |
}
|
| - |
|
394 |
return "response";
|
| - |
|
395 |
|
| - |
|
396 |
}
|
| - |
|
397 |
|
| 427 |
@RequestMapping(value = "/downloadLoiFromReport", method = RequestMethod.GET)
|
398 |
@RequestMapping(value = "/downloadLoiFromReport", method = RequestMethod.GET)
|
| 428 |
public ResponseEntity<?> downloadAllLoiForm(@RequestParam LocalDate from, @RequestParam LocalDate to) throws Exception {
|
399 |
public ResponseEntity<?> downloadAllLoiForm(@RequestParam LocalDate from, @RequestParam LocalDate to) throws Exception {
|
| 429 |
ResponseEntity<?> responseEntity = loiFormService.createLoiFormReport(from, to);
|
400 |
ResponseEntity<?> responseEntity = loiFormService.createLoiFormReport(from, to);
|
| 430 |
return responseEntity;
|
401 |
return responseEntity;
|
| 431 |
}
|
402 |
}
|
| 432 |
|
403 |
|
| 433 |
@RequestMapping(value = "/updatePayment", method = RequestMethod.POST)
|
404 |
@RequestMapping(value = "/updatePayment", method = RequestMethod.POST)
|
| 434 |
public String updateForm(@RequestBody BrandFeeCollection brandFeeCollection, Model model) throws Exception {
|
405 |
public String updateForm(@RequestBody BrandFeeCollection brandFeeCollection, Model model) throws Exception {
|
| 435 |
BrandFeeCollection brandFeeCollection1 = brandFeeCollectionRepository.selectById(brandFeeCollection.getId());
|
406 |
BrandFeeCollection brandFeeCollection1 = brandFeeCollectionRepository.selectById(brandFeeCollection.getId());
|
| - |
|
407 |
double totalConfirmPayment = brandFeeCollectionRepository.selectAllConfirmPaymetByLoiId(brandFeeCollection1.getLoiFormId()).stream().mapToDouble(x -> x.getCollectedAmount()).sum() + brandFeeCollection.getCollectedAmount();
|
| - |
|
408 |
double totalCollection = totalConfirmPayment + brandFeeCollection.getCollectedAmount();
|
| - |
|
409 |
LoiForm loiForm = loiFormRepository.selectById(brandFeeCollection1.getLoiFormId());
|
| - |
|
410 |
if (totalCollection <= loiForm.getAgreedBrandFees()) {
|
| 436 |
brandFeeCollection1.setFeeCollectingTimeStamp(brandFeeCollection.getFeeCollectingTimeStamp());
|
411 |
brandFeeCollection1.setFeeCollectingTimeStamp(brandFeeCollection.getFeeCollectingTimeStamp());
|
| 437 |
brandFeeCollection1.setCollectedAmount(brandFeeCollection.getCollectedAmount());
|
412 |
brandFeeCollection1.setCollectedAmount(brandFeeCollection.getCollectedAmount());
|
| 438 |
brandFeeCollection1.setPaymentReferenceNo(brandFeeCollection.getPaymentReferenceNo());
|
413 |
brandFeeCollection1.setPaymentReferenceNo(brandFeeCollection.getPaymentReferenceNo());
|
| 439 |
brandFeeCollection1.setPaymentMode(brandFeeCollection.getPaymentMode());
|
414 |
brandFeeCollection1.setPaymentMode(brandFeeCollection.getPaymentMode());
|
| - |
|
415 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
416 |
} else {
|
| - |
|
417 |
double differanceAmount = loiForm.getAgreedBrandFees() - totalConfirmPayment;
|
| 440 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
418 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
419 |
throw new ProfitMandiBusinessException("You need to add only due brand fee that is Only, " + differanceAmount + " INR", null, "Pay differance amount or less then differance amount");
|
| - |
|
420 |
}
|
| 441 |
return "response";
|
421 |
return "response";
|
| 442 |
}
|
422 |
}
|
| 443 |
|
423 |
|
| 444 |
@RequestMapping(value = "/updateAgreedBrandFee", method = RequestMethod.PUT)
|
424 |
@RequestMapping(value = "/updateAgreedBrandFee", method = RequestMethod.PUT)
|
| 445 |
public String updateAgreedBrandFee(HttpServletRequest request, @RequestParam int loiId, @RequestParam double brandFee, Model model) throws Exception {
|
425 |
public String updateAgreedBrandFee(HttpServletRequest request, @RequestParam int loiId, @RequestParam double brandFee, Model model) throws Exception {
|
| 446 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
426 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 447 |
boolean isAgreedBrandFeeChanger = agreedBrandFeeChangerEmail.stream().anyMatch(x -> x.equals(loginDetails.getEmailId()));
|
427 |
boolean isAgreedBrandFeeChanger = agreedBrandFeeChangerEmail.stream().anyMatch(x -> x.equals(loginDetails.getEmailId()));
|
| 448 |
if (isAgreedBrandFeeChanger) {
|
428 |
if (isAgreedBrandFeeChanger) {
|
| 449 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
429 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 450 |
loiForm.setAgreedBrandFees(brandFee);
|
430 |
loiForm.setAgreedBrandFees(brandFee);
|
| 451 |
double totalCollectedPayment = brandFeeCollectionRepository.selectAllConfirmPaymetByLoiId(loiId).stream().mapToDouble(x -> x.getCollectedAmount()).sum();
|
- |
|
| 452 |
double agreedBrandFee = loiForm.getAgreedBrandFees();
|
- |
|
| 453 |
if (agreedBrandFee == totalCollectedPayment && loiForm.getLoiSignOtp() != null) {
|
- |
|
| 454 |
loiForm.setStatus(LoiStatus.PRE_ONBOARDING_DONE);
|
- |
|
| 455 |
loiFormService.createPartnerOnboardingPanel(loiId);
|
- |
|
| 456 |
}
|
- |
|
| 457 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
431 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 458 |
return "response";
|
432 |
return "response";
|
| 459 |
} else {
|
433 |
} else {
|
| 460 |
throw new ProfitMandiBusinessException("failed in Authority check ", null, "Sorry " + authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getName() + " you have no authority to change agreed brand fee");
|
434 |
throw new ProfitMandiBusinessException("failed in Authority check ", null, "Sorry " + authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getName() + " you have no authority to change agreed brand fee");
|
| 461 |
}
|
435 |
}
|
| 462 |
|
- |
|
| 463 |
}
|
436 |
}
|
| 464 |
|
437 |
|
| 465 |
@RequestMapping(value = "/cancelLoi", method = RequestMethod.PUT)
|
438 |
// @RequestMapping(value = "/cancelLoi", method = RequestMethod.PUT)
|
| 466 |
public String loiCancellation(@RequestParam int loiId, Model model) throws Exception {
|
439 |
// public String loiCancellation(@RequestParam int loiId, Model model) throws Exception {
|
| - |
|
440 |
// LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| - |
|
441 |
// loiForm.setStatus(LoiStatus.LOI_REJECT);
|
| - |
|
442 |
// loiForm.setLoiApproved(false);
|
| - |
|
443 |
// model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
444 |
// return "response";
|
| - |
|
445 |
// }
|
| - |
|
446 |
|
| - |
|
447 |
@RequestMapping(value = "/approve-reject-Loi", method = RequestMethod.PUT)
|
| - |
|
448 |
public String approveDetails(HttpServletRequest request, @RequestParam int loiId, @RequestParam boolean flag, Model model) throws Exception {
|
| - |
|
449 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
450 |
String email = loginDetails.getEmailId();
|
| 467 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
451 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| - |
|
452 |
AuthUser filledBy = authRepository.selectByEmailOrMobile(loiForm.getFilledBy());
|
| - |
|
453 |
AuthUser manager = authRepository.selectById(filledBy.getManagerId());
|
| - |
|
454 |
AuthUser upperManager = null;
|
| - |
|
455 |
List<String> approverMail = new ArrayList<>();
|
| - |
|
456 |
approverMail.add(manager.getEmailId());
|
| - |
|
457 |
upperManager = authRepository.selectById(manager.getManagerId());
|
| - |
|
458 |
approverMail.add(upperManager.getEmailId());
|
| - |
|
459 |
|
| - |
|
460 |
LOGGER.info("approverMail-" + approverMail);
|
| - |
|
461 |
// Approver - Manager or Upper manager of loi filledBy(BM)
|
| - |
|
462 |
boolean isApprover = approverMail.contains(email);
|
| - |
|
463 |
LOGGER.info("isApprover-" + isApprover);
|
| - |
|
464 |
List<String> authEmail = Arrays.asList("sm@smartdukaan.com", "tarun.verma@smartdukaan.com", "ashutosh.verma@smartdukaan.com");
|
| - |
|
465 |
boolean isAuthUser = authEmail.stream().anyMatch(x -> x.equals(email));
|
| - |
|
466 |
if (flag) {
|
| - |
|
467 |
if (isApprover || isAuthUser) {
|
| - |
|
468 |
loiForm.setLoiApprover(email);
|
| - |
|
469 |
loiForm.setLoiApproved(flag);
|
| - |
|
470 |
loiFormService.checkLoiDetailsCompletion(loiForm);
|
| - |
|
471 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
472 |
} else {
|
| 468 |
loiForm.setStatus(LoiStatus.LOI_CANCELLED);
|
473 |
throw new ProfitMandiBusinessException("Failed in Authority check ", "Read", "Sorry " + authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getName() + " you have no authority to Approve this Loi Form ,Only reporting manager and upper can Approve");
|
| - |
|
474 |
}
|
| - |
|
475 |
} else {
|
| - |
|
476 |
if (isApprover || isAuthUser) {
|
| - |
|
477 |
loiForm.setLoiApprover(email);
|
| - |
|
478 |
loiForm.setLoiApproved(flag);
|
| - |
|
479 |
loiForm.setStatus(LoiStatus.LOI_REJECT);
|
| 469 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
480 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
481 |
} else {
|
| - |
|
482 |
throw new ProfitMandiBusinessException("Failed in Authority check ", "Read", "Sorry " + authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getName() + " you have no authority to Approve this Loi Form ,Only reporting manager and upper can Approve");
|
| - |
|
483 |
}
|
| - |
|
484 |
}
|
| 470 |
return "response";
|
485 |
return "response";
|
| 471 |
}
|
486 |
}
|
| 472 |
|
487 |
|
| - |
|
488 |
|
| 473 |
}
|
489 |
}
|