CHANGE_ in tax with amount : GWM

This commit is contained in:
bitbucket 2024-05-10 08:22:51 +05:30
parent 73f1941af0
commit cb5dda2769
9 changed files with 139 additions and 45 deletions

View File

@ -33,6 +33,7 @@ class Complaint extends BaseController
$data = [ $data = [
"name" => $this->request->getPost('name'), "name" => $this->request->getPost('name'),
"labour_charge" => $this->request->getPost('labour_charge'), "labour_charge" => $this->request->getPost('labour_charge'),
"labour_cost_with_tax" => $this->request->getPost('labour_cost_with_tax'),
"cgst" => $this->request->getPost('tax')/2, "cgst" => $this->request->getPost('tax')/2,
"sgst" => $this->request->getPost('tax')/2, "sgst" => $this->request->getPost('tax')/2,
"tax" => $this->request->getPost('tax'), "tax" => $this->request->getPost('tax'),

View File

@ -176,7 +176,7 @@ class Products extends BaseController
'isactive' => 1 , 'isactive' => 1 ,
'branch_id' => $this->session->get('logged_user_branch_id'), 'branch_id' => $this->session->get('logged_user_branch_id'),
'total_amount' => $this->session->get('total_amount'), 'total_amount' => $this->request->getPost('total_amount'),
'per' => $this->request->getPost('per'), 'per' => $this->request->getPost('per'),
'ml' => $ml 'ml' => $ml
]; ];
@ -370,6 +370,7 @@ class Products extends BaseController
$modelData = [ $modelData = [
'model_name' => $model, 'model_name' => $model,
'make_id' => $make_id, 'make_id' => $make_id,
'business_id' => $this->session->get('logged_user_business_id'),
]; ];

View File

@ -155,6 +155,7 @@ class Service extends BaseController
'sgst' => $tax, 'sgst' => $tax,
'tax' => $this->request->getPost('tax'), 'tax' => $this->request->getPost('tax'),
'labour_cost' => $this->request->getPost('labour_cost'), 'labour_cost' => $this->request->getPost('labour_cost'),
'labour_cost_with_cost' => $this->request->getPost('labour_cost_with_cost'),
'price' => $this->request->getPost('price'), 'price' => $this->request->getPost('price'),
'makes_id' => $make_json, 'makes_id' => $make_json,
'models_id' => $model_json, 'models_id' => $model_json,

View File

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

View File

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

View File

@ -19,7 +19,9 @@
<table id="datatable-buttons-2" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;"> <table id="datatable-buttons-2" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;">
<thead> <thead>
<tr> <tr>
<th> Name</th> <th> Complaint</th>
<th>Tax</th>
<th>Labour Charge With Tax</th>
<th>Labour Charge</th> <th>Labour Charge</th>
<th hidden>Status</th> <th hidden>Status</th>
<th>Actions</th> <th>Actions</th>
@ -30,6 +32,8 @@
<?php foreach ($complaint as $value) : ?> <?php foreach ($complaint as $value) : ?>
<tr> <tr>
<td><?= $value['name']; ?></td> <td><?= $value['name']; ?></td>
<td><?= $value['tax']; ?></td>
<td><?= $value['labour_cost_with_tax']; ?></td>
<td><?= $value['labour_charge']; ?></td> <td><?= $value['labour_charge']; ?></td>
<td hidden> <td hidden>
<?php if($value['isactive'] == 1): ?> <?php if($value['isactive'] == 1): ?>
@ -62,22 +66,27 @@
</div> </div>
<form id="model_form_data" class="px-3"> <form id="model_form_data" class="px-3">
<div class="form-group"> <div class="form-group">
<label for="name">Name </label> <label for="name">Complaint </label>
<input class="form-control" type="text" id="complaint_id" hidden> <input class="form-control" type="text" id="complaint_id" hidden>
<input class="form-control" type="text" id="name" required="" placeholder="Name...."> <input class="form-control" type="text" id="name" required="" placeholder="Complaint">
</div>
<div class="form-group">
<label for="labour_charge">Labour Charge </label>
<input class="form-control" type="text" id="labour_charge" required="" placeholder="Labour Charge....">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="labour_charge">Tax </label> <label for="labour_charge">Tax </label>
<select class="form-control status-select" id="tax" name="tax" required data-toggle="select2"> <select class="form-control status-select" id="tax" name="tax" required data-toggle="select2" onchange="ReverseCalculation()">
<option value="0">Select Tax</option> <option value="0">Select Tax</option>
<option value="18">18%</option> <option value="18">18%</option>
<option value="28" >28%</option> <option value="28" >28%</option>
</select> </select>
</div> </div>
<div class="form-group">
<label for="labour_cost_with_tax">Labour Charge + Tax</label>
<input class="form-control" type="text" id="labour_cost_with_tax" placeholder="Labour Charge + Tax" onkeyup="ReverseCalculation()" required>
</div>
<div class="form-group">
<label for="labour_charge">Labour Charge </label>
<input class="form-control" type="text" id="labour_charge" placeholder="Labour Charge" required readonly>
</div>
<div class="form-group text-center"> <div class="form-group text-center">
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitComplaint(this)">Submit</button> <button class="btn btn-rounded btn-primary" type="submit" onclick="submitComplaint(this)">Submit</button>
</div> </div>
@ -90,6 +99,22 @@
<?php include('layout/footer.php'); ?> <?php include('layout/footer.php'); ?>
<script> <script>
function ReverseCalculation() {
var tax = parseFloat($("#tax").val());
if(tax == ''){
toastr.warning('Please select Tax', 'Warning');
}else{
var labour_cost_with_tax = parseFloat($("#labour_cost_with_tax").val());
var labour_cost = labour_cost_with_tax / parseFloat((tax / 100) + 1);
$("#labour_charge").val(labour_cost.toFixed(2));
}
}
function submitComplaint(params) { function submitComplaint(params) {
if (!$('#name').val() || !$('#labour_charge').val()) { if (!$('#name').val() || !$('#labour_charge').val()) {
return false; return false;
@ -97,7 +122,8 @@
var formData = { var formData = {
name: $('#name').val(), name: $('#name').val(),
labour_charge: $('#labour_charge').val(), labour_charge: $('#labour_charge').val(),
tax: $('#tax').val() tax: $('#tax').val(),
labour_cost_with_tax: $('#labour_cost_with_tax').val(),
}; };
var complaint_id = $('#complaint_id').val(); var complaint_id = $('#complaint_id').val();
if (!complaint_id) { if (!complaint_id) {
@ -110,9 +136,8 @@
dataType: 'json', dataType: 'json',
success: function(response) { success: function(response) {
console.log(response); console.log(response);
// $('#bike_model_login-modal').modal('hide'); // Reload the page after successful submission
$('#name').val(''); window.location.reload();
$('#labour_charge').val('');
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
// Handle error response here // Handle error response here
@ -121,6 +146,9 @@
}); });
} }
function editComplaint(params) { function editComplaint(params) {
var complaint_id = $(params).data('value'); var complaint_id = $(params).data('value');
$.ajax({ $.ajax({
@ -133,6 +161,7 @@
$('#complaint_id').val(response.complaint[0].complaint_id); $('#complaint_id').val(response.complaint[0].complaint_id);
$('#name').val(response.complaint[0].name); $('#name').val(response.complaint[0].name);
$('#labour_charge').val(response.complaint[0].labour_charge); $('#labour_charge').val(response.complaint[0].labour_charge);
$('#labour_cost_with_tax').val(response.complaint[0].labour_cost_with_tax);
var tax = parseFloat(response.complaint[0].cgst) + parseFloat(response.complaint[0].sgst); var tax = parseFloat(response.complaint[0].cgst) + parseFloat(response.complaint[0].sgst);
var selectElement = document.getElementById('tax'); var selectElement = document.getElementById('tax');

View File

@ -173,10 +173,7 @@
<label for="inputPassword4" class="col-form-label">Purchase Cost<span class="text-danger">*</span></label> <label for="inputPassword4" class="col-form-label">Purchase Cost<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="purchase_cost" placeholder="Purchase Cost"value="<?= isset($products['purchase_cost']) ? $products['purchase_cost'] : '' ?>" required> <input type="number" class="form-control" name="purchase_cost" placeholder="Purchase Cost"value="<?= isset($products['purchase_cost']) ? $products['purchase_cost'] : '' ?>" required>
</div> </div>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Unit Price<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="unit_price" placeholder="Price"value="<?= isset($products['unit_price']) ? $products['unit_price'] : '' ?>" required>
</div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Tax</label> <label for="inputPassword4" class="col-form-label">Tax</label>
<select class="form-control status-select" name="tax" required data-toggle="select2"> <select class="form-control status-select" name="tax" required data-toggle="select2">
@ -192,7 +189,11 @@
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Unit Price + Tax</label> <label for="inputPassword4" class="col-form-label">Unit Price + Tax</label>
<input type="number" class="form-control" name="total_amount" placeholder="Total Price"value="<?= isset($products['total_amount']) ? $products['total_amount'] : '' ?>" required readonly> <input type="number" class="form-control" name="total_amount" placeholder="Total Price" value="<?= isset($products['total_amount']) ? $products['total_amount'] : '' ?>" required >
</div>
<div class="form-group col-md-3">
<label for="inputPassword4" class="col-form-label">Unit Price<span class="text-danger">*</span></label>
<input type="test" class="form-control" name="unit_price" placeholder="Price" value="<?= isset($products['unit_price']) ? $products['unit_price'] : '' ?>" required readonly>
</div> </div>
</div><br> </div><br>
<h4 class="header-title">Stock Information :</h4><br> <h4 class="header-title">Stock Information :</h4><br>
@ -349,22 +350,44 @@
<!-- End Bike Make Create Pop-UP --> <!-- End Bike Make Create Pop-UP -->
<script> <script>
/** CALCULATE TOTAL AMOUNT ( UNIT PRICE + TAX ) */
$(document).ready(function() { $(document).ready(function() {
function calculateTotalAmount() { function unitPriceReverseCalculation() {
var unitPrice = parseFloat($("input[name='unit_price']").val());
var tax = parseFloat($("select[name='tax']").val()); var tax = parseFloat($("select[name='tax']").val());
var totalAmount = unitPrice + (unitPrice * tax / 100); if(tax == ''){
$("input[name='total_amount']").val(totalAmount.toFixed(2)); toastr.warning('Please select Tax', 'Warning');
}else{
var total_amount = parseFloat($("input[name='total_amount']").val());
var unitPrice = total_amount / parseFloat((tax / 100) + 1);
$("input[name='unit_price']").val(unitPrice.toFixed(2));
} }
$("input[name='unit_price'], select[name='tax']").change(function() { }
calculateTotalAmount();
$("input[name='total_amount'], select[name='tax']").change(function() {
unitPriceReverseCalculation();
}); });
calculateTotalAmount();
}); });
/** CALCULATE TOTAL AMOUNT ( UNIT PRICE + TAX ) */
// $(document).ready(function() {
// function calculateTotalAmount() {
// var unitPrice = parseFloat($("input[name='unit_price']").val());
// var tax = parseFloat($("select[name='tax']").val());
// var totalAmount = unitPrice + (unitPrice * tax / 100);
// $("input[name='total_amount']").val(totalAmount.toFixed(2));
// }
// $("input[name='unit_price'], select[name='tax']").change(function() {
// calculateTotalAmount();
// });
// calculateTotalAmount();
// });
$(document).ready(function() { $(document).ready(function() {
// Check SGST checkbox by default // Check SGST checkbox by default

View File

@ -56,9 +56,9 @@
</div> </div>
</div><br> </div><br>
<h4 class="header-title">Select Item :</h4> <h4 class="header-title">Select Items :</h4>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-3"> <div class="form-group col-md-6">
<label for="model" class="col-form-label">Product</label> <label for="model" class="col-form-label">Product</label>
<select class="form-control SelExample" id="productSelect" name="product_id[]" multiple> <select class="form-control SelExample" id="productSelect" name="product_id[]" multiple>
<option value="">Select a Product</option> <option value="">Select a Product</option>
@ -72,7 +72,7 @@
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-6">
<label for="model" class="col-form-label">Service</label> <label for="model" class="col-form-label">Service</label>
<select class="form-control SelExample" id="serviceSelected" name="sub_service_id[]" multiple> <select class="form-control SelExample" id="serviceSelected" name="sub_service_id[]" multiple>
<option value="">Select a Service</option> <option value="">Select a Service</option>
@ -90,14 +90,7 @@
<input type="hidden" id="service_id" name="service_id" value="<?= isset($services['service_id']) ? $services['service_id'] : '' ?>"><br> <input type="hidden" id="service_id" name="service_id" value="<?= isset($services['service_id']) ? $services['service_id'] : '' ?>"><br>
<h4 class="header-title">Pricing Information :</h4> <h4 class="header-title">Pricing Information :</h4>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Labour Cost<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="labour_cost" id="labour_cost" placeholder="Labour Cost" value="<?= isset($services['labour_cost']) ? $services['labour_cost'] : '' ?>" required>
</div>
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Total Price<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="price" id="price" placeholder="Price"value="<?= isset($services['price']) ? $services['price'] : '' ?>" required>
</div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Tax</label> <label for="inputPassword4" class="col-form-label">Tax</label>
<select class="form-control status-select" name="tax" required data-toggle="select2"> <select class="form-control status-select" name="tax" required data-toggle="select2">
@ -111,7 +104,29 @@
<option value="28" <?= ($tax == 28) ? 'selected' : '' ?>>28%</option> <option value="28" <?= ($tax == 28) ? 'selected' : '' ?>>28%</option>
</select> </select>
</div> </div>
</div><br>
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Labour Cost + Tax<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="labour_cost_With_Tax" id="LabourCostWithTax" placeholder="Labour Cost + Tax" value="<?= isset($services['price']) ? $services['price'] : '' ?>" required>
</div>
<div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Labour Cost<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="labour_cost" id="labour_cost" placeholder="Labour Cost" value="<?= isset($services['labour_cost']) ? $services['labour_cost'] : '' ?>" required readonly>
</div>
<div class="form-group col-md-4">
<label for="inputPassword4" class="col-form-label">Total Price<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="price" id="price" placeholder="Price"value="<?= isset($services['price']) ? $services['price'] : '' ?>" required>
</div>
</div>
<br>
<h4 class="header-title">Description Details :</h4> <h4 class="header-title">Description Details :</h4>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
@ -128,6 +143,9 @@
<?php include('layout/footer.php'); ?> <?php include('layout/footer.php'); ?>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
// Check SGST checkbox by default // Check SGST checkbox by default
$('#sgstCheckbox').prop('checked', true); $('#sgstCheckbox').prop('checked', true);
@ -398,6 +416,30 @@ document.getElementById('category').addEventListener('change', function() {
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + parseInt(newValue); add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + parseInt(newValue);
$('#price').val(add); $('#price').val(add);
}); });
$(document).ready(function() {
function unitPriceReverseCalculation() {
var tax = parseFloat($("select[name='tax']").val());
if(tax == ''){
toastr.warning('Please select Tax', 'Warning');
}else{
var labour_cost_With_Tax = parseFloat($("input[name='labour_cost_With_Tax']").val());
var labour_cost = labour_cost_With_Tax / parseFloat((tax / 100) + 1);
$("input[name='labour_cost']").val(labour_cost.toFixed(2));
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + parseInt(labour_cost.toFixed(2));
$('#price').val(add);
}
}
$("input[name='labour_cost_With_Tax'], select[name='tax']").change(function() {
unitPriceReverseCalculation();
});
});
</script> </script>
@ -421,3 +463,4 @@ document.getElementById('category').addEventListener('change', function() {
border-bottom: 1px solid #747474; border-bottom: 1px solid #747474;
} }
</style> </style>

View File

@ -23,8 +23,6 @@
<thead> <thead>
<tr> <tr>
<th>Service Name</th> <th>Service Name</th>
<th>Make List</th>
<!-- <th>Model List</th> -->
<th>Price</th> <th>Price</th>
<th>Cgst</th> <th>Cgst</th>
<th>Sgst</th> <th>Sgst</th>
@ -37,8 +35,6 @@
if ($value['isactive'] == 1) : ?> if ($value['isactive'] == 1) : ?>
<tr> <tr>
<td><?= $value['service_name']; ?></td> <td><?= $value['service_name']; ?></td>
<td><?= $value['makes_names']; ?></td>
<!-- <td><?= $value['models_names']; ?></td> -->
<td><?= $value['price']; ?></td> <td><?= $value['price']; ?></td>
<td><?= $value['cgst']; ?></td> <td><?= $value['cgst']; ?></td>
<td><?= $value['sgst']; ?></td> <td><?= $value['sgst']; ?></td>