diff --git a/account/application/controllers/inventory/Purchases.php b/account/application/controllers/inventory/Purchases.php
index 2841c0a..5351777 100644
--- a/account/application/controllers/inventory/Purchases.php
+++ b/account/application/controllers/inventory/Purchases.php
@@ -50,6 +50,7 @@ class Purchases extends CI_Controller
'items_id' => $item,
'qty' => $_POST['quantity'][$a],
'rate' => $_POST['rate'][$a],
+ 'vat' => $_POST['vat'][$a],
'created_on' => date('Y-m-d H:i:s'),
'created_by' => 'admin',
'remarks' => '',
diff --git a/account/application/controllers/inventory/Sales.php b/account/application/controllers/inventory/Sales.php
index ee682a6..2540937 100644
--- a/account/application/controllers/inventory/Sales.php
+++ b/account/application/controllers/inventory/Sales.php
@@ -44,12 +44,13 @@ class Sales extends CI_Controller
// print_r($_POST);die;
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(
'sales_id' => $sales_id,
'items_id' => $item,
'qty' => $_POST['qty'][$i],
'rate' => $_POST['rate'][$i],
+ 'vat' => $_POST['vat'][$i],
'created_on' => date('Y-m-d H:i:s'),
'created_by' => 'admin',
'status' => 1,
diff --git a/account/application/views/inventory/purchases/create.php b/account/application/views/inventory/purchases/create.php
index bbdebe5..7bdd7f7 100644
--- a/account/application/views/inventory/purchases/create.php
+++ b/account/application/views/inventory/purchases/create.php
@@ -143,6 +143,7 @@
Qty |
Units |
Rate |
+ VAT* |
Amount |
|
@@ -154,6 +155,8 @@
|
|
|
+ |
+
|
|
Total Amount |
@@ -198,11 +201,13 @@
|
- 13% VAT |
-
+ | 13% VAT |
+
|
- |
+
+
+ |
Grand Total Amount |
@@ -404,7 +409,7 @@
calculateTotals();
});
// 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"));
calculateTotals();
});
@@ -419,6 +424,9 @@
calculateTotals('amount');
});
+
+ });
+
function updateSerialNumbers(){
$('.purchase-detail').each(function(index){
$(this).find('.bbsn').text(index + 1);
@@ -429,7 +437,15 @@
function calculateRowTotal(row) {
var quantity = parseFloat(row.find("input[name^='quantity']").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));
}
// Calculate totals
@@ -453,18 +469,19 @@
// var discountamount = subtotal * (discountpercent/100);
var taxable = subtotal - discountamount;
var tax = 0;
- if ($('#vatToggle').is(':checked')) {
- tax = taxable * 0.13; // Include 13% VAT if checkbox is checked
- }
- var grandTotal = taxable + tax;
+ // if ($('#vatToggle').is(':checked')) {
+ // tax = taxable * 0.13; // Include 13% VAT if checkbox is checked
+ // }
+ // var grandTotal = taxable + tax;
+ var grandTotal = taxable;
+
$("#subtotal").val(subtotal.toFixed(2));
// $("#discount").val(discountamount.toFixed(2));
$("#taxable").val(taxable.toFixed(2));
$("#tax").val(tax.toFixed(2));
$("#grand_total").val(grandTotal.toFixed(2));
- }
- });
+ };
purchase_ref; ?> |
purchase_date; ?> |
- myaccounts->getAccountDetails($TableRow->accounts_id)->account_name; ?>
+ | myaccounts->getAccountDetails($TableRow->accounts_id)->account_name ?? "")); ?>
+
Item->title; ?>
qty; ?>
- rate, true); ?>
- qty * $r->rate, true); ?>
+ rate, true); ?>
+ vat, true); ?>
+ qty * $r->rate, true); ?>
diff --git a/account/application/views/inventory/purchases/view.php b/account/application/views/inventory/purchases/view.php
index c5def29..55f1170 100644
--- a/account/application/views/inventory/purchases/view.php
+++ b/account/application/views/inventory/purchases/view.php
@@ -23,7 +23,7 @@
Bill Number: purchase_id; ?>
Date: purchase_date); ?>
- Vendor: myaccounts->getAccountDetails($Purchase->accounts_id)->account_name; ?>
+ Vendor: myaccounts->getAccountDetails($Purchase->accounts_id)->account_name ?? "")); ?>
@@ -40,6 +40,9 @@
+
@@ -58,7 +61,10 @@
rate; echo myCurrency($rate); ?>
-
+ vat; echo myCurrency($vat); ?>
+
+
diff --git a/account/application/views/inventory/sales/create.php b/account/application/views/inventory/sales/create.php
index 004247d..8176603 100644
--- a/account/application/views/inventory/sales/create.php
+++ b/account/application/views/inventory/sales/create.php
@@ -49,6 +49,7 @@
| Items * |
Qty * |
Units |
+ VAT* |
Rate * |
Amount |
|
@@ -65,7 +66,9 @@
|
|
+ |
|
+
|
|
- 13% VAT |
-
+ |
| |
@@ -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));
diff --git a/account/application/views/inventory/sales/list.php b/account/application/views/inventory/sales/list.php
index b3368c1..2fc1dd5 100644
--- a/account/application/views/inventory/sales/list.php
+++ b/account/application/views/inventory/sales/list.php
@@ -29,6 +29,7 @@
+
Item->title; ?>
qty; ?>
- rate, true); ?>
- qty * $r->rate, true); ?>
+ rate, true); ?>
+ vat, true); ?>
+ qty * $r->rate, true); ?>
diff --git a/account/application/views/inventory/sales/register.php b/account/application/views/inventory/sales/register.php
index d090c1b..0f11011 100644
--- a/account/application/views/inventory/sales/register.php
+++ b/account/application/views/inventory/sales/register.php
@@ -29,14 +29,14 @@
sales_id; ?> |
Details[$key]->Item->title) ?? ""; ?> |
sales_date; ?> |
- myaccounts->getAccountDetails($TableRow->accounts_id)->account_name; ?>
- |
+ myaccounts->getAccountDetails($TableRow->accounts_id)->account_name)?? ""); ?>
+ |
totalsales); ?> |
uri->segment(1) . "/" . $this->uri->segment(2) . "/details/$TableRow->sales_id"); ?>
sales_id); ?>
|
-
+