Subversion Repositories SmartDukaan

Rev

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

Rev 31991 Rev 32003
Line 615... Line 615...
615
 
615
 
616
    public void processSchemeOut(List<String> invoiceNumbers) throws Exception {
616
    public void processSchemeOut(List<String> invoiceNumbers) throws Exception {
617
        for (String invoiceNumber : invoiceNumbers) {
617
        for (String invoiceNumber : invoiceNumbers) {
618
            System.out.println("Invoice Number - " + invoiceNumber);
618
            System.out.println("Invoice Number - " + invoiceNumber);
619
            FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
619
            FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
620
            //orderService.reverseScheme(fofoOrder);
620
            //orderService.reverseScheme(fofoOrder);1
621
            schemeService.processSchemeOut(fofoOrder.getId(), fofoOrder.getFofoId());
621
            schemeService.processSchemeOut(fofoOrder.getId(), fofoOrder.getFofoId());
622
        }
622
        }
623
    }
623
    }
624
 
624
 
625
    public void processSchemeIn(List<String> invoiceNumbers) throws Exception {
625
    public void processSchemeIn(List<String> invoiceNumbers) throws Exception {
Line 694... Line 694...
694
    public void rollOutUpgardedMarginsNextMonth() throws Exception {
694
    public void rollOutUpgardedMarginsNextMonth() throws Exception {
695
        LocalDate startOfPreviousMonth = LocalDate.now().with(ChronoField.DAY_OF_MONTH, 1).minusMonths(1);
695
        LocalDate startOfPreviousMonth = LocalDate.now().with(ChronoField.DAY_OF_MONTH, 1).minusMonths(1);
696
 
696
 
697
        List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
697
        List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
698
        for (FofoStore store : stores) {
698
        for (FofoStore store : stores) {
699
            int fofoId = store.getId();
699
            this.rolloutMarginForStoreOnMonth(store, startOfPreviousMonth);
-
 
700
        }
-
 
701
    }
700
 
702
 
701
            PartnerType startOfPreviousMonthPartnerType = partnerTypeChangeService.getTypeOnDate(fofoId, startOfPreviousMonth);
-
 
702
            PartnerType todayPartnerType = partnerTypeChangeService.getTypeOnMonth(fofoId, YearMonth.from(startOfPreviousMonth.atStartOfDay()));
-
 
703
            if (!startOfPreviousMonthPartnerType.nextPartnerTypes().contains(todayPartnerType)) {
703
    public void rolloutMarginForStoreOnMonth(FofoStore store, LocalDate startOfMonth) throws ProfitMandiBusinessException {
704
                continue;
704
        int fofoId = store.getId();
705
            }
-
 
706
            if (!startOfPreviousMonthPartnerType.equals(todayPartnerType)) {
-
 
707
                LOGGER.info("Partner Type has been changed for code {} from {} to {}", store.getCode(), startOfPreviousMonthPartnerType, todayPartnerType);
-
 
708
                List<FofoOrder> fofoOrders = fofoOrderRepository.selectByFofoId(fofoId, startOfPreviousMonth.atStartOfDay(), startOfPreviousMonth.plusMonths(1).atStartOfDay(), 0, 0);
-
 
709
                for (FofoOrder fofoOrder : fofoOrders) {
-
 
710
                    schemeService.processSchemeOut(fofoOrder.getId(), fofoId);
-
 
711
                }
-
 
712
 
705
 
-
 
706
        PartnerType startOfPreviousMonthPartnerType = partnerTypeChangeService.getTypeOnDate(fofoId, startOfMonth);
-
 
707
        PartnerType todayPartnerType = partnerTypeChangeService.getTypeOnMonth(fofoId, YearMonth.from(startOfMonth.atStartOfDay()));
-
 
708
        if (!startOfPreviousMonthPartnerType.nextPartnerTypes().contains(todayPartnerType)) {
-
 
709
            return;
-
 
710
        }
-
 
711
        if (!startOfPreviousMonthPartnerType.equals(todayPartnerType)) {
-
 
712
            LOGGER.info("Partner Type has been changed for code {} from {} to {}", store.getCode(), startOfPreviousMonthPartnerType, todayPartnerType);
-
 
713
            List<FofoOrder> fofoOrders = fofoOrderRepository.selectByFofoId(fofoId, startOfMonth.atStartOfDay(), startOfMonth.plusMonths(1).atStartOfDay(), 0, 0);
-
 
714
            for (FofoOrder fofoOrder : fofoOrders) {
-
 
715
                schemeService.processSchemeOut(fofoOrder.getId(), fofoId);
713
            }
716
            }
714
        }
717
        }
715
    }
718
    }
716
 
719
 
-
 
720
 
717
    public void rollOutUpgardedMargins() throws Exception {
721
    public void rollOutUpgardedMargins() throws Exception {
718
        LocalDate today = LocalDate.now();
722
        LocalDate today = LocalDate.now();
719
        LocalDate yesterday = today.minusDays(1);
723
        LocalDate yesterday = today.minusDays(1);
720
        int upgradedCount = 0;
724
        int upgradedCount = 0;
721
        List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
725
        List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
Line 984... Line 988...
984
 
988
 
985
    @Autowired
989
    @Autowired
986
    BrandRegionMappingRepository brandRegionMappingRepository;
990
    BrandRegionMappingRepository brandRegionMappingRepository;
987
 
991
 
988
    public void test() throws Exception {
992
    public void test() throws Exception {
-
 
993
        partnerTypeChangeService.getTypeOnDate(175139287, LocalDate.of(2023,04, 01));
-
 
994
        FofoStore fs = fofoStoreRepository.selectByRetailerId(175139287);
-
 
995
        this.rolloutMarginForStoreOnMonth(fs, LocalDate.of(2023, 2, 1));
-
 
996
        this.rolloutMarginForStoreOnMonth(fs, LocalDate.of(2023, 3, 1));
-
 
997
 
989
        //this.sendMailForSamsungRebilling();
998
        //this.sendMailForSamsungRebilling();
990
        /*List<PurchaseReturnItem> purchaseReturnItems = purchaseReturnItemRepository.selectPurchaseReturnByStatuses(Arrays.asList(PurchaseReturnStatus.DEBIT_NOTE_CREATED));
999
        /*List<PurchaseReturnItem> purchaseReturnItems = purchaseReturnItemRepository.selectPurchaseReturnByStatuses(Arrays.asList(PurchaseReturnStatus.DEBIT_NOTE_CREATED));
991
        Map<Integer, List<PurchaseReturnItem>> inventoryItemsMap = purchaseReturnItems.stream().collect(Collectors.groupingBy(x -> x.getDebitNoteId()));
1000
        Map<Integer, List<PurchaseReturnItem>> inventoryItemsMap = purchaseReturnItems.stream().collect(Collectors.groupingBy(x -> x.getDebitNoteId()));
992
        for (Map.Entry<Integer, List<PurchaseReturnItem>> debitNotePurcahseReturnMap : inventoryItemsMap.entrySet()) {
1001
        for (Map.Entry<Integer, List<PurchaseReturnItem>> debitNotePurcahseReturnMap : inventoryItemsMap.entrySet()) {
993
            List<InventoryItem> inventoryItems = inventoryItemRepository.selectAllByIds(debitNotePurcahseReturnMap.getValue().stream().map(x -> x.getInventoryItemId()).collect(Collectors.toList()));
1002
            List<InventoryItem> inventoryItems = inventoryItemRepository.selectAllByIds(debitNotePurcahseReturnMap.getValue().stream().map(x -> x.getInventoryItemId()).collect(Collectors.toList()));
994
            offerService.reverseAdditionalSelloutSchemes(debitNotePurcahseReturnMap.getValue().get(0).getFofoId(), inventoryItems);
1003
            offerService.reverseAdditionalSelloutSchemes(debitNotePurcahseReturnMap.getValue().get(0).getFofoId(), inventoryItems);
995
        }*/
1004
        }*/
996
        this.sendMailForAgeingAlert();
1005
        //this.sendMailForAgeingAlert();
997
        //this.sendMailForAgeingAlert();
1006
        //this.sendMailForAgeingAlert();
998
        //System.out.println(brandRegionMappingRepository.getAvailabilityToVendorWarehouse(Arrays.asList(33353), 7720));
1007
        //System.out.println(brandRegionMappingRepository.getAvailabilityToVendorWarehouse(Arrays.asList(33353), 7720));
999
 
1008
 
1000
    }
1009
    }
1001
 
1010