bbnepal new changes

This commit is contained in:
2024-10-08 15:47:07 +05:45
parent ad3e5eb1ec
commit 4ac5a5e491
9 changed files with 79 additions and 34 deletions

View File

@ -49,6 +49,7 @@
<th width=50%>Items <span class="text-danger">*</span></th>
<th class="text-center" width=5%>Qty <span class="text-danger">*</span></th>
<th class="text-center" width=5%>Units</th>
<th class="text-center" width=13%>VAT<span class="text-danger">*</span></th>
<th class="text-center" width=13%>Rate <span class="text-danger">*</span></th>
<th class="text-right" width=20%>Amount</th>
<th width=5%></th>
@ -65,7 +66,9 @@
</select></td>
<td> <input type="text" class="form-control input-group-sm" name="qty[]" required></td>
<td><input type="text" class="form-control item_unit" name="pcs/dozen/kgs" required> </td>
<td><input type="number" name="vat[]" class="form-control vat" required></td>
<td><input type="text" class="form-control" name="rate[]" required></td>
<span class="total-price"></span>
<td><input type="text" class="form-control" name="ltotal[]" required></td>
<td>
<button type="button" class="btn btn-primary btn-xs add-row">
@ -98,9 +101,9 @@
<td></td>
</tr>
<tr>
<td class="text-right"><b><input type="checkbox" name="vat_checkbox" id="vat_checkbox"
<td class="text-right d-none"><b><input type="checkbox" name="vat_checkbox" id="vat_checkbox"
>13% VAT</b></td>
<td class="text-right">
<td class="text-right d-none">
<input type="text" class="form-control" id="tax">
<td></td>
<input type="hidden" name="vat_checkbox_value" id="vat_checkbox_value" value="0">
@ -150,7 +153,7 @@
}
});
$(document).on('input', '.sales-detail-duplicator input[name^="qty"], .sales-detail-duplicator input[name^="rate"]', function() {
$(document).on('input', '.sales-detail-duplicator input[name^="qty"],.sales-detail-duplicator input[name^="vat"], .sales-detail-duplicator input[name^="rate"]', function() {
calculateLineTotal($(this).closest('tr'));
calculateTotals();
});
@ -178,9 +181,13 @@
function calculateLineTotal(row) {
var quantity = parseFloat(row.find('input[name^="qty"]').val());
var rate = parseFloat(row.find('input[name^="rate"]').val());
if (!isNaN(quantity) && !isNaN(rate)) {
var vat = parseFloat(row.find('input[name^="vat"]').val());
if (!isNaN(quantity) && !isNaN(rate) && !isNaN(vat)) {
var lineTotal = quantity * rate;
row.find("input[name^='ltotal[]']").val(lineTotal.toFixed(2));
var vat_amt =(vat/100)*lineTotal;
var ltotal =lineTotal + vat_amt ;
console.log(lineTotal,vat_amt,ltotal);
row.find("input[name^='ltotal[]']").val(ltotal.toFixed(2));
}
@ -269,7 +276,8 @@
}
var taxable = subtotal - discountamount;
var tax = taxable * tax_percentage;
var grandTotal = taxable + tax;
// var grandTotal = taxable + tax;
var grandTotal = taxable;
$('#subtotal').val(subtotal.toFixed(2));
$("#taxable").val(taxable.toFixed(2));