Subversion Repositories SmartDukaan

Rev

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

Rev 34404 Rev 34641
Line 455... Line 455...
455
 
455
 
456
    @Autowired
456
    @Autowired
457
    OrderRepository orderRepository;
457
    OrderRepository orderRepository;
458
 
458
 
459
    @Override
459
    @Override
460
    public double calculateFofoIdTodayTarget(int fofoId, double secondryMtd) {
460
    public double calculateFofoIdTodayTarget(int fofoId, double secondryMtd,LocalDate date) {
461
 
-
 
462
        LocalDate todayDate = LocalDate.now();
-
 
463
 
461
 
464
        MonthlyTarget monthlyTarget = monthlyTargetRepository.selectByDateAndFofoId(YearMonth.now(), fofoId);
462
        MonthlyTarget monthlyTarget = monthlyTargetRepository.selectByDateAndFofoId(YearMonth.now(), fofoId);
465
        if (monthlyTarget == null) {
463
        if (monthlyTarget == null) {
466
            // Log or handle as needed
464
            // Log or handle as needed
467
            return 0; // or -1 or some fallback
465
            return 0; // or -1 or some fallback
468
        }
466
        }
469
 
467
 
470
        double remainingTarget = monthlyTarget.getPurchaseTarget() - secondryMtd;
468
        double remainingTarget = monthlyTarget.getPurchaseTarget() - secondryMtd;
471
 
469
 
472
        double remainingWorkingDays = getWorkingDaysCount(todayDate);
470
        double remainingWorkingDays = getWorkingDaysCount(date);
473
 
471
 
474
        if (remainingWorkingDays == 0) return remainingTarget; // Last day
472
        if (remainingWorkingDays == 0) return remainingTarget; // Last day
475
 
473
 
476
        return (int) Math.ceil(remainingTarget / remainingWorkingDays);
474
        return (int) Math.ceil(remainingTarget / remainingWorkingDays);
477
    }
475
    }