Subversion Repositories SmartDukaan

Rev

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

Rev 27302 Rev 27303
Line 1007... Line 1007...
1007
						fofoLineItemRepository.delete(fli);
1007
						fofoLineItemRepository.delete(fli);
1008
					}
1008
					}
1009
				}
1009
				}
1010
				//Rollback entry with reversal reason
1010
				//Rollback entry with reversal reason
1011
				if(fofoOrder.getCreateTimestamp().isAfter(LocalDate.of(2020, 4, 1).atStartOfDay())) {
1011
				if(fofoOrder.getCreateTimestamp().isAfter(LocalDate.of(2020, 4, 1).atStartOfDay())) {
1012
					float invoiceWalletAmount = 0;
-
 
1013
					float invoiceSchemeReversalAmount = 0;
1012
					float invoiceSchemeReversalAmount = 0;
1014
					List<UserWalletHistory> userWalletHistory = userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(fofoOrder.getId(), WalletReferenceType.SCHEME_OUT);
1013
					List<UserWalletHistory> userWalletHistory = userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(fofoOrder.getId(), WalletReferenceType.SCHEME_OUT);
1015
					float amountToRollback =  userWalletHistory.stream().collect(Collectors.summingInt(y->y.getAmount()));
1014
					float invoiceWalletAmount =  userWalletHistory.stream().collect(Collectors.summingInt(y->y.getAmount()));
1016
					totalAmount += amountToRollback;
1015
					totalAmount += invoiceWalletAmount;
1017
					invoiceWalletAmount += amountToRollback;
-
 
1018
					try {
1016
					try {
1019
					walletService.rollbackAmountFromWallet(fofoOrder.getFofoId(), amountToRollback, fofoOrder.getId(), WalletReferenceType.SCHEME_OUT, 
1017
					walletService.rollbackAmountFromWallet(fofoOrder.getFofoId(), invoiceWalletAmount, fofoOrder.getId(), WalletReferenceType.SCHEME_OUT, 
1020
							"Same order for Invoice-"+ invoiceNumber + "created twice, duplicate invoice rollback", fofoOrder.getCancelledTimestamp());
1018
							"Same order for Invoice-"+ invoiceNumber + "created twice, duplicate invoice rollback", fofoOrder.getCancelledTimestamp());
1021
					} catch (Exception e) {
1019
					} catch (Exception e) {
1022
						LOGGER.info("Failed wallet update Reson [{}]", e.getMessage());
1020
						LOGGER.info("Failed wallet update Reson [{}]", e.getMessage());
1023
					}
1021
					}
1024
					LOGGER.info("inventoryItemId - {}", inventoryItemId);
1022
					LOGGER.info("inventoryItemId - {}", inventoryItemId);
Line 1036... Line 1034...
1036
								schemeReverseAmount += sio.getAmount();
1034
								schemeReverseAmount += sio.getAmount();
1037
								invoiceSchemeReversalAmount += sio.getAmount();
1035
								invoiceSchemeReversalAmount += sio.getAmount();
1038
							}
1036
							}
1039
						}
1037
						}
1040
					}
1038
					}
-
 
1039
					if(Math.abs(invoiceWalletAmount - invoiceSchemeReversalAmount) < 2) {
-
 
1040
						LOGGER.info("No Matchhhh");
-
 
1041
					}
1041
					LOGGER.info("invoiceWalletAmount - {}, invoiceSchemeReversalAmount {}", invoiceWalletAmount, invoiceSchemeReversalAmount);
1042
 					LOGGER.info("invoiceWalletAmount - {}, invoiceSchemeReversalAmount {}", invoiceWalletAmount, invoiceSchemeReversalAmount);
1042
				} 
1043
				} 
1043
			}
1044
			}
1044
		}
1045
		}
1045
		LOGGER.info("Total Sale Amount Reversal - {}, Total Wallet Amount Reversal {}, Total Scheme Reversal Amount - {}", saleAmount, totalAmount, schemeReverseAmount);
1046
		LOGGER.info("Total Sale Amount Reversal - {}, Total Wallet Amount Reversal {}, Total Scheme Reversal Amount - {}", saleAmount, totalAmount, schemeReverseAmount);
1046
		throw new Exception();
1047
		throw new Exception();