| Line 17... |
Line 17... |
| 17 |
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.StoreType;
|
17 |
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.StoreType;
|
| 18 |
import com.spice.profitmandi.dao.model.LoiFormModel;
|
18 |
import com.spice.profitmandi.dao.model.LoiFormModel;
|
| 19 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
19 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 20 |
import com.spice.profitmandi.dao.repository.brandFee.BrandFeeCollectionRepository;
|
20 |
import com.spice.profitmandi.dao.repository.brandFee.BrandFeeCollectionRepository;
|
| 21 |
import com.spice.profitmandi.dao.repository.brandFee.BrandFeeRepository;
|
21 |
import com.spice.profitmandi.dao.repository.brandFee.BrandFeeRepository;
|
| - |
|
22 |
import com.spice.profitmandi.dao.repository.catalog.BrandCategoryRepository;
|
| - |
|
23 |
import com.spice.profitmandi.dao.repository.catalog.BrandsRepository;
|
| 22 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
24 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 23 |
import com.spice.profitmandi.dao.repository.dtr.DistrictMasterRepository;
|
25 |
import com.spice.profitmandi.dao.repository.dtr.DistrictMasterRepository;
|
| 24 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
26 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
| 25 |
import com.spice.profitmandi.dao.repository.dtr.OtpRepository;
|
27 |
import com.spice.profitmandi.dao.repository.dtr.OtpRepository;
|
| 26 |
import com.spice.profitmandi.dao.repository.inventory.PartnerOnboardingService;
|
28 |
import com.spice.profitmandi.dao.repository.inventory.PartnerOnboardingService;
|
| 27 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
29 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| - |
|
30 |
import com.spice.profitmandi.dao.repository.onboarding.BrandCommitRepository;
|
| - |
|
31 |
import com.spice.profitmandi.dao.repository.onboarding.LoiBrandCommitmentRepository;
|
| 28 |
import com.spice.profitmandi.dao.repository.onboarding.LoiDocMasterRepository;
|
32 |
import com.spice.profitmandi.dao.repository.onboarding.LoiDocMasterRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.onboarding.LoiDocRepository;
|
33 |
import com.spice.profitmandi.dao.repository.onboarding.LoiDocRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
34 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| - |
|
35 |
import com.spice.profitmandi.dao.repository.user.BillingAddressRepository;
|
| 31 |
import com.spice.profitmandi.dao.repository.user.LoiFormRepository;
|
36 |
import com.spice.profitmandi.dao.repository.user.LoiFormRepository;
|
| 32 |
import com.spice.profitmandi.dao.service.LoiDocModel;
|
37 |
import com.spice.profitmandi.dao.service.LoiDocModel;
|
| 33 |
import com.spice.profitmandi.dao.service.OTPResponse;
|
38 |
import com.spice.profitmandi.dao.service.OTPResponse;
|
| 34 |
import com.spice.profitmandi.dao.service.OtpProcessor;
|
39 |
import com.spice.profitmandi.dao.service.OtpProcessor;
|
| 35 |
import com.spice.profitmandi.dao.service.loiForm.LoiFormService;
|
40 |
import com.spice.profitmandi.dao.service.loiForm.LoiFormService;
|
| Line 104... |
Line 109... |
| 104 |
LoiDocRepository loiDocRepository;
|
109 |
LoiDocRepository loiDocRepository;
|
| 105 |
@Autowired
|
110 |
@Autowired
|
| 106 |
MVCResponseSender mvcResponseSender;
|
111 |
MVCResponseSender mvcResponseSender;
|
| 107 |
@Autowired
|
112 |
@Autowired
|
| 108 |
private CookiesProcessor cookiesProcessor;
|
113 |
private CookiesProcessor cookiesProcessor;
|
| - |
|
114 |
@Autowired
|
| - |
|
115 |
BrandCommitRepository brandMasterRepository;
|
| - |
|
116 |
@Autowired
|
| - |
|
117 |
BrandsRepository brandsRepository;
|
| - |
|
118 |
@Autowired
|
| - |
|
119 |
BrandCategoryRepository brandCategoryRepository;
|
| - |
|
120 |
@Autowired
|
| - |
|
121 |
BillingAddressRepository billingAddressRepository;
|
| - |
|
122 |
@Autowired
|
| - |
|
123 |
LoiBrandCommitmentRepository brandCommitmentRepository;
|
| 109 |
|
124 |
|
| 110 |
// OnBoarding Form
|
125 |
// OnBoarding Form
|
| 111 |
@RequestMapping(value = "/onboardingForm", method = RequestMethod.GET)
|
126 |
@RequestMapping(value = "/onboardingForm", method = RequestMethod.GET)
|
| 112 |
public String loiForm(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
127 |
public String loiForm(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| 113 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
128 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 114 |
AuthUser selfAuth = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
- |
|
| 115 |
List<AuthUser> authUsersList = loiFormService.getReferalAuthList();
|
129 |
List<AuthUser> authUsersList = loiFormService.getReferalAuthList();
|
| 116 |
List<BrandFee> brandFee = brandFeeRepository.selectFeeOnDate(LocalDateTime.now());
|
130 |
List<BrandFee> brandFee = brandFeeRepository.selectFeeOnDate(LocalDateTime.now());
|
| 117 |
LOGGER.info("brandFee - " + brandFee);
|
- |
|
| 118 |
Set<Pair<StoreType, BrandFee>> storeTypeFeePairs = new HashSet<>();
|
131 |
Set<Pair<StoreType, BrandFee>> storeTypeFeePairs = new HashSet<>();
|
| 119 |
for (BrandFee fee : brandFee) {
|
132 |
for (BrandFee fee : brandFee) {
|
| 120 |
for (StoreType storeType : StoreType.values()) {
|
133 |
for (StoreType storeType : StoreType.values()) {
|
| 121 |
storeTypeFeePairs.add(Pair.of(storeType, fee));
|
134 |
storeTypeFeePairs.add(Pair.of(storeType, fee));
|
| 122 |
}
|
135 |
}
|
| 123 |
}
|
136 |
}
|
| - |
|
137 |
List<BrandCommit> brandCommits = brandMasterRepository.selectAllBrand();
|
| 124 |
List<BusinessType> businessTypes = Arrays.asList(BusinessType.Proprietorship, BusinessType.Partnership, BusinessType.Company);
|
138 |
List<BusinessType> businessTypes = Arrays.asList(BusinessType.Proprietorship, BusinessType.Partnership, BusinessType.Company);
|
| 125 |
model.addAttribute("businessTypes", businessTypes);
|
139 |
model.addAttribute("businessTypes", businessTypes);
|
| - |
|
140 |
model.addAttribute("brandCommits", brandCommits);
|
| 126 |
model.addAttribute("storeTypeFeePairs", storeTypeFeePairs);
|
141 |
model.addAttribute("storeTypeFeePairs", storeTypeFeePairs);
|
| 127 |
model.addAttribute("authUsersList", authUsersList);
|
142 |
model.addAttribute("authUsersList", authUsersList);
|
| 128 |
model.addAttribute("selfAuth", selfAuth);
|
- |
|
| 129 |
return "partner-onboarding-form";
|
143 |
return "partner-onboarding-form";
|
| 130 |
}
|
144 |
}
|
| 131 |
|
145 |
|
| 132 |
// use to validate GSTIN
|
146 |
// use to validate GSTIN
|
| 133 |
@RequestMapping(value = "/gstValidate", method = RequestMethod.GET)
|
147 |
@RequestMapping(value = "/gstValidate", method = RequestMethod.GET)
|
| Line 152... |
Line 166... |
| 152 |
@RequestMapping(value = "/submitLoiForm", method = RequestMethod.POST)
|
166 |
@RequestMapping(value = "/submitLoiForm", method = RequestMethod.POST)
|
| 153 |
public String submitLoiForm(HttpServletRequest request, @RequestBody LoiFormData loiFormData, Model model) throws Exception {
|
167 |
public String submitLoiForm(HttpServletRequest request, @RequestBody LoiFormData loiFormData, Model model) throws Exception {
|
| 154 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
168 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 155 |
LOGGER.info("filledBy - " + loginDetails.getEmailId());
|
169 |
LOGGER.info("filledBy - " + loginDetails.getEmailId());
|
| 156 |
boolean isDataCreated = loiFormService.createLoiForm(loiFormData, loginDetails.getEmailId());
|
170 |
boolean isDataCreated = loiFormService.createLoiForm(loiFormData, loginDetails.getEmailId());
|
| 157 |
List<LoiFormModel> formList = loiFormService.pendingFormList(loginDetails.getEmailId());
|
- |
|
| 158 |
model.addAttribute("formList", formList);
|
- |
|
| 159 |
if (isDataCreated) {
|
171 |
if (isDataCreated) {
|
| 160 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
172 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 161 |
return "response";
|
173 |
return "response";
|
| 162 |
} else {
|
174 |
} else {
|
| 163 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
175 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
| Line 178... |
Line 190... |
| 178 |
}
|
190 |
}
|
| 179 |
boolean isAuthUser = false;
|
191 |
boolean isAuthUser = false;
|
| 180 |
List<String> authEmail = Arrays.asList("sm@smartdukaan.com", "gaurav.sharma@smartdukaan.com", "tejus.lohani@smartdukaan.com");
|
192 |
List<String> authEmail = Arrays.asList("sm@smartdukaan.com", "gaurav.sharma@smartdukaan.com", "tejus.lohani@smartdukaan.com");
|
| 181 |
isAuthUser = authEmail.stream().anyMatch(x -> x.equals(email));
|
193 |
isAuthUser = authEmail.stream().anyMatch(x -> x.equals(email));
|
| 182 |
List<LoiFormModel> pendingFormList = loiFormService.pendingFormList(email);
|
194 |
List<LoiFormModel> pendingFormList = loiFormService.pendingFormList(email);
|
| 183 |
LOGGER.info("pendingFormList {}", pendingFormList);
|
- |
|
| 184 |
model.addAttribute("isDocApprover", isDocApprover);
|
195 |
model.addAttribute("isDocApprover", isDocApprover);
|
| 185 |
model.addAttribute("isAuthUser", isAuthUser);
|
196 |
model.addAttribute("isAuthUser", isAuthUser);
|
| 186 |
model.addAttribute("pendingFormList", pendingFormList);
|
197 |
model.addAttribute("pendingFormList", pendingFormList);
|
| 187 |
return "pendingForm";
|
198 |
return "pendingForm";
|
| 188 |
}
|
199 |
}
|
| 189 |
|
200 |
|
| 190 |
// generate LOI for specific Form data
|
201 |
// generate LOI for specific Form data
|
| 191 |
@RequestMapping(value = "/generateLoi", method = RequestMethod.GET)
|
202 |
@RequestMapping(value = "/generateLoi", method = RequestMethod.GET)
|
| 192 |
public String generateLoi(HttpServletRequest request, @RequestParam int loiId, Model model) throws ProfitMandiBusinessException {
|
203 |
public String generateLoi(@RequestParam int loiId, Model model) throws ProfitMandiBusinessException {
|
| 193 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 194 |
int authId = authRepository.selectByEmailOrMobile(loginDetails.getEmailId()).getId();
|
- |
|
| 195 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
204 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 196 |
String filledBy = authRepository.selectByEmailOrMobile(loiForm.getFilledBy()).getFullName();
|
205 |
String filledBy = authRepository.selectByEmailOrMobile(loiForm.getFilledBy()).getFullName();
|
| 197 |
loiForm.setLoiGeneratedBy(authId);
|
- |
|
| 198 |
loiForm.setLoiGeneratedOn(LocalDateTime.now());
|
206 |
loiForm.setLoiGeneratedOn(LocalDateTime.now());
|
| 199 |
loiForm.setStatus(LoiStatus.LOI_GENERATED);
|
207 |
loiForm.setStatus(LoiStatus.LOI_GENERATED);
|
| 200 |
BrandFee brandFee = brandFeeRepository.selectById(1);
|
208 |
BrandFee brandFee = brandFeeRepository.selectById(1);
|
| 201 |
BrandFee givenFee = brandFeeRepository.selectById(loiForm.getBrandFeeId());
|
209 |
BrandFee givenFee = brandFeeRepository.selectById(loiForm.getBrandFeeId());
|
| 202 |
BillingAddress address = loiForm.getBillingAddress();
|
210 |
BillingAddress address = billingAddressRepository.selectByLoiFormId(loiId);
|
| - |
|
211 |
List<BrandFeeCollection> brandFeeCollections = brandFeeCollectionRepository.selectAllByLoiFormId(loiId);
|
| - |
|
212 |
List<LoiBrandCommitment> loiBrandCommitments = brandCommitmentRepository.selectByLoiId(loiId).stream().filter(x -> x.getAmount() > 0).collect(Collectors.toList());
|
| - |
|
213 |
double totalCommitment = loiBrandCommitments.stream().mapToDouble(x -> x.getAmount()).sum();
|
| 203 |
double brandFeeAmount = loiForm.getBrandFeeCollection().stream().filter(x -> x.getPaymentStatus().equals(FeePaymentStatus.CONFIRM)).mapToDouble(x -> x.getCollectedAmount()).sum();
|
214 |
double brandFeeAmount = brandFeeCollections.stream().filter(x -> x.getPaymentStatus().equals(FeePaymentStatus.CONFIRM)).mapToDouble(x -> x.getCollectedAmount()).sum();
|
| 204 |
BrandFeeCollection brandFeeCollection = loiForm.getBrandFeeCollection().get(0);
|
215 |
BrandFeeCollection brandFeeCollection = brandFeeCollections.get(0);
|
| - |
|
216 |
model.addAttribute("totalCommitment", totalCommitment);
|
| - |
|
217 |
model.addAttribute("loiBrandCommitments", loiBrandCommitments);
|
| 205 |
model.addAttribute("brandFeeAmount", brandFeeAmount);
|
218 |
model.addAttribute("brandFeeAmount", brandFeeAmount);
|
| 206 |
model.addAttribute("brandFee", brandFee);
|
219 |
model.addAttribute("brandFee", brandFee);
|
| 207 |
model.addAttribute("givenFee", givenFee);
|
220 |
model.addAttribute("givenFee", givenFee);
|
| 208 |
model.addAttribute("brandFeeCollection", brandFeeCollection);
|
221 |
model.addAttribute("brandFeeCollection", brandFeeCollection);
|
| 209 |
model.addAttribute("address", address);
|
222 |
model.addAttribute("address", address);
|
| 210 |
model.addAttribute("pod", loiForm);
|
223 |
model.addAttribute("loiForm", loiForm);
|
| 211 |
model.addAttribute("filledBy", filledBy);
|
224 |
model.addAttribute("filledBy", filledBy);
|
| 212 |
return "auto-Loi";
|
225 |
return "auto-Loi";
|
| 213 |
|
226 |
|
| 214 |
}
|
227 |
}
|
| 215 |
|
228 |
|
| 216 |
@RequestMapping(value = "/saveLoiDoc", method = RequestMethod.POST)
|
229 |
@RequestMapping(value = "/saveLoiDoc", method = RequestMethod.POST)
|
| 217 |
public String saveLoiDoc(@RequestParam int loiId, @RequestParam int loiDocId, Model model) throws Exception {
|
230 |
public String saveLoiDoc(@RequestParam int loiId, @RequestParam int loiDocId, Model model) throws Exception {
|
| 218 |
LOGGER.info("loi_docId-" + loiDocId);
|
231 |
LOGGER.info("loi_docId-" + loiDocId);
|
| 219 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
232 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 220 |
LOGGER.info("loiForm - " + loiForm);
|
- |
|
| 221 |
int loiDoc = loiForm.getLoiDoc();
|
233 |
int loiDoc = loiForm.getLoiDoc();
|
| 222 |
if (loiDoc == 0) {
|
234 |
if (loiDoc == 0) {
|
| 223 |
loiForm.setLoiDoc(loiDocId);
|
235 |
loiForm.setLoiDoc(loiDocId);
|
| 224 |
loiFormService.sendSignedLoiPdfToPartner(loiForm);
|
236 |
loiFormService.sendSignedLoiPdfToPartner(loiForm);
|
| 225 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
237 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| Line 230... |
Line 242... |
| 230 |
}
|
242 |
}
|
| 231 |
|
243 |
|
| 232 |
}
|
244 |
}
|
| 233 |
|
245 |
|
| 234 |
// send Filled form for update purpose
|
246 |
// send Filled form for update purpose
|
| 235 |
@RequestMapping(value = "/updateOnboardingForm", method = RequestMethod.GET)
|
247 |
@RequestMapping(value = "/updateLoiForm", method = RequestMethod.GET)
|
| 236 |
public String UpdateLoiForm(HttpServletRequest request,
|
248 |
public String UpdateLoiForm(HttpServletRequest request,
|
| 237 |
@RequestParam int loiId,
|
249 |
@RequestParam int loiId,
|
| 238 |
Model model) throws ProfitMandiBusinessException {
|
250 |
Model model) throws ProfitMandiBusinessException {
|
| 239 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
251 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 240 |
List<AuthUser> salesAuthList = loiFormService.getReferalAuthList();
|
- |
|
| 241 |
List<BrandFee> brandFee = brandFeeRepository.selectFeeOnDate(LocalDateTime.now());
|
- |
|
| 242 |
Set<Pair<StoreType, BrandFee>> storeTypeFeePairs = new HashSet<>();
|
- |
|
| 243 |
for (BrandFee fee : brandFee) {
|
- |
|
| 244 |
for (StoreType storeType : StoreType.values()) {
|
- |
|
| 245 |
storeTypeFeePairs.add(Pair.of(storeType, fee));
|
- |
|
| 246 |
}
|
- |
|
| 247 |
}
|
- |
|
| 248 |
model.addAttribute("storeTypeFeePairs", storeTypeFeePairs);
|
- |
|
| 249 |
model.addAttribute("authUsersList", salesAuthList);
|
252 |
model.addAttribute("updateForm", true);
|
| 250 |
model.addAttribute("onBoardingData", loiForm);
|
253 |
model.addAttribute("loiForm", loiForm);
|
| 251 |
return "partner-onboarding-form";
|
254 |
return "loiForm/update-loiForm";
|
| 252 |
}
|
255 |
}
|
| 253 |
|
256 |
|
| 254 |
@RequestMapping(value = "/updateLoiFormData", method = RequestMethod.POST)
|
257 |
@RequestMapping(value = "/updateLoiFormData", method = RequestMethod.POST)
|
| 255 |
public String UpdateLoiFormDetail(HttpServletRequest request,
|
258 |
public String UpdateLoiFormDetail(HttpServletRequest request,
|
| 256 |
@RequestParam int loiId,
|
259 |
@RequestParam int loiId,
|
| 257 |
@RequestBody LoiFormData partnerOnBoardingFormData,
|
260 |
@RequestBody LoiFormData loiFormData,
|
| 258 |
Model model) throws Exception {
|
261 |
Model model) throws Exception {
|
| 259 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 260 |
String email = loginDetails.getEmailId();
|
- |
|
| 261 |
loiFormService.updateLoiForm(partnerOnBoardingFormData, loiId);
|
262 |
loiFormService.updateLoiForm(loiFormData, loiId);
|
| 262 |
List<LoiFormModel> pendingFormList = loiFormService.pendingFormList(email);
|
- |
|
| 263 |
model.addAttribute("formList", pendingFormList);
|
- |
|
| 264 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
263 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 265 |
return "response";
|
264 |
return "response";
|
| 266 |
}
|
265 |
}
|
| 267 |
|
266 |
|
| 268 |
// TODO , add paymnet if brand fee due
|
267 |
// TODO , add paymnet if brand fee due
|
| 269 |
@RequestMapping(value = "/brandfeeCollection", method = RequestMethod.POST)
|
268 |
@RequestMapping(value = "/brandfeeCollection", method = RequestMethod.POST)
|
| 270 |
public String addBrandFee(HttpServletRequest request, @RequestBody BrandFeeCollection brandFeeCollection, @RequestParam int loiId, Model model) throws Exception {
|
269 |
public String addBrandFee(HttpServletRequest request, @RequestBody BrandFeeCollection brandFeeCollection, @RequestParam int loiId, Model model) throws Exception {
|
| 271 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
270 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 272 |
List<BrandFeeCollection> brandFeeCollections = loiForm.getBrandFeeCollection();
|
271 |
List<BrandFeeCollection> brandFeeCollections = brandFeeCollectionRepository.selectAllByLoiFormId(loiId);
|
| 273 |
double totatcollectedfee = brandFeeCollections.stream().filter(x -> x.getPaymentStatus().equals(FeePaymentStatus.CONFIRM) || x.getPaymentStatus().equals(FeePaymentStatus.PENDING)).mapToDouble(x -> x.getCollectedAmount()).sum();
|
272 |
double totatcollectedfee = brandFeeCollections.stream().filter(x -> x.getPaymentStatus().equals(FeePaymentStatus.CONFIRM) || x.getPaymentStatus().equals(FeePaymentStatus.PENDING)).mapToDouble(x -> x.getCollectedAmount()).sum();
|
| 274 |
double brandFee = loiForm.getAgreedBrandFees();
|
273 |
double brandFee = loiForm.getAgreedBrandFees();
|
| 275 |
double differanceAmount = brandFee - totatcollectedfee;
|
274 |
double differanceAmount = brandFee - totatcollectedfee;
|
| 276 |
if (totatcollectedfee + brandFeeCollection.getCollectedAmount() <= brandFee) {
|
275 |
if (totatcollectedfee + brandFeeCollection.getCollectedAmount() <= brandFee) {
|
| 277 |
brandFeeCollection.setTimeStamp(LocalDateTime.now());
|
- |
|
| 278 |
brandFeeCollection.setPaymentStatus(FeePaymentStatus.PENDING);
|
276 |
brandFeeCollection.setPaymentStatus(FeePaymentStatus.PENDING);
|
| 279 |
brandFeeCollection.setLoiData(loiForm);
|
277 |
brandFeeCollection.setLoiFormId(loiId);
|
| 280 |
brandFeeCollections.add(brandFeeCollection);
|
278 |
brandFeeCollectionRepository.persist(brandFeeCollection);
|
| 281 |
loiForm.setBrandFeeCollection(brandFeeCollections);
|
- |
|
| 282 |
loiFormService.sentMailToPaymentApprover(brandFeeCollection);
|
279 |
loiFormService.sentMailToPaymentApprover(brandFeeCollection);
|
| 283 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
280 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 284 |
return "response";
|
281 |
return "response";
|
| 285 |
} else {
|
282 |
} else {
|
| 286 |
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");
|
283 |
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");
|
| Line 294... |
Line 291... |
| 294 |
String email = loginDetails.getEmailId();
|
291 |
String email = loginDetails.getEmailId();
|
| 295 |
boolean isNiraj = false;
|
292 |
boolean isNiraj = false;
|
| 296 |
if (email.equals("neeraj.gupta@smartdukaan.com")) {
|
293 |
if (email.equals("neeraj.gupta@smartdukaan.com")) {
|
| 297 |
isNiraj = true;
|
294 |
isNiraj = true;
|
| 298 |
}
|
295 |
}
|
| 299 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
- |
|
| 300 |
List<BrandFeeCollection> brandFeeCollections = loiForm.getBrandFeeCollection();
|
296 |
List<BrandFeeCollection> brandFeeCollections = brandFeeCollectionRepository.selectAllByLoiFormId(loiId);
|
| 301 |
model.addAttribute("brandFeeCollections", brandFeeCollections);
|
297 |
model.addAttribute("brandFeeCollections", brandFeeCollections);
|
| 302 |
model.addAttribute("confirm", FeePaymentStatus.CONFIRM);
|
298 |
model.addAttribute("confirm", FeePaymentStatus.CONFIRM);
|
| 303 |
model.addAttribute("isNiraj", isNiraj);
|
299 |
model.addAttribute("isNiraj", isNiraj);
|
| 304 |
return "payment-collection-details";
|
300 |
return "payment-collection-details";
|
| 305 |
}
|
301 |
}
|
| Line 309... |
Line 305... |
| 309 |
public String feePaymentApproval(HttpServletRequest request, @RequestParam int bfcId, @RequestParam FeePaymentStatus feePaymentStatus, @RequestParam String description,
|
305 |
public String feePaymentApproval(HttpServletRequest request, @RequestParam int bfcId, @RequestParam FeePaymentStatus feePaymentStatus, @RequestParam String description,
|
| 310 |
Model model) throws Exception {
|
306 |
Model model) throws Exception {
|
| 311 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
307 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 312 |
String authEmail = loginDetails.getEmailId();
|
308 |
String authEmail = loginDetails.getEmailId();
|
| 313 |
BrandFeeCollection brandFeeCollection = brandFeeCollectionRepository.selectById(bfcId);
|
309 |
BrandFeeCollection brandFeeCollection = brandFeeCollectionRepository.selectById(bfcId);
|
| 314 |
LoiForm loiForm = brandFeeCollection.getLoiData();
|
310 |
LoiForm loiForm = loiFormRepository.selectById(brandFeeCollection.getLoiFormId());
|
| 315 |
List<BrandFeeCollection> brandFeeCollections = brandFeeCollectionRepository.selectAllConfirmPaymetByLoiForm(loiForm);
|
311 |
List<BrandFeeCollection> brandFeeCollections = brandFeeCollectionRepository.selectAllConfirmPaymetByLoiForm(brandFeeCollection.getLoiFormId());
|
| 316 |
brandFeeCollection.setApproverEmail(authEmail);
|
312 |
brandFeeCollection.setApproverEmail(authEmail);
|
| 317 |
brandFeeCollection.setPaymentStatus(feePaymentStatus);
|
313 |
brandFeeCollection.setPaymentStatus(feePaymentStatus);
|
| 318 |
brandFeeCollection.setDescription(description);
|
314 |
brandFeeCollection.setDescription(description);
|
| 319 |
double agreedBrandFee = loiForm.getAgreedBrandFees();
|
315 |
double agreedBrandFee = loiForm.getAgreedBrandFees();
|
| 320 |
double totalBrandFeeCollection = brandFeeCollections.stream().mapToDouble(x -> x.getCollectedAmount()).sum() + brandFeeCollection.getCollectedAmount();
|
316 |
double totalBrandFeeCollection = brandFeeCollections.stream().mapToDouble(x -> x.getCollectedAmount()).sum() + brandFeeCollection.getCollectedAmount();
|
| 321 |
LOGGER.info("agreedBrandeFee -" + agreedBrandFee);
|
- |
|
| 322 |
LOGGER.info("totalBrandFeeCollection -" + totalBrandFeeCollection);
|
- |
|
| 323 |
boolean b = agreedBrandFee == totalBrandFeeCollection && loiForm.getLoiSignOtp() != null;
|
- |
|
| 324 |
if (brandFeeCollection.getPaymentStatus().equals(FeePaymentStatus.REJECT)) {
|
317 |
if (brandFeeCollection.getPaymentStatus().equals(FeePaymentStatus.REJECT)) {
|
| 325 |
loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
|
318 |
loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
|
| 326 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
319 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
| 327 |
} else {
|
320 |
} else {
|
| 328 |
loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
|
321 |
loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
|
| Line 333... |
Line 326... |
| 333 |
}
|
326 |
}
|
| 334 |
return "response";
|
327 |
return "response";
|
| 335 |
|
328 |
|
| 336 |
}
|
329 |
}
|
| 337 |
|
330 |
|
| - |
|
331 |
|
| 338 |
@RequestMapping(value = "/uploadDocumentForm", method = RequestMethod.GET)
|
332 |
@RequestMapping(value = "/uploadDocumentForm", method = RequestMethod.GET)
|
| 339 |
public String uploadDocumentForm(HttpServletRequest request, @RequestParam int loiId, Model model) throws ProfitMandiBusinessException {
|
333 |
public String uploadDocumentForm(HttpServletRequest request, @RequestParam int loiId, Model model) throws ProfitMandiBusinessException {
|
| 340 |
List<LoiDocMaster> activeDocMasterList = loiDocMasterList.getAllActiveDoc();
|
334 |
List<LoiDocMaster> activeDocMasterList = loiDocMasterList.getAllActiveDoc();
|
| 341 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
335 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 342 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
336 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| Line 344... |
Line 338... |
| 344 |
String approverEmail = "gaurav.sharma@smartdukaan.com";
|
338 |
String approverEmail = "gaurav.sharma@smartdukaan.com";
|
| 345 |
boolean isApprover = false;
|
339 |
boolean isApprover = false;
|
| 346 |
if (authEmail.equals(approverEmail)) {
|
340 |
if (authEmail.equals(approverEmail)) {
|
| 347 |
isApprover = true;
|
341 |
isApprover = true;
|
| 348 |
}
|
342 |
}
|
| 349 |
Map<Integer, LoiDoc> masterDocIdLoiDocMap = loiForm.getLoiDocs().stream().collect(Collectors.toMap(x -> x.getMasterDocId(), x -> x));
|
343 |
Map<Integer, LoiDoc> masterDocIdLoiDocMap = loiDocRepository.selectLoiFormId(loiId).stream().collect(Collectors.toMap(x -> x.getMasterDocId(), x -> x));
|
| 350 |
model.addAttribute("isApprover", isApprover);
|
344 |
model.addAttribute("isApprover", isApprover);
|
| 351 |
model.addAttribute("loiId", loiId);
|
345 |
model.addAttribute("loiId", loiId);
|
| 352 |
model.addAttribute("activeDocMasterList", activeDocMasterList);
|
346 |
model.addAttribute("activeDocMasterList", activeDocMasterList);
|
| 353 |
model.addAttribute("masterDocIdLoiDocMap", masterDocIdLoiDocMap);
|
347 |
model.addAttribute("masterDocIdLoiDocMap", masterDocIdLoiDocMap);
|
| 354 |
return "loiForm/document-upload";
|
348 |
return "loiForm/document-upload";
|
| 355 |
}
|
349 |
}
|
| 356 |
|
350 |
|
| 357 |
@RequestMapping(value = "/uploadOnboardingDocument", method = RequestMethod.POST)
|
351 |
@RequestMapping(value = "/uploadOnboardingDocument", method = RequestMethod.POST)
|
| 358 |
public String uploadDocument(HttpServletRequest request, @RequestParam int loiId, @RequestBody List<LoiDocModel> loiDocModels, Model model) throws Exception {
|
352 |
public String uploadDocument(HttpServletRequest request, @RequestParam int loiId, @RequestBody List<LoiDocModel> loiDocModels, Model model) throws Exception {
|
| 359 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
353 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 360 |
LOGGER.info("loiForm - " + loiForm);
|
- |
|
| 361 |
LOGGER.info("loiDocModels - " + loiDocModels);
|
- |
|
| 362 |
loiFormService.setDocs(loiForm, loiDocModels);
|
354 |
loiFormService.setDocs(loiForm, loiDocModels);
|
| 363 |
model.addAttribute("response1", mvcResponseSender.createResponseString("Document uploaded successfully"));
|
355 |
model.addAttribute("response1", mvcResponseSender.createResponseString("Document uploaded successfully"));
|
| 364 |
return "response";
|
356 |
return "response";
|
| 365 |
|
357 |
|
| 366 |
}
|
358 |
}
|
| Line 377... |
Line 369... |
| 377 |
model.addAttribute("response1", mvcResponseSender.createResponseString(loiDoc.getDocType() + " is Accepted "));
|
369 |
model.addAttribute("response1", mvcResponseSender.createResponseString(loiDoc.getDocType() + " is Accepted "));
|
| 378 |
return "response";
|
370 |
return "response";
|
| 379 |
} else {
|
371 |
} else {
|
| 380 |
loiDoc.setOk(false);
|
372 |
loiDoc.setOk(false);
|
| 381 |
loiDoc.setVerifyBy(auth.getId());
|
373 |
loiDoc.setVerifyBy(auth.getId());
|
| 382 |
loiFormService.sendDocApprovalMail(loiDoc);
|
374 |
loiFormService.sendDocRejectionMail(loiDoc);
|
| 383 |
model.addAttribute("response1", mvcResponseSender.createResponseString(loiDoc.getDocType() + " is Rejected"));
|
375 |
model.addAttribute("response1", mvcResponseSender.createResponseString(loiDoc.getDocType() + " is Rejected"));
|
| 384 |
return "response";
|
376 |
return "response";
|
| 385 |
}
|
377 |
}
|
| 386 |
}
|
378 |
}
|
| 387 |
|
379 |
|
| 388 |
@RequestMapping(value = "/loiAcceptanceOtp", method = RequestMethod.POST)
|
380 |
@RequestMapping(value = "/loiAcceptanceOtp", method = RequestMethod.POST)
|
| 389 |
public String sentLoiAcceptanceOtp(@RequestParam int loiId, Model model) throws Exception {
|
381 |
public String sentLoiAcceptanceOtp(@RequestParam int loiId, Model model) throws Exception {
|
| 390 |
LoiForm pod = loiFormRepository.selectById(loiId);
|
382 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 391 |
String mobile = String.valueOf(pod.getMobile());
|
383 |
String mobile = String.valueOf(loiForm.getMobile());
|
| 392 |
OTPResponse otpResponse = otpProcessor.generateOtp(mobile, OtpType.LOI_ACCEPTANCE);
|
384 |
OTPResponse otpResponse = otpProcessor.generateOtp(mobile, OtpType.LOI_ACCEPTANCE);
|
| 393 |
String message = "OTP send to your register mobile number -";
|
385 |
String message = "OTP send on your register mobile and EmailId - ";
|
| 394 |
LOGGER.info("OTPResponse Message - " + otpResponse.getMessage());
|
386 |
LOGGER.info("OTPResponse Message - " + otpResponse.getMessage());
|
| 395 |
if (otpResponse.isResult()) {
|
387 |
if (otpResponse.isResult()) {
|
| 396 |
model.addAttribute("response1", mvcResponseSender.createResponseString(message + mobile));
|
388 |
model.addAttribute("response1", mvcResponseSender.createResponseString(message + mobile + " and " + loiForm.getEmail()));
|
| 397 |
return "response";
|
389 |
return "response";
|
| 398 |
} else {
|
390 |
} else {
|
| 399 |
model.addAttribute("response1", mvcResponseSender.createResponseString("Something went wrong.."));
|
391 |
model.addAttribute("response1", mvcResponseSender.createResponseString("Something went wrong.."));
|
| 400 |
return "response";
|
392 |
return "response";
|
| 401 |
}
|
393 |
}
|
| 402 |
}
|
394 |
}
|
| 403 |
|
395 |
|
| 404 |
@RequestMapping(value = "/validateLoiOtp", method = RequestMethod.PUT)
|
396 |
@RequestMapping(value = "/validateLoiOtp", method = RequestMethod.PUT)
|
| 405 |
public String validateLoiAcceptanceOtp(@RequestParam int loiId, @RequestParam String provideOtp, Model model) throws Exception {
|
397 |
public String validateLoiAcceptanceOtp(@RequestParam int loiId, @RequestParam String provideOtp, Model model) throws Exception {
|
| 406 |
LOGGER.info("loiId -" + loiId);
|
- |
|
| 407 |
LOGGER.info("provideOtp -" + provideOtp);
|
- |
|
| 408 |
LoiForm pod = loiFormRepository.selectById(loiId);
|
398 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 409 |
double brandFee = pod.getAgreedBrandFees();
|
399 |
double agreedBrandFees = loiForm.getAgreedBrandFees();
|
| 410 |
double totalCollectfee = pod.getBrandFeeCollection().stream().filter(x -> x.getPaymentStatus().equals(FeePaymentStatus.CONFIRM)).mapToDouble(x -> x.getCollectedAmount()).sum();
|
400 |
double totalCollectfee = brandFeeCollectionRepository.selectAllByLoiFormId(loiId).stream().filter(x -> x.getPaymentStatus().equals(FeePaymentStatus.CONFIRM)).mapToDouble(x -> x.getCollectedAmount()).sum();
|
| 411 |
String mobile = String.valueOf(pod.getMobile());
|
401 |
String mobile = String.valueOf(loiForm.getMobile());
|
| 412 |
Otp otp = otpRepository.selectAllByMobileWithTime(mobile).get(0);
|
402 |
Otp otp = otpRepository.selectAllByMobileWithTime(mobile).get(0);
|
| 413 |
LOGGER.info("otp-" + otp);
|
- |
|
| 414 |
OTPResponse otpResponse = otpProcessor.validateOtp(otp.getId(), mobile, provideOtp);
|
403 |
OTPResponse otpResponse = otpProcessor.validateOtp(otp.getId(), mobile, provideOtp);
|
| 415 |
if (!otpResponse.isResult()) {
|
404 |
if (!otpResponse.isResult()) {
|
| 416 |
throw new ProfitMandiBusinessException("Wrong OTP", provideOtp, "Your given Otp ->" + provideOtp + " is wrong , please check OTP and try again");
|
405 |
throw new ProfitMandiBusinessException("Wrong OTP", provideOtp, "Your given Otp ->" + provideOtp + " is wrong , please check OTP and try again");
|
| 417 |
}
|
406 |
}
|
| 418 |
if (otpResponse.isResult()) {
|
407 |
if (otpResponse.isResult()) {
|
| 419 |
pod.setLoiSignOtp(provideOtp);
|
408 |
loiForm.setLoiSignOtp(provideOtp);
|
| 420 |
pod.setLoiSignedOn(LocalDateTime.now());
|
409 |
loiForm.setLoiSignedOn(LocalDateTime.now());
|
| 421 |
if (brandFee == totalCollectfee && pod.getLoiSignOtp() != null) {
|
410 |
if (agreedBrandFees == totalCollectfee && loiForm.getLoiSignOtp() != null) {
|
| 422 |
pod.setStatus(LoiStatus.PRE_ONBOARDING_DONE);
|
411 |
loiForm.setStatus(LoiStatus.PRE_ONBOARDING_DONE);
|
| - |
|
412 |
|
| 423 |
} else {
|
413 |
} else {
|
| 424 |
pod.setStatus(LoiStatus.LOI_SIGNED);
|
414 |
loiForm.setStatus(LoiStatus.LOI_SIGNED);
|
| 425 |
}
|
415 |
}
|
| 426 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
416 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 427 |
}
|
417 |
}
|
| 428 |
return "response";
|
418 |
return "response";
|
| 429 |
}
|
419 |
}
|
| Line 437... |
Line 427... |
| 437 |
loiFormModel.setId(loiForm.getId());
|
427 |
loiFormModel.setId(loiForm.getId());
|
| 438 |
loiFormModel.setLoiFormFilledBy(authRepository.selectByEmailOrMobile(loiForm.getFilledBy()).getFullName());
|
428 |
loiFormModel.setLoiFormFilledBy(authRepository.selectByEmailOrMobile(loiForm.getFilledBy()).getFullName());
|
| 439 |
loiFormModel.setCompanyName(loiForm.getCompanyName());
|
429 |
loiFormModel.setCompanyName(loiForm.getCompanyName());
|
| 440 |
loiFormModel.setOwnerName(loiForm.getFullName());
|
430 |
loiFormModel.setOwnerName(loiForm.getFullName());
|
| 441 |
loiFormModel.setMobile(loiForm.getMobile());
|
431 |
loiFormModel.setMobile(loiForm.getMobile());
|
| 442 |
loiFormModel.setCity(loiForm.getBillingAddress().getLoc());
|
432 |
loiFormModel.setCity(billingAddressRepository.selectByLoiFormId(loiForm.getId()).getLoc());
|
| 443 |
loiFormModels.add(loiFormModel);
|
433 |
loiFormModels.add(loiFormModel);
|
| 444 |
}
|
434 |
}
|
| 445 |
List<EscalationType> EscalationTypeList = new ArrayList<>();
|
435 |
List<EscalationType> EscalationTypeList = new ArrayList<>();
|
| 446 |
EscalationTypeList.add(EscalationType.L2);
|
436 |
EscalationTypeList.add(EscalationType.L2);
|
| 447 |
EscalationTypeList.add(EscalationType.L1);
|
437 |
EscalationTypeList.add(EscalationType.L1);
|
| Line 469... |
Line 459... |
| 469 |
ResponseEntity<?> responseEntity = loiFormService.createLoiFormReport(from, to);
|
459 |
ResponseEntity<?> responseEntity = loiFormService.createLoiFormReport(from, to);
|
| 470 |
|
460 |
|
| 471 |
return responseEntity;
|
461 |
return responseEntity;
|
| 472 |
}
|
462 |
}
|
| 473 |
|
463 |
|
| - |
|
464 |
@RequestMapping(value = "/updatePayment", method = RequestMethod.POST)
|
| - |
|
465 |
public String updateForm(@RequestBody BrandFeeCollection brandFeeCollection, Model model) throws Exception {
|
| - |
|
466 |
BrandFeeCollection brandFeeCollection1 = brandFeeCollectionRepository.selectById(brandFeeCollection.getId());
|
| - |
|
467 |
brandFeeCollection1.setFeeCollectingTimeStamp(brandFeeCollection.getFeeCollectingTimeStamp());
|
| - |
|
468 |
brandFeeCollection1.setCollectedAmount(brandFeeCollection.getCollectedAmount());
|
| - |
|
469 |
brandFeeCollection1.setPaymentReferenceNo(brandFeeCollection.getPaymentReferenceNo());
|
| - |
|
470 |
brandFeeCollection1.setPaymentMode(brandFeeCollection.getPaymentMode());
|
| - |
|
471 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
472 |
return "response";
|
| - |
|
473 |
}
|
| 474 |
|
474 |
|
| 475 |
}
|
475 |
}
|