Subversion Repositories SmartDukaan

Rev

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

Rev 35629 Rev 35895
Line 651... Line 651...
651
        }
651
        }
652
 
652
 
653
    }
653
    }
654
 
654
 
655
 
655
 
656
    // We are maintaining price drop after grn
656
    // Calculate payout amount for an inventory item based on scheme type.
-
 
657
    // For PERCENTAGE schemes: uses price-drop-adjusted DP (purchase price minus any price drop).
-
 
658
    //   GRN (IN): dpForCalc = purchasePrice - priceDropAmount
-
 
659
    //   Sale (OUT): dpForCalc = min(purchasePrice - priceDropAmount, currentSellingPrice)
-
 
660
    //   On price increase, priceDropAmount stays 0 so payout is on original purchase price.
-
 
661
    // For FIXED schemes (IN only): returns the fixed scheme amount directly.
657
    private float getAmount(InventoryItem inventoryItem, Scheme scheme) throws ProfitMandiBusinessException {
662
    private float getAmount(InventoryItem inventoryItem, Scheme scheme) throws ProfitMandiBusinessException {
658
        if (this.getBlockedImeis().contains(inventoryItem.getSerialNumber())) {
663
        if (this.getBlockedImeis().contains(inventoryItem.getSerialNumber())) {
659
            return 0;
664
            return 0;
660
        }
665
        }
661
        float amount = 0;
666
        float amount = 0;
662
        float dpForCalc = 0;
667
        float dpForCalc = 0;
663
        float taxableSellingPrice = 0;
-
 
664
 
668
 
665
        //float totalTaxRate = stateGstRateRepository.getTotalTaxRate(inventoryItem.getItemId());
-
 
666
        if (scheme.getAmountType().equals(AmountType.PERCENTAGE)) {
669
        if (scheme.getAmountType().equals(AmountType.PERCENTAGE)) {
667
            if (scheme.getType().getTransactionType().equals(StockTransactionType.IN)) {
670
            if (scheme.getType().getTransactionType().equals(StockTransactionType.IN)) {
668
                dpForCalc = inventoryItem.getUnitPrice() - inventoryItem.getPriceDropAmount();
671
                dpForCalc = inventoryItem.getUnitPrice() - inventoryItem.getPriceDropAmount();
669
            } else {
672
            } else {
670
                try {
673
                try {
671
                    dpForCalc = Math.min(inventoryItem.getUnitPrice() - inventoryItem.getPriceDropAmount(),
674
                    dpForCalc = Math.min(inventoryItem.getUnitPrice() - inventoryItem.getPriceDropAmount(),
672
                            tagListingRepository.selectByItemId(inventoryItem.getItemId()).getSellingPrice());
675
                            tagListingRepository.selectByItemId(inventoryItem.getItemId()).getSellingPrice());
673
                } catch (Exception e) {
676
                } catch (Exception e) {
674
                    LOGGER.info("Could not find tag Listing entry in {}", inventoryItem.getItemId());
677
                    LOGGER.info("Could not find tag Listing entry for itemId {}", inventoryItem.getItemId());
675
                    e.printStackTrace();
-
 
676
                }
678
                }
677
            }
679
            }
678
            //TODO:Should be calculated on unit price
-
 
679
            //taxableSellingPrice = dpForCalc / (1 + totalTaxRate / 100);
-
 
680
            //amount = taxableSellingPrice * scheme.getAmount() / 100;
-
 
681
            amount = dpForCalc * scheme.getAmount() / 100;
680
            amount = dpForCalc * scheme.getAmount() / 100;
682
            System.out.println(String.format("%d\t%s\t%d\t%d\t%s\t%s\t%s\t%s\t%f\t%f\t%f\t%f", inventoryItem.getId(),
681
            LOGGER.debug("Scheme payout: invId={}, imei={}, schemeId={}, dpForCalc={}, schemeAmt={}%, payout={}",
683
                    inventoryItem.getSerialNumber(), inventoryItem.getItemId(), scheme.getId(), scheme.getName(),
682
                    inventoryItem.getId(), inventoryItem.getSerialNumber(), scheme.getId(),
684
                    scheme.getType(), scheme.getAmountType(), scheme.getPartnerType(), dpForCalc, taxableSellingPrice,
-
 
685
                    scheme.getAmount(), amount));
683
                    dpForCalc, scheme.getAmount(), amount);
686
        } else if (scheme.getType().getTransactionType().equals(StockTransactionType.IN)) {
684
        } else if (scheme.getType().getTransactionType().equals(StockTransactionType.IN)) {
687
            amount = scheme.getAmount();
685
            amount = scheme.getAmount();
688
        }
686
        }
689
        return amount;
687
        return amount;
690
    }
688
    }