Subversion Repositories SmartDukaan

Rev

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

Rev 31234 Rev 31903
Line 75... Line 75...
75
                #set($fieldIndex=$velocityCount*2 + (4 + $allMargins.size() + $add))
75
                #set($fieldIndex=$velocityCount*2 + (4 + $allMargins.size() + $add))
76
                <th data-idx="$fieldIndex" colspan=2 data-offerid="$offer.getId()"><a href="javascript:void(0)"
76
                <th data-idx="$fieldIndex" colspan=2 data-offerid="$offer.getId()"><a href="javascript:void(0)"
77
                                                                                      class="mk_partner_view">$offer.getName()</a>
77
                                                                                      class="mk_partner_view">$offer.getName()</a>
78
                </th>
78
                </th>
79
            #end
79
            #end
80
            <th rowspan=$rowspan>Total Margin</th>
80
            <th rowspan=$rowspan>NLC</th>
81
            <th rowspan=$rowspan>Net Landing Price</th>
-
 
82
            <th rowspan=$rowspan>MOP-DP</th>
81
            <th rowspan=$rowspan>MOP-DP</th>
83
            <th rowspan=$rowspan>Total Profit</th>
82
            <th rowspan=$rowspan>Total Margin</th>
84
            <th rowspan=$rowspan>Net % Margin</th>
83
            <th rowspan=$rowspan>Net % Margin</th>
85
 
84
 
86
        </tr>
85
        </tr>
87
            #if($rowspan==2)
86
            #if($rowspan==2)
88
            <tr>
87
            <tr>
Line 95... Line 94...
95
                #end
94
                #end
96
            </tr>
95
            </tr>
97
            #end
96
            #end
98
        </thead>
97
        </thead>
99
        <tbody>
98
        <tbody>
100
            #foreach($pc in $priceCircular )
99
            #foreach($priceCircularItemModel in $priceCircularItemModels )
101
            <tr>
100
            <tr>
-
 
101
                <td>$priceCircularItemModel.getCatalogSummaryModel().getModelName() $priceCircularItemModel.getCatalogSummaryModel().getModelNumber()</td>
102
                <td>$pc.getModelName() $pc.getModelNumber()</td>
102
                <td>$priceCircularItemModel.getCatalogSummaryModel().getCategory()</td>
103
                <td>$pc.getType()</td>
103
                <td class="currency">$priceCircularItemModel.getCatalogSummaryModel().getMrp()</td>
104
                <td class="currency">$pc.getMrp()</td>
104
                <td class="currency mop"
-
 
105
                    data-value="$priceCircularItemModel.getCatalogSummaryModel().getMop()">$priceCircularItemModel.getCatalogSummaryModel().getMop()</td>
105
                <td class="currency">$pc.getMop()</td>
106
                <td class="currency dp"
106
                <td class="currency dp" data-value="$pc.getSellingPrice()">$pc.getSellingPrice()</td>
107
                    data-value='$priceCircularItemModel.getCatalogSummaryModel().getDp()'>$priceCircularItemModel.getCatalogSummaryModel().getDp()</td>
107
                #foreach($marginName in $allMargins)
108
                #foreach($marginName in $allMargins)
-
 
109
                    #if ($priceCircularItemModel.getHeaderSchemeModelsMap().containsKey($marginName))
-
 
110
                        <td class="currency margin"
108
                    <td class="currency">$pc.getByPayoutType($marginName)</td>
111
                            data-value='$mvcResponseSender.createResponseString($priceCircularItemModel.getHeaderSchemeModelsMap().get($marginName))'>$mvcResponseSender.createResponseString($priceCircularItemModel.getHeaderSchemeModelsMap().get($marginName))</td>
-
 
112
                    #else
-
 
113
                        <td>-</td>
-
 
114
                    #end
109
                #end
115
                #end
110
                #if($upgradeOffer)
116
                #if($upgradeOffer)
111
                    <td class="currency">$pc.getUpgradeOffer()</td>
117
                    <td class="currency">$priceCircularItemModel.getUpgradeOffer()</td>
112
                #end
118
                #end
113
                #foreach($slabPayouts in $pc.getSlabPayouts())
119
                #foreach($slabPayouts in $priceCircularItemModel.getSlabPayouts())
114
                    #if($slabPayouts && $slabPayouts.size()>0)
120
                    #if($slabPayouts && $slabPayouts.size()>0)
115
                        <td>
121
                        <td>
116
                            <select class="mk_criteria_slab"
122
                            <select class="mk_criteria_slab"
117
                                    data-value="$slabPayouts.entrySet().iterator().next().getValue()">
123
                                    data-value='$slabPayouts.entrySet().iterator().next().getValue()'>
118
                                #foreach($payout in $slabPayouts.entrySet())
124
                                #foreach($payout in $slabPayouts.entrySet())
119
                                    <option data-value="$payout.getValue()"
-
 
120
                                            value="$payout.getKey()">$payout.getKey()
125
                                    <option value='$mvcResponseSender.createResponseString($payout.getValue())'>$payout.getKey()
121
                                        onwards
126
                                        onwards
122
                                    </option>
127
                                    </option>
123
                                #end
128
                                #end
124
                            </select>
129
                            </select>
125
                        </td>
130
                        </td>
-
 
131
                        <td class="currency margin"
-
 
132
                            data-value='$mvcResponseSender.createResponseString($slabPayouts.values().iterator().next())'>
126
                        <td class="currency">$slabPayouts.values().iterator().next()</td>
133
                            $mvcResponseSender.createResponseString($slabPayouts.values().iterator().next())
-
 
134
                        </td>
127
                    #else
135
                    #else
128
                        <td> -</td>
136
                        <td> -</td>
129
                        <td> -</td>
137
                        <td> -</td>
130
                    #end
138
                    #end
131
                #end
139
                #end
132
                <td class="currency totalmargin" data-value="$pc.getTotalScheme()">$pc.getTotalScheme()</td>
-
 
133
                <td class="currency netprice" data-value="$pc.getNetPrice()">$pc.getNetPrice()</td>
140
                <td class="currency netprice">-</td>
134
                <td class="currency">$pc.getMopdp()</td>
141
                <td class="currency dpmop">-</td>
135
                <td class="currency totalprofit" data-value="$pc.getTotalProfit()">$pc.getTotalProfit()</td>
142
                <td class="currency totalmargin">-</td>
136
                <td class="netmargin">$pc.getNetMargin()</td>
143
                <td class="netmargin">-</td>
137
 
144
 
138
            </tr>
145
            </tr>
139
            #end
146
            #end
140
        </tbody>
147
        </tbody>
141
    </table>
148
    </table>
Line 150... Line 157...
150
    </div>
157
    </div>
151
</div>
158
</div>
152
</body>
159
</body>
153
<script type="text/javascript">
160
<script type="text/javascript">
154
    $(document).ready(function () {
161
    $(document).ready(function () {
-
 
162
        $('#circular-table').find('tr').each(function (i, el) {
-
 
163
            setMargins(el);
-
 
164
        });
155
        priceCircularTable = $('#circular-table').DataTable({
165
        priceCircularTable = $('#circular-table').DataTable({
156
            "scrollX": true,
166
            "scrollX": true,
157
            "bPaginate": true,
167
            "bPaginate": true,
158
            "bLengthChange": true,
168
            "bLengthChange": true,
159
            "bFilter": true,
169
            "bFilter": true,
160
            "bInfo": false,
170
            "bInfo": false,
161
            "bAutoWidth": false,
171
            "bAutoWidth": false,
162
            "pageLength": 100
172
            "pageLength": 100
163
 
173
 
164
        });
174
        });
-
 
175
        //setMargins();
165
    });
176
    });
-
 
177
 
166
    $('select.mk_criteria_slab').change(function () {
178
    $('select.mk_criteria_slab').change(function () {
167
        debugger;
-
 
168
        oldSelectedValue = $(this).data("value");
179
        let tdPayout = $(this).closest('td').next();
169
        $(this).closest('td').next().html($(this).find("option:selected").data("value"));
180
        tdPayout.data("value", JSON.parse($(this).val()));
170
        let diff = oldSelectedValue - $(this).find("option:selected").data("value");
181
        console.log("--------" + tdPayout.data('value'));
171
        let $tr = $(this).closest('tr');
182
        setMargins($(this).closest('tr'));
172
        let totalMargin = numberToComma($tr.find('.totalmargin').data('value') - diff);
-
 
173
            $tr.find('.totalmargin').html(totalMargin);
-
 
174
        let netLanding = $tr.find('.netprice').data('value') + diff;
-
 
175
        let netLandingString = numberToComma(netLanding);
-
 
176
            $tr.find('.netprice').html(netLandingString);
-
 
177
 
-
 
178
        let totalProfit = $tr.find('.totalprofit').data('value') - diff;
-
 
179
        let totalProfitString = numberToComma(totalProfit);
-
 
180
            $tr.find('.totalprofit').html(totalProfitString);
-
 
181
 
-
 
182
        ##let rouoff = totalProfit / (netLanding / 1.18) * 100;
-
 
183
        let rouoff = totalProfit / ($tr.find('.dp').data('value') / 1.18) * 100;
-
 
184
        let roundOff = Math.round(rouoff * 100.0) / 100.0;
-
 
185
            $tr.find('.netmargin').html(roundOff);
183
        priceCircularTable.draw();
186
    });
184
    });
-
 
185
 
-
 
186
    function setMargins(trContainer) {
-
 
187
        let dp = $(trContainer).find('.dp').data("value");
-
 
188
        if (dp == undefined) return;
-
 
189
        let mop = $(trContainer).find('.mop').data('value');
-
 
190
        let totalMargin = 0;
-
 
191
        if ($(trContainer).find('.margin').length > 0) {
-
 
192
            let fixedMargin = 0;
-
 
193
            let percentageMargin = 0;
-
 
194
            $(trContainer).find('.margin').each(function (i, ele) {
-
 
195
                let amountModel = $(ele).data('value');
-
 
196
                //console.log(amountModel);
-
 
197
                if (amountModel.amountType == 'FIXED') {
-
 
198
                    fixedMargin += amountModel.amount;
-
 
199
                } else if (amountModel.amountType == 'PERCENTAGE') {
-
 
200
                    percentageMargin += amountModel.amount;
-
 
201
                }
-
 
202
            });
-
 
203
            let effectiveDp = dp - fixedMargin;
-
 
204
            console.log(fixedMargin);
-
 
205
            let percentageValue = effectiveDp / (100 + percentageMargin);
-
 
206
            console.log(percentageValue + "(" + percentageMargin + "%)");
-
 
207
            $(trContainer).find('.margin').each(function (i, ele) {
-
 
208
                let amountModel = $(ele).data('value');
-
 
209
                //console.log(amountModel);
-
 
210
                if (amountModel.amountType == 'PERCENTAGE') {
-
 
211
                    $(ele).html(numberToComma(percentageValue * amountModel.amount));
-
 
212
                    totalMargin += percentageValue * amountModel.amount;
-
 
213
                } else {
-
 
214
                    $(ele).html(numberToComma(amountModel.amount));
-
 
215
                    totalMargin += amountModel.amount;
-
 
216
                }
-
 
217
            });
-
 
218
        }
-
 
219
        let dpmop = mop - dp;
-
 
220
        let nlc = dp - totalMargin;
-
 
221
        $(trContainer).find('.netprice').html(numberToComma(nlc));
-
 
222
        $(trContainer).find('.dpmop').html(numberToComma(dpmop));
-
 
223
        totalMargin += dpmop;
-
 
224
        $(trContainer).find('.totalmargin').html(numberToComma(totalMargin));
-
 
225
        //debugger;
-
 
226
        $(trContainer).find('.netmargin').html(numberToComma(totalMargin * 100 / (nlc)) + '%');
-
 
227
        //priceCircularTable.draw();
-
 
228
    }
-
 
229
 
187
</script>
230
</script>
188
231