bbnepal new changes

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

View File

@ -50,6 +50,7 @@ class Purchases extends CI_Controller
'items_id' => $item, 'items_id' => $item,
'qty' => $_POST['quantity'][$a], 'qty' => $_POST['quantity'][$a],
'rate' => $_POST['rate'][$a], 'rate' => $_POST['rate'][$a],
'vat' => $_POST['vat'][$a],
'created_on' => date('Y-m-d H:i:s'), 'created_on' => date('Y-m-d H:i:s'),
'created_by' => 'admin', 'created_by' => 'admin',
'remarks' => '', 'remarks' => '',

View File

@ -44,12 +44,13 @@ class Sales extends CI_Controller
// print_r($_POST);die; // print_r($_POST);die;
foreach ($_POST['item_id'] as $item) { foreach ($_POST['item_id'] as $item) {
if ($item != 0 || $_POST['qty'][$i] != 0 || $_POST['rate'][$i] != 0) : if ($item != 0 || $_POST['qty'][$i] != 0 || $_POST['rate'][$i] != 0 || $_POST['vat'][$i] != 0) :
$TableData = array( $TableData = array(
'sales_id' => $sales_id, 'sales_id' => $sales_id,
'items_id' => $item, 'items_id' => $item,
'qty' => $_POST['qty'][$i], 'qty' => $_POST['qty'][$i],
'rate' => $_POST['rate'][$i], 'rate' => $_POST['rate'][$i],
'vat' => $_POST['vat'][$i],
'created_on' => date('Y-m-d H:i:s'), 'created_on' => date('Y-m-d H:i:s'),
'created_by' => 'admin', 'created_by' => 'admin',
'status' => 1, 'status' => 1,

View File

@ -143,6 +143,7 @@
<th class="text-right">Qty</th> <th class="text-right">Qty</th>
<th class="text-right">Units</th> <th class="text-right">Units</th>
<th class="text-right">Rate</th> <th class="text-right">Rate</th>
<th class="text-right" width=13%>VAT<span class="text-danger">*</span></th>
<th class="text-right">Amount</th> <th class="text-right">Amount</th>
<th></th> <th></th>
</tr> </tr>
@ -154,6 +155,8 @@
<td width=10%> <input type="text" class="form-control input-group-sm" name="quantity[]"></td> <td width=10%> <input type="text" class="form-control input-group-sm" name="quantity[]"></td>
<td width=5%><input type="text" class="form-control item_unit" name="pcs/dozen/kgs" required> </td> <td width=5%><input type="text" class="form-control item_unit" name="pcs/dozen/kgs" required> </td>
<td width=15%><input type="text" class="form-control" name="rate[]"></td> <td width=15%><input type="text" class="form-control" name="rate[]"></td>
<td><input type="number" name="vat[]" class="form-control vat" required></td>
<td width=15%><input type="text" class="form-control" name="total[]"></td> <td width=15%><input type="text" class="form-control" name="total[]"></td>
<td width="5%"> <td width="5%">
<button type="button" class="btn btn-primary btn-xs addPurchaseDetail" id="addPurchaseDetail"> <button type="button" class="btn btn-primary btn-xs addPurchaseDetail" id="addPurchaseDetail">
@ -174,9 +177,9 @@
<br> <br>
<br> <br>
<label for="vatToggle">VAT</label> <label for="vatToggle" class="d-none">VAT</label>
<input type="checkbox" id="vatToggle" checked> <input class="d-none" type="checkbox" id="vatToggle" checked>
<input type="hidden" id="vatToggleValue" name="vatToggleValue" value="1"> <input type="hidden" class="d-none" id="vatToggleValue" name="vatToggleValue" value="1">
</td> </td>
<td class="text-right "><b>Total Amount</b></td> <td class="text-right "><b>Total Amount</b></td>
<td class="text-right"> <td class="text-right">
@ -198,11 +201,13 @@
</tr> </tr>
<tr> <tr>
<td class="text-right "><b>13% VAT</b></td> <td class="text-right d-none "><b>13% VAT</b></td>
<td class="text-right"> <td class="text-right d-none">
<input type="text" class="form-control" name="tax" id="tax" /> <input type="text" class="form-control" name="tax" id="tax" />
</td> </td>
<td></td> <td>
<input type="hidden" name="vat_checkbox_value" id="vat_checkbox_value" value="0">
</td>
</tr> </tr>
<tr> <tr>
<td class="text-right "><b>Grand Total Amount</b></td> <td class="text-right "><b>Grand Total Amount</b></td>
@ -404,7 +409,7 @@
calculateTotals(); calculateTotals();
}); });
// Calculate totals on change of rate or quantity // Calculate totals on change of rate or quantity
$(document).on("change", ".purchase-detail input[name^='quantity'], .purchase-detail input[name^='rate']", function() { $(document).on("change", ".purchase-detail input[name^='quantity'], .purchase-detail input[name^='rate'],.purchase-detail input[name^='vat']", function() {
calculateRowTotal($(this).closest(".purchase-detail")); calculateRowTotal($(this).closest(".purchase-detail"));
calculateTotals(); calculateTotals();
}); });
@ -419,6 +424,9 @@
calculateTotals('amount'); calculateTotals('amount');
}); });
});
function updateSerialNumbers(){ function updateSerialNumbers(){
$('.purchase-detail').each(function(index){ $('.purchase-detail').each(function(index){
$(this).find('.bbsn').text(index + 1); $(this).find('.bbsn').text(index + 1);
@ -429,7 +437,15 @@
function calculateRowTotal(row) { function calculateRowTotal(row) {
var quantity = parseFloat(row.find("input[name^='quantity']").val()) || 0; var quantity = parseFloat(row.find("input[name^='quantity']").val()) || 0;
var rate = parseFloat(row.find("input[name^='rate']").val()) || 0; var rate = parseFloat(row.find("input[name^='rate']").val()) || 0;
var total = quantity * rate; var vat = parseFloat(row.find('input[name^="vat"]').val()) || 0;
//
var lineTotal = quantity * rate;
var vat_amt =(vat/100)*lineTotal;
var total =lineTotal + vat_amt ;
//
// var total = quantity * rate;
row.find("input[name^='total']").val(total.toFixed(2)); row.find("input[name^='total']").val(total.toFixed(2));
} }
// Calculate totals // Calculate totals
@ -453,18 +469,19 @@
// var discountamount = subtotal * (discountpercent/100); // var discountamount = subtotal * (discountpercent/100);
var taxable = subtotal - discountamount; var taxable = subtotal - discountamount;
var tax = 0; var tax = 0;
if ($('#vatToggle').is(':checked')) { // if ($('#vatToggle').is(':checked')) {
tax = taxable * 0.13; // Include 13% VAT if checkbox is checked // tax = taxable * 0.13; // Include 13% VAT if checkbox is checked
} // }
var grandTotal = taxable + tax; // var grandTotal = taxable + tax;
var grandTotal = taxable;
$("#subtotal").val(subtotal.toFixed(2)); $("#subtotal").val(subtotal.toFixed(2));
// $("#discount").val(discountamount.toFixed(2)); // $("#discount").val(discountamount.toFixed(2));
$("#taxable").val(taxable.toFixed(2)); $("#taxable").val(taxable.toFixed(2));
$("#tax").val(tax.toFixed(2)); $("#tax").val(tax.toFixed(2));
$("#grand_total").val(grandTotal.toFixed(2)); $("#grand_total").val(grandTotal.toFixed(2));
} };
});
</script> </script>
<?php function footerFunctions() <?php function footerFunctions()

View File

@ -27,11 +27,12 @@
endforeach; ?><tr> endforeach; ?><tr>
<td><?php echo $TableRow->purchase_ref; ?></td> <td><?php echo $TableRow->purchase_ref; ?></td>
<td><?php echo $TableRow->purchase_date; ?></td> <td><?php echo $TableRow->purchase_date; ?></td>
<td><b><?php echo $this->myaccounts->getAccountDetails($TableRow->accounts_id)->account_name; ?></b> <td><b><?php echo (($this->myaccounts->getAccountDetails($TableRow->accounts_id)->account_name ?? "")); ?></b>
<div class="row ml-2 mr-2" style="border-bottom: 1px solid;"> <div class="row ml-2 mr-2" style="border-bottom: 1px solid;">
<span class="col item_name"><?php echo myLang("Particulars") ?></span> <span class="col item_name"><?php echo myLang("Particulars") ?></span>
<span class="col item_qty"><?php echo myLang("Qty") ?></span> <span class="col item_qty"><?php echo myLang("Qty") ?></span>
<span class="col item_rate"><?php echo myLang("Rate") ?></span> <span class="col item_rate"><?php echo myLang("Rate") ?></span>
<span class="col item_vat"><?php echo myLang("vat") ?></span>
<span class="col item_amount"><?php echo myLang("Amount") ?></span> <span class="col item_amount"><?php echo myLang("Amount") ?></span>
</div> </div>
<?php $l = 0; <?php $l = 0;
@ -39,8 +40,9 @@
<div class="row ml-2 mr-2"> <div class="row ml-2 mr-2">
<span class="col item_name"><?php echo $r->Item->title; ?></span> <span class="col item_name"><?php echo $r->Item->title; ?></span>
<span class="col item_qty"><?php echo $r->qty; ?></span> <span class="col item_qty"><?php echo $r->qty; ?></span>
<span class="col item_rate text-right"><?php echo myCurrency($r->rate, true); ?></span> <span class="col item_rate"><?php echo myCurrency($r->rate, true); ?></span>
<span class="col item_amount text-right"><?php echo myCurrency($r->qty * $r->rate, true); ?></span> <span class="col item_vat"><?php echo myCurrency($r->vat, true); ?></span>
<span class="col item_amount"><?php echo myCurrency($r->qty * $r->rate, true); ?></span>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
<div class="row ml-2 mr-2" style="border-top: 1px dotted;"> <div class="row ml-2 mr-2" style="border-top: 1px dotted;">

View File

@ -23,7 +23,7 @@
<div class="col"> <div class="col">
<p><strong>Bill Number:</strong> <?php echo $Purchase->purchase_id; ?></p> <p><strong>Bill Number:</strong> <?php echo $Purchase->purchase_id; ?></p>
<p><strong>Date:</strong> <?php echo dbDate($Purchase->purchase_date); ?></p> <p><strong>Date:</strong> <?php echo dbDate($Purchase->purchase_date); ?></p>
<p><strong>Vendor:</strong> <?php echo $this->myaccounts->getAccountDetails($Purchase->accounts_id)->account_name; ?></p> <p><strong>Vendor:</strong> <?php echo (($this->myaccounts->getAccountDetails($Purchase->accounts_id)->account_name ?? "")); ?></p>
</div> </div>
</div> </div>
@ -40,6 +40,9 @@
<div class="col"> <div class="col">
<p class="text-right"><strong>Price</strong></p> <p class="text-right"><strong>Price</strong></p>
</div> </div>
<div class="col">
<p class="text-right"><strong>VAT</strong></p>
</div>
<div class="col"> <div class="col">
<p class="text-right"><strong>Total</strong></p> <p class="text-right"><strong>Total</strong></p>
</div> </div>
@ -58,7 +61,10 @@
<p><?php $rate=$PurchaseDetail->rate; echo myCurrency($rate); ?></p> <p><?php $rate=$PurchaseDetail->rate; echo myCurrency($rate); ?></p>
</div> </div>
<div class="col"> <div class="col">
<p><?php $ltotal=$rate*$qty; $total+=$ltotal; echo myCurrency($ltotal); ?></p> <p><?php $vat=$PurchaseDetail->vat; echo myCurrency($vat); ?></p>
</div>
<div class="col">
<p><?php $ltotal=$rate*$qty*((100-$vat)/100); $total+=$ltotal; echo myCurrency($ltotal); ?></p>
</div> </div>
</div> </div>
</div> </div>

View File

@ -49,6 +49,7 @@
<th width=50%>Items <span class="text-danger">*</span></th> <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%>Qty <span class="text-danger">*</span></th>
<th class="text-center" width=5%>Units</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-center" width=13%>Rate <span class="text-danger">*</span></th>
<th class="text-right" width=20%>Amount</th> <th class="text-right" width=20%>Amount</th>
<th width=5%></th> <th width=5%></th>
@ -65,7 +66,9 @@
</select></td> </select></td>
<td> <input type="text" class="form-control input-group-sm" name="qty[]" required></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="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> <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><input type="text" class="form-control" name="ltotal[]" required></td>
<td> <td>
<button type="button" class="btn btn-primary btn-xs add-row"> <button type="button" class="btn btn-primary btn-xs add-row">
@ -98,9 +101,9 @@
<td></td> <td></td>
</tr> </tr>
<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> >13% VAT</b></td>
<td class="text-right"> <td class="text-right d-none">
<input type="text" class="form-control" id="tax"> <input type="text" class="form-control" id="tax">
<td></td> <td></td>
<input type="hidden" name="vat_checkbox_value" id="vat_checkbox_value" value="0"> <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')); calculateLineTotal($(this).closest('tr'));
calculateTotals(); calculateTotals();
}); });
@ -178,9 +181,13 @@
function calculateLineTotal(row) { function calculateLineTotal(row) {
var quantity = parseFloat(row.find('input[name^="qty"]').val()); var quantity = parseFloat(row.find('input[name^="qty"]').val());
var rate = parseFloat(row.find('input[name^="rate"]').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; 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 taxable = subtotal - discountamount;
var tax = taxable * tax_percentage; var tax = taxable * tax_percentage;
var grandTotal = taxable + tax; // var grandTotal = taxable + tax;
var grandTotal = taxable;
$('#subtotal').val(subtotal.toFixed(2)); $('#subtotal').val(subtotal.toFixed(2));
$("#taxable").val(taxable.toFixed(2)); $("#taxable").val(taxable.toFixed(2));

View File

@ -29,6 +29,7 @@
<span class="col item_name"><?php echo myLang("Particulars") ?></span> <span class="col item_name"><?php echo myLang("Particulars") ?></span>
<span class="col item_qty"><?php echo myLang("Qty") ?></span> <span class="col item_qty"><?php echo myLang("Qty") ?></span>
<span class="col item_rate"><?php echo myLang("Rate") ?></span> <span class="col item_rate"><?php echo myLang("Rate") ?></span>
<span class="col item_vat"><?php echo myLang("VAT") ?></span>
<span class="col item_amount"><?php echo myLang("Amount") ?></span> <span class="col item_amount"><?php echo myLang("Amount") ?></span>
</div> </div>
<?php $l = 0; <?php $l = 0;
@ -36,8 +37,9 @@
<div class="row ml-2 mr-2"> <div class="row ml-2 mr-2">
<span class="col item_name"><?php echo $r->Item->title; ?></span> <span class="col item_name"><?php echo $r->Item->title; ?></span>
<span class="col item_qty"><?php echo $r->qty; ?></span> <span class="col item_qty"><?php echo $r->qty; ?></span>
<span class="col item_rate text-right"><?php echo myCurrency($r->rate, true); ?></span> <span class="col item_rate"><?php echo myCurrency($r->rate, true); ?></span>
<span class="col item_amount text-right"><?php echo myCurrency($r->qty * $r->rate, true); ?></span> <span class="col item_vat"><?php echo myCurrency($r->vat, true); ?></span>
<span class="col item_amount"><?php echo myCurrency($r->qty * $r->rate, true); ?></span>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
<div class="row ml-2 mr-2" style="border-top: 1px dotted;"> <div class="row ml-2 mr-2" style="border-top: 1px dotted;">

View File

@ -29,14 +29,14 @@
<td class="text-center"><?php echo $TableRow->sales_id; ?></td> <td class="text-center"><?php echo $TableRow->sales_id; ?></td>
<td class="text-center"><?php echo ($TableRow->Details[$key]->Item->title) ?? ""; ?></td> <td class="text-center"><?php echo ($TableRow->Details[$key]->Item->title) ?? ""; ?></td>
<td><?php echo $TableRow->sales_date; ?></td> <td><?php echo $TableRow->sales_date; ?></td>
<td><?php echo $this->myaccounts->getAccountDetails($TableRow->accounts_id)->account_name; ?> <td><?php echo (($this->myaccounts->getAccountDetails($TableRow->accounts_id)->account_name)?? ""); ?>
</td> </td>
<td><?php echo myCurrency($TableRow->totalsales); ?></td> <td><?php echo myCurrency($TableRow->totalsales); ?></td>
<td class="text-center"><?php showDetailsButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/details/$TableRow->sales_id"); ?> <td class="text-center"><?php showDetailsButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/details/$TableRow->sales_id"); ?>
<?php showDeleteButton($TableRow->sales_id); ?> <?php showDeleteButton($TableRow->sales_id); ?>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
<tbody> <tbody>
</table> </table>
<script> <script>

View File

@ -23,7 +23,7 @@
<div class="col"> <div class="col">
<p><strong>Bill Number:</strong> <?php echo $Sales->sales_id; ?></p> <p><strong>Bill Number:</strong> <?php echo $Sales->sales_id; ?></p>
<p><strong>Date:</strong> <?php echo dbDate($Sales->sales_date); ?></p> <p><strong>Date:</strong> <?php echo dbDate($Sales->sales_date); ?></p>
<p><strong>Vendor:</strong> <?php echo $this->myaccounts->getAccountDetails($Sales->accounts_id)->account_name; ?></p> <p><strong>Vendor:</strong> <?php echo (($this->myaccounts->getAccountDetails($Sales->accounts_id)->account_name ?? "")); ?></p>
</div> </div>
</div> </div>
@ -40,6 +40,9 @@
<div class="col text-right"> <div class="col text-right">
<p><strong>Price</strong></p> <p><strong>Price</strong></p>
</div> </div>
<div class="col text-right">
<p><strong>VAT</strong></p>
</div>
<div class="col text-right"> <div class="col text-right">
<p><strong>Total</strong></p> <p><strong>Total</strong></p>
</div> </div>
@ -57,6 +60,9 @@
<div class="col"> <div class="col">
<p><?php $rate=$SalesDetail->rate; echo myCurrency($rate); ?></p> <p><?php $rate=$SalesDetail->rate; echo myCurrency($rate); ?></p>
</div> </div>
<div class="col">
<p><?php $vat=($SalesDetail->vat); echo myCurrency($vat); ?></p>
</div>
<div class="col"> <div class="col">
<p><?php $ltotal=$rate*$qty; $total+=$ltotal; echo myCurrency($ltotal); ?></p> <p><?php $ltotal=$rate*$qty; $total+=$ltotal; echo myCurrency($ltotal); ?></p>
</div> </div>
@ -80,9 +86,11 @@
<?php //print_r($Purchase->vatToggle);die; ?> <?php //print_r($Purchase->vatToggle);die; ?>
<!-- <?php //if($Sales->vatToggle != 1): ?> --> <!-- <?php //if($Sales->vatToggle != 1): ?> -->
<p><strong>Taxable amount:</strong> <?php echo myCurrency($taxable,true); ?></p> <p><strong>Taxable amount:</strong> <?php echo myCurrency($taxable,true); ?></p>
<p><strong>Tax (13%):</strong> <?php echo myCurrency($tax=($taxable*13)/100,true); ?></p> <!-- <p><strong>Tax (13%):</strong> <?php echo myCurrency($tax=($taxable*13)/100,true); ?></p> -->
<!-- <?php //endif; ?> --> <!-- <?php //endif; ?> -->
<p><strong>Total:</strong> <?php echo myCurrency(($taxable+$tax),true); ?></p> <!-- <p><strong>Total:</strong> <?php echo myCurrency(($taxable+$tax),true); ?></p> -->
<p><strong>Total:</strong> <?php echo myCurrency(($taxable),true); ?></p>
</div> </div>
</div> </div>