Subversion Repositories SmartDukaan

Rev

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

Rev 35530 Rev 35531
Line 711... Line 711...
711
    }
711
    }
712
 
712
 
713
    public void rolloutMarginForStoreOnMonth(FofoStore store, LocalDate startOfMonth) throws ProfitMandiBusinessException {
713
    public void rolloutMarginForStoreOnMonth(FofoStore store, LocalDate startOfMonth) throws ProfitMandiBusinessException {
714
        int fofoId = store.getId();
714
        int fofoId = store.getId();
715
 
715
 
-
 
716
        // Check if there's a manual partner type change on day 1 of the month
-
 
717
        PartnerTypeChange day1Change = partnerTypeChangeRepository.selectPartnerType(fofoId, startOfMonth);
-
 
718
        if (day1Change != null && day1Change.getSource() == PartnerTypeSource.MANUAL) {
-
 
719
            LOGGER.info("Manual partner type upgrade detected for code {} to {}", store.getCode(), day1Change.getPartnerType());
-
 
720
            List<FofoOrder> fofoOrders = fofoOrderRepository.selectByFofoId(fofoId, startOfMonth.atStartOfDay(), startOfMonth.plusMonths(1).atStartOfDay(), 0, 0);
-
 
721
            for (FofoOrder fofoOrder : fofoOrders) {
-
 
722
                schemeService.processSchemeOut(fofoOrder.getId(), fofoId);
-
 
723
            }
-
 
724
            return;
-
 
725
        }
-
 
726
 
-
 
727
        // Existing logic for calculated upgrades
716
        PartnerType startOfPreviousMonthPartnerType = partnerTypeChangeService.getTypeOnDate(fofoId, startOfMonth);
728
        PartnerType startOfPreviousMonthPartnerType = partnerTypeChangeService.getTypeOnDate(fofoId, startOfMonth);
717
        PartnerType todayPartnerType = partnerTypeChangeService.getTypeOnMonth(fofoId, YearMonth.from(startOfMonth));
729
        PartnerType todayPartnerType = partnerTypeChangeService.getTypeOnMonth(fofoId, YearMonth.from(startOfMonth));
718
        if (!startOfPreviousMonthPartnerType.nextPartnerTypes().contains(todayPartnerType)) {
730
        if (!startOfPreviousMonthPartnerType.nextPartnerTypes().contains(todayPartnerType)) {
719
            return;
731
            return;
720
        }
732
        }