CHANGE_SALES_ORDER_AND_JOB_CARD_CALCULATION_ISSUE : AADHAVAN

This commit is contained in:
unknown 2024-06-10 17:12:42 +05:30
parent fbf43cc737
commit fd18f1011d
2 changed files with 23 additions and 15 deletions

View File

@ -1276,8 +1276,9 @@ $(document).ready(function() {
$(row).find('.item-tax').val(tax.toFixed(0));
finrate = Number(product.unit_price) * quantity;
$(row).find('.item-rate').val(finrate);
rate = Number(product.unit_price);
var amount = (rate + (rate * tax / 100)) * quantity;
// rate = Number(product.unit_price);
rate = Number(product.total_amount);
var amount = rate * quantity;
total_tax_amt = amount - finrate;
$(row).find('.total-tax-amount').val(total_tax_amt.toFixed(2));
$(row).find('.item-amount').val(amount.toFixed(2));
@ -1291,13 +1292,14 @@ $(document).ready(function() {
var $targetField = $previousRow.find('.item-rate1');
finrate = Number($targetField.val()) * quantity;
// rate = $targetField.val();
rate = $targetField.val();
$(row).find('.item-rate').val(finrate);
var amount = (Number(rate) + (Number(rate) * tax / 100)) *quantity;
total_tax_amt = amount - finrate;
$(row).find('.total-tax-amount').val(total_tax_amt.toFixed(2));
$(row).find('.item-amount').val(amount.toFixed(2));
$(row).find('.item-amount').val(Math.round(amount.toFixed(2)).toFixed(2));
}
else if(type.includes("complaint")) {
if(action == 'parent') var $previousRow = row;
@ -1486,7 +1488,7 @@ $(document).ready(function() {
$('#subtotal').val(sb_tot.toFixed(2));
$('#invoicetax').val(calculateTax().toFixed(2));
$('#grandtotal').val(tot.toFixed(2));
$('#grandtotal').val(Math.round(tot.toFixed(2)));
});
// Function to calculate total
@ -1520,7 +1522,7 @@ $(document).ready(function() {
tot = sb_tot + calculateTax();
$('#subtotal').val(sb_tot.toFixed(2));
$('#invoicetax').val(calculateTax().toFixed(2));
$('#grandtotal').val(tot.toFixed(2));
$('#grandtotal').val(Math.round(tot.toFixed(2)));
<?php if(isset($rework)) { ?>
$('#dt_amount').attr('readonly', true);
$('#dt_amount').val(tot.toFixed(2));
@ -1530,7 +1532,7 @@ $(document).ready(function() {
{
$('#subtotal').val(calculateSubtotal().toFixed(2));
$('#invoicetax').val(calculateTax().toFixed(2));
$('#grandtotal').val(calculateTotal().toFixed(2));
$('#grandtotal').val(Math.round(calculateTotal().toFixed(2)));
<?php if(isset($rework)) { ?>
$('#dt_amount').attr('readonly', true);
$('#dt_amount').val(calculateTotal().toFixed(2));

View File

@ -215,7 +215,7 @@
$tax_amount=0 ;
}
?>
<input type="text" class="form-control" name="tax-amount[]" value="<?= $tax_amount; ?>" readonly>
<input type="text" class="form-control" name="tax-amount[]" value="<?= number_format($tax_amount,2); ?>" readonly>
</td>
<!-- <td style="width:12%;">
<input type="number" class="form-control item-discount-amount" min="0" name="discount_amount[]" value="<?= isset($salechild['discount']) ? $salechild['discount'] : '' ?>">
@ -541,12 +541,14 @@ $(document).ready(function() {
var rate = $(row).find('.item-rate').val();
var quantity = $(row).find('.item-quantity').val();
var amount = rate * quantity;
// var amount = rate * quantity;
var amount = product.total_amount *quantity;
// console.log(amount);
var taxamount = amount * tax / 100;
var finalamt = amount + taxamount;
// var taxamount = amount * tax / 100;
// var finalamt = amount + taxamount;
var finalamt = amount;
// console.log("samount".samount);
$(row).find('.item-amount').val(finalamt);
$(row).find('.item-amount').val(parseFloat(finalamt).toFixed(2));
}
// Event listener for product selection
@ -565,8 +567,8 @@ $(document).ready(function() {
var cgst = parseInt(product.cgst);
var sgst = parseInt(product.sgst);
var totalTax = cgst + sgst;
var total_tax_amount = parseInt(product.unit_price) * totalTax / 100;
// var total_tax_amount = product.unit_price * totalTax / 100;
var total_tax_amount = product.total_amount;
$(this).closest('tr').find('.item-quantity').attr('max', product.qty_stock);
@ -641,8 +643,12 @@ $(document).ready(function() {
function calculateTotal() {
var subtotal = calculateSubtotal();
var total_tax_amount = $('#invoicetax').val();
// console.log(total_tax_amount + parseInt(subtotal));
var discount = calculateDiscount();
var total = subtotal - discount;
var total = parseFloat(total_tax_amount) + parseFloat(subtotal) - discount;
// return total;
return Math.round(total);
}
@ -1036,7 +1042,7 @@ $(document).on('click', '#selectClient', function() {
const itemResult = parseFloat(row.querySelector('.item-result').value);
const taxValue = parseFloat(row.querySelector('.item-tax').value);
const taxAmount = itemResult * taxValue / 100;
row.querySelector('[name="tax-amount[]"]').value = taxAmount; // Ensure two decimal places
row.querySelector('[name="tax-amount[]"]').value = parseFloat(taxAmount).toFixed(2); // Ensure two decimal places
}