Subversion Repositories SmartDukaan

Rev

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

Rev 34503 Rev 34504
Line 17... Line 17...
17
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
17
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
18
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
18
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
19
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
19
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
20
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
20
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
21
import com.spice.profitmandi.dao.enumuration.catalog.StockTransactionType;
21
import com.spice.profitmandi.dao.enumuration.catalog.StockTransactionType;
-
 
22
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
22
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
23
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
23
import com.spice.profitmandi.dao.model.AmountModel;
24
import com.spice.profitmandi.dao.model.AmountModel;
24
import com.spice.profitmandi.dao.model.CreateSchemeRequest;
25
import com.spice.profitmandi.dao.model.CreateSchemeRequest;
25
import com.spice.profitmandi.dao.repository.catalog.*;
26
import com.spice.profitmandi.dao.repository.catalog.*;
26
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
27
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
27
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
28
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
28
import com.spice.profitmandi.dao.repository.fofo.*;
29
import com.spice.profitmandi.dao.repository.fofo.*;
29
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
30
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
30
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
31
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
31
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
32
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
-
 
33
import com.spice.profitmandi.dao.repository.warehouse.AgeingSummaryModel;
32
import com.spice.profitmandi.dao.repository.warehouse.WarehouseInventoryItemRepository;
34
import com.spice.profitmandi.dao.repository.warehouse.WarehouseInventoryItemRepository;
33
import com.spice.profitmandi.service.NotificationService;
35
import com.spice.profitmandi.service.NotificationService;
34
import com.spice.profitmandi.service.authentication.RoleManager;
36
import com.spice.profitmandi.service.authentication.RoleManager;
35
import com.spice.profitmandi.service.inventory.AgeingService;
37
import com.spice.profitmandi.service.inventory.AgeingService;
36
import com.spice.profitmandi.service.inventory.PurchaseService;
38
import com.spice.profitmandi.service.inventory.PurchaseService;
Line 56... Line 58...
56
import javax.persistence.criteria.Root;
58
import javax.persistence.criteria.Root;
57
import java.text.MessageFormat;
59
import java.text.MessageFormat;
58
import java.time.LocalDate;
60
import java.time.LocalDate;
59
import java.time.LocalDateTime;
61
import java.time.LocalDateTime;
60
import java.time.LocalTime;
62
import java.time.LocalTime;
-
 
63
import java.time.YearMonth;
61
import java.util.*;
64
import java.util.*;
62
import java.util.stream.Collectors;
65
import java.util.stream.Collectors;
63
 
66
 
64
@Component
67
@Component
65
public class SchemeServiceImpl implements SchemeService {
68
public class SchemeServiceImpl implements SchemeService {
Line 432... Line 435...
432
    OfferPayoutRepository offerPayoutRepository;
435
    OfferPayoutRepository offerPayoutRepository;
433
    @Autowired
436
    @Autowired
434
    AgeingService ageingService;
437
    AgeingService ageingService;
435
 
438
 
436
    public void processSchemeIn(int purchaseId, int retailerId) throws ProfitMandiBusinessException {
439
    public void processSchemeIn(int purchaseId, int retailerId) throws ProfitMandiBusinessException {
437
        /*LOGGER.info("Processing scheme in  for purchaseId - {}", purchaseId);
440
        LOGGER.info("Processing scheme in  for purchaseId - {}", purchaseId);
438
        Purchase purchase = purchaseRepository.selectByIdAndFofoId(purchaseId, retailerId);
441
        Purchase purchase = purchaseRepository.selectByIdAndFofoId(purchaseId, retailerId);
439
        PartnerType partnerType = partnerTypeChangeService.getTypeOnMonth(retailerId,
442
        PartnerType partnerType = partnerTypeChangeService.getTypeOnMonth(retailerId,
440
                YearMonth.from(purchase.getCreateTimestamp()));
443
                YearMonth.from(purchase.getCreateTimestamp()));
441
        List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchaseId);
444
        List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchaseId);
442
        //Remove imeis from blocked imeis list
445
        //Remove imeis from blocked imeis list
Line 467... Line 470...
467
 
470
 
468
        int itemsCount = 0;
471
        int itemsCount = 0;
469
        float totalCashback = 0;
472
        float totalCashback = 0;
470
        for (Map.Entry<CatalogSummaryModel, List<SchemeSummaryModel>> catalogSummaryModelListEntry : catalogSchemeSummaryMap.entrySet()) {
473
        for (Map.Entry<CatalogSummaryModel, List<SchemeSummaryModel>> catalogSummaryModelListEntry : catalogSchemeSummaryMap.entrySet()) {
471
            CatalogSummaryModel catalogSummaryModel = catalogSummaryModelListEntry.getKey();
474
            CatalogSummaryModel catalogSummaryModel = catalogSummaryModelListEntry.getKey();
472
            List<SchemeSummaryModel> schemeSummaryModels = catalogSummaryModelListEntry.getValue().stream().filter(x -> x != null).collect(Collectors.toList());
475
            List<SchemeSummaryModel> schemeSummaryModels = catalogSummaryModelListEntry.getValue().stream().filter(Objects::nonNull).collect(Collectors.toList());
473
            schemeSummaryModels.stream().filter(x -> x != null && x.getSchemeType().getTransactionType().equals(StockTransactionType.IN)).forEach(x -> x.setProcess(true));
476
            schemeSummaryModels.stream().filter(x -> x != null && x.getSchemeType().getTransactionType().equals(StockTransactionType.IN)).forEach(x -> x.setProcess(true));
474
            if (schemeSummaryModels.stream().filter(x -> x.isProcess()).count() == 0) continue;
477
            if (schemeSummaryModels.stream().filter(x -> x.isProcess()).count() == 0) continue;
475
            List<InventoryItem> modelInventoryItems = catalogInventoryItemMap.get(catalogSummaryModel.getCatalogId());
478
            List<InventoryItem> modelInventoryItems = catalogInventoryItemMap.get(catalogSummaryModel.getCatalogId());
476
            for (InventoryItem inventoryItem : modelInventoryItems) {
479
            for (InventoryItem inventoryItem : modelInventoryItems) {
477
                float inventoryItemCashback = this.createSchemeInOut(schemeSummaryModels, inventoryItem);
480
                float inventoryItemCashback = this.createSchemeInOut(schemeSummaryModels, inventoryItem);
Line 489... Line 492...
489
                    retailerId, purchaseId, WalletReferenceType.SCHEME_IN, "Added for SCHEME IN against invoice "
492
                    retailerId, purchaseId, WalletReferenceType.SCHEME_IN, "Added for SCHEME IN against invoice "
490
                            + purchase.getPurchaseReference() + " (total " + itemsCount + " pcs)",
493
                            + purchase.getPurchaseReference() + " (total " + itemsCount + " pcs)",
491
                    totalCashback, purchase.getCreateTimestamp());
494
                    totalCashback, purchase.getCreateTimestamp());
492
            LOGGER.info("Added Rs.{} for SCHEME IN against invoice {} total pcs({}) {}", totalCashback,
495
            LOGGER.info("Added Rs.{} for SCHEME IN against invoice {} total pcs({}) {}", totalCashback,
493
                    purchase.getPurchaseReference(), itemsCount);
496
                    purchase.getPurchaseReference(), itemsCount);
494
        }*/
497
        }
495
 
498
 
496
    }
499
    }
497
 
500
 
498
 
501
 
499
    // We are maintaining price drop after grn
502
    // We are maintaining price drop after grn
Line 681... Line 684...
681
    @Autowired
684
    @Autowired
682
    WarehouseInventoryItemRepository warehouseInventoryItemRepository;
685
    WarehouseInventoryItemRepository warehouseInventoryItemRepository;
683
 
686
 
684
    @Override
687
    @Override
685
    public float processSchemeOut(int fofoOrderId, int retailerId) throws ProfitMandiBusinessException {
688
    public float processSchemeOut(int fofoOrderId, int retailerId) throws ProfitMandiBusinessException {
686
        /*float totalCashback = 0;
689
        float totalCashback = 0;
687
        FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(retailerId, fofoOrderId);
690
        FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(retailerId, fofoOrderId);
688
        // Process only if order is not cancelled
691
        // Process only if order is not cancelled
689
        if (fofoOrder.getCancelledTimestamp() == null) {
692
        if (fofoOrder.getCancelledTimestamp() == null) {
690
            // PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(retailerId,
693
            // PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(retailerId,
691
            // fofoOrder.getCreateTimestamp().toLocalDate());
694
            // fofoOrder.getCreateTimestamp().toLocalDate());
Line 757... Line 760...
757
                                + fofoOrder.getInvoiceNumber() + ". Total " + count + " pc(s)",
760
                                + fofoOrder.getInvoiceNumber() + ". Total " + count + " pc(s)",
758
                        totalCashback, fofoOrder.getCreateTimestamp());
761
                        totalCashback, fofoOrder.getCreateTimestamp());
759
                fofoOrder.setCashback(totalCashback + fofoOrder.getCashback());
762
                fofoOrder.setCashback(totalCashback + fofoOrder.getCashback());
760
            }
763
            }
761
        }
764
        }
762
        return totalCashback;*/
765
        return totalCashback;
763
        return 0;
-
 
764
    }
766
    }
765
 
767
 
766
    @Override
768
    @Override
767
    //Tax rate has been passed to 0 to ensure no tax deduction
769
    //Tax rate has been passed to 0 to ensure no tax deduction
768
    public float getSpecialSupportAmount(float supportAmount, PartnerType partnerType, LocalDate onDate,
770
    public float getSpecialSupportAmount(float supportAmount, PartnerType partnerType, LocalDate onDate,