Subversion Repositories SmartDukaan

Rev

Rev 37823 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37823 Rev 37846
Line 79... Line 79...
79
    private static final Logger LOGGER = LogManager.getLogger(SupplierController.class);
79
    private static final Logger LOGGER = LogManager.getLogger(SupplierController.class);
80
 
80
 
81
    @Autowired
81
    @Autowired
82
    WarehouseRepository warehouseRepository;
82
    WarehouseRepository warehouseRepository;
83
 
83
 
84
    // Physical warehouses are the ones with an active seller registration (transaction.sellerwarehouse);
84
    // Physical warehouses are the ones with an operational (active or suspended) seller registration - a suspended
85
    // inventory.warehouse only supplies the name.
85
    // warehouse still moves its stock out; inventory.warehouse only supplies the name.
86
    private Map<Integer, String> activePhysicalWarehouses() {
86
    private Map<Integer, String> activePhysicalWarehouses() {
87
        Map<Integer, String> activeWarehouses = new TreeMap<>();
87
        Map<Integer, String> activeWarehouses = new TreeMap<>();
88
        for (SellerWarehouse sellerWarehouse : sellerWarehouseRepository.selectAll()) {
88
        for (SellerWarehouse sellerWarehouse : sellerWarehouseRepository.selectAll()) {
89
            if (!sellerWarehouse.isActive() || activeWarehouses.containsKey(sellerWarehouse.getWarehouseId())) {
89
            if (!sellerWarehouse.getStatus().isOperational() || activeWarehouses.containsKey(sellerWarehouse.getWarehouseId())) {
90
                continue;
90
                continue;
91
            }
91
            }
92
            Warehouse warehouse = warehouseRepository.selectById(sellerWarehouse.getWarehouseId());
92
            Warehouse warehouse = warehouseRepository.selectById(sellerWarehouse.getWarehouseId());
93
            activeWarehouses.put(sellerWarehouse.getWarehouseId(), sellerWarehouse.getPrefix() + " - "
93
            activeWarehouses.put(sellerWarehouse.getWarehouseId(), sellerWarehouse.getPrefix() + " - "
94
                    + (warehouse == null ? String.valueOf(sellerWarehouse.getWarehouseId()) : warehouse.getDisplayName()));
94
                    + (warehouse == null ? String.valueOf(sellerWarehouse.getWarehouseId()) : warehouse.getDisplayName()));
Line 162... Line 162...
162
 
162
 
163
 
163
 
164
    @RequestMapping(value = "/getCreateNewSupplier", method = RequestMethod.GET)
164
    @RequestMapping(value = "/getCreateNewSupplier", method = RequestMethod.GET)
165
    public String getCreateNewSupplier(HttpServletRequest request, Model model) throws Exception {
165
    public String getCreateNewSupplier(HttpServletRequest request, Model model) throws Exception {
166
        List<SellerWarehouse> sellerWarehouses = sellerWarehouseRepository.selectAll().stream()
166
        List<SellerWarehouse> sellerWarehouses = sellerWarehouseRepository.selectAll().stream()
167
                .filter(SellerWarehouse::isActive).collect(Collectors.toList());
167
                .filter(x -> x.getStatus().isOperational()).collect(Collectors.toList());
168
 
168
 
169
        Map<Integer, WarehouseIdPrefixModel> warehouseIdAndState = new HashMap<>();
169
        Map<Integer, WarehouseIdPrefixModel> warehouseIdAndState = new HashMap<>();
170
 
170
 
171
        for (SellerWarehouse sw : sellerWarehouses) {
171
        for (SellerWarehouse sw : sellerWarehouses) {
172
            WarehouseAddressMapping warehouseAddressMapping = warehouseAddressMappingRepository.selectByWarehouseId(sw.getWarehouseId());
172
            WarehouseAddressMapping warehouseAddressMapping = warehouseAddressMappingRepository.selectByWarehouseId(sw.getWarehouseId());
Line 280... Line 280...
280
 
280
 
281
    @RequestMapping(value = "/supplier/edit/{supplierId}", method = RequestMethod.GET)
281
    @RequestMapping(value = "/supplier/edit/{supplierId}", method = RequestMethod.GET)
282
    public String getEditSupplier(HttpServletRequest request, Model model, @PathVariable int supplierId) throws Exception {
282
    public String getEditSupplier(HttpServletRequest request, Model model, @PathVariable int supplierId) throws Exception {
283
        Supplier supplier  = supplierRepository.selectById(supplierId);
283
        Supplier supplier  = supplierRepository.selectById(supplierId);
284
        List<SellerWarehouse> sellerWarehouses = sellerWarehouseRepository.selectAll().stream()
284
        List<SellerWarehouse> sellerWarehouses = sellerWarehouseRepository.selectAll().stream()
285
                .filter(SellerWarehouse::isActive).collect(Collectors.toList());
285
                .filter(x -> x.getStatus().isOperational()).collect(Collectors.toList());
286
        Map<Integer, WarehouseIdPrefixModel> warehouseIdAndState = new HashMap<>();
286
        Map<Integer, WarehouseIdPrefixModel> warehouseIdAndState = new HashMap<>();
287
 
287
 
288
        List<Warehouse> supplierWarehouses = warehouseRepository.selectVendorWarehouses(supplierId, WarehouseType.OURS, InventoryType.GOOD);
288
        List<Warehouse> supplierWarehouses = warehouseRepository.selectVendorWarehouses(supplierId, WarehouseType.OURS, InventoryType.GOOD);
289
        List<Integer> supplierPhysicalWarehouseIds = supplierWarehouses.stream().map(x -> x.getShippingWarehouseId()).collect(Collectors.toList());
289
        List<Integer> supplierPhysicalWarehouseIds = supplierWarehouses.stream().map(x -> x.getShippingWarehouseId()).collect(Collectors.toList());
290
        LOGGER.info("supplierPhysicalWarehouseIds" + supplierPhysicalWarehouseIds);
290
        LOGGER.info("supplierPhysicalWarehouseIds" + supplierPhysicalWarehouseIds);