I want to give product wise discount in my invoice application. I used to create dynamic row using jquery.invoice.js
plugin. I have to get Discount type which is in percentage either amount. I can't get that discount type.
There is any way to get that discount type and calculate the discount of each product?
I have tried to store that click events to array and fetch into that calculation. But it stores repeated values by clicks.
newRow: function () {
jQuery(".item-row:last").after('<tr class="item-row"><td class="item-name"><div class="delete-btn"><a class=' + $.opt.delete.substring(1) + ' href="javascript:;" title="Remove row">X</a><input type="text" class="form-control item custom-width" placeholder="Product Name" type="text" name="name[]"></div></td><td><input class="form-control price" placeholder="Price" type="text" name="price[]"></td><td><input class="form-control qty" placeholder="Quantity" type="text" name="quantity[]"></td><td><input type="radio" name="discountType" class="discountType" id="discountType" value="percentage">%<input type="radio" name="discountType" class="discountType" id="discountType" value="amount">₹<input class="form-control discount" placeholder="Value" class="value" type="text" name="discount"></td><td align="right"><span class="total">0.00</span></td></tr>');
if (jQuery($.opt.delete).length > 0) {
jQuery($.opt.delete).show();
}
return 1;
},
and total of each product function is
calcTotal: function () {
jQuery($.opt.parentClass).each(function (i) {
var row = jQuery(this);
var total = row.find($.opt.price).val() * row.find($.opt.qty).val();
total = self.roundNumber(total, 2);
row.find($.opt.total).html(total);
});
return 1;
},
Please help me to get the discount type and calculate it to same row's product. Thanks in Advance.