Subversion Repositories SmartDukaan

Rev

Rev 37919 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37919 Rev 37921
Line 40... Line 40...
40
import com.spice.profitmandi.dao.repository.user.*;
40
import com.spice.profitmandi.dao.repository.user.*;
41
import com.spice.profitmandi.dao.service.LoiDocModel;
41
import com.spice.profitmandi.dao.service.LoiDocModel;
42
import com.spice.profitmandi.dao.service.OTPResponse;
42
import com.spice.profitmandi.dao.service.OTPResponse;
43
import com.spice.profitmandi.dao.service.OtpProcessor;
43
import com.spice.profitmandi.dao.service.OtpProcessor;
44
import com.spice.profitmandi.dao.service.loiForm.LoiFormService;
44
import com.spice.profitmandi.dao.service.loiForm.LoiFormService;
-
 
45
import com.spice.profitmandi.service.AuthService;
45
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
46
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
46
import com.spice.profitmandi.service.integrations.gstpro.entity.GstDetails;
47
import com.spice.profitmandi.service.integrations.gstpro.entity.GstDetails;
47
import com.spice.profitmandi.service.user.StoreTimelineTatService;
48
import com.spice.profitmandi.service.user.StoreTimelineTatService;
48
import com.spice.profitmandi.web.model.LoginDetails;
49
import com.spice.profitmandi.web.model.LoginDetails;
49
import com.spice.profitmandi.web.util.CookiesProcessor;
50
import com.spice.profitmandi.web.util.CookiesProcessor;
Line 144... Line 145...
144
 
145
 
145
    @Autowired
146
    @Autowired
146
    RbmAssignmentRepository rbmAssignmentRepository;
147
    RbmAssignmentRepository rbmAssignmentRepository;
147
 
148
 
148
    @Autowired
149
    @Autowired
-
 
150
    AuthService authService;
-
 
151
 
-
 
152
    @Autowired
149
    PartnerDashboardTrainingRepository partnerDashboardTrainingRepository;
153
    PartnerDashboardTrainingRepository partnerDashboardTrainingRepository;
150
 
154
 
151
    @Autowired
155
    @Autowired
152
    ResponseSender responseSender;
156
    ResponseSender responseSender;
153
 
157
 
Line 652... Line 656...
652
    public String approveDetails(HttpServletRequest request, @RequestParam int loiId, @RequestParam boolean flag, Model model) throws Exception {
656
    public String approveDetails(HttpServletRequest request, @RequestParam int loiId, @RequestParam boolean flag, Model model) throws Exception {
653
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
657
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
654
        String email = loginDetails.getEmailId();
658
        String email = loginDetails.getEmailId();
655
        LoiForm loiForm = loiFormRepository.selectById(loiId);
659
        LoiForm loiForm = loiFormRepository.selectById(loiId);
656
        AuthUser filledBy = authRepository.selectByEmailOrMobile(loiForm.getFilledBy());
660
        AuthUser filledBy = authRepository.selectByEmailOrMobile(loiForm.getFilledBy());
657
        AuthUser manager = authRepository.selectById(filledBy.getManagerId());
661
        // Approver chain = every manager above the filler. Previously hardcoded to
-
 
662
        // (immediate manager, grandmanager) which NPE'd whenever the filler sat near
-
 
663
        // the top of the hierarchy — common now that upper-level users fill LOIs on
-
 
664
        // behalf of their reportees (filledBy = themselves). Walk the full chain so
658
        AuthUser upperManager = null;
665
        // any ancestor can approve, and null-guard every hop.
659
        List<String> approverMail = new ArrayList<>();
666
        List<String> approverMail = new ArrayList<>();
660
        approverMail.add(manager.getEmailId());
667
        if (filledBy != null) {
661
        upperManager = authRepository.selectById(manager.getManagerId());
668
            for (AuthUser ancestor : authService.getAllManagers(filledBy.getId())) {
-
 
669
                if (ancestor != null && ancestor.getEmailId() != null) {
662
        approverMail.add(upperManager.getEmailId());
670
                    approverMail.add(ancestor.getEmailId());
-
 
671
                }
-
 
672
            }
-
 
673
        }
663
 
674
 
664
        LOGGER.info("approverMail-" + approverMail);
675
        LOGGER.info("approverMail-" + approverMail);
665
        // Approver - Manager or Upper manager of loi filledBy(BM)
676
        // Approver - Manager or Upper manager of loi filledBy(BM)
666
        boolean isApprover = approverMail.contains(email);
677
        boolean isApprover = approverMail.contains(email);
667
        LOGGER.info("isApprover-" + isApprover);
678
        LOGGER.info("isApprover-" + isApprover);