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 = [
"name" => $this->request->getPost('name'),
"labour_charge" => $this->request->getPost('labour_charge'),
"labour_cost_with_tax" => $this->request->getPost('labour_cost_with_tax'),
"cgst" => $this->request->getPost('tax')/2,
"sgst" => $this->request->getPost('tax')/2,
"tax" => $this->request->getPost('tax'),

View File

@ -176,7 +176,7 @@ class Products extends BaseController
'isactive' => 1 ,
'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'),
'ml' => $ml
];
@ -370,6 +370,7 @@ class Products extends BaseController
$modelData = [
'model_name' => $model,
'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,
'tax' => $this->request->getPost('tax'),
'labour_cost' => $this->request->getPost('labour_cost'),
'labour_cost_with_cost' => $this->request->getPost('labour_cost_with_cost'),
'price' => $this->request->getPost('price'),
'makes_id' => $make_json,
'models_id' => $model_json,

View File

@ -5,5 +5,5 @@ class ComplaintModel extends Model
{
protected $table = 'complaints';
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 $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()

View File

@ -19,7 +19,9 @@
<table id="datatable-buttons-2" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;">
<thead>
<tr>
<th> Name</th>
<th> Complaint</th>
<th>Tax</th>
<th>Labour Charge With Tax</th>
<th>Labour Charge</th>
<th hidden>Status</th>
<th>Actions</th>
@ -30,6 +32,8 @@
<?php foreach ($complaint as $value) : ?>
<tr>
<td><?= $value['name']; ?></td>
<td><?= $value['tax']; ?></td>
<td><?= $value['labour_cost_with_tax']; ?></td>
<td><?= $value['labour_charge']; ?></td>
<td hidden>
<?php if($value['isactive'] == 1): ?>
@ -62,22 +66,27 @@
</div>
<form id="model_form_data" class="px-3">
<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="name" required="" placeholder="Name....">
</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....">
<input class="form-control" type="text" id="name" required="" placeholder="Complaint">
</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">
<select class="form-control status-select" id="tax" name="tax" required data-toggle="select2" onchange="ReverseCalculation()">
<option value="0">Select Tax</option>
<option value="18">18%</option>
<option value="28" >28%</option>
</select>
</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">
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitComplaint(this)">Submit</button>
</div>
@ -90,6 +99,22 @@
<?php include('layout/footer.php'); ?>
<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) {
if (!$('#name').val() || !$('#labour_charge').val()) {
return false;
@ -97,7 +122,8 @@
var formData = {
name: $('#name').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();
if (!complaint_id) {
@ -110,9 +136,8 @@
dataType: 'json',
success: function(response) {
console.log(response);
// $('#bike_model_login-modal').modal('hide');
$('#name').val('');
$('#labour_charge').val('');
// Reload the page after successful submission
window.location.reload();
},
error: function(xhr, status, error) {
// Handle error response here
@ -121,6 +146,9 @@
});
}
function editComplaint(params) {
var complaint_id = $(params).data('value');
$.ajax({
@ -133,6 +161,7 @@
$('#complaint_id').val(response.complaint[0].complaint_id);
$('#name').val(response.complaint[0].name);
$('#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 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>
<input type="number" class="form-control" name="purchase_cost" placeholder="Purchase Cost"value="<?= isset($products['purchase_cost']) ? $products['purchase_cost'] : '' ?>" 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="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">
<label for="inputPassword4" class="col-form-label">Tax</label>
<select class="form-control status-select" name="tax" required data-toggle="select2">
@ -192,7 +189,11 @@
</div>
<div class="form-group col-md-3">
<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><br>
<h4 class="header-title">Stock Information :</h4><br>
@ -349,22 +350,44 @@
<!-- End Bike Make Create Pop-UP -->
<script>
/** CALCULATE TOTAL AMOUNT ( UNIT PRICE + TAX ) */
$(document).ready(function() {
function calculateTotalAmount() {
var unitPrice = parseFloat($("input[name='unit_price']").val());
function unitPriceReverseCalculation() {
var tax = parseFloat($("select[name='tax']").val());
var totalAmount = unitPrice + (unitPrice * tax / 100);
$("input[name='total_amount']").val(totalAmount.toFixed(2));
if(tax == ''){
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() {
// Check SGST checkbox by default

View File

@ -56,9 +56,9 @@
</div>
</div><br>
<h4 class="header-title">Select Item :</h4>
<h4 class="header-title">Select Items :</h4>
<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>
<select class="form-control SelExample" id="productSelect" name="product_id[]" multiple>
<option value="">Select a Product</option>
@ -72,7 +72,7 @@
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-3">
<div class="form-group col-md-6">
<label for="model" class="col-form-label">Service</label>
<select class="form-control SelExample" id="serviceSelected" name="sub_service_id[]" multiple>
<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>
<h4 class="header-title">Pricing Information :</h4>
<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">
<label for="inputPassword4" class="col-form-label">Tax</label>
<select class="form-control status-select" name="tax" required data-toggle="select2">
@ -111,7 +104,29 @@
<option value="28" <?= ($tax == 28) ? 'selected' : '' ?>>28%</option>
</select>
</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>
<div class="form-row">
<div class="form-group col-md-12">
@ -128,6 +143,9 @@
<?php include('layout/footer.php'); ?>
<script>
$(document).ready(function() {
// Check SGST checkbox by default
$('#sgstCheckbox').prop('checked', true);
@ -398,6 +416,30 @@ document.getElementById('category').addEventListener('change', function() {
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + parseInt(newValue);
$('#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>
@ -420,4 +462,5 @@ document.getElementById('category').addEventListener('change', function() {
font-weight: 500;
border-bottom: 1px solid #747474;
}
</style>
</style>

View File

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