diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php index a8a6852c..8d1fc095 100755 --- a/app/Views/invoice_form.php +++ b/app/Views/invoice_form.php @@ -483,13 +483,13 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
- > + >
- step="0.001" > + step="0.001" >
@@ -1197,7 +1197,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d // Calculate the total using the formula: subtotal - tax + shipping - discount var total = overallAmount - overallTax + shippingCharges - overallDiscount; - console.log(total); + // console.log(total); // Update the subtotal, tax, shipping charges, discount, and total in the calculation card var subtotalElement = parseFloat(overallAmount.toFixed(2)); @@ -2551,111 +2551,112 @@ $('#saveButton').click(function() { function hideBillingShippingModel(params) { $('#editAddressesCheckbox').click(); } +// When discount is entered (keyup event) +$('#discount').keyup(function() { + // Ensure the discount type is set (percentage or fixed amount) + if ($('#discount-type').css('display') == 'none') { + $('#discount-type').val('%'); + } + $('#discount-type').show(); + $('#discount-type').attr('name', 'dis_type'); + // Clear individual item discount fields + $('.item-discount-amount').val(''); - $('#discount').keyup(function() { - if($('#discount-type').css('display') == 'none'){ - $('#discount-type').val('%'); - } - $('#discount-type').show(); - $('#discount-type').attr('name', 'dis_type'); + var discountValue = $(this).val(); + var discountType = $('#discount-type').val(); - $('.item-discount-amount').val(''); - - var discountValue = $(this).val(); - var discountType = $('#discount-type').val(); - - var totalAmount = 0 ; - var discountLastValue = 0; - $('.item-amount').each(function() { - totalAmount += parseInt($(this).val()); - }); - - if (discountType == '%') { - discountLastValue = totalAmount - (totalAmount * discountValue / 100 ); - }else{ - discountLastValue = totalAmount - discountValue; - } - - var shippingCharges = $('#shippingCharges').val(); - - if (isNaN(shippingCharges)) { - shippingCharges =0; - } - discountLastValue += parseInt(shippingCharges); - - $('#exacttotal').val(discountLastValue); - $('#grandtotal').val(parseInt(discountLastValue)); - $('#balanceAmount').val(parseInt(discountLastValue)); - - - - - // var discountedPrice = calculateDiscountedPrice(discountValue); - // $('#discounted-price').text(discountedPrice); + // Calculate the total amount of items (subtotal) + var totalAmount = 0; + $('.item-amount').each(function() { + totalAmount += parseFloat($(this).val()) || 0; // Ensure it's a number }); - function discountTypeKeyup(params) { - if($('#discount-type').css('display') == 'none'){ - $('#discount-type').val('%'); - } - $('#discount-type').show(); - - $('.item-discount-amount').val(''); - - var discountValue = $('#discount').val(); - var discountType = $('#discount-type').val(); - - var totalAmount = 0 ; - var discountLastValue = 0; - $('.item-amount').each(function() { - totalAmount += parseInt($(this).val()); - }); - - if (discountType == '%') { - discountLastValue = totalAmount - (totalAmount * discountValue / 100 ); - }else{ - discountLastValue = totalAmount - discountValue; - } - - var shippingCharges = $('#shippingCharges').val(); - if (isNaN(shippingCharges)) { - shippingCharges =0; - } - discountLastValue += parseInt(shippingCharges); - $('#exacttotal').val(discountLastValue ); - $('#grandtotal').val(parseInt(discountLastValue)); - $('#balanceAmount').val(parseInt(discountLastValue)); - + // Apply the discount based on the discount type + var discountedAmount = 0; + if (discountType == '%') { + discountedAmount = totalAmount - (totalAmount * discountValue / 100); + } else { + discountedAmount = totalAmount - discountValue; } - $('#discount-type').change(function () { - - var discountValue = $('#discount').val(); - var discountType = $(this).val(); + // Get the shipping charges and ensure it's a valid number + var shippingCharges = parseFloat($('#shippingCharges').val()) || 0; - var totalAmount = 0 ; - var discountLastValue = 0; - $('.item-amount').each(function() { - totalAmount += parseInt( $(this).val()); - }); + // Final total after adding shipping charges + var finalTotal = discountedAmount + shippingCharges; - if (discountType == '%') { - discountLastValue = totalAmount - (totalAmount * discountValue / 100 ); - }else{ - discountLastValue = totalAmount - discountValue; - } + // Update the fields with the calculated values + $('#subtotal').val(totalAmount.toFixed(2)); // Subtotal remains as the sum of item amounts + $('#exacttotal').val(finalTotal.toFixed(2)); // Final total after discount and shipping + $('#grandtotal').val(finalTotal.toFixed(2)); // Grand total + $('#balanceAmount').val(finalTotal.toFixed(2)); // Balance amount (same as final total) +}); - var shippingCharges = $('#shippingCharges').val(); - if (isNaN(shippingCharges)) { - shippingCharges =0; - } - discountLastValue += parseInt(shippingCharges); +// When the discount type is changed (percentage or fixed) +$('#discount-type').change(function() { + var discountValue = $('#discount').val(); + var discountType = $(this).val(); + + // Calculate the total amount of items (subtotal) + var totalAmount = 0; + $('.item-amount').each(function() { + totalAmount += parseFloat($(this).val()) || 0; // Ensure it's a number + }); + + // Apply the discount based on the discount type + var discountedAmount = 0; + if (discountType == '%') { + discountedAmount = totalAmount - (totalAmount * discountValue / 100); + } else { + discountedAmount = totalAmount - discountValue; + } + + // Get the shipping charges and ensure it's a valid number + var shippingCharges = parseFloat($('#shippingCharges').val()) || 0; + + // Final total after adding shipping charges + var finalTotal = discountedAmount + shippingCharges; + + // Update the fields with the calculated values + $('#subtotal').val(totalAmount.toFixed(2)); // Subtotal remains as the sum of item amounts + $('#exacttotal').val(finalTotal.toFixed(2)); // Final total after discount and shipping + $('#grandtotal').val(finalTotal.toFixed(2)); // Grand total + $('#balanceAmount').val(finalTotal.toFixed(2)); // Balance amount (same as final total) +}); + +// When shipping charge is updated +$('#shippingCharges').keyup(function() { + // Recalculate the final total with shipping charge + var shippingCharges = parseFloat($(this).val()) || 0; + + // Recalculate the discount and apply shipping + var discountValue = $('#discount').val(); + var discountType = $('#discount-type').val(); + + // Calculate the total amount of items (subtotal) + var totalAmount = 0; + $('.item-amount').each(function() { + totalAmount += parseFloat($(this).val()) || 0; // Ensure it's a number + }); + + // Apply the discount based on the discount type + var discountedAmount = 0; + if (discountType == '%') { + discountedAmount = totalAmount - (totalAmount * discountValue / 100); + } else { + discountedAmount = totalAmount - discountValue; + } + + // Final total after adding shipping charges + var finalTotal = discountedAmount + shippingCharges; + + // Update the fields with the recalculated values + $('#exacttotal').val(finalTotal.toFixed(2)); // Final total after discount and shipping + $('#grandtotal').val(finalTotal.toFixed(2)); // Grand total + $('#balanceAmount').val(finalTotal.toFixed(2)); // Balance amount (same as final total) +}); - $('#exacttotal').val(discountLastValue); - $('#grandtotal').val(parseInt(discountLastValue)); - $('#balanceAmount').val(parseInt(discountLastValue)); - }) \ No newline at end of file diff --git a/app/Views/itemwise_report_with_payment_method.php b/app/Views/itemwise_report_with_payment_method.php index d5db80e6..27d48cfa 100644 --- a/app/Views/itemwise_report_with_payment_method.php +++ b/app/Views/itemwise_report_with_payment_method.php @@ -24,40 +24,45 @@ - +
- +
- - - - - - - + + + + + + + - - books as $book): ?> - - - - - - - - - - + + books as $book): ?> + + + + + + + + + - + + + + + + +
Publisher CodePublisher Item CountPublisher Total CostBook NameItem CountPayment methodTotal CostPublisher CodePublisher Item CountPublisher Total CostBook NameItem CountPayment methodTotal Cost
publisher_code) ? $row->publisher_code : '-' ?>publisher_item_count ?>publisher_total_cost, 2) ?>book_name ?>item_count ?>payment_method) ?>total_cost, 2) ?>
publisher_code) ? $row->publisher_code : '-' ?>publisher_item_count ?>publisher_total_cost, 2) ?>book_name ?>item_count ?>payment_method) ?>total_cost, 2) ?>
Total
@@ -66,43 +71,64 @@
- \ No newline at end of file + diff --git a/app/Views/received_payments_report.php b/app/Views/received_payments_report.php index 018aa306..a8aa9a03 100644 --- a/app/Views/received_payments_report.php +++ b/app/Views/received_payments_report.php @@ -1,46 +1,45 @@ - -
+ + +
@@ -65,49 +64,47 @@
-
- + // Display the combined results + foreach ($combinedPayments as $paymentMethod => $totalAmount) { ?> +
  • +
    + +
    +
  • + +
    - +
    @@ -125,7 +122,7 @@ - + @@ -137,24 +134,17 @@ - - - - - - - Total Amount - - - + + +
    @@ -166,23 +156,40 @@ - - - - \ No newline at end of file + + $('.today-btn').on('click', function() { + var today = moment(); + dateRangeFilter.data('daterangepicker').setStartDate(today); + dateRangeFilter.data('daterangepicker').setEndDate(today); + dateRangeFilter.val(today.format('DD/MM/YYYY') + ' - ' + today.format('DD/MM/YYYY')); + dateRangeFilter.trigger('apply.daterangepicker'); + }); + + if ($select_data === '') { + $('.today-btn').trigger('click'); + } + }); +