Subversion Repositories SmartDukaan

Rev

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

Rev 25043 Rev 25049
Line 654... Line 654...
654
			schemeInOutRepository.persist(schemeInOut);
654
			schemeInOutRepository.persist(schemeInOut);
655
		}
655
		}
656
		return amount;
656
		return amount;
657
	}
657
	}
658
 
658
 
-
 
659
	// We are maintaining price drop after grn
659
	private float getAmount(InventoryItem inventoryItem, Scheme scheme) {
660
	private float getAmount(InventoryItem inventoryItem, Scheme scheme) {
660
		float amount = 0;
661
		float amount = 0;
-
 
662
		float dpForCalc = 0;
-
 
663
		float taxableSellingPrice = 0;
661
		float totalTaxRate = inventoryItem.getIgstRate() + inventoryItem.getSgstRate() + inventoryItem.getCgstRate();
664
		float totalTaxRate = inventoryItem.getIgstRate() + inventoryItem.getSgstRate() + inventoryItem.getCgstRate();
662
		if (scheme.getAmountType() == AmountType.PERCENTAGE) {
665
		if (scheme.getAmountType() == AmountType.PERCENTAGE) {
663
			if (scheme.getType().equals(SchemeType.IN)) {
666
			if (scheme.getType().equals(SchemeType.IN)) {
664
				amount = inventoryItem.getUnitPrice() - inventoryItem.getPriceDropAmount();
667
				dpForCalc = inventoryItem.getUnitPrice() - inventoryItem.getPriceDropAmount();
665
			} else {
668
			} else {
666
				try {
669
				try {
667
					amount = tagListingRepository.selectByItemId(inventoryItem.getItemId()).getSellingPrice();
670
					dpForCalc = tagListingRepository.selectByItemId(inventoryItem.getItemId()).getSellingPrice();
668
				} catch (Exception e) {
671
				} catch (Exception e) {
669
					LOGGER.info("Could not find tag Listing entry in {}", inventoryItem.getItemId());
672
					LOGGER.info("Could not find tag Listing entry in {}", inventoryItem.getItemId());
670
					e.printStackTrace();
673
					e.printStackTrace();
671
				}
674
				}
672
			}
675
			}
673
			float taxableSellingPrice = amount / (1 + totalTaxRate / 100);
676
			taxableSellingPrice = dpForCalc / (1 + totalTaxRate / 100);
674
			amount = taxableSellingPrice * scheme.getAmount() / 100;
677
			amount = taxableSellingPrice * scheme.getAmount() / 100;
-
 
678
			System.out.println(String.format(
-
 
679
					"%d\t%s\t%d\t%d\t%s\t%s\t%s\t%f\t%f\t%f",
-
 
680
					inventoryItem.getId(), inventoryItem.getSerialNumber(), inventoryItem.getItemId(), scheme.getId(),
-
 
681
					scheme.getName(), scheme.getType(), scheme.getAmountType(), dpForCalc, taxableSellingPrice,
-
 
682
					amount));
675
		} else {
683
		} else {
676
			/*
684
			/*
677
			 * List<SchemeInOut> sios = schemeInOutRepository.selectByInventoryItemIds(new
685
			 * List<SchemeInOut> sios = schemeInOutRepository.selectByInventoryItemIds(new
678
			 * HashSet<>(Arrays.asList(inventoryItem.getId()))); List<Integer> schemeIds =
686
			 * HashSet<>(Arrays.asList(inventoryItem.getId()))); List<Integer> schemeIds =
679
			 * sios.stream().filter(x->x.getSchemeType().equals(SchemeType.IN)).map(x->x.
687
			 * sios.stream().filter(x->x.getSchemeType().equals(SchemeType.IN)).map(x->x.
680
			 * getSchemeId()).collect(Collectors.toList()); List<Scheme> schemes =
688
			 * getSchemeId()).collect(Collectors.toList()); List<Scheme> schemes =
681
			 * schemeRepository.selectBySchemeIds(schemeIds, 0, 0); if(schemes.
689
			 * schemeRepository.selectBySchemeIds(schemeIds, 0, 0); if(schemes.
682
			 */
690
			 */
683
			amount = scheme.getAmount();
691
			amount = scheme.getAmount();
-
 
692
			System.out.println(String.format(
-
 
693
					"%d\t%s\t%d\t%d\t%s\t%s\t%s\t%f\t%f\t%f",
-
 
694
					inventoryItem.getId(), inventoryItem.getSerialNumber(), inventoryItem.getItemId(), scheme.getId(),
-
 
695
					scheme.getName(), scheme.getType(), scheme.getAmountType(), dpForCalc, taxableSellingPrice,
-
 
696
					amount));
684
		}
697
		}
-
 
698
 
685
		return amount;
699
		return amount;
686
	}
700
	}
687
 
701
 
688
	@Override
702
	@Override
689
	public void processSchemeOut(int fofoOrderId, int retailerId) throws ProfitMandiBusinessException {
703
	public void processSchemeOut(int fofoOrderId, int retailerId) throws ProfitMandiBusinessException {