Subversion Repositories SmartDukaan

Rev

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

Rev 23781 Rev 23823
Line 244... Line 244...
244
 
244
 
245
	@Autowired
245
	@Autowired
246
	private OtpRepository otpRepository;
246
	private OtpRepository otpRepository;
247
 
247
 
248
	@Override
248
	@Override
249
	public int createOrder(CreateOrderRequest createOrderRequest, int fofoId) throws ProfitMandiBusinessException {
249
	public int createOrder(CreateOrderRequest createOrderRequest, int fofoId, boolean accessoriesDeals) throws ProfitMandiBusinessException {
250
 
250
 
251
		CustomCustomer customCustomer = createOrderRequest.getCustomer();
251
		CustomCustomer customCustomer = createOrderRequest.getCustomer();
252
 
252
 
253
		if (!StringUtils.isValidEmailAddress(customCustomer.getEmailId())) {
253
		if (!StringUtils.isValidEmailAddress(customCustomer.getEmailId())) {
254
			LOGGER.error("invalid customer emailId {} ", customCustomer.getEmailId());
254
			LOGGER.error("invalid customer emailId {} ", customCustomer.getEmailId());
Line 471... Line 471...
471
			}
471
			}
472
		}
472
		}
473
 
473
 
474
		Map<Integer, PriceModel> itemIdMopPriceMap = pricingService
474
		Map<Integer, PriceModel> itemIdMopPriceMap = pricingService
475
				.getPurchasePriceMopPriceNotFound(itemIdCustomFofoOrderItemMap.keySet(), fofoId);
475
				.getPurchasePriceMopPriceNotFound(itemIdCustomFofoOrderItemMap.keySet(), fofoId);
-
 
476
		if(accessoriesDeals) {
-
 
477
			this.validateDpPrice(itemIdMopPriceMap, itemIdCustomFofoOrderItemMap);
476
 
478
		} else {
477
		this.validateMopPrice(itemIdMopPriceMap, itemIdCustomFofoOrderItemMap);
479
			this.validateMopPrice(itemIdMopPriceMap, itemIdCustomFofoOrderItemMap);
-
 
480
		}
478
 
481
 
479
		String fofoStoreCode = this.getFofoStoreCode(fofoId);
482
		String fofoStoreCode = this.getFofoStoreCode(fofoId);
480
 
483
 
481
		InvoiceNumberGenerationSequence invoiceNumberGenerationSequence = this
484
		InvoiceNumberGenerationSequence invoiceNumberGenerationSequence = this
482
				.createAndGetInvoiceNumberGenerationSequence(fofoId, fofoStoreCode);
485
				.createAndGetInvoiceNumberGenerationSequence(fofoId, fofoStoreCode);
Line 1120... Line 1123...
1120
					invalidInsuranceSalePurchaseAmount);
1123
					invalidInsuranceSalePurchaseAmount);
1121
			throw new ProfitMandiBusinessException("invalidInsuranceSalePurchaseAmount",
1124
			throw new ProfitMandiBusinessException("invalidInsuranceSalePurchaseAmount",
1122
					invalidInsuranceSalePurchaseAmount, "FFORDR_1009");
1125
					invalidInsuranceSalePurchaseAmount, "FFORDR_1009");
1123
		}
1126
		}
1124
	}
1127
	}
-
 
1128
	private void validateDpPrice(Map<Integer, PriceModel> itemIdMopPriceMap,
-
 
1129
			Map<Integer, CustomFofoOrderItem> itemIdCustomFofoLineItemMap) throws ProfitMandiBusinessException {
-
 
1130
		for (Map.Entry<Integer, CustomFofoOrderItem> entry : itemIdCustomFofoLineItemMap.entrySet()) {
-
 
1131
			int itemId = entry.getKey();
-
 
1132
			CustomFofoOrderItem customFofoOrderItem = entry.getValue();
-
 
1133
			PriceModel priceModel = itemIdMopPriceMap.get(itemId);
-
 
1134
			if(customFofoOrderItem.getSerialNumberDetails().size() > 0) {
-
 
1135
				if(priceModel.getPrice() < customFofoOrderItem.getSellingPrice()) {
-
 
1136
					throw new ProfitMandiBusinessException("Selling Price", itemRepository.selectById(itemId).getItemDescription(), "FFORDR_1010");
-
 
1137
				}
-
 
1138
			} else {
-
 
1139
				if(priceModel.getPurchasePrice() < customFofoOrderItem.getSellingPrice()) {
-
 
1140
					throw new ProfitMandiBusinessException("Selling Price", itemRepository.selectById(itemId).getItemDescription(), "Selling Price should not be less than DP");
-
 
1141
				}
-
 
1142
			}
-
 
1143
		}
1125
 
1144
	}
1126
	private void validateMopPrice(Map<Integer, PriceModel> itemIdMopPriceMap,
1145
	private void validateMopPrice(Map<Integer, PriceModel> itemIdMopPriceMap,
1127
			Map<Integer, CustomFofoOrderItem> itemIdCustomFofoLineItemMap) throws ProfitMandiBusinessException {
1146
			Map<Integer, CustomFofoOrderItem> itemIdCustomFofoLineItemMap) throws ProfitMandiBusinessException {
1128
		Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
1147
		Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
1129
		Map<Integer, Float> invalidDiscountAmountMap = new HashMap<>();
1148
		Map<Integer, Float> invalidDiscountAmountMap = new HashMap<>();
1130
		// Map<Integer, PriceModel> itemIdMopPriceMap =
-
 
1131
		// pricingService.getPurchasePriceMopPriceNotFound(itemIds, fofoId);
-
 
1132
		for (Map.Entry<Integer, PriceModel> entry : itemIdMopPriceMap.entrySet()) {
1149
		for (Map.Entry<Integer, PriceModel> entry : itemIdMopPriceMap.entrySet()) {
1133
			CustomFofoOrderItem customFofoOrderItem = itemIdCustomFofoLineItemMap.get(entry.getKey());
1150
			CustomFofoOrderItem customFofoOrderItem = itemIdCustomFofoLineItemMap.get(entry.getKey());
1134
			if (entry.getValue().getPrice() < Float.MAX_VALUE
1151
			if (entry.getValue().getPrice() < Float.MAX_VALUE
1135
					&& customFofoOrderItem.getSellingPrice() < entry.getValue().getPrice()) {
1152
					&& customFofoOrderItem.getSellingPrice() < entry.getValue().getPrice()) {
1136
				invalidMopItemIdPriceMap.put(entry.getKey(), customFofoOrderItem.getSellingPrice());
1153
				invalidMopItemIdPriceMap.put(entry.getKey(), customFofoOrderItem.getSellingPrice());