| Line 259... |
Line 259... |
| 259 |
}
|
259 |
}
|
| 260 |
|
260 |
|
| 261 |
@RequestMapping(value = "/brandfeeCollection", method = RequestMethod.POST)
|
261 |
@RequestMapping(value = "/brandfeeCollection", method = RequestMethod.POST)
|
| 262 |
public String addBrandFee(HttpServletRequest request, @RequestBody BrandFeeCollection brandFeeCollection, @RequestParam int loiId, Model model) throws Exception {
|
262 |
public String addBrandFee(HttpServletRequest request, @RequestBody BrandFeeCollection brandFeeCollection, @RequestParam int loiId, Model model) throws Exception {
|
| 263 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
263 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 264 |
double totatcollectedfee = brandFeeCollectionRepository.selectAllByLoiFormId(loiId).stream().mapToDouble(x -> x.getCollectedAmount()).sum();
|
264 |
double totatcollectedfee = brandFeeCollectionRepository.selectAllConfirmPaymetByLoiId(loiId).stream().mapToDouble(x -> x.getCollectedAmount()).sum();
|
| 265 |
double brandFee = loiForm.getAgreedBrandFees();
|
265 |
double brandFee = loiForm.getAgreedBrandFees();
|
| 266 |
double differanceAmount = brandFee - totatcollectedfee;
|
266 |
double differanceAmount = brandFee - totatcollectedfee;
|
| 267 |
if (totatcollectedfee + brandFeeCollection.getCollectedAmount() <= brandFee) {
|
267 |
if (totatcollectedfee + brandFeeCollection.getCollectedAmount() <= brandFee) {
|
| 268 |
brandFeeCollection.setPaymentStatus(FeePaymentStatus.PENDING);
|
268 |
brandFeeCollection.setPaymentStatus(FeePaymentStatus.PENDING);
|
| 269 |
brandFeeCollection.setLoiFormId(loiId);
|
269 |
brandFeeCollection.setLoiFormId(loiId);
|
| Line 442... |
Line 442... |
| 442 |
boolean isAgreedBrandFeeChanger = agreedBrandFeeChangerEmail.stream().anyMatch(x -> x.equals(loginDetails.getEmailId()));
|
442 |
boolean isAgreedBrandFeeChanger = agreedBrandFeeChangerEmail.stream().anyMatch(x -> x.equals(loginDetails.getEmailId()));
|
| 443 |
if (isAgreedBrandFeeChanger) {
|
443 |
if (isAgreedBrandFeeChanger) {
|
| 444 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
444 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 445 |
loiForm.setAgreedBrandFees(brandFee);
|
445 |
loiForm.setAgreedBrandFees(brandFee);
|
| 446 |
loiForm.setBrandType(storeType);
|
446 |
loiForm.setBrandType(storeType);
|
| - |
|
447 |
loiFormService.checkLoiDetailsCompletion(loiFormRepository.selectById(loiId));
|
| 447 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
448 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 448 |
return "response";
|
449 |
return "response";
|
| 449 |
} else {
|
450 |
} else {
|
| 450 |
throw new ProfitMandiBusinessException("failed in Authority check ", null, "Sorry " + authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getName() + " you have no authority to change agreed brand fee");
|
451 |
throw new ProfitMandiBusinessException("failed in Authority check ", null, "Sorry " + authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getName() + " you have no authority to change agreed brand fee");
|
| 451 |
}
|
452 |
}
|