Subversion Repositories SmartDukaan

Rev

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

Rev 34370 Rev 34382
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 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 758... Line 761...
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
         */
-
 
764
        return 0;
-
 
765
    }
766
    }
766
 
767
 
767
    @Override
768
    @Override
768
    //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
769
    public float getSpecialSupportAmount(float supportAmount, PartnerType partnerType, LocalDate onDate,
770
    public float getSpecialSupportAmount(float supportAmount, PartnerType partnerType, LocalDate onDate,
Line 1200... Line 1201...
1200
                pendingPayout.setCreditTimestamp(LocalDateTime.now());
1201
                pendingPayout.setCreditTimestamp(LocalDateTime.now());
1201
                pendingPayout.setStatus(SchemePayoutStatus.CREDITED);
1202
                pendingPayout.setStatus(SchemePayoutStatus.CREDITED);
1202
            } else {
1203
            } else {
1203
                pendingPayout.setStatus(SchemePayoutStatus.REJECTED);
1204
                pendingPayout.setStatus(SchemePayoutStatus.REJECTED);
1204
                pendingPayout.setRolledBackTimestamp(LocalDateTime.now());
1205
                pendingPayout.setRolledBackTimestamp(LocalDateTime.now());
1205
                ;
-
 
1206
                pendingPayout.setStatusDescription(
1206
                pendingPayout.setStatusDescription(
1207
                        "Rejected, activated on " + FormattingUtils.formatDate(activatedImei.getActivationTimestamp()));
1207
                        "Rejected, activated on " + FormattingUtils.formatDate(activatedImei.getActivationTimestamp()));
1208
            }
1208
            }
1209
        }
1209
        }
1210
    }
1210
    }