Subversion Repositories SmartDukaan

Rev

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

Rev 33952 Rev 33957
Line 321... Line 321...
321
    @RequestMapping(value = "/createUpdateCatalogMovement", method = RequestMethod.GET)
321
    @RequestMapping(value = "/createUpdateCatalogMovement", method = RequestMethod.GET)
322
    public String createUpdateCatalogMovement(HttpServletRequest request, Model model, @RequestParam int catalogId, @RequestParam CatalogMovingEnum status, @RequestParam LocalDate startDate, @RequestParam String brand) throws Exception {
322
    public String createUpdateCatalogMovement(HttpServletRequest request, Model model, @RequestParam int catalogId, @RequestParam CatalogMovingEnum status, @RequestParam LocalDate startDate, @RequestParam String brand) throws Exception {
323
 
323
 
324
        CategorisedCatalog currentCategorisedCatalog = categorisedCatalogRepository.getCurrentCatalogMovement(catalogId);
324
        CategorisedCatalog currentCategorisedCatalog = categorisedCatalogRepository.getCurrentCatalogMovement(catalogId);
325
 
325
 
326
        LOGGER.info("currentCategorisedCatalog {}", currentCategorisedCatalog);
326
        LOGGER.info("currentCategorisedCatalogg - {}", currentCategorisedCatalog);
327
 
327
 
328
        if (currentCategorisedCatalog != null) {
328
        if (currentCategorisedCatalog != null) {
-
 
329
            if (currentCategorisedCatalog.getStartDate().isEqual(startDate) && (startDate.isEqual(LocalDate.now()) || startDate.isAfter(LocalDate.now()))) {
-
 
330
                currentCategorisedCatalog.setStatus(status);
-
 
331
            } else if (startDate.isBefore(currentCategorisedCatalog.getStartDate()) || startDate.isEqual(currentCategorisedCatalog.getStartDate())) {
-
 
332
                throw new Exception("Start date cannot be less than or equal to the current catalog's start date(" + currentCategorisedCatalog.getStartDate() + ").");
-
 
333
            }
329
            if (currentCategorisedCatalog.getStatus().equals(status)) {
334
//            else if (currentCategorisedCatalog.getStatus().equals(status)) {
330
                currentCategorisedCatalog.setStartDate(startDate);
335
//                currentCategorisedCatalog.setStartDate(startDate);
-
 
336
//            }
331
            } else {
337
            else {
332
                currentCategorisedCatalog.setEndDate(LocalDate.now().minusDays(1));
338
                currentCategorisedCatalog.setEndDate(startDate.minusDays(1));
333
 
339
 
334
                CategorisedCatalog categorisedCatalog = new CategorisedCatalog();
340
                CategorisedCatalog categorisedCatalog = new CategorisedCatalog();
335
                categorisedCatalog.setCatalogId(catalogId);
341
                categorisedCatalog.setCatalogId(catalogId);
336
                categorisedCatalog.setStatus(status);
342
                categorisedCatalog.setStatus(status);
337
                categorisedCatalog.setStartDate(startDate);
343
                categorisedCatalog.setStartDate(startDate);