Subversion Repositories SmartDukaan

Rev

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

Rev 28353 Rev 28390
Line 318... Line 318...
318
			}
318
			}
319
			if (!(customFofoOrderItem.getSellingPrice() > 0)) {
319
			if (!(customFofoOrderItem.getSellingPrice() > 0)) {
320
				lineItemPrice.put(customFofoOrderItem.getItemId(), customFofoOrderItem.getSellingPrice());
320
				lineItemPrice.put(customFofoOrderItem.getItemId(), customFofoOrderItem.getSellingPrice());
321
			} else {
321
			} else {
322
				totalAmount = totalAmount + customFofoOrderItem.getSellingPrice() * customFofoOrderItem.getQuantity();
322
				totalAmount = totalAmount + customFofoOrderItem.getSellingPrice() * customFofoOrderItem.getQuantity();
323
				totalAmount = totalAmount - customFofoOrderItem.getDiscountAmount() * customFofoOrderItem.getQuantity();
-
 
324
				for (SerialNumberDetail serialNumberDetail : customFofoOrderItem.getSerialNumberDetails()) {
323
				for (SerialNumberDetail serialNumberDetail : customFofoOrderItem.getSerialNumberDetails()) {
325
					if (serialNumberDetail.getAmount() > 0) {
324
					if (serialNumberDetail.getAmount() > 0) {
326
						totalAmount = totalAmount + serialNumberDetail.getAmount();
325
						totalAmount = totalAmount + serialNumberDetail.getAmount();
327
					}
326
					}
328
				}
327
				}
Line 487... Line 486...
487
			}
486
			}
488
		}
487
		}
489
 
488
 
490
		Map<Integer, PriceModel> itemIdMopPriceMap = pricingService
489
		Map<Integer, PriceModel> itemIdMopPriceMap = pricingService
491
				.getPurchasePriceMopPriceNotFound(itemIdCustomFofoOrderItemMap.keySet(), fofoId);
490
				.getPurchasePriceMopPriceNotFound(itemIdCustomFofoOrderItemMap.keySet(), fofoId);
-
 
491
		LOGGER.info("itemIdMopMap {}",itemIdMopPriceMap);
492
		if (accessoriesDeals) {
492
		if (accessoriesDeals) {
493
			this.validateDpPrice(itemIdMopPriceMap, itemIdCustomFofoOrderItemMap);
493
			this.validateDpPrice(itemIdMopPriceMap, itemIdCustomFofoOrderItemMap);
494
		} else {
494
		} else {
495
			this.validateMopPrice(itemIdMopPriceMap, itemIdCustomFofoOrderItemMap);
495
			this.validateMopPrice(itemIdMopPriceMap, itemIdCustomFofoOrderItemMap);
496
		}
496
		}
Line 868... Line 868...
868
		customRetailer.setAddress(this.createCustomAddress(retailerAddress));
868
		customRetailer.setAddress(this.createCustomAddress(retailerAddress));
869
		pdfModel.setRetailer(customRetailer);
869
		pdfModel.setRetailer(customRetailer);
870
 
870
 
871
		Set<CustomOrderItem> customerFofoOrderItems = new HashSet<>();
871
		Set<CustomOrderItem> customerFofoOrderItems = new HashSet<>();
872
		for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
872
		for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
-
 
873
			float discount = fofoOrderItem.getDiscount();
873
			CustomOrderItem customFofoOrderItem = new CustomOrderItem();
874
			CustomOrderItem customFofoOrderItem = new CustomOrderItem();
874
			float totalTaxRate = fofoOrderItem.getIgstRate() + fofoOrderItem.getSgstRate()
875
			float totalTaxRate = fofoOrderItem.getIgstRate() + fofoOrderItem.getSgstRate()
875
					+ fofoOrderItem.getCgstRate();
876
					+ fofoOrderItem.getCgstRate();
876
			float taxableSellingPrice = fofoOrderItem.getSellingPrice() / (1 + totalTaxRate / 100);
877
			float taxableSellingPrice = (fofoOrderItem.getSellingPrice() + discount) / (1 + totalTaxRate / 100);
877
			float taxableDiscountPrice = fofoOrderItem.getDiscount() / (1 + totalTaxRate / 100);
878
			float taxableDiscountPrice = discount / (1 + totalTaxRate / 100);
878
 
879
 
879
			customFofoOrderItem.setAmount(fofoOrderItem.getQuantity() * (taxableSellingPrice - taxableDiscountPrice));
880
			customFofoOrderItem.setAmount(fofoOrderItem.getQuantity() * (taxableSellingPrice - taxableDiscountPrice));
880
			customFofoOrderItem.setDescription(fofoOrderItem.getBrand() + " " + fofoOrderItem.getModelName() + " "
881
			customFofoOrderItem.setDescription(fofoOrderItem.getBrand() + " " + fofoOrderItem.getModelName() + " "
881
					+ fofoOrderItem.getModelNumber() + "-" + fofoOrderItem.getColor());
882
					+ fofoOrderItem.getModelNumber() + "-" + fofoOrderItem.getColor());
882
			Set<String> serialNumbers = this.toSerialNumbers(fofoOrderItem.getFofoLineItems());
883
			Set<String> serialNumbers = this.toSerialNumbers(fofoOrderItem.getFofoLineItems());
Line 887... Line 888...
887
						customFofoOrderItem.getDescription() + "\n IMEIS - " + String.join(", ", serialNumbers));
888
						customFofoOrderItem.getDescription() + "\n IMEIS - " + String.join(", ", serialNumbers));
888
			}
889
			}
889
			customFofoOrderItem.setRate(taxableSellingPrice);
890
			customFofoOrderItem.setRate(taxableSellingPrice);
890
			customFofoOrderItem.setDiscount(taxableDiscountPrice);
891
			customFofoOrderItem.setDiscount(taxableDiscountPrice);
891
			customFofoOrderItem.setQuantity(fofoOrderItem.getQuantity());
892
			customFofoOrderItem.setQuantity(fofoOrderItem.getQuantity());
892
			customFofoOrderItem.setNetAmount(
-
 
893
					(fofoOrderItem.getSellingPrice() - fofoOrderItem.getDiscount()) * fofoOrderItem.getQuantity());
893
			customFofoOrderItem.setNetAmount(fofoOrderItem.getSellingPrice() * fofoOrderItem.getQuantity());
894
			float igstAmount = (customFofoOrderItem.getAmount() * fofoOrderItem.getIgstRate()) / 100;
894
			float igstAmount = (customFofoOrderItem.getAmount() * fofoOrderItem.getIgstRate()) / 100;
895
			float cgstAmount = (customFofoOrderItem.getAmount() * fofoOrderItem.getCgstRate()) / 100;
895
			float cgstAmount = (customFofoOrderItem.getAmount() * fofoOrderItem.getCgstRate()) / 100;
896
			float sgstAmount = (customFofoOrderItem.getAmount() * fofoOrderItem.getSgstRate()) / 100;
896
			float sgstAmount = (customFofoOrderItem.getAmount() * fofoOrderItem.getSgstRate()) / 100;
897
			customFofoOrderItem.setIgstRate(fofoOrderItem.getIgstRate());
897
			customFofoOrderItem.setIgstRate(fofoOrderItem.getIgstRate());
898
			customFofoOrderItem.setIgstAmount(igstAmount);
898
			customFofoOrderItem.setIgstAmount(igstAmount);
Line 1123... Line 1123...
1123
			CustomFofoOrderItem customFofoOrderItem = entry.getValue();
1123
			CustomFofoOrderItem customFofoOrderItem = entry.getValue();
1124
			PriceModel priceModel = itemIdMopPriceMap.get(itemId);
1124
			PriceModel priceModel = itemIdMopPriceMap.get(itemId);
1125
			if (customFofoOrderItem.getSerialNumberDetails().stream()
1125
			if (customFofoOrderItem.getSerialNumberDetails().stream()
1126
					.filter(x -> org.apache.commons.lang.StringUtils.isNotEmpty(x.getSerialNumber()))
1126
					.filter(x -> org.apache.commons.lang.StringUtils.isNotEmpty(x.getSerialNumber()))
1127
					.collect(Collectors.toList()).size() > 0) {
1127
					.collect(Collectors.toList()).size() > 0) {
1128
				if (priceModel.getPrice() > customFofoOrderItem.getSellingPrice()) {
1128
				if (priceModel.getPrice() > customFofoOrderItem.getSellingPrice() + customFofoOrderItem.getDiscountAmount()) {
1129
					throw new ProfitMandiBusinessException("Selling Price for ",
1129
					throw new ProfitMandiBusinessException("Selling Price for ",
1130
							itemRepository.selectById(itemId).getItemDescription(), "FFORDR_1010");
1130
							itemRepository.selectById(itemId).getItemDescription(), "FFORDR_1010");
1131
				}
1131
				}
1132
			} else {
1132
			} else {
1133
				if (priceModel.getPurchasePrice() > customFofoOrderItem.getSellingPrice()) {
1133
				if (priceModel.getPurchasePrice() > customFofoOrderItem.getSellingPrice()) {
Line 1142... Line 1142...
1142
	private void validateMopPrice(Map<Integer, PriceModel> itemIdMopPriceMap,
1142
	private void validateMopPrice(Map<Integer, PriceModel> itemIdMopPriceMap,
1143
			Map<Integer, CustomFofoOrderItem> itemIdCustomFofoLineItemMap) throws ProfitMandiBusinessException {
1143
			Map<Integer, CustomFofoOrderItem> itemIdCustomFofoLineItemMap) throws ProfitMandiBusinessException {
1144
		Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
1144
		Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
1145
		for (Map.Entry<Integer, PriceModel> entry : itemIdMopPriceMap.entrySet()) {
1145
		for (Map.Entry<Integer, PriceModel> entry : itemIdMopPriceMap.entrySet()) {
1146
			CustomFofoOrderItem customFofoOrderItem = itemIdCustomFofoLineItemMap.get(entry.getKey());
1146
			CustomFofoOrderItem customFofoOrderItem = itemIdCustomFofoLineItemMap.get(entry.getKey());
1147
			if (customFofoOrderItem.getSellingPrice() < entry.getValue().getPrice()) {
1147
			if (customFofoOrderItem.getSellingPrice() + customFofoOrderItem.getDiscountAmount() < entry.getValue().getPrice()) {
1148
				invalidMopItemIdPriceMap.put(entry.getKey(), customFofoOrderItem.getSellingPrice());
1148
				invalidMopItemIdPriceMap.put(entry.getKey(), customFofoOrderItem.getSellingPrice());
1149
			}
1149
			}
1150
		}
1150
		}
1151
 
1151
 
1152
		if (!invalidMopItemIdPriceMap.isEmpty()) {
1152
		if (!invalidMopItemIdPriceMap.isEmpty()) {
Line 1462... Line 1462...
1462
		for (CustomPaymentOption customPaymentOption : customPaymentOptions) {
1462
		for (CustomPaymentOption customPaymentOption : customPaymentOptions) {
1463
			paymentOptionIds.add(customPaymentOption.getPaymentOptionId());
1463
			paymentOptionIds.add(customPaymentOption.getPaymentOptionId());
1464
			calculatedAmount = calculatedAmount + customPaymentOption.getAmount();
1464
			calculatedAmount = calculatedAmount + customPaymentOption.getAmount();
1465
		}
1465
		}
1466
		if (calculatedAmount != totalAmount) {
1466
		if (calculatedAmount != totalAmount) {
1467
			LOGGER.warn("Error occured while validating payment options amount[{}] != TotalAmount [{}]",
1467
			LOGGER.warn("Error occured while validating payment options amount - {} != TotalAmount {}",
1468
					calculatedAmount, totalAmount);
1468
					calculatedAmount, totalAmount);
1469
			throw new ProfitMandiBusinessException(ProfitMandiConstants.PAYMENT_OPTION_CALCULATED_AMOUNT,
1469
			throw new ProfitMandiBusinessException(ProfitMandiConstants.PAYMENT_OPTION_CALCULATED_AMOUNT,
1470
					calculatedAmount, "FFORDR_1016");
1470
					calculatedAmount, "FFORDR_1016");
1471
		}
1471
		}
1472
 
1472