Subversion Repositories SmartDukaan

Rev

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

Rev 37193 Rev 37285
Line 1693... Line 1693...
1693
    }
1693
    }
1694
 
1694
 
1695
    @RequestMapping(value = "/getSecondaryBillingItemByBrand", method = RequestMethod.GET)
1695
    @RequestMapping(value = "/getSecondaryBillingItemByBrand", method = RequestMethod.GET)
1696
    public String getSecondaryBillingItemByBrand(HttpServletRequest request, @RequestParam(name = "warehouseId", required = true, defaultValue = "0") int warehouseId, @RequestParam(name = "brand", required = true, defaultValue = "") String brand, @RequestParam List<LocalDate> date, Model model) throws Exception {
1696
    public String getSecondaryBillingItemByBrand(HttpServletRequest request, @RequestParam(name = "warehouseId", required = true, defaultValue = "0") int warehouseId, @RequestParam(name = "brand", required = true, defaultValue = "") String brand, @RequestParam List<LocalDate> date, Model model) throws Exception {
1697
 
1697
 
-
 
1698
        // Band-aid for URL '+' decode issue on brand names (e.g. "Ai+"):
-
 
1699
        // if the incoming brand isn't found in catalog.brand but "<brand>+" is,
-
 
1700
        // switch to the plus variant. Zero regression for the other brands.
-
 
1701
        if (brand != null && !brand.trim().isEmpty()) {
-
 
1702
            String probe = brand.replaceAll("\\s+$", "");
-
 
1703
            try {
-
 
1704
                if (brandsRepository.selectByBrand(brand) == null
-
 
1705
                        && (probe.equals(brand) || brandsRepository.selectByBrand(probe) == null)) {
-
 
1706
                    String withPlus = probe + "+";
-
 
1707
                    if (brandsRepository.selectByBrand(withPlus) != null) {
-
 
1708
                        LOGGER.info("getSecondaryBillingItemByBrand brand fallback: '{}' -> '{}'", brand, withPlus);
-
 
1709
                        brand = withPlus;
-
 
1710
                    }
-
 
1711
                }
-
 
1712
            } catch (Exception e) {
-
 
1713
                LOGGER.warn("getSecondaryBillingItemByBrand brand fallback failed for '{}': {}", brand, e.getMessage());
-
 
1714
            }
-
 
1715
        }
-
 
1716
 
1698
        List<SecondaryOrderItemBillingModel> orderItemBilling = orderRepository.selectAllBilledOrderItemByBrand(warehouseId, brand, date);
1717
        List<SecondaryOrderItemBillingModel> orderItemBilling = orderRepository.selectAllBilledOrderItemByBrand(warehouseId, brand, date);
1699
 
1718
 
1700
        LOGGER.info("orderItemBilling" + orderItemBilling);
1719
        LOGGER.info("orderItemBilling" + orderItemBilling);
1701
        model.addAttribute("billedItem", orderItemBilling);
1720
        model.addAttribute("billedItem", orderItemBilling);
1702
        model.addAttribute("date", date);
1721
        model.addAttribute("date", date);