Subversion Repositories SmartDukaan

Rev

Rev 35754 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35754 Rev 35971
Line 8... Line 8...
8
import com.spice.profitmandi.common.web.util.ResponseSender;
8
import com.spice.profitmandi.common.web.util.ResponseSender;
9
import com.spice.profitmandi.dao.entity.auth.AuthUser;
9
import com.spice.profitmandi.dao.entity.auth.AuthUser;
10
import com.spice.profitmandi.dao.entity.brandFee.BrandFee;
10
import com.spice.profitmandi.dao.entity.brandFee.BrandFee;
11
import com.spice.profitmandi.dao.entity.brandFee.BrandFeeCollection;
11
import com.spice.profitmandi.dao.entity.brandFee.BrandFeeCollection;
12
import com.spice.profitmandi.dao.entity.dtr.Otp;
12
import com.spice.profitmandi.dao.entity.dtr.Otp;
-
 
13
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
13
import com.spice.profitmandi.dao.entity.onBoarding.*;
14
import com.spice.profitmandi.dao.entity.onBoarding.*;
14
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
15
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
15
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
16
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
-
 
17
import com.spice.profitmandi.dao.enumuration.dtr.StoreTimeline;
16
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.FeePaymentStatus;
18
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.FeePaymentStatus;
17
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.LoiStatus;
19
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.LoiStatus;
18
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.StoreType;
20
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.StoreType;
19
import com.spice.profitmandi.dao.model.LoiFormModel;
21
import com.spice.profitmandi.dao.model.LoiFormModel;
20
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
22
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
Line 25... Line 27...
25
import com.spice.profitmandi.dao.repository.cs.CsService;
27
import com.spice.profitmandi.dao.repository.cs.CsService;
26
import com.spice.profitmandi.dao.repository.dtr.DistrictMasterRepository;
28
import com.spice.profitmandi.dao.repository.dtr.DistrictMasterRepository;
27
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
29
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
28
import com.spice.profitmandi.dao.repository.dtr.OtpRepository;
30
import com.spice.profitmandi.dao.repository.dtr.OtpRepository;
29
import com.spice.profitmandi.dao.repository.dtr.PartnerOnBoardingPanelRepository;
31
import com.spice.profitmandi.dao.repository.dtr.PartnerOnBoardingPanelRepository;
-
 
32
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
30
import com.spice.profitmandi.dao.repository.inventory.PartnerOnboardingService;
33
import com.spice.profitmandi.dao.repository.inventory.PartnerOnboardingService;
31
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
34
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
32
import com.spice.profitmandi.dao.repository.onboarding.*;
35
import com.spice.profitmandi.dao.repository.onboarding.*;
33
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
36
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
34
import com.spice.profitmandi.dao.repository.user.BillingAddressRepository;
37
import com.spice.profitmandi.dao.repository.user.BillingAddressRepository;
Line 124... Line 127...
124
    PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
127
    PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
125
    @Autowired
128
    @Autowired
126
    LoiAuditTrailRepository loiAuditTrailRepository;
129
    LoiAuditTrailRepository loiAuditTrailRepository;
127
 
130
 
128
    @Autowired
131
    @Autowired
-
 
132
    PaymentOptionRepository paymentOptionRepository;
-
 
133
 
-
 
134
    @Autowired
129
    ResponseSender responseSender;
135
    ResponseSender responseSender;
130
 
136
 
131
    List<String> agreedBrandFeeChangerEmail = Arrays.asList("sm@smartdukaan.com");
137
    List<String> agreedBrandFeeChangerEmail = Arrays.asList("sm@smartdukaan.com");
132
 
138
 
133
    // Loi Form
139
    // Loi Form
Line 146... Line 152...
146
        List<AuthUser> abmHeadList = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_ABM, Arrays.asList(EscalationType.L2, EscalationType.L3));
152
        List<AuthUser> abmHeadList = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_ABM, Arrays.asList(EscalationType.L2, EscalationType.L3));
147
        List<AuthUser> abmList = csService.getAuthUserByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_ABM, EscalationType.L1);
153
        List<AuthUser> abmList = csService.getAuthUserByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_ABM, EscalationType.L1);
148
        bdmList.addAll(abmList);
154
        bdmList.addAll(abmList);
149
        stateHeadList.addAll(abmHeadList);
155
        stateHeadList.addAll(abmHeadList);
150
        List<BrandCommit> brandCommits = brandCommitRepository.selectAllActiveBrand();
156
        List<BrandCommit> brandCommits = brandCommitRepository.selectAllActiveBrand();
-
 
157
        List<PaymentOption> paperFinanceOptions = paymentOptionRepository.selectAllPaperFinanceOption();
151
        model.addAttribute("businessTypes", BusinessType.values());
158
        model.addAttribute("businessTypes", BusinessType.values());
152
        model.addAttribute("brandCommits", brandCommits);
159
        model.addAttribute("brandCommits", brandCommits);
153
        model.addAttribute("storeTypeFeePairs", storeTypeFeePairs);
160
        model.addAttribute("storeTypeFeePairs", storeTypeFeePairs);
154
        model.addAttribute("authUsersList", authUsersList);
161
        model.addAttribute("authUsersList", authUsersList);
155
        model.addAttribute("stateHeadList", stateHeadList);
162
        model.addAttribute("stateHeadList", stateHeadList);
156
        model.addAttribute("bdmList", bdmList);
163
        model.addAttribute("bdmList", bdmList);
-
 
164
        model.addAttribute("paperFinanceOptions", paperFinanceOptions);
157
        return "loi-form";
165
        return "loi-form";
158
    }
166
    }
159
 
167
 
160
    // use to validate GSTIN
168
    // use to validate GSTIN
161
    @RequestMapping(value = "/gstValidate", method = RequestMethod.GET)
169
    @RequestMapping(value = "/gstValidate", method = RequestMethod.GET)
Line 287... Line 295...
287
        double differanceAmount = brandFee - totatcollectedfee;
295
        double differanceAmount = brandFee - totatcollectedfee;
288
        if (totatcollectedfee + brandFeeCollection.getCollectedAmount() <= brandFee) {
296
        if (totatcollectedfee + brandFeeCollection.getCollectedAmount() <= brandFee) {
289
            brandFeeCollection.setPaymentStatus(FeePaymentStatus.PENDING);
297
            brandFeeCollection.setPaymentStatus(FeePaymentStatus.PENDING);
290
            brandFeeCollection.setLoiFormId(loiId);
298
            brandFeeCollection.setLoiFormId(loiId);
291
            brandFeeCollectionRepository.persist(brandFeeCollection);
299
            brandFeeCollectionRepository.persist(brandFeeCollection);
292
//            loiFormService.sentMailToPaymentApprover(brandFeeCollection, loiForm);
300
            loiFormService.sentMailToPaymentApprover(brandFeeCollection, loiForm);
293
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
301
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
294
            return "response";
302
            return "response";
295
        } else {
303
        } else {
296
            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");
304
            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");
297
        }
305
        }
Line 323... Line 331...
323
        brandFeeCollection.setApproverEmail(authEmail);
331
        brandFeeCollection.setApproverEmail(authEmail);
324
        brandFeeCollection.setPaymentStatus(feePaymentStatus);
332
        brandFeeCollection.setPaymentStatus(feePaymentStatus);
325
        brandFeeCollection.setDescription(description);
333
        brandFeeCollection.setDescription(description);
326
        brandFeeCollection.setApprovalTimeStamp(LocalDateTime.now());
334
        brandFeeCollection.setApprovalTimeStamp(LocalDateTime.now());
327
        if (feePaymentStatus.equals(FeePaymentStatus.CONFIRM)) {
335
        if (feePaymentStatus.equals(FeePaymentStatus.CONFIRM)) {
-
 
336
            // Payment Approval timeline entry
-
 
337
            storeTimelineTatService.createStoreTimeline(brandFeeCollection.getLoiFormId(), StoreTimeline.PAYMENT_APPROVAL);
328
            loiFormService.checkLoiDetailsCompletion(loiFormRepository.selectById(brandFeeCollection.getLoiFormId()));
338
            loiFormService.checkLoiDetailsCompletion(loiFormRepository.selectById(brandFeeCollection.getLoiFormId()));
329
        }
339
        }
330
        loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
340
        loiFormService.sendPaymentStatusMailToLoiFormFilledBy(brandFeeCollection);
331
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
341
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
332
        return "response";
342
        return "response";
Line 377... Line 387...
377
        AuthUser auth = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
387
        AuthUser auth = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
378
        LoiDoc loiDoc = loiDocRepository.selectByLoiIdAndMasterDocId(loiId, docMasterId);
388
        LoiDoc loiDoc = loiDocRepository.selectByLoiIdAndMasterDocId(loiId, docMasterId);
379
        if (flag) {
389
        if (flag) {
380
            loiDoc.setOk(true);
390
            loiDoc.setOk(true);
381
            loiDoc.setVerifyBy(auth.getId());
391
            loiDoc.setVerifyBy(auth.getId());
-
 
392
            // Document Approval timeline entry
-
 
393
            storeTimelineTatService.createStoreTimeline(loiId, StoreTimeline.LOI_DOCUMENT_APPROVAL);
382
            model.addAttribute("response1", mvcResponseSender.createResponseString(loiDoc.getDocType() + " is Accepted "));
394
            model.addAttribute("response1", mvcResponseSender.createResponseString(loiDoc.getDocType() + " is Accepted "));
383
            return "response";
395
            return "response";
384
        } else {
396
        } else {
385
            loiDoc.setOk(false);
397
            loiDoc.setOk(false);
386
            loiDoc.setVerifyBy(auth.getId());
398
            loiDoc.setVerifyBy(auth.getId());
-
 
399
            LoiForm loiForm = loiFormRepository.selectById(loiId);
-
 
400
            if (loiForm.isLoiApproved()) {
-
 
401
                loiForm.setLoiApproved(false);
-
 
402
            }
387
            loiFormService.sendDocRejectionMail(loiDoc);
403
            loiFormService.sendDocRejectionMail(loiDoc);
388
            model.addAttribute("response1", mvcResponseSender.createResponseString(loiDoc.getDocType() + " is Rejected"));
404
            model.addAttribute("response1", mvcResponseSender.createResponseString(loiDoc.getDocType() + " is Rejected"));
389
            return "response";
405
            return "response";
390
        }
406
        }
391
    }
407
    }
Line 545... Line 561...
545
        boolean isAuthUser = authEmail.stream().anyMatch(x -> x.equals(email));
561
        boolean isAuthUser = authEmail.stream().anyMatch(x -> x.equals(email));
546
        if (flag) {
562
        if (flag) {
547
            if (isApprover || isAuthUser) {
563
            if (isApprover || isAuthUser) {
548
                loiForm.setLoiApprover(email);
564
                loiForm.setLoiApprover(email);
549
                loiForm.setLoiApproved(flag);
565
                loiForm.setLoiApproved(flag);
-
 
566
                if (loiForm.getStatus() == LoiStatus.LOI_REJECT) {
-
 
567
                    loiForm.setStatus(LoiStatus.PENDING);
-
 
568
                }
-
 
569
                // BM Approval timeline entry
-
 
570
                storeTimelineTatService.createStoreTimeline(loiId, StoreTimeline.BM_APPROVAL);
-
 
571
                // Check if all LOI conditions are now met (BM approval could be the last step)
-
 
572
                loiFormService.checkLoiDetailsCompletion(loiForm);
550
                model.addAttribute("response1", mvcResponseSender.createResponseString(true));
573
                model.addAttribute("response1", mvcResponseSender.createResponseString(true));
551
            } else {
574
            } else {
552
                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");
575
                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");
553
            }
576
            }
554
        } else {
577
        } else {