purchasevoucher

This commit is contained in:
Sampanna Rimal
2024-08-06 12:48:20 +05:45
parent d164f3139d
commit 52f9c0dd15
4 changed files with 52 additions and 6 deletions

View File

@ -99,6 +99,7 @@
<legend><span id="selectedAccountName"></span> Balance</legend><span id="selectedAccountBalance" style="padding: 6px 0px; display: inline-block; text-align: right; width: 100%;">Choose A/C First</span>
</fieldset> -->
</div>
<div class="col-2">
<fieldset>
<legend> Voucher No. #</legend><input type="text" readonly class="form-control2" id="voucher_no" value="<?php echo generateVoucherNo(); ?>" name="voucher_no">
@ -126,6 +127,12 @@
<!--COL END-->
</div>
</fieldset>
<div class="mt-3">
<label for="vatToggle">VAT</label>
<input type="checkbox" id="vatToggle" checked>
</div>
<input type="hidden" id="vatToggleValue" name="vatToggleValue" value="0">
<!-- Purchase Details Section -->
<div class="col-12 table-responsive p-0 mt-3">
<table class="table table-striped">
@ -180,6 +187,7 @@
<td></td>
</tr>
<tr>
<td class="text-right "><b>13% VAT</b></td>
<td class="text-right">
<input type="text" class="form-control" name="tax" id="tax" />
@ -315,6 +323,7 @@
<!-- <button type="reset" class="btn btn-default">Reset</button> -->
<button class="btn btn-primary" type="submit" name="submit">Save</button>
</div>
</form>
</div>
</div>
@ -328,6 +337,18 @@
var counter = $('.purchase-detail').length;
// Clone purchase detail div
var purchaseDetailClone = $(".purchase-detail").clone().show();
$("#vatToggle").change(function() {
if (this.checked) {
$('#vatToggleValue').val('0');
$("tfoot tr:nth-child(4)").show();
} else {
//1 because i will use this for conditions so that it does not alter previously entered vouchers
$('#vatToggleValue').val('1');
$("tfoot tr:nth-child(4)").hide();
}
calculateTotals();
});
// Add Purchase Detail
$(document).on("click", ".addPurchaseDetail", function() {
counter+=1;
@ -419,7 +440,10 @@
// var discountpercent = parseFloat($("input[name=discountpercentage]").val());
// var discountamount = subtotal * (discountpercent/100);
var taxable = subtotal - discountamount;
var tax = taxable * 0.13;
var tax = 0;
if ($('#vatToggle').is(':checked')) {
tax = taxable * 0.13; // Include 13% VAT if checkbox is checked
}
var grandTotal = taxable + tax;
$("#subtotal").val(subtotal.toFixed(2));