Subversion Repositories SmartDukaan

Rev

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

Rev 24547 Rev 24548
Line 673... Line 673...
673
	public void walletmismatch() throws Exception {
673
	public void walletmismatch() throws Exception {
674
		LocalDate curDate = LocalDate.now();
674
		LocalDate curDate = LocalDate.now();
675
		List<Integer> mismatched = new ArrayList<>();
675
		List<Integer> mismatched = new ArrayList<>();
676
		List<PartnerDailyInvestment> pdis = partnerDailyInvestmentRepository.selectAll(curDate.minusDays(1));
676
		List<PartnerDailyInvestment> pdis = partnerDailyInvestmentRepository.selectAll(curDate.minusDays(1));
677
		for (PartnerDailyInvestment pdi : pdis) {
677
		for (PartnerDailyInvestment pdi : pdis) {
678
			LOGGER.info("PartnerDaily", pdi.getFofoId());
678
			LOGGER.info("PartnerId - {}, Wallet Amount {}, Statement {}", pdi.getFofoId(), pdi.getWalletAmount(),
-
 
679
					walletService.getOpeningTill(pdi.getFofoId(), curDate.atStartOfDay()));
679
			if (pdi.getWalletAmount() != walletService.getOpeningTill(pdi.getFofoId(), curDate.atStartOfDay())) {
680
			if (pdi.getWalletAmount() != walletService.getOpeningTill(pdi.getFofoId(), curDate.atStartOfDay())) {
680
				mismatched.add(pdi.getFofoId());
681
				mismatched.add(pdi.getFofoId());
681
				LOGGER.info("Added mistmatch for partnerId {}", pdi.getFofoId());
682
				LOGGER.info("Added mistmatch for partnerId {}", pdi.getFofoId());
682
			}
683
			}
683
		}
684
		}
684
 
685
 
685
		for (Integer fofoId : mismatched) {
686
		for (Integer fofoId : mismatched) {
686
			for (PartnerDailyInvestment investment : Lists
687
			for (PartnerDailyInvestment investment : Lists
687
					.reverse(partnerDailyInvestmentRepository.selectAll(fofoId, null, null))) {
688
					.reverse(partnerDailyInvestmentRepository.selectAll(fofoId, null, null))) {
-
 
689
				if (investment.getDate().isAfter(LocalDate.of(2018, 12, 20))) {
688
				float statementAmount = walletService.getOpeningTill(fofoId, investment.getDate().plusDays(1).atStartOfDay());
690
					float statementAmount = walletService.getOpeningTill(fofoId,
-
 
691
							investment.getDate().plusDays(1).atStartOfDay());
689
				if (investment.getWalletAmount() != statementAmount) {
692
					if (investment.getWalletAmount() != statementAmount) {
690
					LOGGER.info("{}\t{}\t{}\t{}", fofoId, investment.getDate(), investment.getWalletAmount(),
693
						LOGGER.info("{}\t{}\t{}\t{}", fofoId, investment.getDate(), investment.getWalletAmount(),
691
							statementAmount);
694
								statementAmount);
692
					break;
695
						break;
-
 
696
					}
693
				}
697
				}
694
			}
698
			}
695
 
699
 
696
		}
700
		}
697
	}
701
	}
Line 766... Line 770...
766
			throw new ProfitMandiBusinessException("Escalated Ticket", to, "Could not send Escalated ticket mail");
770
			throw new ProfitMandiBusinessException("Escalated Ticket", to, "Could not send Escalated ticket mail");
767
		}
771
		}
768
	}
772
	}
769
 
773
 
770
	public void gst() throws Exception {
774
	public void gst() throws Exception {
771
		List<FofoOrder> fofoOrders = fofoOrderRepository.selectBetweenSaleDate(LocalDate.of(2019, 1, 26).atStartOfDay(), LocalDate.of(2019, 1, 27).atTime(LocalTime.MAX));
775
		List<FofoOrder> fofoOrders = fofoOrderRepository.selectBetweenSaleDate(LocalDate.of(2019, 1, 26).atStartOfDay(),
-
 
776
				LocalDate.of(2019, 1, 27).atTime(LocalTime.MAX));
772
		for(FofoOrder fofoOrder : fofoOrders) {
777
		for (FofoOrder fofoOrder : fofoOrders) {
773
			int retailerAddressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(fofoOrder.getFofoId());
778
			int retailerAddressId = retailerRegisteredAddressRepository
-
 
779
					.selectAddressIdByRetailerId(fofoOrder.getFofoId());
774
 
780
 
775
			Address retailerAddress = addressRepository.selectById(retailerAddressId);
781
			Address retailerAddress = addressRepository.selectById(retailerAddressId);
776
			CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
782
			CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
777
			Integer stateId = null;
783
			Integer stateId = null;
778
			if (customerAddress.getState().equals(retailerAddress.getState())) {
784
			if (customerAddress.getState().equals(retailerAddress.getState())) {
Line 782... Line 788...
782
					LOGGER.error("Unable to get state rates");
788
					LOGGER.error("Unable to get state rates");
783
				}
789
				}
784
			}
790
			}
785
			Map<Integer, GstRate> itemIdStateTaxRateMap = null;
791
			Map<Integer, GstRate> itemIdStateTaxRateMap = null;
786
			Map<Integer, Float> itemIdIgstTaxRateMap = null;
792
			Map<Integer, Float> itemIdIgstTaxRateMap = null;
787
			
793
 
788
			List<FofoOrderItem> fofoOrderItems  = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
794
			List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
789
			Set<Integer> itemIds = fofoOrderItems.stream().map(x->x.getItemId()).collect(Collectors.toSet());
795
			Set<Integer> itemIds = fofoOrderItems.stream().map(x -> x.getItemId()).collect(Collectors.toSet());
790
			if (stateId != null) {
796
			if (stateId != null) {
791
				itemIdStateTaxRateMap = Utils.getStateTaxRate(new ArrayList<>(itemIds), stateId);
797
				itemIdStateTaxRateMap = Utils.getStateTaxRate(new ArrayList<>(itemIds), stateId);
792
			} else {
798
			} else {
793
				itemIdIgstTaxRateMap = Utils.getIgstTaxRate(new ArrayList<>(itemIds));
799
				itemIdIgstTaxRateMap = Utils.getIgstTaxRate(new ArrayList<>(itemIds));
794
			}
800
			}
795
 
801
 
796
			for(FofoOrderItem foi : fofoOrderItems) {
802
			for (FofoOrderItem foi : fofoOrderItems) {
797
				if (stateId == null) {
803
				if (stateId == null) {
798
					foi.setIgstRate(itemIdIgstTaxRateMap.get(foi.getItemId()));
804
					foi.setIgstRate(itemIdIgstTaxRateMap.get(foi.getItemId()));
799
				} else {
805
				} else {
800
					foi.setCgstRate(itemIdStateTaxRateMap.get(foi.getItemId()).getCgstRate());
806
					foi.setCgstRate(itemIdStateTaxRateMap.get(foi.getItemId()).getCgstRate());
801
					foi.setSgstRate(itemIdStateTaxRateMap.get(foi.getItemId()).getSgstRate());
807
					foi.setSgstRate(itemIdStateTaxRateMap.get(foi.getItemId()).getSgstRate());
802
				}
808
				}
803
				fofoOrderItemRepository.persist(foi);
809
				fofoOrderItemRepository.persist(foi);
804
			}
810
			}
805
		}
811
		}
806
		
-
 
807
		
812
 
808
	}
813
	}
809
 
814
 
810
}
815
}