changes for bbnepal data

This commit is contained in:
Roshan 2024-10-07 13:59:13 +05:45
parent 967642f2be
commit 318998d272

View File

@ -12,11 +12,11 @@
<div class="col-2">
<fieldset>
<legend>Transaction Date <span class="text-danger">*</span></legend>
<input type="text" class="form-control2" id="salesDate" value="<?php echo NepaliDate(); ?>" data-start="<?php echo $fiscalStart;?>" data-end="<?php echo $fiscalEnd;?>" name="salesDate" required>
<input type="text" class="form-control2" id="salesDate" value="<?php echo NepaliDate(); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" name="salesDate" required>
</fieldset>
</div>
<div class="col-8">
<h1 class="text-center"><?php echo $pageTitle; ?> Voucher</h1>
<h1 class="text-center"><?php echo $pageTitle; ?> Voucher</h1>
<!-- <fieldset>
<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> -->
@ -31,7 +31,7 @@
<legend> Enter Transaction </legend>
<div class="form-row mb-2">
<div class="form-group col">
<?php $this->myaccounts->showAccountsCombo("accounts_id", " Account <span class='text-danger'>*</span>", "accounts_id", "accategory_id=4","required"); ?>
<?php $this->myaccounts->showAccountsCombo("accounts_id", " Account <span class='text-danger'>*</span>", "accounts_id", "accategory_id=4", "required"); ?>
</div>
<!-- <div class="form-group col">
<label for="salesDate">Sales Date:</label>
@ -98,10 +98,13 @@
<td></td>
</tr>
<tr>
<td class="text-right "><b>13% VAT</b></td>
<td class="text-right"><b><input type="checkbox" name="vat_checkbox" id="vat_checkbox"
>13% VAT</b></td>
<td class="text-right">
<input type="text" class="form-control" id="tax">
<td></td>
<input type="hidden" name="vat_checkbox_value" id="vat_checkbox_value" value="0">
</tr>
<tr>
<td class="text-right "><b>Grand Total Amount</b></td>
@ -142,7 +145,7 @@
$(document).on("click", ".remove-sales-detail", function() {
if ($("#salesDetails tr").length > 1) {
$(this).closest("tr").remove();
updateSerialNumbers();
updateSerialNumbers();
calculateTotals();
}
@ -153,22 +156,25 @@
});
$(document).on("change", "input[name=discountpercentage]", function() {
calculateLineTotal($(this).closest("tr"));
calculateTotals();
});
calculateLineTotal($(this).closest("tr"));
calculateTotals();
});
$(document).on("change", "input[name=discount]", function() {
calculateLineTotal($(this).closest("tr"));
calculateTotals('amount');
});
calculateLineTotal($(this).closest("tr"));
calculateTotals('amount');
});
$(document).on("change", "input[name=vat_checkbox]", function() {
calculateLineTotal($(this).closest("tr"));
calculateTotals('vat');
});
function updateSerialNumbers() {
$('.purchase-detail').each(function(index) {
$(this).find('.bbsn').text(index + 1);
})
counter = $('.purchase-detail').length;
}
function updateSerialNumbers(){
$('.purchase-detail').each(function(index){
$(this).find('.bbsn').text(index + 1);
})
counter = $('.purchase-detail').length;
}
function calculateLineTotal(row) {
var quantity = parseFloat(row.find('input[name^="qty"]').val());
var rate = parseFloat(row.find('input[name^="rate"]').val());
@ -183,7 +189,7 @@
var counter = $('.sales-detail-duplicator').length;
var currentRow = $(".sales-detail-duplicator").clone().show();
$(document).on("click", ".add-row", function() {
counter+=1;
counter += 1;
var newRow = currentRow.clone();
newRow.find('.bbsn').text(counter);
$("#salesDetails").append(newRow);
@ -191,8 +197,8 @@
// calculateTotals();
});
$(document).on('change', '.select_item', function(){
$(document).on('change', '.select_item', function() {
var selectedOption = $(this).find(':selected');
var selectedValue = selectedOption.val();
var unitInput = $(this).closest('.sales-detail-duplicator').find('.item_unit');
@ -200,7 +206,7 @@
$.ajax({
url: "<?php echo site_url("inventory/Sales/getunitbyitem/"); ?>" + selectedValue,
async: true,
dataType:"json",
dataType: "json",
method: 'POST',
success: function(response) {
console.log(response);
@ -218,7 +224,7 @@
}
});
// $(document).on("click", ".remove-sales-detail", function() {
// $(this).closest(".sales-detail").remove();
// calculateTotals();
@ -229,7 +235,7 @@
});
</script>
<script>
function calculateTotals(type='') {
function calculateTotals(type = '') {
var subtotal = 0;
$(".sales-detail-duplicator").each(function() {
var lineTotal = parseFloat($(this).find("input[name^='ltotal']").val());
@ -239,36 +245,49 @@
});
var discountamount = 0;
var discountpercent = 0;
if(type=='amount'){
var tax_percentage =0;
if (type == 'amount') {
discountamount = parseFloat($("input[name='discount']").val());
discountpercent = (discountamount * 100) / subtotal;
discountpercent = (discountamount * 100) / subtotal;
$("#discountpercentage").val(discountpercent.toFixed(2));
}else{
} else if(type == 'vat'){
checkBox = $("input[name='vat_checkbox_value']").val();
if(checkBox == "0"){
// if(checkBox){
tax_percentage= 0.13;
$("input[name='vat_checkbox_value']").val('13');
}else{
tax_percentage =0;
$("input[name='vat_checkbox_value']").val('0');
}
// }
}
else {
discountpercent = parseFloat($("input[name='discountpercentage']").val());
discountamount = subtotal * (discountpercent/100);
discountamount = subtotal * (discountpercent / 100);
$("#discount").val(discountamount.toFixed(2));
}
var taxable = subtotal - discountamount;
var tax = taxable * 0.13;
var tax = taxable * tax_percentage;
var grandTotal = taxable + tax;
$('#subtotal').val(subtotal.toFixed(2));
$("#taxable").val(taxable.toFixed(2));
$('#tax').val(tax.toFixed(2));
$('#grandtotal').val(grandTotal.toFixed(2));
$('#grandtotal').val(grandTotal.toFixed(2));
}
</script>
<?php function footerFunctions()
{ ?>
<script>
$("#salesDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#salesDate').data('start'),
maxDate: $('#salesDate').data('end'),
<script>
$("#salesDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#salesDate').data('start'),
maxDate: $('#salesDate').data('end'),
});
</script>
});
</script>
<?php } ?>