CHANGE_COMPLAINT_ADD_TAX_IGST_TO_SGST : AADHAVAN

This commit is contained in:
aadhavan valli 2024-04-25 13:48:43 +05:30
parent 873b1350cd
commit 7e309f9594
9 changed files with 43 additions and 14 deletions

View File

@ -29,9 +29,18 @@ class Complaint extends BaseController
{
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
try {
$data = [
"name" => $this->request->getPost('name'),
"labour_charge" => $this->request->getPost('labour_charge'),
"cgst" => $this->request->getPost('tax')/2,
"sgst" => $this->request->getPost('tax')/2,
"tax" => $this->request->getPost('tax')
];
if (!$complaint_id) {
$ComplaintModel = new ComplaintModel();
$data = $this->request->getPost();
// $data = $this->request->getPost();
$inserted = $ComplaintModel->insert($data);
if ($inserted) {
$result = $data;
@ -42,7 +51,7 @@ class Complaint extends BaseController
}
} else {
$ComplaintModel = new ComplaintModel();
$data = $this->request->getPost();
// $data = $this->request->getPost();
$updated = $ComplaintModel->update($complaint_id,$data);
if ($updated) {
$result = $data;

View File

@ -151,7 +151,7 @@ class Service extends BaseController
'category' => $this->request->getPost('category'),
'product_id' => json_encode($this->request->getPost('product_id')),
'cgst' => $tax,
'igst' => $tax,
'sgst' => $tax,
'tax' => $this->request->getPost('tax'),
'labour_cost' => $this->request->getPost('labour_cost'),
'price' => $this->request->getPost('price'),

View File

@ -5,5 +5,5 @@ class ComplaintModel extends Model
{
protected $table = 'complaints';
protected $primaryKey = 'complaint_id';
protected $allowedFields = ['complaint_id','name','labour_charge','isactive'];
protected $allowedFields = ['complaint_id','name','labour_charge','cgst','sgst','tax','isactive'];
}

View File

@ -5,7 +5,7 @@ class ServiceModel extends Model
{
protected $table = 'services';
protected $primaryKey = 'service_id';
protected $allowedFields = ['service_id','branch_id','category','service_name','labour_cost','cgst','igst','price','tax','description','makes_id','models_id','product_id','sub_service_id','isactive'];
protected $allowedFields = ['service_id','branch_id','category','service_name','labour_cost','cgst','sgst','price','tax','description','makes_id','models_id','product_id','sub_service_id','isactive'];
public function getTax()

View File

@ -5,7 +5,7 @@ class ServicesModel extends Model
{
protected $table = 'services';
protected $primaryKey = 'service_id';
protected $allowedFields = ['service_id','service_name','price','commission_rate','cgst','igst','purchase_cost','description','isactive'];
protected $allowedFields = ['service_id','service_name','price','commission_rate','cgst','sgst','purchase_cost','description','isactive'];
}

View File

@ -70,6 +70,16 @@
<label for="labour_charge">Labour Charge </label>
<input class="form-control" type="text" id="labour_charge" required="" placeholder="Labour Charge....">
</div>
<div class="form-group">
<label for="labour_charge">Tax </label>
<select class="form-control status-select" id="tax" name="tax" required data-toggle="select2">
<option value="0">0%</option>
<option value="5" >5%</option>
<option value="12">12%</option>
<option value="18">18%</option>
<option value="28" >28%</option>
</select>
</div>
<div class="form-group text-center">
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitComplaint(this)">Submit</button>
</div>
@ -88,6 +98,7 @@
var formData = {
name: $('#name').val(),
labour_charge: $('#labour_charge').val(),
tax: $('#tax').val()
};
var complaint_id = $('#complaint_id').val();
if (!complaint_id) {
@ -124,6 +135,17 @@
$('#complaint_id').val(response.complaint[0].complaint_id);
$('#name').val(response.complaint[0].name);
$('#labour_charge').val(response.complaint[0].labour_charge);
var tax = parseFloat(response.complaint[0].cgst) + parseFloat(response.complaint[0].sgst);
var selectElement = document.getElementById('tax');
var options = selectElement.options;
for (var i = 0; i < options.length; i++) {
if (parseInt(options[i].value) === tax) {
options[i].selected = true;
break;
}
}
},
error: function(xhr, status, error) {
// Handle error response here

View File

@ -439,13 +439,11 @@
var product = services.find(function(item) {
return item.service_id == productId;
});
console.log("3333333");
console.log(product);
var cgst = parseFloat(product.cgst);
var igst = parseFloat(product.igst);
var sgst = parseFloat(product.sgst);
// Calculate total tax by adding CGST and SGST
var tax = cgst + igst;
var tax = cgst + sgst;
$(row).find('.item-tax-service').val(tax.toFixed(2));
}

View File

@ -99,8 +99,8 @@
<select class="form-control status-select" name="tax" required data-toggle="select2">
<?php
$cgst = isset($services['cgst']) ? $services['cgst'] : 0; // CGST value (half of the tax amount)
$igst = isset($services['igst']) ? $services['igst'] : 0; // IGST value (half of the tax amount)
$tax = $cgst + $igst; // Total tax (sum of CGST and IGST)
$sgst = isset($services['sgst']) ? $services['sgst'] : 0; // SGST value (half of the tax amount)
$tax = $cgst + $sgst; // Total tax (sum of CGST and SGST)
?>
<option value="0" <?= ($tax == 0) ? 'selected' : '' ?>>0%</option>
<option value="5" <?= ($tax == 5) ? 'selected' : '' ?>>5%</option>

View File

@ -27,7 +27,7 @@
<!-- <th>Model List</th> -->
<th>Price</th>
<th>Cgst</th>
<th>Igst</th>
<th>Sgst</th>
<th>Description</th>
<th>Action</th>
</tr>
@ -41,7 +41,7 @@
<!-- <td><?= $value['models_names']; ?></td> -->
<td><?= $value['price']; ?></td>
<td><?= $value['cgst']; ?></td>
<td><?= $value['igst']; ?></td>
<td><?= $value['sgst']; ?></td>
<td><?= $value['description']; ?></td>
<td>
<a href="<?= "new_service/" . $value['service_id']; ?>" class="edit-button">