| Line 18... |
Line 18... |
| 18 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
18 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 19 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
|
19 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
|
| 20 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
20 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
| 21 |
import com.spice.profitmandi.dao.entity.transaction.Loan;
|
21 |
import com.spice.profitmandi.dao.entity.transaction.Loan;
|
| 22 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
22 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| - |
|
23 |
import com.spice.profitmandi.dao.entity.transaction.SDCreditRequirement;
|
| 23 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
24 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 24 |
import com.spice.profitmandi.dao.entity.user.User;
|
25 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 25 |
import com.spice.profitmandi.dao.entity.warehouse.BrandRegionMapping;
|
26 |
import com.spice.profitmandi.dao.entity.warehouse.BrandRegionMapping;
|
| 26 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
27 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 27 |
import com.spice.profitmandi.dao.model.*;
|
28 |
import com.spice.profitmandi.dao.model.*;
|
| Line 39... |
Line 40... |
| 39 |
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
|
40 |
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
|
| 40 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
41 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
| 41 |
import com.spice.profitmandi.dao.repository.inventory.WarehouseRepository;
|
42 |
import com.spice.profitmandi.dao.repository.inventory.WarehouseRepository;
|
| 42 |
import com.spice.profitmandi.dao.repository.transaction.LoanRepository;
|
43 |
import com.spice.profitmandi.dao.repository.transaction.LoanRepository;
|
| 43 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
44 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| - |
|
45 |
import com.spice.profitmandi.dao.repository.transaction.SDCreditRequirementRepository;
|
| 44 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
46 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 45 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
47 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 46 |
import com.spice.profitmandi.dao.repository.warehouse.BrandRegionMappingRepository;
|
48 |
import com.spice.profitmandi.dao.repository.warehouse.BrandRegionMappingRepository;
|
| - |
|
49 |
import com.spice.profitmandi.service.FofoUser;
|
| 47 |
import com.spice.profitmandi.service.NotificationService;
|
50 |
import com.spice.profitmandi.service.NotificationService;
|
| - |
|
51 |
import com.spice.profitmandi.service.RbmTargetService;
|
| 48 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
52 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 49 |
import com.spice.profitmandi.service.inventory.*;
|
53 |
import com.spice.profitmandi.service.inventory.*;
|
| 50 |
import com.spice.profitmandi.service.user.RetailerService;
|
54 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 51 |
import com.spice.profitmandi.service.wallet.WalletService;
|
55 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 52 |
import com.spice.profitmandi.thrift.clients.PaymentClient;
|
56 |
import com.spice.profitmandi.thrift.clients.PaymentClient;
|
| Line 230... |
Line 234... |
| 230 |
AgeingService ageingService;
|
234 |
AgeingService ageingService;
|
| 231 |
|
235 |
|
| 232 |
@Autowired
|
236 |
@Autowired
|
| 233 |
LoanRepository loanRepository;
|
237 |
LoanRepository loanRepository;
|
| 234 |
|
238 |
|
| - |
|
239 |
@Autowired
|
| - |
|
240 |
RbmTargetService rbmTargetService;
|
| - |
|
241 |
|
| - |
|
242 |
@Autowired
|
| - |
|
243 |
FofoUser fofoUser;
|
| - |
|
244 |
|
| - |
|
245 |
@Autowired
|
| - |
|
246 |
SDCreditRequirementRepository sdCreditRequirementRepository;
|
| - |
|
247 |
|
| 235 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
248 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
| 236 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
|
249 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
|
| 237 |
@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
|
250 |
@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
|
| 238 |
if (fofoId == 0) {
|
251 |
if (fofoId == 0) {
|
| 239 |
|
252 |
|
| Line 2099... |
Line 2112... |
| 2099 |
|
2112 |
|
| 2100 |
return "partner-stock-detail";
|
2113 |
return "partner-stock-detail";
|
| 2101 |
|
2114 |
|
| 2102 |
}
|
2115 |
}
|
| 2103 |
|
2116 |
|
| - |
|
2117 |
|
| 2104 |
@RequestMapping(value = "/getPartnerShortageStock", method = RequestMethod.GET)
|
2118 |
@RequestMapping(value = "/getPartnerShortageStock", method = RequestMethod.GET)
|
| 2105 |
public String getPartnerShortageStock(HttpServletRequest request,
|
2119 |
public String getPartnerShortageStock(HttpServletRequest request,
|
| 2106 |
@RequestParam(required = false, defaultValue = "") String brand, @RequestParam int fofoId, Model model)
|
2120 |
@RequestParam(required = false, defaultValue = "") String brand, @RequestParam(required = false, defaultValue = "0") long shortInvest, @RequestParam int fofoId, Model model)
|
| 2107 |
throws Exception {
|
2121 |
throws Exception {
|
| 2108 |
|
2122 |
|
| 2109 |
LocalDateTime presentDate = LocalDateTime.now();
|
2123 |
LocalDateTime presentDate = LocalDateTime.now();
|
| 2110 |
|
- |
|
| - |
|
2124 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 2111 |
|
2125 |
|
| 2112 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
2126 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 2113 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
2127 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
| 2114 |
|
2128 |
|
| 2115 |
List<String> brands = ProfitMandiConstants.BRANDS;
|
- |
|
| 2116 |
|
- |
|
| 2117 |
List<BrandWisePartnerSaleModel> brandWisePartnerSaleModels = fofoStoreRepository.selectGroupByBrandWarehousePartnerSale(Arrays.asList(fofoId));
|
2129 |
List<BrandWisePartnerSaleModel> brandWisePartnerSaleModels = fofoStoreRepository.selectGroupByBrandWarehousePartnerSale(Arrays.asList(fofoId));
|
| 2118 |
LOGGER.info("brandWisePartnerSaleModels {}", brandWisePartnerSaleModels);
|
2130 |
LOGGER.info("brandWisePartnerSaleModels {}", brandWisePartnerSaleModels);
|
| 2119 |
|
2131 |
|
| 2120 |
Map<String, Long> brandToMtdMap = brandWisePartnerSaleModels.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> x.getMtd()));
|
2132 |
Map<String, Long> brandToMtdMap = brandWisePartnerSaleModels.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> x.getMtd()));
|
| 2121 |
|
2133 |
|
| - |
|
2134 |
Map<Integer, Double> secondaryMtd = orderRepository.selectOrderValueBetweenDatesGroupByFofoId(Arrays.asList(fofoId),
|
| - |
|
2135 |
Arrays.asList(OrderStatus.BILLED, OrderStatus.SHIPPED_FROM_WH, OrderStatus.SHIPPED_TO_LOGST, OrderStatus.DELIVERY_SUCCESS, OrderStatus.ACCEPTED, OrderStatus.SUBMITTED_FOR_PROCESSING),
|
| - |
|
2136 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getAmount()));
|
| - |
|
2137 |
|
| - |
|
2138 |
double purchaseMtd = secondaryMtd.getOrDefault(fofoId, 0.0);
|
| - |
|
2139 |
|
| - |
|
2140 |
Map<Integer, Double> secondaryToday = orderRepository.selectOrderValueBetweenDatesGroupByFofoId(Arrays.asList(fofoId),
|
| - |
|
2141 |
Arrays.asList(OrderStatus.BILLED, OrderStatus.SHIPPED_FROM_WH, OrderStatus.SHIPPED_TO_LOGST, OrderStatus.DELIVERY_SUCCESS, OrderStatus.ACCEPTED, OrderStatus.SUBMITTED_FOR_PROCESSING),
|
| - |
|
2142 |
curDate, curDate.with(LocalTime.MAX)).stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getAmount()));
|
| - |
|
2143 |
|
| - |
|
2144 |
double purchasedFtd = secondaryToday.getOrDefault(fofoId, 0.0);
|
| - |
|
2145 |
|
| - |
|
2146 |
double purchaseTargetFtd = rbmTargetService.calculateFofoIdTodayTarget(fofoId, purchaseMtd);
|
| - |
|
2147 |
|
| - |
|
2148 |
double saleMtd = (Double) fofoUser.getSales(fofoId).get("mtdSale");
|
| - |
|
2149 |
|
| - |
|
2150 |
double recoverableAmount = saleMtd - purchaseMtd;
|
| - |
|
2151 |
|
| - |
|
2152 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(fofoId);
|
| - |
|
2153 |
BigDecimal availableLimit = sdCreditRequirement.getAvailableLimit();
|
| - |
|
2154 |
UserWallet userWallet = walletService.getUserWallet(fofoId);
|
| - |
|
2155 |
|
| - |
|
2156 |
BigDecimal totalAvailableFunds = availableLimit.add(BigDecimal.valueOf(userWallet.getAmount()));
|
| - |
|
2157 |
|
| - |
|
2158 |
List<Loan> loans = loanRepository.selectActiveLoan(fofoId);
|
| - |
|
2159 |
boolean isLoanPending = false;
|
| - |
|
2160 |
if (loans.size() > 0) {
|
| - |
|
2161 |
isLoanPending = true;
|
| - |
|
2162 |
}
|
| - |
|
2163 |
|
| 2122 |
// Sort the BRANDS list based on MTD sale in descending order
|
2164 |
// Sort the BRANDS list based on MTD sale in descending order
|
| 2123 |
List<String> sortedBrands = ProfitMandiConstants.BRANDS.stream()
|
2165 |
List<String> sortedBrands = ProfitMandiConstants.BRANDS.stream()
|
| 2124 |
.sorted((b1, b2) -> {
|
2166 |
.sorted((b1, b2) -> {
|
| 2125 |
long mtd1 = brandToMtdMap.getOrDefault(b1, 0L);
|
2167 |
long mtd1 = brandToMtdMap.getOrDefault(b1, 0L);
|
| 2126 |
long mtd2 = brandToMtdMap.getOrDefault(b2, 0L);
|
2168 |
long mtd2 = brandToMtdMap.getOrDefault(b2, 0L);
|
| Line 2205... |
Line 2247... |
| 2205 |
model.addAttribute("twentyEightDayAboveSoldsCatalogsMap", twentyEightDayAboveSoldsCatalogsMap);
|
2247 |
model.addAttribute("twentyEightDayAboveSoldsCatalogsMap", twentyEightDayAboveSoldsCatalogsMap);
|
| 2206 |
model.addAttribute("brands", sortedBrands);
|
2248 |
model.addAttribute("brands", sortedBrands);
|
| 2207 |
model.addAttribute("brand", brand);
|
2249 |
model.addAttribute("brand", brand);
|
| 2208 |
model.addAttribute("fofoId", fofoId);
|
2250 |
model.addAttribute("fofoId", fofoId);
|
| 2209 |
model.addAttribute("customRetailer", customRetailer);
|
2251 |
model.addAttribute("customRetailer", customRetailer);
|
| - |
|
2252 |
model.addAttribute("shortInvest", shortInvest);
|
| - |
|
2253 |
model.addAttribute("purchaseMtd", purchaseMtd);
|
| - |
|
2254 |
model.addAttribute("purchasedFtd", purchasedFtd);
|
| - |
|
2255 |
model.addAttribute("saleMtd", saleMtd);
|
| - |
|
2256 |
model.addAttribute("purchaseTargetFtd", purchaseTargetFtd);
|
| - |
|
2257 |
model.addAttribute("recoverableAmount", recoverableAmount);
|
| - |
|
2258 |
model.addAttribute("isLoanPending", isLoanPending);
|
| - |
|
2259 |
model.addAttribute("totalAvailableFunds", totalAvailableFunds);
|
| 2210 |
return "partner-stock";
|
2260 |
return "partner-stock";
|
| 2211 |
|
2261 |
|
| 2212 |
}
|
2262 |
}
|
| 2213 |
|
2263 |
|
| 2214 |
private List<PartnerStockDescriptionModel> getBrandItemwiseDescription(String brand,
|
2264 |
private List<PartnerStockDescriptionModel> getBrandItemwiseDescription(String brand,
|