Subversion Repositories SmartDukaan

Rev

Rev 37533 | 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
    /**
37586 ranu 33
     * Opening stock value per movement class for a warehouse at the start of a period.
34
     * Used by the RBM DRR drill-down "Warehouse Flow" table to contextualise the
35
     * period's buying/selling ratio against stock that already existed before the
36
     * period.
37
     *
38
     * @param warehouseId warehouse whose opening we want
39
     * @param asOfDate    the period start; everything received before this date
40
     *                    and everything sold before this date contribute
41
     */
42
    List<WarehouseOpeningByMovementModel> getWarehouseOpeningByMovement(int warehouseId, LocalDate asOfDate);
43
 
44
    /**
37497 ranu 45
     * Daily writer for Sales-hierarchy targets (mirrors {@link #setMovementWiseRbmTargets}).
46
     * Reads today's persisted RBM snapshots from inventory.rbm_targets, rolls them up per
47
     * (sales_auth_id × warehouse_id) for every active Sales person whose downline contains
48
     * at least one RBM, and inserts one row per (sales, warehouse) into inventory.sales_targets.
49
     * Intended to run once daily via the cron flag {@code pushSalesTargets},
50
     * chained after {@code pushRbmTargets}.
51
     */
52
    void setSalesTargets();
53
 
54
    /**
55
     * Same as {@link #setSalesTargets()} but for a specific date — reads that
56
     * day's persisted RBM snapshots and writes Sales snapshots stamped to that
57
     * day. Useful for backfilling missed cron runs or seeding local/staging
58
     * data without needing today's RBM snapshot.
59
     */
60
    void setSalesTargetsForDate(LocalDate date);
61
 
62
    List<SalesTargets> getSalesTargetsByDates(LocalDate startDate, LocalDate endDate);
63
 
64
    /**
65
     * Historical snapshot writer for Sales-hierarchy achievement (mirrors
66
     * {@link #setMovementWiseRbmAchievement}). Rolls up today's live order
67
     * ACH into one row per (Sales person × warehouse) and persists to
68
     * {@code inventory.sales_achievements} for later reconciliation.
69
     * The DRR dashboard reads ACH LIVE from orders — this table is audit only.
70
     */
71
    void setSalesAchievements();
72
 
73
    /**
74
     * Dated variant of {@link #setSalesAchievements()} for backfill.
75
     */
76
    void setSalesAchievementsForDate(LocalDate date);
77
 
37505 ranu 78
    /**
79
     * Per-(auth × warehouse) live achievement for a specific Sales-hierarchy role
80
     * (category 4, escalation L1..L6) in a date range. Direct query — no RBM roll-up.
81
     */
82
    List<SalesHierarchyAchievedByMovementModel> getSalesAchievementByRole(
83
            int categoryId, String escalationType, LocalDate startDate, LocalDate endDate);
84
 
85
    /**
86
     * Monthly target per (auth × warehouse) for a specific Sales-hierarchy role,
87
     * looked up for the month of {@code refDate}. Sum of
88
     * {@code fofo.monthly_target.purchase} across each Sales person's assigned partners.
89
     */
90
    List<SalesHierarchyMonthlyTargetModel> getSalesMonthlyTargetByRole(
91
            int categoryId, String escalationType, LocalDate refDate);
92
 
37519 ranu 93
    /**
94
     * Distinct-partner rolled-up ACH per warehouse for a set of Sales-hierarchy
95
     * auth_ids (RSM/NSM's downline). Dedupes partners across positions so overlapping
96
     * assignments don't double-count.
97
     */
98
    List<com.spice.profitmandi.dao.model.SalesDownlineAchievedByMovementModel>
99
    getSalesDownlineAchievement(java.util.Collection<Integer> authIds, LocalDate startDate, LocalDate endDate);
100
 
101
    /**
102
     * Distinct-partner rolled-up monthly target per warehouse for a set of
103
     * Sales-hierarchy auth_ids. Same dedup guarantee as
104
     * {@link #getSalesDownlineAchievement}.
105
     */
106
    List<com.spice.profitmandi.dao.model.SalesDownlineMonthlyTargetModel>
107
    getSalesDownlineMonthlyTarget(java.util.Collection<Integer> authIds, LocalDate refDate);
108
 
37533 ranu 109
    /**
110
     * Brand × movement-status sold by a set of Sales-hierarchy auth_ids in one
111
     * warehouse × date range. Works for both single-person views (pass one
112
     * authId) and RSM/NSM roll-ups (pass self + full downline). Dedupes
113
     * partners via SELECT DISTINCT.
114
     */
115
    List<com.spice.profitmandi.dao.model.SalesHierarchyBrandSoldModel>
116
    getSalesBrandsSold(java.util.Collection<Integer> authIds, int warehouseId, LocalDate startDate, LocalDate endDate);
117
 
118
    /**
119
     * Distinct partner count per brand for the same Sales-hierarchy auth_ids
120
     * set. Used for the "N partners" badge in the drill-down brand mix.
121
     */
122
    List<com.spice.profitmandi.dao.model.SalesHierarchyBrandPartnerCountModel>
123
    getSalesBrandPartnerCount(java.util.Collection<Integer> authIds, int warehouseId, LocalDate startDate, LocalDate endDate);
124
 
33997 ranu 125
    List<RbmTargetAndAchievementsModel> getRbmTargetsAndAchievemnts(LocalDate startDate, LocalDate endDate);
126
 
33917 ranu 127
    List<RbmArrViewModel> getRbmTodayArr(LocalDate todayDate) throws Exception;
128
 
129
    List<RbmArrViewModel> getRbmTodayArr() throws Exception;
130
 
33926 ranu 131
    void setMovementWiseRbmTargets();
132
 
33985 ranu 133
    void setMovementWiseRbmAchievement();
134
 
34055 ranu 135
    List<Sold15daysOldAgingModel> getAgingSale(LocalDate startDate, LocalDate endDate);
136
 
137
    List<Our15DaysOldAgingStock> our15DaysAgingStock();
138
 
36334 ranu 139
    List<WarehouseAgingStockModel> getWarehouseWiseAgingStock();
140
 
34103 ranu 141
    List<RbmBilledFofoIdsModel> getDateWiseBilledFofoIdByRbm(LocalDate startDate, LocalDate endDate);
142
 
35453 amit 143
    List<RbmWeeklyBillingModel> getWeeklyBillingDataForMonth(LocalDate monthStart, LocalDate monthEnd);
144
 
34641 ranu 145
    double calculateFofoIdTodayTarget(int fofoId, double secondryMtd, LocalDate date);
34880 ranu 146
 
147
    long getRemainingDaysInMonth(LocalDate date);
35631 ranu 148
 
149
    List<RbmCallTargetModel> getRbmCallTargetModels() throws Exception;
150
 
36234 ranu 151
    List<RbmCallTargetModel> getRbmCallTargetModels(LocalDate queryDate) throws Exception;
152
 
35631 ranu 153
    List<OutOfSequenceDetailModel> getOutOfSequenceDetails(int authId);
35645 ranu 154
 
35672 ranu 155
    List<CalledPartnerDetailModel> getCalledPartnerDetails(int authId) throws ProfitMandiBusinessException;
35670 ranu 156
 
35730 ranu 157
    List<CalledPartnerDetailModel> getCalledPartnerDetails(int authId, LocalDate date) throws ProfitMandiBusinessException;
158
 
35645 ranu 159
    List<List<String>> getRbmCallTargetRawDataByAuthId(int authId) throws Exception;
35852 ranu 160
 
161
    List<List<String>> getAllCallDataByDate(LocalDate date) throws Exception;
36596 ranu 162
 
163
    List<List<String>> getAllRbmCallTargetRawData() throws Exception;
33917 ranu 164
}