Subversion Repositories SmartDukaan

Rev

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

Rev 37846 Rev 37871
Line 10... Line 10...
10
import com.spice.profitmandi.dao.entity.transaction.WarehouseAddressMapping;
10
import com.spice.profitmandi.dao.entity.transaction.WarehouseAddressMapping;
11
import com.spice.profitmandi.dao.entity.transaction.WarehouseAddressMaster;
11
import com.spice.profitmandi.dao.entity.transaction.WarehouseAddressMaster;
12
import com.spice.profitmandi.dao.entity.warehouse.Supplier;
12
import com.spice.profitmandi.dao.entity.warehouse.Supplier;
13
import com.spice.profitmandi.dao.enumuration.inventory.InventoryType;
13
import com.spice.profitmandi.dao.enumuration.inventory.InventoryType;
14
import com.spice.profitmandi.dao.enumuration.inventory.WarehouseType;
14
import com.spice.profitmandi.dao.enumuration.inventory.WarehouseType;
-
 
15
import com.spice.profitmandi.dao.enumuration.warehouse.WarehouseStatus;
15
import com.spice.profitmandi.dao.hrms.CreateNewSupplier;
16
import com.spice.profitmandi.dao.hrms.CreateNewSupplier;
16
import com.spice.profitmandi.dao.hrms.WarehouseIdPrefixModel;
17
import com.spice.profitmandi.dao.hrms.WarehouseIdPrefixModel;
17
import com.spice.profitmandi.dao.model.hdfc.SupplierFormData;
18
import com.spice.profitmandi.dao.model.hdfc.SupplierFormData;
18
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
19
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
19
import com.spice.profitmandi.dao.repository.inventory.VendorRepository;
20
import com.spice.profitmandi.dao.repository.inventory.VendorRepository;
Line 87... Line 88...
87
        Map<Integer, String> activeWarehouses = new TreeMap<>();
88
        Map<Integer, String> activeWarehouses = new TreeMap<>();
88
        for (SellerWarehouse sellerWarehouse : sellerWarehouseRepository.selectAll()) {
89
        for (SellerWarehouse sellerWarehouse : sellerWarehouseRepository.selectAll()) {
89
            if (!sellerWarehouse.getStatus().isOperational() || activeWarehouses.containsKey(sellerWarehouse.getWarehouseId())) {
90
            if (!sellerWarehouse.getStatus().isOperational() || activeWarehouses.containsKey(sellerWarehouse.getWarehouseId())) {
90
                continue;
91
                continue;
91
            }
92
            }
92
            Warehouse warehouse = warehouseRepository.selectById(sellerWarehouse.getWarehouseId());
-
 
93
            activeWarehouses.put(sellerWarehouse.getWarehouseId(), sellerWarehouse.getPrefix() + " - "
93
            activeWarehouses.put(sellerWarehouse.getWarehouseId(), sellerWarehouse.getPrefix() + " - " + this.warehouseName(sellerWarehouse));
94
                    + (warehouse == null ? String.valueOf(sellerWarehouse.getWarehouseId()) : warehouse.getDisplayName()));
-
 
95
        }
94
        }
96
        return activeWarehouses;
95
        return activeWarehouses;
97
    }
96
    }
98
 
97
 
-
 
98
    private String warehouseName(SellerWarehouse sellerWarehouse) {
-
 
99
        Warehouse warehouse = warehouseRepository.selectById(sellerWarehouse.getWarehouseId());
-
 
100
        return warehouse == null ? String.valueOf(sellerWarehouse.getWarehouseId()) : warehouse.getDisplayName();
-
 
101
    }
-
 
102
 
99
    // 0 means not internal. A supplier marked internal stands for that physical warehouse in stock movements, so it
103
    // 0 means not internal. A supplier marked internal stands for that physical warehouse in stock movements, so it
100
    // must be an active one.
104
    // must be an active one.
101
    private void applyInternalWarehouse(Supplier supplier, Integer internalWarehouseId) throws ProfitMandiBusinessException {
105
    private void applyInternalWarehouse(Supplier supplier, Integer internalWarehouseId) throws ProfitMandiBusinessException {
102
        int warehouseId = internalWarehouseId == null ? 0 : internalWarehouseId;
106
        int warehouseId = internalWarehouseId == null ? 0 : internalWarehouseId;
103
        if (warehouseId > 0 && !this.activePhysicalWarehouses().containsKey(warehouseId)) {
107
        if (warehouseId > 0 && !this.activePhysicalWarehouses().containsKey(warehouseId)) {
Line 141... Line 145...
141
                LOGGER.info("WarehouseAddressMaster" + WarehouseAddressMaster);
145
                LOGGER.info("WarehouseAddressMaster" + WarehouseAddressMaster);
142
                State state = stateRepository.selectById(WarehouseAddressMaster.getStateId());
146
                State state = stateRepository.selectById(WarehouseAddressMaster.getStateId());
143
                WarehouseIdPrefixModel wp = new WarehouseIdPrefixModel();
147
                WarehouseIdPrefixModel wp = new WarehouseIdPrefixModel();
144
                wp.setPrefix(sw.getPrefix());
148
                wp.setPrefix(sw.getPrefix());
145
                wp.setStateName(state.getName());
149
                wp.setStateName(state.getName());
-
 
150
                wp.setName(this.warehouseName(sw));
146
                warehouseIdAndState.put(sw.getWarehouseId(), wp);
151
                warehouseIdAndState.put(sw.getWarehouseId(), wp);
147
                LOGGER.info("state" + state);
152
                LOGGER.info("state" + state);
148
            }
153
            }
149
        }
154
        }
150
        LOGGER.info("warehouseIdAndState" + warehouseIdAndState);
155
        LOGGER.info("warehouseIdAndState" + warehouseIdAndState);
Line 162... Line 167...
162
 
167
 
163
 
168
 
164
    @RequestMapping(value = "/getCreateNewSupplier", method = RequestMethod.GET)
169
    @RequestMapping(value = "/getCreateNewSupplier", method = RequestMethod.GET)
165
    public String getCreateNewSupplier(HttpServletRequest request, Model model) throws Exception {
170
    public String getCreateNewSupplier(HttpServletRequest request, Model model) throws Exception {
166
        List<SellerWarehouse> sellerWarehouses = sellerWarehouseRepository.selectAll().stream()
171
        List<SellerWarehouse> sellerWarehouses = sellerWarehouseRepository.selectAll().stream()
167
                .filter(x -> x.getStatus().isOperational()).collect(Collectors.toList());
172
                .filter(x -> x.getStatus() == WarehouseStatus.ACTIVE).collect(Collectors.toList());
168
 
173
 
169
        Map<Integer, WarehouseIdPrefixModel> warehouseIdAndState = new HashMap<>();
174
        Map<Integer, WarehouseIdPrefixModel> warehouseIdAndState = new HashMap<>();
170
 
175
 
171
        for (SellerWarehouse sw : sellerWarehouses) {
176
        for (SellerWarehouse sw : sellerWarehouses) {
172
            WarehouseAddressMapping warehouseAddressMapping = warehouseAddressMappingRepository.selectByWarehouseId(sw.getWarehouseId());
177
            WarehouseAddressMapping warehouseAddressMapping = warehouseAddressMappingRepository.selectByWarehouseId(sw.getWarehouseId());
Line 177... Line 182...
177
                LOGGER.info("WarehouseAddressMaster" + WarehouseAddressMaster);
182
                LOGGER.info("WarehouseAddressMaster" + WarehouseAddressMaster);
178
                State state = stateRepository.selectById(WarehouseAddressMaster.getStateId());
183
                State state = stateRepository.selectById(WarehouseAddressMaster.getStateId());
179
                WarehouseIdPrefixModel wp = new WarehouseIdPrefixModel();
184
                WarehouseIdPrefixModel wp = new WarehouseIdPrefixModel();
180
                wp.setPrefix(sw.getPrefix());
185
                wp.setPrefix(sw.getPrefix());
181
                wp.setStateName(state.getName());
186
                wp.setStateName(state.getName());
-
 
187
                wp.setName(this.warehouseName(sw));
182
                warehouseIdAndState.put(sw.getWarehouseId(), wp);
188
                warehouseIdAndState.put(sw.getWarehouseId(), wp);
183
                LOGGER.info("state" + state);
189
                LOGGER.info("state" + state);
184
            }
190
            }
185
        }
191
        }
186
        LOGGER.info("warehouseIdAndState" + warehouseIdAndState);
192
        LOGGER.info("warehouseIdAndState" + warehouseIdAndState);
Line 280... Line 286...
280
 
286
 
281
    @RequestMapping(value = "/supplier/edit/{supplierId}", method = RequestMethod.GET)
287
    @RequestMapping(value = "/supplier/edit/{supplierId}", method = RequestMethod.GET)
282
    public String getEditSupplier(HttpServletRequest request, Model model, @PathVariable int supplierId) throws Exception {
288
    public String getEditSupplier(HttpServletRequest request, Model model, @PathVariable int supplierId) throws Exception {
283
        Supplier supplier  = supplierRepository.selectById(supplierId);
289
        Supplier supplier  = supplierRepository.selectById(supplierId);
284
        List<SellerWarehouse> sellerWarehouses = sellerWarehouseRepository.selectAll().stream()
290
        List<SellerWarehouse> sellerWarehouses = sellerWarehouseRepository.selectAll().stream()
285
                .filter(x -> x.getStatus().isOperational()).collect(Collectors.toList());
291
                .filter(x -> x.getStatus() == WarehouseStatus.ACTIVE).collect(Collectors.toList());
286
        Map<Integer, WarehouseIdPrefixModel> warehouseIdAndState = new HashMap<>();
292
        Map<Integer, WarehouseIdPrefixModel> warehouseIdAndState = new HashMap<>();
287
 
293
 
288
        List<Warehouse> supplierWarehouses = warehouseRepository.selectVendorWarehouses(supplierId, WarehouseType.OURS, InventoryType.GOOD);
294
        List<Warehouse> supplierWarehouses = warehouseRepository.selectVendorWarehouses(supplierId, WarehouseType.OURS, InventoryType.GOOD);
289
        List<Integer> supplierPhysicalWarehouseIds = supplierWarehouses.stream().map(x -> x.getShippingWarehouseId()).collect(Collectors.toList());
295
        List<Integer> supplierPhysicalWarehouseIds = supplierWarehouses.stream().map(x -> x.getShippingWarehouseId()).collect(Collectors.toList());
290
        LOGGER.info("supplierPhysicalWarehouseIds" + supplierPhysicalWarehouseIds);
296
        LOGGER.info("supplierPhysicalWarehouseIds" + supplierPhysicalWarehouseIds);
Line 294... Line 300...
294
                WarehouseAddressMaster WarehouseAddressMaster = warehouseAddressMasterRepository.selectById(warehouseAddressMapping.getAddressId());
300
                WarehouseAddressMaster WarehouseAddressMaster = warehouseAddressMasterRepository.selectById(warehouseAddressMapping.getAddressId());
295
                State state = stateRepository.selectById(WarehouseAddressMaster.getStateId());
301
                State state = stateRepository.selectById(WarehouseAddressMaster.getStateId());
296
                WarehouseIdPrefixModel wp = new WarehouseIdPrefixModel();
302
                WarehouseIdPrefixModel wp = new WarehouseIdPrefixModel();
297
                wp.setPrefix(sw.getPrefix());
303
                wp.setPrefix(sw.getPrefix());
298
                wp.setStateName(state.getName());
304
                wp.setStateName(state.getName());
-
 
305
                wp.setName(this.warehouseName(sw));
299
                warehouseIdAndState.put(sw.getWarehouseId(), wp);
306
                warehouseIdAndState.put(sw.getWarehouseId(), wp);
300
            }
307
            }
301
        }
308
        }
302
        LOGGER.info("warehouseIdAndState" + warehouseIdAndState);
309
        LOGGER.info("warehouseIdAndState" + warehouseIdAndState);
303
        model.addAttribute("warehouseIdAndState", warehouseIdAndState);
310
        model.addAttribute("warehouseIdAndState", warehouseIdAndState);