Subversion Repositories SmartDukaan

Rev

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

Rev 37588 Rev 37592
Line 36... Line 36...
36
    private int fofoId;
36
    private int fofoId;
37
 
37
 
38
    @Column(name = "wallet_amount")
38
    @Column(name = "wallet_amount")
39
    private BigDecimal walletAmount = BigDecimal.ZERO;
39
    private BigDecimal walletAmount = BigDecimal.ZERO;
40
 
40
 
-
 
41
    /** Gross stock value; the live-demo haircut is applied by {@link #getNetInStockAmount()}. */
41
    @Column(name = "in_stock_amount")
42
    @Column(name = "in_stock_gross_amount")
42
    private BigDecimal inStockAmount = BigDecimal.ZERO;
43
    private BigDecimal inStockGrossAmount = BigDecimal.ZERO;
43
 
44
 
44
    @Column(name = "unbilled_amount")
45
    @Column(name = "unbilled_amount")
45
    private BigDecimal unbilledAmount = BigDecimal.ZERO;
46
    private BigDecimal unbilledAmount = BigDecimal.ZERO;
46
 
47
 
47
    @Column(name = "grn_pending_amount")
48
    @Column(name = "grn_pending_amount")
Line 60... Line 61...
60
    private BigDecimal utilizedAmount = BigDecimal.ZERO;
61
    private BigDecimal utilizedAmount = BigDecimal.ZERO;
61
 
62
 
62
    @Column(name = "aged_apple_stock_amount")
63
    @Column(name = "aged_apple_stock_amount")
63
    private BigDecimal agedAppleStockAmount = BigDecimal.ZERO;
64
    private BigDecimal agedAppleStockAmount = BigDecimal.ZERO;
64
 
65
 
-
 
66
    /** Unit count behind {@link #agedAppleStockAmount}; maintained on the same daily cycle. */
-
 
67
    @Column(name = "aged_apple_qty")
-
 
68
    private int agedAppleQty;
-
 
69
 
65
    @Column(name = "demo_excluded_amount")
70
    @Column(name = "demo_excluded_amount")
66
    private BigDecimal demoExcludedAmount = BigDecimal.ZERO;
71
    private BigDecimal demoExcludedAmount = BigDecimal.ZERO;
67
 
72
 
68
    @Column(name = "aged_refreshed_on")
73
    @Column(name = "aged_refreshed_on")
69
    private LocalDate agedRefreshedOn;
74
    private LocalDate agedRefreshedOn;
Line 95... Line 100...
95
     * utilisation — the same chain PartnerLimitHelper.getSuggestedAmount() applies before the tier
100
     * utilisation — the same chain PartnerLimitHelper.getSuggestedAmount() applies before the tier
96
     * multiply. Keeping it here means the limit never has to re-derive it from separate reads.
101
     * multiply. Keeping it here means the limit never has to re-derive it from separate reads.
97
     */
102
     */
98
    public void recalculate() {
103
    public void recalculate() {
99
        BigDecimal total = scaled(walletAmount)
104
        BigDecimal total = scaled(walletAmount)
100
                .add(scaled(inStockAmount))
105
                .add(getNetInStockAmount())
101
                .add(scaled(unbilledAmount))
106
                .add(scaled(unbilledAmount))
102
                .add(scaled(grnPendingAmount))
107
                .add(scaled(grnPendingAmount))
103
                .add(scaled(returnInTransitAmount))
108
                .add(scaled(returnInTransitAmount))
104
                .subtract(scaled(activatedStockAmount))
109
                .subtract(scaled(activatedStockAmount))
105
                .subtract(scaled(activatedGrnPendingAmount));
110
                .subtract(scaled(activatedGrnPendingAmount));
Line 131... Line 136...
131
 
136
 
132
    public void setWalletAmount(BigDecimal walletAmount) {
137
    public void setWalletAmount(BigDecimal walletAmount) {
133
        this.walletAmount = scaled(walletAmount);
138
        this.walletAmount = scaled(walletAmount);
134
    }
139
    }
135
 
140
 
136
    public BigDecimal getInStockAmount() {
141
    public BigDecimal getInStockGrossAmount() {
137
        return inStockAmount;
142
        return inStockGrossAmount;
-
 
143
    }
-
 
144
 
-
 
145
    public void setInStockGrossAmount(BigDecimal inStockGrossAmount) {
-
 
146
        this.inStockGrossAmount = scaled(inStockGrossAmount);
138
    }
147
    }
139
 
148
 
-
 
149
    /**
-
 
150
     * Stock as investment counts it: gross less live-demo units held past 90 days.
-
 
151
     *
-
 
152
     * <p>This is what {@code InventoryService.getTotalAmountInStock()} returns and what both
-
 
153
     * original investment paths assigned to {@code PartnerDailyInvestment.inStockAmount} — which is
-
 
154
     * why {@code getTotalInvestment()} carries no separate demo term. Derived rather than stored so
-
 
155
     * that the daily demo refresh flows through to stock and base with nothing to keep in sync.
-
 
156
     */
140
    public void setInStockAmount(BigDecimal inStockAmount) {
157
    public BigDecimal getNetInStockAmount() {
141
        this.inStockAmount = scaled(inStockAmount);
158
        return scaled(scaled(inStockGrossAmount).subtract(scaled(demoExcludedAmount)));
142
    }
159
    }
143
 
160
 
144
    public BigDecimal getUnbilledAmount() {
161
    public BigDecimal getUnbilledAmount() {
145
        return unbilledAmount;
162
        return unbilledAmount;
146
    }
163
    }
Line 195... Line 212...
195
 
212
 
196
    public void setAgedAppleStockAmount(BigDecimal agedAppleStockAmount) {
213
    public void setAgedAppleStockAmount(BigDecimal agedAppleStockAmount) {
197
        this.agedAppleStockAmount = scaled(agedAppleStockAmount);
214
        this.agedAppleStockAmount = scaled(agedAppleStockAmount);
198
    }
215
    }
199
 
216
 
-
 
217
    public int getAgedAppleQty() {
-
 
218
        return agedAppleQty;
-
 
219
    }
-
 
220
 
-
 
221
    public void setAgedAppleQty(int agedAppleQty) {
-
 
222
        this.agedAppleQty = agedAppleQty;
-
 
223
    }
-
 
224
 
200
    public BigDecimal getDemoExcludedAmount() {
225
    public BigDecimal getDemoExcludedAmount() {
201
        return demoExcludedAmount;
226
        return demoExcludedAmount;
202
    }
227
    }
203
 
228
 
204
    public void setDemoExcludedAmount(BigDecimal demoExcludedAmount) {
229
    public void setDemoExcludedAmount(BigDecimal demoExcludedAmount) {
Line 239... Line 264...
239
 
264
 
240
    @Override
265
    @Override
241
    public String toString() {
266
    public String toString() {
242
        return "PartnerInvestment{fofoId=" + fofoId
267
        return "PartnerInvestment{fofoId=" + fofoId
243
                + ", wallet=" + walletAmount
268
                + ", wallet=" + walletAmount
244
                + ", inStock=" + inStockAmount
269
                + ", inStockGross=" + inStockGrossAmount
-
 
270
                + ", inStockNet=" + getNetInStockAmount()
245
                + ", unbilled=" + unbilledAmount
271
                + ", unbilled=" + unbilledAmount
246
                + ", grnPending=" + grnPendingAmount
272
                + ", grnPending=" + grnPendingAmount
247
                + ", activatedStock=" + activatedStockAmount
273
                + ", activatedStock=" + activatedStockAmount
248
                + ", activatedGrnPending=" + activatedGrnPendingAmount
274
                + ", activatedGrnPending=" + activatedGrnPendingAmount
249
                + ", agedApple=" + agedAppleStockAmount
275
                + ", agedApple=" + agedAppleStockAmount