Subversion Repositories SmartDukaan

Rev

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

Rev 36401 Rev 37003
Line 337... Line 337...
337
        int regionId = createPositionModel.getRegionId();
337
        int regionId = createPositionModel.getRegionId();
338
        if (regionId > 0 && regionId != 5 && regionRepository.selectById(regionId) == null) {
338
        if (regionId > 0 && regionId != 5 && regionRepository.selectById(regionId) == null) {
339
            throw new ProfitMandiBusinessException("Position", regionId, "Invalid regionId");
339
            throw new ProfitMandiBusinessException("Position", regionId, "Invalid regionId");
340
        }
340
        }
341
 
341
 
-
 
342
        // Partners are optional — a position can be created for a region that doesn't have
342
        // Validate fofoIds exist (0 means "All Partners")
343
        // partners yet (e.g., a newly opened region). Partners can be added later via
-
 
344
        // /cs/updatePartnerPosition. When provided, validate the list; when empty, skip.
343
        List<Integer> fofoIds = createPositionModel.getFofoIds();
345
        List<Integer> fofoIds = createPositionModel.getFofoIds();
344
        if (fofoIds == null || fofoIds.isEmpty()) {
-
 
345
            throw new ProfitMandiBusinessException("Position", 0, "At least one partner must be specified");
-
 
346
        }
-
 
347
        boolean hasAllPartners = fofoIds.contains(0);
346
        boolean hasAllPartners = fofoIds != null && fofoIds.contains(0);
348
        if (hasAllPartners && fofoIds.size() > 1) {
347
        if (hasAllPartners && fofoIds.size() > 1) {
349
            throw new ProfitMandiBusinessException("Position", 0, "Cannot mix 'All Partners' (0) with specific partner IDs");
348
            throw new ProfitMandiBusinessException("Position", 0, "Cannot mix 'All Partners' (0) with specific partner IDs");
350
        }
349
        }
351
        if (!hasAllPartners) {
350
        if (fofoIds != null && !fofoIds.isEmpty() && !hasAllPartners) {
352
            Map<Integer, CustomRetailer> validRetailers = retailerService.getFofoRetailers(false);
351
            Map<Integer, CustomRetailer> validRetailers = retailerService.getFofoRetailers(false);
353
            for (int fofoId : fofoIds) {
352
            for (int fofoId : fofoIds) {
354
                if (!validRetailers.containsKey(fofoId)) {
353
                if (!validRetailers.containsKey(fofoId)) {
355
                    throw new ProfitMandiBusinessException("Position", fofoId, "Invalid fofoId");
354
                    throw new ProfitMandiBusinessException("Position", fofoId, "Invalid fofoId");
356
                }
355
                }