Subversion Repositories SmartDukaan

Rev

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

Rev 23370 Rev 23371
Line 962... Line 962...
962
		}
962
		}
963
	}
963
	}
964
	
964
	
965
	private void createPaymentOptions(int fofoOrderId, Set<CustomPaymentOption> customPaymentOptions) throws ProfitMandiBusinessException{
965
	private void createPaymentOptions(int fofoOrderId, Set<CustomPaymentOption> customPaymentOptions) throws ProfitMandiBusinessException{
966
		for(CustomPaymentOption customPaymentOption : customPaymentOptions){
966
		for(CustomPaymentOption customPaymentOption : customPaymentOptions){
-
 
967
			if(customPaymentOption.getAmount() > 0) {
967
			FofoOrderPaymentOption fofoOrderPaymentOption = new FofoOrderPaymentOption();
968
				FofoOrderPaymentOption fofoOrderPaymentOption = new FofoOrderPaymentOption();
968
			fofoOrderPaymentOption.setFofoOrderId(fofoOrderId);
969
				fofoOrderPaymentOption.setFofoOrderId(fofoOrderId);
969
			fofoOrderPaymentOption.setPaymentOptionId(customPaymentOption.getPaymentOptionId());
970
				fofoOrderPaymentOption.setPaymentOptionId(customPaymentOption.getPaymentOptionId());
970
			fofoOrderPaymentOption.setAmount(customPaymentOption.getAmount());
971
				fofoOrderPaymentOption.setAmount(customPaymentOption.getAmount());
971
			fofoOrderPaymentOptionRepository.persist(fofoOrderPaymentOption);
972
				fofoOrderPaymentOptionRepository.persist(fofoOrderPaymentOption);
-
 
973
			}
972
		}
974
		}
973
	}
975
	}
974
	
976
	
975
	private FofoOrder createAndGetFofoOrder(int customerId, String customerGstNumber, int fofoId, InvoiceNumberGenerationSequence invoiceNumberGenerationSequence, float totalAmount, int customerAddressId){
977
	private FofoOrder createAndGetFofoOrder(int customerId, String customerGstNumber, int fofoId, InvoiceNumberGenerationSequence invoiceNumberGenerationSequence, float totalAmount, int customerAddressId){
976
		FofoOrder fofoOrder = new FofoOrder();
978
		FofoOrder fofoOrder = new FofoOrder();
Line 1146... Line 1148...
1146
	}
1148
	}
1147
 
1149
 
1148
	private void validatePaymentOptionsAndTotalAmount(Set<CustomPaymentOption> customPaymentOptions, float totalAmount) throws ProfitMandiBusinessException
1150
	private void validatePaymentOptionsAndTotalAmount(Set<CustomPaymentOption> customPaymentOptions, float totalAmount) throws ProfitMandiBusinessException
1149
	{
1151
	{
1150
		Set<Integer> paymentOptionIds = new HashSet<>();
1152
		Set<Integer> paymentOptionIds = new HashSet<>();
1151
		Set<Integer> invalidPaymentOptionIdAmounts = new HashSet<>(); 
-
 
1152
		
1153
		
1153
		float calculatedAmount = 0;
1154
		float calculatedAmount = 0;
1154
		for(CustomPaymentOption customPaymentOption : customPaymentOptions){
1155
		for(CustomPaymentOption customPaymentOption : customPaymentOptions){
1155
			if(customPaymentOption.getAmount() <= 0) {
-
 
1156
				invalidPaymentOptionIdAmounts.add(customPaymentOption.getPaymentOptionId());
-
 
1157
			}
-
 
1158
			paymentOptionIds.add(customPaymentOption.getPaymentOptionId());
1156
			paymentOptionIds.add(customPaymentOption.getPaymentOptionId());
1159
			calculatedAmount = calculatedAmount + customPaymentOption.getAmount();
1157
			calculatedAmount = calculatedAmount + customPaymentOption.getAmount();
1160
		}
1158
		}
1161
		if(calculatedAmount != totalAmount){
1159
		if(calculatedAmount != totalAmount){
1162
			LOGGER.warn("Error occured while validating payment options amount[{}] != TotalAmount [{}]", calculatedAmount, totalAmount);
1160
			LOGGER.warn("Error occured while validating payment options amount[{}] != TotalAmount [{}]", calculatedAmount, totalAmount);
1163
			throw new ProfitMandiBusinessException(ProfitMandiConstants.PAYMENT_OPTION_CALCULATED_AMOUNT, calculatedAmount, "FFORDR_1016");
1161
			throw new ProfitMandiBusinessException(ProfitMandiConstants.PAYMENT_OPTION_CALCULATED_AMOUNT, calculatedAmount, "FFORDR_1016");
1164
		}
1162
		}
1165
		
1163
		
1166
		if(!invalidPaymentOptionIdAmounts.isEmpty()) {
-
 
1167
			throw new ProfitMandiBusinessException(ProfitMandiConstants.PAYMENT_OPTION_ID, invalidPaymentOptionIdAmounts, "FFORDR_1018");
-
 
1168
		}
-
 
1169
		List<Integer> foundPaymentOptionIds = paymentOptionRepository.selectIdsByIds(paymentOptionIds);
1164
		List<Integer> foundPaymentOptionIds = paymentOptionRepository.selectIdsByIds(paymentOptionIds);
1170
		if(foundPaymentOptionIds.size() != paymentOptionIds.size()) {
1165
		if(foundPaymentOptionIds.size() != paymentOptionIds.size()) {
1171
			paymentOptionIds.removeAll(foundPaymentOptionIds);
1166
			paymentOptionIds.removeAll(foundPaymentOptionIds);
1172
			throw new ProfitMandiBusinessException(ProfitMandiConstants.PAYMENT_OPTION_ID, paymentOptionIds, "FFORDR_1017");
1167
			throw new ProfitMandiBusinessException(ProfitMandiConstants.PAYMENT_OPTION_ID, paymentOptionIds, "FFORDR_1017");
1173
		}
1168
		}