Subversion Repositories SmartDukaan

Rev

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

Rev 30321 Rev 30426
Line 1192... Line 1192...
1192
		} else {
1192
		} else {
1193
			map.put("end", offset + limit);
1193
			map.put("end", offset + limit);
1194
		}
1194
		}
1195
		return map;
1195
		return map;
1196
	}
1196
	}
1197
	
1197
 
1198
	public ResponseEntity<?> downloadReportInCsv( org.apache.commons.io.output.ByteArrayOutputStream baos , List<List<?>> rows, String fileName)
1198
	public ResponseEntity<?> downloadReportInCsv(org.apache.commons.io.output.ByteArrayOutputStream baos,
1199
	{
-
 
-
 
1199
			List<List<?>> rows, String fileName) {
1200
		final HttpHeaders headers = new HttpHeaders();
1200
		final HttpHeaders headers = new HttpHeaders();
1201
		headers.set("Content-Type", "text/csv");
1201
		headers.set("Content-Type", "text/csv");
1202
		
1202
 
1203
		headers.set("Content-disposition", "inline; filename=" + fileName + ".csv" );
1203
		headers.set("Content-disposition", "inline; filename=" + fileName + ".csv");
1204
		headers.setContentLength(baos.toByteArray().length);
1204
		headers.setContentLength(baos.toByteArray().length);
1205
 
1205
 
1206
		final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
1206
		final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
1207
		final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
1207
		final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
1208
		
1208
 
1209
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
1209
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
1210
	}
1210
	}
1211
 
1211
 
1212
	@Override
1212
	@Override
1213
	public Map<String, Object> getSaleHistoryPaginated(int fofoId, SearchType searchType, String searchValue,
1213
	public Map<String, Object> getSaleHistoryPaginated(int fofoId, SearchType searchType, String searchValue,
Line 1265... Line 1265...
1265
			int itemId = entry.getKey();
1265
			int itemId = entry.getKey();
1266
			CustomFofoOrderItem customFofoOrderItem = entry.getValue();
1266
			CustomFofoOrderItem customFofoOrderItem = entry.getValue();
1267
			LOGGER.info("CustomFofoOrderItem -- {}", customFofoOrderItem);
1267
			LOGGER.info("CustomFofoOrderItem -- {}", customFofoOrderItem);
1268
			PriceModel priceModel = itemIdMopPriceMap.get(itemId);
1268
			PriceModel priceModel = itemIdMopPriceMap.get(itemId);
1269
			Item item = itemRepository.selectById(itemId);
1269
			Item item = itemRepository.selectById(itemId);
-
 
1270
			if (!item.getBrand().equals("Live Demo")
-
 
1271
					&& (item.getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID
1270
			if (!item.getBrand().equals("Live Demo") && (item.getCategoryId()==ProfitMandiConstants.MOBILE_CATEGORY_ID || item.getCategoryId()==ProfitMandiConstants.TABLET_CATEGORY_ID) &&
1272
							|| item.getCategoryId() == ProfitMandiConstants.TABLET_CATEGORY_ID)
1271
					customFofoOrderItem.getSerialNumberDetails().stream()
1273
					&& customFofoOrderItem.getSerialNumberDetails().stream()
1272
					.filter(x -> org.apache.commons.lang.StringUtils.isNotEmpty(x.getSerialNumber()))
1274
							.filter(x -> org.apache.commons.lang.StringUtils.isNotEmpty(x.getSerialNumber()))
1273
					.collect(Collectors.toList()).size() > 0) {
1275
							.collect(Collectors.toList()).size() > 0) {
1274
				if (Utils.compareFloat(priceModel.getPrice(),
1276
				if (Utils.compareFloat(priceModel.getPrice(),
1275
						customFofoOrderItem.getSellingPrice() + customFofoOrderItem.getDiscountAmount()) > 0) {
1277
						customFofoOrderItem.getSellingPrice() + customFofoOrderItem.getDiscountAmount()) > 0) {
1276
					throw new ProfitMandiBusinessException("Selling Price for ",
1278
					throw new ProfitMandiBusinessException("Selling Price for ", item.getItemDescription(),
1277
							item.getItemDescription(), "FFORDR_1010");
1279
							"FFORDR_1010");
1278
				}
1280
				}
1279
			} else {
1281
			} else {
-
 
1282
				if (!item.getBrand().equals("Live Demo")
1280
				if (!item.getBrand().equals("Live Demo") && priceModel.getPurchasePrice() > customFofoOrderItem.getSellingPrice()) {
1283
						&& priceModel.getPurchasePrice() > customFofoOrderItem.getSellingPrice()) {
1281
					throw new ProfitMandiBusinessException("Selling Price",
1284
					throw new ProfitMandiBusinessException("Selling Price",
1282
							itemRepository.selectById(itemId).getItemDescription(),
1285
							itemRepository.selectById(itemId).getItemDescription(),
1283
							"Selling Price should not be less than DP");
1286
							"Selling Price should not be less than DP");
1284
				}
1287
				}
1285
			}
1288
			}
Line 1290... Line 1293...
1290
			Map<Integer, CustomFofoOrderItem> itemIdCustomFofoLineItemMap) throws ProfitMandiBusinessException {
1293
			Map<Integer, CustomFofoOrderItem> itemIdCustomFofoLineItemMap) throws ProfitMandiBusinessException {
1291
		Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
1294
		Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
1292
		for (Map.Entry<Integer, PriceModel> entry : itemIdMopPriceMap.entrySet()) {
1295
		for (Map.Entry<Integer, PriceModel> entry : itemIdMopPriceMap.entrySet()) {
1293
			CustomFofoOrderItem customFofoOrderItem = itemIdCustomFofoLineItemMap.get(entry.getKey());
1296
			CustomFofoOrderItem customFofoOrderItem = itemIdCustomFofoLineItemMap.get(entry.getKey());
1294
			Item item = itemRepository.selectById(customFofoOrderItem.getItemId());
1297
			Item item = itemRepository.selectById(customFofoOrderItem.getItemId());
1295
			if (!(item.getBrand().equals("Live Demo") || item.getCategoryId()!=ProfitMandiConstants.MOBILE_CATEGORY_ID || item.getCategoryId()!=ProfitMandiConstants.TABLET_CATEGORY_ID) &&
1298
			if (!(item.getBrand().equals("Live Demo") || item.getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID
-
 
1299
					|| item.getCategoryId() != ProfitMandiConstants.TABLET_CATEGORY_ID)
1296
					customFofoOrderItem.getSellingPrice() + customFofoOrderItem.getDiscountAmount() < entry.getValue()
1300
					&& customFofoOrderItem.getSellingPrice() + customFofoOrderItem.getDiscountAmount() < entry
1297
					.getPrice()) {
1301
							.getValue().getPrice()) {
1298
				invalidMopItemIdPriceMap.put(entry.getKey(), customFofoOrderItem.getSellingPrice());
1302
				invalidMopItemIdPriceMap.put(entry.getKey(), customFofoOrderItem.getSellingPrice());
1299
			}
1303
			}
1300
		}
1304
		}
1301
 
1305
 
1302
		if (!invalidMopItemIdPriceMap.isEmpty()) {
1306
		if (!invalidMopItemIdPriceMap.isEmpty()) {
Line 1806... Line 1810...
1806
		List<CustomerReturnItem> customerReturnItems = customerReturnItemRepository
1810
		List<CustomerReturnItem> customerReturnItems = customerReturnItemRepository
1807
				.selectAllByCreditNoteId(creditNote.getId());
1811
				.selectAllByCreditNoteId(creditNote.getId());
1808
		CustomCustomer customCustomer = getCustomCustomer(fofoOrder);
1812
		CustomCustomer customCustomer = getCustomCustomer(fofoOrder);
1809
 
1813
 
1810
		Set<CustomOrderItem> customerFofoOrderItems = new HashSet<>();
1814
		Set<CustomOrderItem> customerFofoOrderItems = new HashSet<>();
1811
		CustomRetailer customRetailer = retailerService.getFofoRetailers(Arrays.asList(fofoOrder.getFofoId()))
1815
		CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoOrder.getFofoId());
1812
				.get(fofoOrder.getFofoId());
-
 
1813
 
1816
 
1814
		FofoOrderItem fofoOrderItem = fofoOrderItemRepository.selectById(creditNote.getFofoOrderItemId());
1817
		FofoOrderItem fofoOrderItem = fofoOrderItemRepository.selectById(creditNote.getFofoOrderItemId());
1815
		float totalTaxRate = fofoOrderItem.getIgstRate() + fofoOrderItem.getSgstRate() + fofoOrderItem.getCgstRate();
1818
		float totalTaxRate = fofoOrderItem.getIgstRate() + fofoOrderItem.getSgstRate() + fofoOrderItem.getCgstRate();
1816
		float taxableSellingPrice = fofoOrderItem.getSellingPrice() / (1 + totalTaxRate / 100);
1819
		float taxableSellingPrice = fofoOrderItem.getSellingPrice() / (1 + totalTaxRate / 100);
1817
		float taxableDiscountPrice = fofoOrderItem.getDiscount() / (1 + totalTaxRate / 100);
1820
		float taxableDiscountPrice = fofoOrderItem.getDiscount() / (1 + totalTaxRate / 100);