| Line 649... |
Line 649... |
| 649 |
|
649 |
|
| 650 |
Map<String, Double> serialNumberPaid = offerPayouts.stream().filter(x -> x.getRejectTimestamp() == null).collect(Collectors.groupingBy(x -> x.getSerialNumber(), Collectors.summingDouble(x -> x.getSlabAmount())));
|
650 |
Map<String, Double> serialNumberPaid = offerPayouts.stream().filter(x -> x.getRejectTimestamp() == null).collect(Collectors.groupingBy(x -> x.getSerialNumber(), Collectors.summingDouble(x -> x.getSlabAmount())));
|
| 651 |
Map<Integer, Map<Integer, List<FofoOrderItem>>> criteriaPartnerwiseTertiary = offerRepository.getCriteriaWisePartnerTertiary(createOfferRequest);
|
651 |
Map<Integer, Map<Integer, List<FofoOrderItem>>> criteriaPartnerwiseTertiary = offerRepository.getCriteriaWisePartnerTertiary(createOfferRequest);
|
| 652 |
|
652 |
|
| 653 |
Map<String, AgeingSummaryModel> ageingSummaryModelsMap = null;
|
653 |
Map<String, AgeingSummaryModel> ageingSummaryModelsMap = null;
|
| 654 |
final Map<String, LocalDateTime> activatedImeisActiovationDateMap;
|
654 |
final Map<String, LocalDateTime> activatedImeisActivationDateMap;
|
| 655 |
if (createOfferRequest.getSchemeType().equals(OfferSchemeType.ACTIVATION)) {
|
655 |
if (createOfferRequest.getSchemeType().equals(OfferSchemeType.ACTIVATION)) {
|
| 656 |
//All Serialnumbers for all eligible retailers
|
656 |
//All Serialnumbers for all eligible retailers
|
| 657 |
List<String> serialNumbers = criteriaPartnerwiseTertiary.entrySet().stream().flatMap(x -> x.getValue().entrySet().stream().flatMap(foiList -> foiList.getValue().stream()))
|
657 |
List<String> serialNumbers = criteriaPartnerwiseTertiary.entrySet().stream().flatMap(x -> x.getValue().entrySet().stream().flatMap(foiList -> foiList.getValue().stream()))
|
| 658 |
.flatMap(y -> y.getFofoLineItems().stream()).filter(fli -> fli.getSerialNumber() != null)
|
658 |
.flatMap(y -> y.getFofoLineItems().stream()).filter(fli -> fli.getSerialNumber() != null)
|
| 659 |
.map(x -> x.getSerialNumber()).collect(Collectors.toList());
|
659 |
.map(x -> x.getSerialNumber()).collect(Collectors.toList());
|
| 660 |
if (serialNumbers.size() > 0) {
|
660 |
if (serialNumbers.size() > 0) {
|
| 661 |
activatedImeisActiovationDateMap = activatedImeiRepository.selectBySerialNumbers(serialNumbers).stream()
|
661 |
activatedImeisActivationDateMap = activatedImeiRepository.selectBySerialNumbers(serialNumbers).stream()
|
| 662 |
.filter(x -> createOfferRequest.isWithinRange(x.getActivationTimestamp()))
|
662 |
.filter(x -> createOfferRequest.isWithinRange(x.getActivationTimestamp()))
|
| 663 |
.collect(Collectors.toMap(x -> x.getSerialNumber(), x -> x.getActivationTimestamp()));
|
663 |
.collect(Collectors.toMap(x -> x.getSerialNumber(), x -> x.getActivationTimestamp()));
|
| 664 |
ageingSummaryModelsMap = warehouseInventoryItemRepository.findStockAgeingByFofoIdSerialNumbers(0, serialNumbers).stream().collect(Collectors.toMap(x -> x.getSerialNumber(), x -> x, (u, v) -> v));
|
664 |
ageingSummaryModelsMap = warehouseInventoryItemRepository.findStockAgeingByFofoIdSerialNumbers(0, serialNumbers).stream().collect(Collectors.toMap(x -> x.getSerialNumber(), x -> x, (u, v) -> v));
|
| 665 |
} else {
|
665 |
} else {
|
| 666 |
activatedImeisActiovationDateMap = null;
|
666 |
activatedImeisActivationDateMap = null;
|
| 667 |
}
|
667 |
}
|
| 668 |
} else {
|
668 |
} else {
|
| 669 |
activatedImeisActiovationDateMap = null;
|
669 |
activatedImeisActivationDateMap = null;
|
| 670 |
}
|
670 |
}
|
| 671 |
|
671 |
|
| 672 |
Map<Integer, Integer> userBaseQtyMap = new HashMap<>();
|
672 |
Map<Integer, Integer> userBaseQtyMap = new HashMap<>();
|
| 673 |
Map<Integer, Integer> userBaseValueMap = new HashMap<>();
|
673 |
Map<Integer, Integer> userBaseValueMap = new HashMap<>();
|
| 674 |
Map<Integer, Integer> eligibleBaseQtyMap = new HashMap<>();
|
674 |
Map<Integer, Integer> eligibleBaseQtyMap = new HashMap<>();
|
| Line 686... |
Line 686... |
| 686 |
if (createOfferRequest.getSchemeType().equals(OfferSchemeType.ACTIVATION)) {
|
686 |
if (createOfferRequest.getSchemeType().equals(OfferSchemeType.ACTIVATION)) {
|
| 687 |
Map<Integer, Integer> inventoryItemValueMap = new HashMap<>();
|
687 |
Map<Integer, Integer> inventoryItemValueMap = new HashMap<>();
|
| 688 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
688 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
| 689 |
fofoOrderItem.getFofoLineItems().stream().filter(x -> x.getSerialNumber() != null).forEach(
|
689 |
fofoOrderItem.getFofoLineItems().stream().filter(x -> x.getSerialNumber() != null).forEach(
|
| 690 |
lineItem -> {
|
690 |
lineItem -> {
|
| 691 |
if (activatedImeisActiovationDateMap == null || activatedImeisActiovationDateMap.containsKey(lineItem.getSerialNumber())) {
|
691 |
if (activatedImeisActivationDateMap == null || activatedImeisActivationDateMap.containsKey(lineItem.getSerialNumber())) {
|
| 692 |
inventoryItemValueMap.put(lineItem.getInventoryItemId(), (int) fofoOrderItem.getDp());
|
692 |
inventoryItemValueMap.put(lineItem.getInventoryItemId(), (int) fofoOrderItem.getDp());
|
| 693 |
}
|
693 |
}
|
| 694 |
}
|
694 |
}
|
| 695 |
);
|
695 |
);
|
| 696 |
}
|
696 |
}
|
| Line 723... |
Line 723... |
| 723 |
Map<FofoLineItem, Integer> lineItemValueMap = new HashMap<>();
|
723 |
Map<FofoLineItem, Integer> lineItemValueMap = new HashMap<>();
|
| 724 |
if (createOfferRequest.getSchemeType().equals(OfferSchemeType.ACTIVATION)) {
|
724 |
if (createOfferRequest.getSchemeType().equals(OfferSchemeType.ACTIVATION)) {
|
| 725 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
725 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
| 726 |
fofoOrderItem.getFofoLineItems().stream().filter(x -> x.getSerialNumber() != null).forEach(
|
726 |
fofoOrderItem.getFofoLineItems().stream().filter(x -> x.getSerialNumber() != null).forEach(
|
| 727 |
lineItem -> {
|
727 |
lineItem -> {
|
| 728 |
if (activatedImeisActiovationDateMap == null) {
|
728 |
if (activatedImeisActivationDateMap == null) {
|
| 729 |
lineItemValueMap.put(lineItem, (int) fofoOrderItem.getDp());
|
729 |
lineItemValueMap.put(lineItem, (int) fofoOrderItem.getDp());
|
| 730 |
|
730 |
|
| 731 |
} else if (activatedImeisActiovationDateMap.containsKey(lineItem.getSerialNumber())) {
|
731 |
} else if (activatedImeisActivationDateMap.containsKey(lineItem.getSerialNumber())) {
|
| 732 |
if (itemCriteriaPayout.isWithinRange(activatedImeisActiovationDateMap.get(lineItem.getSerialNumber()))) {
|
732 |
if (itemCriteriaPayout.isWithinRange(activatedImeisActivationDateMap.get(lineItem.getSerialNumber()))) {
|
| 733 |
lineItemValueMap.put(lineItem, (int) fofoOrderItem.getDp());
|
733 |
lineItemValueMap.put(lineItem, (int) fofoOrderItem.getDp());
|
| 734 |
}
|
734 |
}
|
| 735 |
}
|
735 |
}
|
| 736 |
|
736 |
|
| 737 |
}
|
737 |
}
|
| Line 754... |
Line 754... |
| 754 |
}
|
754 |
}
|
| 755 |
|
755 |
|
| 756 |
|
756 |
|
| 757 |
int totalSale = totalBaseValue;
|
757 |
int totalSale = totalBaseValue;
|
| 758 |
int eligibleSale = eligibleBaseValue;
|
758 |
int eligibleSale = eligibleBaseValue;
|
| 759 |
int criteriaSale = totalValue;
|
- |
|
| 760 |
int eligibleCriteriaSale = eligibleValue;
|
759 |
int eligibleCriteriaSale = eligibleValue;
|
| 761 |
int eligibleCriteriaSaleDp = eligibleValue;
|
760 |
int eligibleCriteriaSaleDp = eligibleValue;
|
| 762 |
|
761 |
|
| 763 |
if (createOfferRequest.getTargetType().equals(AchievementType.QUANTITY)) {
|
762 |
if (createOfferRequest.getTargetType().equals(AchievementType.QUANTITY)) {
|
| 764 |
totalSale = totalBaseQty;
|
763 |
totalSale = totalBaseQty;
|
| 765 |
eligibleSale = eligibleBaseQty;
|
764 |
eligibleSale = eligibleBaseQty;
|
| 766 |
criteriaSale = totalQty;
|
- |
|
| 767 |
eligibleCriteriaSale = eligibleQty;
|
765 |
eligibleCriteriaSale = eligibleQty;
|
| 768 |
}
|
766 |
}
|
| 769 |
|
767 |
|
| 770 |
offerRowModel.setTotalSale(totalSale);
|
768 |
offerRowModel.setTotalSale(totalSale);
|
| 771 |
offerRowModel.setEligibleSale(eligibleSale);
|
769 |
offerRowModel.setEligibleSale(eligibleSale);
|
| 772 |
float eligiblePayoutValue = 0;
|
770 |
float eligiblePayoutValue = 0;
|
| - |
|
771 |
float previousPayoutValue = 0;
|
| 773 |
double finalPayout;
|
772 |
double finalPayout;
|
| 774 |
for (PayoutSlab payoutSlab : itemCriteriaPayout.getPayoutSlabs()) {
|
773 |
for (PayoutSlab payoutSlab : itemCriteriaPayout.getPayoutSlabs()) {
|
| 775 |
if (payoutSlab.getOnwardsAmount() <= eligibleSale) {
|
774 |
if (payoutSlab.getOnwardsAmount() <= eligibleSale) {
|
| 776 |
LOGGER.info("Eligible Sale {}", eligibleSale);
|
775 |
LOGGER.info("Eligible Sale {}", eligibleSale);
|
| 777 |
offerRowModel.setPayoutTargetAchieved(payoutSlab.getOnwardsAmount());
|
776 |
offerRowModel.setPayoutTargetAchieved(payoutSlab.getOnwardsAmount());
|
| 778 |
eligiblePayoutValue = payoutSlab.getPayoutAmount();
|
777 |
eligiblePayoutValue = payoutSlab.getPayoutAmount();
|
| - |
|
778 |
previousPayoutValue = Math.min(eligiblePayoutValue, previousPayoutValue);
|
| 779 |
offerRowModel.setPayoutValue(eligiblePayoutValue);
|
779 |
offerRowModel.setPayoutValue(eligiblePayoutValue);
|
| - |
|
780 |
} else {
|
| - |
|
781 |
break;
|
| 780 |
}
|
782 |
}
|
| 781 |
}
|
783 |
}
|
| 782 |
if (AmountType.PERCENTAGE.equals(itemCriteriaPayout.getAmountType())) {
|
784 |
if (AmountType.PERCENTAGE.equals(itemCriteriaPayout.getAmountType())) {
|
| 783 |
finalPayout = (eligiblePayoutValue * eligibleCriteriaSaleDp) / 100;
|
785 |
finalPayout = (eligiblePayoutValue * eligibleCriteriaSaleDp) / 100;
|
| 784 |
} else if (AmountType.FIXED.equals(itemCriteriaPayout.getAmountType())) {
|
786 |
} else if (AmountType.FIXED.equals(itemCriteriaPayout.getAmountType())) {
|
| Line 787... |
Line 789... |
| 787 |
Map<Integer, Double> fofoCriteriaMap = fixedSlabCriteriaPartnerMap.get(criteriaId);
|
789 |
Map<Integer, Double> fofoCriteriaMap = fixedSlabCriteriaPartnerMap.get(criteriaId);
|
| 788 |
LOGGER.info("fofoCriteriaMap {}", fofoCriteriaMap);
|
790 |
LOGGER.info("fofoCriteriaMap {}", fofoCriteriaMap);
|
| 789 |
finalPayout = eligiblePayoutValue;
|
791 |
finalPayout = eligiblePayoutValue;
|
| 790 |
if (fofoCriteriaMap != null) {
|
792 |
if (fofoCriteriaMap != null) {
|
| 791 |
if (fofoCriteriaMap.containsKey(fofoId)) {
|
793 |
if (fofoCriteriaMap.containsKey(fofoId)) {
|
| 792 |
double totalPayout = fofoCriteriaMap.get(fofoId);
|
794 |
//double totalPayout = fofoCriteriaMap.get(fofoId);
|
| 793 |
finalPayout = eligiblePayoutValue - totalPayout;
|
795 |
finalPayout = eligiblePayoutValue - previousPayoutValue;
|
| 794 |
if (Math.abs(finalPayout) < Utils.DOUBLE_EPSILON) {
|
796 |
if (Math.abs(finalPayout) < Utils.DOUBLE_EPSILON) {
|
| 795 |
finalPayout = 0;
|
797 |
finalPayout = 0;
|
| 796 |
}
|
798 |
}
|
| 797 |
}
|
799 |
}
|
| 798 |
}
|
800 |
}
|
| Line 800... |
Line 802... |
| 800 |
|
802 |
|
| 801 |
LOGGER.info("Final Payout - {}", finalPayout);
|
803 |
LOGGER.info("Final Payout - {}", finalPayout);
|
| 802 |
|
804 |
|
| 803 |
if (finalPayout > 0) {
|
805 |
if (finalPayout > 0) {
|
| 804 |
List<Integer> inventoryItemIds = lineItemValueMap.keySet().stream().map(x -> x.getInventoryItemId()).collect(Collectors.toList());
|
806 |
List<Integer> inventoryItemIds = lineItemValueMap.keySet().stream().map(x -> x.getInventoryItemId()).collect(Collectors.toList());
|
| - |
|
807 |
int totalDpValue = lineItemValueMap.values().stream().collect(Collectors.summingInt(x -> x));
|
| - |
|
808 |
LOGGER.info("Total DP Value {}", totalDpValue);
|
| 805 |
Map<Integer, InventoryItem> inventoryItemsMap = inventoryItemRepository.selectAllByIds(inventoryItemIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
809 |
Map<Integer, InventoryItem> inventoryItemsMap = inventoryItemRepository.selectAllByIds(inventoryItemIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 806 |
for (Map.Entry<FofoLineItem, Integer> lineItemValueEntry : lineItemValueMap.entrySet()) {
|
810 |
for (Map.Entry<FofoLineItem, Integer> lineItemValueEntry : lineItemValueMap.entrySet()) {
|
| 807 |
FofoLineItem fofoLineItem = lineItemValueEntry.getKey();
|
811 |
FofoLineItem fofoLineItem = lineItemValueEntry.getKey();
|
| 808 |
if (ageingSummaryModelsMap.containsKey(fofoLineItem.getSerialNumber())) {
|
- |
|
| 809 |
if (ageingSummaryModelsMap.get(fofoLineItem.getSerialNumber()).isAgedAbove(300)) {
|
- |
|
| 810 |
continue;
|
- |
|
| 811 |
}
|
- |
|
| 812 |
}
|
- |
|
| 813 |
double amount = 0;
|
812 |
double amount = 0;
|
| 814 |
int totalDpValue = lineItemValueMap.values().stream().collect(Collectors.summingInt(x -> x));
|
- |
|
| 815 |
LOGGER.info("Total DP Value {}", totalDpValue);
|
- |
|
| 816 |
if (AmountType.SLAB_FIXED.equals(itemCriteriaPayout.getAmountType())) {
|
813 |
if (AmountType.SLAB_FIXED.equals(itemCriteriaPayout.getAmountType())) {
|
| 817 |
amount = (eligiblePayoutValue * lineItemValueEntry.getValue()) / totalDpValue;
|
814 |
amount = (eligiblePayoutValue * lineItemValueEntry.getValue()) / totalDpValue;
|
| 818 |
LOGGER.info("Amount - {}", amount);
|
- |
|
| 819 |
//Fixed slab should be treated as fixed after payout
|
- |
|
| 820 |
} else {
|
815 |
} else {
|
| 821 |
amount = eligiblePayoutValue;
|
816 |
if (ageingSummaryModelsMap.containsKey(fofoLineItem.getSerialNumber())) {
|
| 822 |
//Fixed slab has already taken care of that amount;
|
817 |
if (ageingSummaryModelsMap.get(fofoLineItem.getSerialNumber()).isAgedAbove(300)) {
|
| 823 |
if (serialNumberPaid.containsKey(fofoLineItem.getSerialNumber())) {
|
818 |
continue;
|
| 824 |
amount = amount - serialNumberPaid.get(fofoLineItem.getSerialNumber());
|
819 |
}
|
| 825 |
}
|
820 |
}
|
| - |
|
821 |
amount = eligiblePayoutValue;
|
| - |
|
822 |
}
|
| - |
|
823 |
if (serialNumberPaid.containsKey(fofoLineItem.getSerialNumber())) {
|
| - |
|
824 |
amount = amount - serialNumberPaid.get(fofoLineItem.getSerialNumber());
|
| 826 |
}
|
825 |
}
|
| 827 |
LOGGER.info("Amount - {}", amount);
|
826 |
LOGGER.info("Amount - {}", amount);
|
| 828 |
//ignore reasonably small
|
827 |
//ignore reasonably small
|
| 829 |
if (amount < Utils.DOUBLE_EPSILON) continue;
|
828 |
if (amount < Utils.DOUBLE_EPSILON) continue;
|
| 830 |
AmountModel amountModel = new AmountModel();
|
829 |
AmountModel amountModel = new AmountModel();
|
| Line 918... |
Line 917... |
| 918 |
if (createOfferRequest.getTargetType().equals(AchievementType.VALUE)) {
|
917 |
if (createOfferRequest.getTargetType().equals(AchievementType.VALUE)) {
|
| 919 |
purchasedValue = totalBaseValue;
|
918 |
purchasedValue = totalBaseValue;
|
| 920 |
} else {
|
919 |
} else {
|
| 921 |
purchasedValue = totalBaseQty;
|
920 |
purchasedValue = totalBaseQty;
|
| 922 |
}
|
921 |
}
|
| 923 |
PayoutSlab currentSlab = itemCriteriaPayout.getPayoutSlabs().stream()
|
- |
|
| 924 |
.filter(x -> x.getOnwardsAmount() <= purchasedValue).max(Comparator.comparing(x
|
- |
|
| 925 |
-> x.getOnwardsAmount())).orElse(null);
|
- |
|
| 926 |
|
922 |
|
| - |
|
923 |
PayoutSlab eligibleSlab = null;
|
| - |
|
924 |
PayoutSlab previousSlab = null;
|
| - |
|
925 |
|
| - |
|
926 |
for (PayoutSlab payoutSlab : itemCriteriaPayout.getPayoutSlabs()) {
|
| - |
|
927 |
if (payoutSlab.getOnwardsAmount() <= purchasedValue) {
|
| 927 |
//TODO-- payouts handling is here
|
928 |
previousSlab = eligibleSlab;
|
| 928 |
if (currentSlab == null) continue;
|
929 |
eligibleSlab = payoutSlab;
|
| - |
|
930 |
} else {
|
| - |
|
931 |
break;
|
| - |
|
932 |
}
|
| - |
|
933 |
}
|
| 929 |
List<Integer> orderIds = orders.stream().map(x -> x.getId()).collect(Collectors.toList());
|
934 |
List<Integer> orderIds = orders.stream().map(x -> x.getId()).collect(Collectors.toList());
|
| 930 |
Map<Integer, LineItem> lineItemMap = orders.stream().collect(Collectors.toMap(x -> x.getLineItem().getId(), x -> x.getLineItem()));
|
935 |
Map<Integer, LineItem> lineItemMap = orders.stream().collect(Collectors.toMap(x -> x.getLineItem().getId(), x -> x.getLineItem()));
|
| 931 |
List<WarehouseScan> warehouseScans = warehouseScanRepository.selectAllByOrderIds(orderIds);
|
936 |
List<WarehouseScan> warehouseScans = warehouseScanRepository.selectAllByOrderIds(orderIds);
|
| 932 |
LOGGER.info("Warehosue scans --> {}", warehouseScans);
|
937 |
LOGGER.info("Warehosue scans --> {}", warehouseScans);
|
| 933 |
List<Integer> warehouseInventoryItemIds = warehouseScans.stream().collect(Collectors.groupingBy(x -> x.getInventoryItemId())).entrySet()
|
938 |
List<Integer> warehouseInventoryItemIds = warehouseScans.stream().collect(Collectors.groupingBy(x -> x.getInventoryItemId())).entrySet()
|
| Line 958... |
Line 963... |
| 958 |
Map<String, InventoryItem> serialNumberInventoryItemMap = this.getInventoryItemMap(fofoId, serialNumberMap);
|
963 |
Map<String, InventoryItem> serialNumberInventoryItemMap = this.getInventoryItemMap(fofoId, serialNumberMap);
|
| 959 |
//Continue if all imeis havent been grned
|
964 |
//Continue if all imeis havent been grned
|
| 960 |
if (serialNumberInventoryItemMap.size() < serialNumberCountMap.size()) continue;
|
965 |
if (serialNumberInventoryItemMap.size() < serialNumberCountMap.size()) continue;
|
| 961 |
|
966 |
|
| 962 |
|
967 |
|
| 963 |
float eligiblePayoutValue = currentSlab.getPayoutAmount();
|
968 |
float eligiblePayoutValue = eligibleSlab.getPayoutAmount();
|
| 964 |
double finalPayout;
|
969 |
double finalPayout;
|
| 965 |
if (AmountType.PERCENTAGE.equals(itemCriteriaPayout.getAmountType())) {
|
970 |
if (AmountType.PERCENTAGE.equals(itemCriteriaPayout.getAmountType())) {
|
| 966 |
finalPayout = (eligiblePayoutValue * purchasedValue) / 100;
|
971 |
finalPayout = (eligiblePayoutValue * purchasedValue) / 100;
|
| 967 |
} else if (AmountType.FIXED.equals(itemCriteriaPayout.getAmountType())) {
|
972 |
} else if (AmountType.FIXED.equals(itemCriteriaPayout.getAmountType())) {
|
| 968 |
finalPayout = eligiblePayoutValue * purchasedValue;
|
973 |
finalPayout = eligiblePayoutValue * purchasedValue;
|
| Line 971... |
Line 976... |
| 971 |
LOGGER.info("fofoCriteriaMap {}", fofoCriteriaMap);
|
976 |
LOGGER.info("fofoCriteriaMap {}", fofoCriteriaMap);
|
| 972 |
finalPayout = eligiblePayoutValue;
|
977 |
finalPayout = eligiblePayoutValue;
|
| 973 |
if (fofoCriteriaMap != null) {
|
978 |
if (fofoCriteriaMap != null) {
|
| 974 |
if (fofoCriteriaMap.containsKey(fofoId)) {
|
979 |
if (fofoCriteriaMap.containsKey(fofoId)) {
|
| 975 |
double totalPayout = fofoCriteriaMap.get(fofoId);
|
980 |
double totalPayout = fofoCriteriaMap.get(fofoId);
|
| 976 |
finalPayout = eligiblePayoutValue - totalPayout;
|
981 |
finalPayout = eligiblePayoutValue - previousSlab.getPayoutAmount();
|
| 977 |
if (Math.abs(finalPayout) < Utils.DOUBLE_EPSILON) {
|
982 |
if (Math.abs(finalPayout) < Utils.DOUBLE_EPSILON) {
|
| 978 |
finalPayout = 0;
|
983 |
finalPayout = 0;
|
| 979 |
}
|
984 |
}
|
| 980 |
}
|
985 |
}
|
| 981 |
}
|
986 |
}
|
| Line 990... |
Line 995... |
| 990 |
double amount = 0;
|
995 |
double amount = 0;
|
| 991 |
LOGGER.info("Total DP Value {}", totalDpValue);
|
996 |
LOGGER.info("Total DP Value {}", totalDpValue);
|
| 992 |
if (AmountType.SLAB_FIXED.equals(itemCriteriaPayout.getAmountType())) {
|
997 |
if (AmountType.SLAB_FIXED.equals(itemCriteriaPayout.getAmountType())) {
|
| 993 |
amount = (eligiblePayoutValue * serialNumberInventoryItemEntry.getValue().getUnitPrice()) / totalDpValue;
|
998 |
amount = (eligiblePayoutValue * serialNumberInventoryItemEntry.getValue().getUnitPrice()) / totalDpValue;
|
| 994 |
LOGGER.info("Amount - {}", amount);
|
999 |
LOGGER.info("Amount - {}", amount);
|
| 995 |
//Fixed slab should be treated as fixed after payout
|
- |
|
| 996 |
} else {
|
1000 |
} else {
|
| 997 |
amount = eligiblePayoutValue;
|
1001 |
amount = eligiblePayoutValue;
|
| 998 |
//Fixed slab has already taken care of that amount;
|
- |
|
| 999 |
if (serialNumberPaid.containsKey(serialNumberInventoryItemEntry.getKey())) {
|
1002 |
if (serialNumberPaid.containsKey(serialNumberInventoryItemEntry.getKey())) {
|
| 1000 |
amount = amount - serialNumberPaid.get(serialNumberInventoryItemEntry.getKey());
|
1003 |
amount = amount - serialNumberPaid.get(serialNumberInventoryItemEntry.getKey());
|
| 1001 |
}
|
1004 |
}
|
| 1002 |
}
|
1005 |
}
|
| 1003 |
LOGGER.info("Amount - {}", amount);
|
1006 |
LOGGER.info("Amount - {}", amount);
|
| 1004 |
//ignore reasonably small
|
1007 |
//ignore reasonably small
|
| 1005 |
if (amount < Utils.DOUBLE_EPSILON) continue;
|
1008 |
if (Math.abs(amount) < Utils.DOUBLE_EPSILON) continue;
|
| 1006 |
AmountModel amountModel = new AmountModel();
|
1009 |
AmountModel amountModel = new AmountModel();
|
| 1007 |
amountModel.setAmountType(itemCriteriaPayout.getAmountType());
|
1010 |
amountModel.setAmountType(itemCriteriaPayout.getAmountType());
|
| 1008 |
amountModel.setAmount(amount);
|
1011 |
amountModel.setAmount(amount);
|
| 1009 |
amountModel.setDiscount(createOfferRequest.isDiscount());
|
1012 |
amountModel.setDiscount(createOfferRequest.isDiscount());
|
| 1010 |
InventoryPayoutModel inventoryPayoutModel = priceCircularService.getPayouts(serialNumberInventoryItemEntry.getValue());
|
1013 |
InventoryPayoutModel inventoryPayoutModel = priceCircularService.getPayouts(serialNumberInventoryItemEntry.getValue());
|