Subversion Repositories SmartDukaan

Rev

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

Rev 33848 Rev 33850
Line 406... Line 406...
406
    }
406
    }
407
 
407
 
408
    @RequestMapping(value = "/updatePayment", method = RequestMethod.POST)
408
    @RequestMapping(value = "/updatePayment", method = RequestMethod.POST)
409
    public String updateForm(@RequestBody BrandFeeCollection brandFeeCollection, Model model) throws Exception {
409
    public String updateForm(@RequestBody BrandFeeCollection brandFeeCollection, Model model) throws Exception {
410
        BrandFeeCollection brandFeeCollection1 = brandFeeCollectionRepository.selectById(brandFeeCollection.getId());
410
        BrandFeeCollection brandFeeCollection1 = brandFeeCollectionRepository.selectById(brandFeeCollection.getId());
411
        double totalConfirmPayment = brandFeeCollectionRepository.selectAllConfirmPaymetByLoiId(brandFeeCollection1.getLoiFormId()).stream().mapToDouble(x -> x.getCollectedAmount()).sum() + brandFeeCollection.getCollectedAmount();
-
 
412
        double totalCollection = totalConfirmPayment + brandFeeCollection.getCollectedAmount();
-
 
413
        LoiForm loiForm = loiFormRepository.selectById(brandFeeCollection1.getLoiFormId());
411
        LoiForm loiForm = loiFormRepository.selectById(brandFeeCollection1.getLoiFormId());
414
        if (totalCollection <= loiForm.getAgreedBrandFees()) {
-
 
415
            brandFeeCollection1.setFeeCollectingTimeStamp(brandFeeCollection.getFeeCollectingTimeStamp());
412
        brandFeeCollection1.setFeeCollectingTimeStamp(brandFeeCollection.getFeeCollectingTimeStamp());
416
            brandFeeCollection1.setCollectedAmount(brandFeeCollection.getCollectedAmount());
413
        brandFeeCollection1.setCollectedAmount(brandFeeCollection.getCollectedAmount());
417
            brandFeeCollection1.setPaymentReferenceNo(brandFeeCollection.getPaymentReferenceNo());
414
        brandFeeCollection1.setPaymentReferenceNo(brandFeeCollection.getPaymentReferenceNo());
418
            brandFeeCollection1.setPaymentMode(brandFeeCollection.getPaymentMode());
415
        brandFeeCollection1.setPaymentMode(brandFeeCollection.getPaymentMode());
-
 
416
        double totalCollectedFee = brandFeeCollectionRepository.selectAllByLoiFormId(loiForm.getId()).stream().mapToDouble(x -> x.getCollectedAmount()).sum();
-
 
417
        if (totalCollectedFee <= loiForm.getAgreedBrandFees()) {
419
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
418
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
420
        } else {
419
        } else {
421
            double differanceAmount = loiForm.getAgreedBrandFees() - totalConfirmPayment;
420
            double differanceAmount = totalCollectedFee - loiForm.getAgreedBrandFees();
422
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
-
 
423
            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");
421
            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");
424
        }
422
        }
425
        return "response";
423
        return "response";
426
    }
424
    }
427
 
425
 
Line 462... Line 460...
462
        if (flag) {
460
        if (flag) {
463
            if (isApprover || isAuthUser) {
461
            if (isApprover || isAuthUser) {
464
                loiForm.setLoiApprover(email);
462
                loiForm.setLoiApprover(email);
465
                loiForm.setLoiApproved(flag);
463
                loiForm.setLoiApproved(flag);
466
                model.addAttribute("response1", mvcResponseSender.createResponseString(true));
464
                model.addAttribute("response1", mvcResponseSender.createResponseString(true));
-
 
465
                loiFormService.checkLoiDetailsCompletion(loiForm);
467
            } else {
466
            } else {
468
                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");
467
                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");
469
            }
468
            }
470
        } else {
469
        } else {
471
            if (isApprover || isAuthUser) {
470
            if (isApprover || isAuthUser) {