Subversion Repositories SmartDukaan

Rev

Rev 37487 | Rev 37505 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.service;

import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
import com.spice.profitmandi.dao.entity.inventory.SalesTargets;
import com.spice.profitmandi.dao.model.*;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public interface RbmTargetService {

    List<WarehouseRbmTargetModel> getWarehouseWiseRbmMonthlyTarget();

    List<MTDAchievedTargetModel> getDateWiseAchievedTargetOfRbm(LocalDate startDate, LocalDate endDate);

    List<WarehouseMobileStockByMovementModel> getWarehouseMobileStockByMovement();

    List<SoldCatalogsReportModel> getCatalogSoldReport(LocalDate startDate, LocalDate endDate);

    int getWorkingDaysCount(LocalDate startDate);

    List<TodayAchievedMovementModel> getMovementWiseAchievementByDate(LocalDate startDate, LocalDate endDate);

    List<RbmBrandSoldModel> getBrandsSoldByRbm(int authId, int warehouseId, LocalDate startDate, LocalDate endDate);

    List<RbmBrandPartnerCountModel> getBrandPartnerCountByRbm(int authId, int warehouseId, LocalDate startDate, LocalDate endDate);

    List<WarehouseBuyingByMovementModel> getWarehouseBuyingByMovement(int warehouseId, LocalDate startDate, LocalDate endDate);

    /**
     * Daily writer for Sales-hierarchy targets (mirrors {@link #setMovementWiseRbmTargets}).
     * Reads today's persisted RBM snapshots from inventory.rbm_targets, rolls them up per
     * (sales_auth_id × warehouse_id) for every active Sales person whose downline contains
     * at least one RBM, and inserts one row per (sales, warehouse) into inventory.sales_targets.
     * Intended to run once daily via the cron flag {@code pushSalesTargets},
     * chained after {@code pushRbmTargets}.
     */
    void setSalesTargets();

    /**
     * Same as {@link #setSalesTargets()} but for a specific date — reads that
     * day's persisted RBM snapshots and writes Sales snapshots stamped to that
     * day. Useful for backfilling missed cron runs or seeding local/staging
     * data without needing today's RBM snapshot.
     */
    void setSalesTargetsForDate(LocalDate date);

    List<SalesTargets> getSalesTargetsByDates(LocalDate startDate, LocalDate endDate);

    /**
     * Historical snapshot writer for Sales-hierarchy achievement (mirrors
     * {@link #setMovementWiseRbmAchievement}). Rolls up today's live order
     * ACH into one row per (Sales person × warehouse) and persists to
     * {@code inventory.sales_achievements} for later reconciliation.
     * The DRR dashboard reads ACH LIVE from orders — this table is audit only.
     */
    void setSalesAchievements();

    /**
     * Dated variant of {@link #setSalesAchievements()} for backfill.
     */
    void setSalesAchievementsForDate(LocalDate date);

    List<RbmTargetAndAchievementsModel> getRbmTargetsAndAchievemnts(LocalDate startDate, LocalDate endDate);

    List<RbmArrViewModel> getRbmTodayArr(LocalDate todayDate) throws Exception;

    List<RbmArrViewModel> getRbmTodayArr() throws Exception;

    void setMovementWiseRbmTargets();

    void setMovementWiseRbmAchievement();

    List<Sold15daysOldAgingModel> getAgingSale(LocalDate startDate, LocalDate endDate);

    List<Our15DaysOldAgingStock> our15DaysAgingStock();

    List<WarehouseAgingStockModel> getWarehouseWiseAgingStock();

    List<RbmBilledFofoIdsModel> getDateWiseBilledFofoIdByRbm(LocalDate startDate, LocalDate endDate);

    List<RbmWeeklyBillingModel> getWeeklyBillingDataForMonth(LocalDate monthStart, LocalDate monthEnd);

    double calculateFofoIdTodayTarget(int fofoId, double secondryMtd, LocalDate date);

    long getRemainingDaysInMonth(LocalDate date);

    List<RbmCallTargetModel> getRbmCallTargetModels() throws Exception;

    List<RbmCallTargetModel> getRbmCallTargetModels(LocalDate queryDate) throws Exception;

    List<OutOfSequenceDetailModel> getOutOfSequenceDetails(int authId);

    List<CalledPartnerDetailModel> getCalledPartnerDetails(int authId) throws ProfitMandiBusinessException;

    List<CalledPartnerDetailModel> getCalledPartnerDetails(int authId, LocalDate date) throws ProfitMandiBusinessException;

    List<List<String>> getRbmCallTargetRawDataByAuthId(int authId) throws Exception;

    List<List<String>> getAllCallDataByDate(LocalDate date) throws Exception;

    List<List<String>> getAllRbmCallTargetRawData() throws Exception;
}