Subversion Repositories SmartDukaan

Rev

Rev 37519 | Rev 37586 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
33917 ranu 1
package com.spice.profitmandi.service;
2
 
35672 ranu 3
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
37497 ranu 4
import com.spice.profitmandi.dao.entity.inventory.SalesTargets;
33917 ranu 5
import com.spice.profitmandi.dao.model.*;
6
import org.springframework.stereotype.Service;
7
 
8
import java.time.LocalDate;
9
import java.util.List;
10
 
11
@Service
12
public interface RbmTargetService {
13
 
14
    List<WarehouseRbmTargetModel> getWarehouseWiseRbmMonthlyTarget();
15
 
16
    List<MTDAchievedTargetModel> getDateWiseAchievedTargetOfRbm(LocalDate startDate, LocalDate endDate);
17
 
18
    List<WarehouseMobileStockByMovementModel> getWarehouseMobileStockByMovement();
19
 
33991 ranu 20
    List<SoldCatalogsReportModel> getCatalogSoldReport(LocalDate startDate, LocalDate endDate);
21
 
33917 ranu 22
    int getWorkingDaysCount(LocalDate startDate);
23
 
34055 ranu 24
    List<TodayAchievedMovementModel> getMovementWiseAchievementByDate(LocalDate startDate, LocalDate endDate);
33917 ranu 25
 
37442 ranu 26
    List<RbmBrandSoldModel> getBrandsSoldByRbm(int authId, int warehouseId, LocalDate startDate, LocalDate endDate);
27
 
37460 ranu 28
    List<RbmBrandPartnerCountModel> getBrandPartnerCountByRbm(int authId, int warehouseId, LocalDate startDate, LocalDate endDate);
29
 
37487 ranu 30
    List<WarehouseBuyingByMovementModel> getWarehouseBuyingByMovement(int warehouseId, LocalDate startDate, LocalDate endDate);
31
 
37497 ranu 32
    /**
33
     * Daily writer for Sales-hierarchy targets (mirrors {@link #setMovementWiseRbmTargets}).
34
     * Reads today's persisted RBM snapshots from inventory.rbm_targets, rolls them up per
35
     * (sales_auth_id × warehouse_id) for every active Sales person whose downline contains
36
     * at least one RBM, and inserts one row per (sales, warehouse) into inventory.sales_targets.
37
     * Intended to run once daily via the cron flag {@code pushSalesTargets},
38
     * chained after {@code pushRbmTargets}.
39
     */
40
    void setSalesTargets();
41
 
42
    /**
43
     * Same as {@link #setSalesTargets()} but for a specific date — reads that
44
     * day's persisted RBM snapshots and writes Sales snapshots stamped to that
45
     * day. Useful for backfilling missed cron runs or seeding local/staging
46
     * data without needing today's RBM snapshot.
47
     */
48
    void setSalesTargetsForDate(LocalDate date);
49
 
50
    List<SalesTargets> getSalesTargetsByDates(LocalDate startDate, LocalDate endDate);
51
 
52
    /**
53
     * Historical snapshot writer for Sales-hierarchy achievement (mirrors
54
     * {@link #setMovementWiseRbmAchievement}). Rolls up today's live order
55
     * ACH into one row per (Sales person × warehouse) and persists to
56
     * {@code inventory.sales_achievements} for later reconciliation.
57
     * The DRR dashboard reads ACH LIVE from orders — this table is audit only.
58
     */
59
    void setSalesAchievements();
60
 
61
    /**
62
     * Dated variant of {@link #setSalesAchievements()} for backfill.
63
     */
64
    void setSalesAchievementsForDate(LocalDate date);
65
 
37505 ranu 66
    /**
67
     * Per-(auth × warehouse) live achievement for a specific Sales-hierarchy role
68
     * (category 4, escalation L1..L6) in a date range. Direct query — no RBM roll-up.
69
     */
70
    List<SalesHierarchyAchievedByMovementModel> getSalesAchievementByRole(
71
            int categoryId, String escalationType, LocalDate startDate, LocalDate endDate);
72
 
73
    /**
74
     * Monthly target per (auth × warehouse) for a specific Sales-hierarchy role,
75
     * looked up for the month of {@code refDate}. Sum of
76
     * {@code fofo.monthly_target.purchase} across each Sales person's assigned partners.
77
     */
78
    List<SalesHierarchyMonthlyTargetModel> getSalesMonthlyTargetByRole(
79
            int categoryId, String escalationType, LocalDate refDate);
80
 
37519 ranu 81
    /**
82
     * Distinct-partner rolled-up ACH per warehouse for a set of Sales-hierarchy
83
     * auth_ids (RSM/NSM's downline). Dedupes partners across positions so overlapping
84
     * assignments don't double-count.
85
     */
86
    List<com.spice.profitmandi.dao.model.SalesDownlineAchievedByMovementModel>
87
    getSalesDownlineAchievement(java.util.Collection<Integer> authIds, LocalDate startDate, LocalDate endDate);
88
 
89
    /**
90
     * Distinct-partner rolled-up monthly target per warehouse for a set of
91
     * Sales-hierarchy auth_ids. Same dedup guarantee as
92
     * {@link #getSalesDownlineAchievement}.
93
     */
94
    List<com.spice.profitmandi.dao.model.SalesDownlineMonthlyTargetModel>
95
    getSalesDownlineMonthlyTarget(java.util.Collection<Integer> authIds, LocalDate refDate);
96
 
37533 ranu 97
    /**
98
     * Brand × movement-status sold by a set of Sales-hierarchy auth_ids in one
99
     * warehouse × date range. Works for both single-person views (pass one
100
     * authId) and RSM/NSM roll-ups (pass self + full downline). Dedupes
101
     * partners via SELECT DISTINCT.
102
     */
103
    List<com.spice.profitmandi.dao.model.SalesHierarchyBrandSoldModel>
104
    getSalesBrandsSold(java.util.Collection<Integer> authIds, int warehouseId, LocalDate startDate, LocalDate endDate);
105
 
106
    /**
107
     * Distinct partner count per brand for the same Sales-hierarchy auth_ids
108
     * set. Used for the "N partners" badge in the drill-down brand mix.
109
     */
110
    List<com.spice.profitmandi.dao.model.SalesHierarchyBrandPartnerCountModel>
111
    getSalesBrandPartnerCount(java.util.Collection<Integer> authIds, int warehouseId, LocalDate startDate, LocalDate endDate);
112
 
33997 ranu 113
    List<RbmTargetAndAchievementsModel> getRbmTargetsAndAchievemnts(LocalDate startDate, LocalDate endDate);
114
 
33917 ranu 115
    List<RbmArrViewModel> getRbmTodayArr(LocalDate todayDate) throws Exception;
116
 
117
    List<RbmArrViewModel> getRbmTodayArr() throws Exception;
118
 
33926 ranu 119
    void setMovementWiseRbmTargets();
120
 
33985 ranu 121
    void setMovementWiseRbmAchievement();
122
 
34055 ranu 123
    List<Sold15daysOldAgingModel> getAgingSale(LocalDate startDate, LocalDate endDate);
124
 
125
    List<Our15DaysOldAgingStock> our15DaysAgingStock();
126
 
36334 ranu 127
    List<WarehouseAgingStockModel> getWarehouseWiseAgingStock();
128
 
34103 ranu 129
    List<RbmBilledFofoIdsModel> getDateWiseBilledFofoIdByRbm(LocalDate startDate, LocalDate endDate);
130
 
35453 amit 131
    List<RbmWeeklyBillingModel> getWeeklyBillingDataForMonth(LocalDate monthStart, LocalDate monthEnd);
132
 
34641 ranu 133
    double calculateFofoIdTodayTarget(int fofoId, double secondryMtd, LocalDate date);
34880 ranu 134
 
135
    long getRemainingDaysInMonth(LocalDate date);
35631 ranu 136
 
137
    List<RbmCallTargetModel> getRbmCallTargetModels() throws Exception;
138
 
36234 ranu 139
    List<RbmCallTargetModel> getRbmCallTargetModels(LocalDate queryDate) throws Exception;
140
 
35631 ranu 141
    List<OutOfSequenceDetailModel> getOutOfSequenceDetails(int authId);
35645 ranu 142
 
35672 ranu 143
    List<CalledPartnerDetailModel> getCalledPartnerDetails(int authId) throws ProfitMandiBusinessException;
35670 ranu 144
 
35730 ranu 145
    List<CalledPartnerDetailModel> getCalledPartnerDetails(int authId, LocalDate date) throws ProfitMandiBusinessException;
146
 
35645 ranu 147
    List<List<String>> getRbmCallTargetRawDataByAuthId(int authId) throws Exception;
35852 ranu 148
 
149
    List<List<String>> getAllCallDataByDate(LocalDate date) throws Exception;
36596 ranu 150
 
151
    List<List<String>> getAllRbmCallTargetRawData() throws Exception;
33917 ranu 152
}