Gst Updates
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
|
||||
@section('page-title', 'Edit Invoice')
|
||||
|
||||
|
||||
@section('content')
|
||||
<style>
|
||||
:root {
|
||||
@@ -314,7 +312,7 @@
|
||||
</style>
|
||||
|
||||
<div class="container-fluid py-3">
|
||||
{{-- Invoice Preview / Overview --}}
|
||||
{{-- Invoice Overview --}}
|
||||
<div class="glass-card">
|
||||
<div class="card-header-compact">
|
||||
<h4>
|
||||
@@ -323,12 +321,11 @@
|
||||
</h4>
|
||||
</div>
|
||||
<div class="card-body-compact">
|
||||
{{-- Read-only popup: items price/total cannot be edited here --}}
|
||||
@include('admin.popup_invoice', ['invoice' => $invoice, 'shipment' => $shipment])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Edit Invoice Header Details (POST) --}}
|
||||
|
||||
{{-- Edit Invoice Header --}}
|
||||
<div class="glass-card">
|
||||
<div class="card-header-compact">
|
||||
<h4>
|
||||
@@ -365,61 +362,16 @@
|
||||
required>
|
||||
</div>
|
||||
|
||||
{{-- Final Amount (Base) --}}
|
||||
{{-- Final Amount (With GST) – Charge Groups Total --}}
|
||||
<div class="form-group-compact">
|
||||
<label class="form-label-compact">
|
||||
<i class="fas fa-money-bill-wave"></i> Final Amount (Before GST)
|
||||
<i class="fas fa-money-bill-wave"></i> Final Amount (With GST)
|
||||
</label>
|
||||
<input type="number"
|
||||
step="0.01"
|
||||
name="final_amount"
|
||||
class="form-control-compact"
|
||||
value="{{ old('final_amount', $invoice->final_amount) }}"
|
||||
required>
|
||||
</div>
|
||||
|
||||
{{-- Tax Type --}}
|
||||
<div class="form-group-compact">
|
||||
<label class="form-label-compact">
|
||||
<i class="fas fa-receipt"></i> Tax Type
|
||||
</label>
|
||||
<div class="d-flex gap-3 mt-1">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input"
|
||||
type="radio"
|
||||
name="tax_type"
|
||||
value="gst"
|
||||
{{ old('tax_type', $invoice->tax_type) === 'gst' ? 'checked' : '' }}>
|
||||
<label class="form-check-label fw-semibold">GST (CGST + SGST)</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input"
|
||||
type="radio"
|
||||
name="tax_type"
|
||||
value="igst"
|
||||
{{ old('tax_type', $invoice->tax_type) === 'igst' ? 'checked' : '' }}>
|
||||
<label class="form-check-label fw-semibold">IGST</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Tax Percentage --}}
|
||||
<div class="form-group-compact">
|
||||
<label class="form-label-compact">
|
||||
<i class="fas fa-percentage"></i> Tax Percentage
|
||||
</label>
|
||||
<input type="number"
|
||||
step="0.01"
|
||||
min="0"
|
||||
max="28"
|
||||
name="tax_percent"
|
||||
class="form-control-compact"
|
||||
value="{{ old('tax_percent',
|
||||
$invoice->tax_type === 'gst'
|
||||
? ($invoice->cgst_percent + $invoice->sgst_percent)
|
||||
: $invoice->igst_percent
|
||||
) }}"
|
||||
required>
|
||||
value="{{ $invoice->grand_total_with_charges }}"
|
||||
readonly>
|
||||
</div>
|
||||
|
||||
{{-- Status --}}
|
||||
@@ -428,15 +380,9 @@
|
||||
<i class="fas fa-tasks"></i> Status
|
||||
</label>
|
||||
<select name="status" class="form-select-compact" required>
|
||||
<option value="pending" {{ old('status', $invoice->status) === 'pending' ? 'selected' : '' }}>
|
||||
Pending
|
||||
</option>
|
||||
<option value="paid" {{ old('status', $invoice->status) === 'paid' ? 'selected' : '' }}>
|
||||
Paid
|
||||
</option>
|
||||
<option value="overdue" {{ old('status', $invoice->status) === 'overdue' ? 'selected' : '' }}>
|
||||
Overdue
|
||||
</option>
|
||||
<option value="pending" {{ old('status', $invoice->status) === 'pending' ? 'selected' : '' }}>Pending</option>
|
||||
<option value="paid" {{ old('status', $invoice->status) === 'paid' ? 'selected' : '' }}>Paid</option>
|
||||
<option value="overdue" {{ old('status', $invoice->status) === 'overdue' ? 'selected' : '' }}>Overdue</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -462,43 +408,46 @@
|
||||
</div>
|
||||
|
||||
@php
|
||||
// आता helpers वापरू: totalPaid() आणि remainingAmount()
|
||||
$totalPaid = $invoice->totalPaid();
|
||||
$remaining = $invoice->remainingAmount();
|
||||
$totalPaid = $invoice->totalPaid();
|
||||
$remaining = $invoice->remainingAmount();
|
||||
|
||||
// Mixed tax type label from charge groups
|
||||
$taxTypes = $invoice->chargeGroups
|
||||
? $invoice->chargeGroups->pluck('tax_type')->filter()->unique()->values()
|
||||
: collect([]);
|
||||
|
||||
$taxTypeLabel = 'None';
|
||||
|
||||
if ($taxTypes->count() === 1) {
|
||||
if ($taxTypes[0] === 'gst') {
|
||||
$taxTypeLabel = 'GST (CGST + SGST)';
|
||||
} elseif ($taxTypes[0] === 'igst') {
|
||||
$taxTypeLabel = 'IGST';
|
||||
} else {
|
||||
$taxTypeLabel = strtoupper($taxTypes[0]);
|
||||
}
|
||||
} elseif ($taxTypes->count() > 1) {
|
||||
$parts = [];
|
||||
if ($taxTypes->contains('gst')) {
|
||||
$parts[] = 'GST (CGST + SGST)';
|
||||
}
|
||||
if ($taxTypes->contains('igst')) {
|
||||
$parts[] = 'IGST';
|
||||
}
|
||||
$taxTypeLabel = implode(' + ', $parts);
|
||||
}
|
||||
@endphp
|
||||
|
||||
{{-- Amount Breakdown (items + GST + groups) --}}
|
||||
{{-- Amount Breakdown --}}
|
||||
<div class="amount-breakdown-compact">
|
||||
<h6 class="fw-bold mb-3 text-dark">
|
||||
<i class="fas fa-calculator me-2"></i>Amount Breakdown
|
||||
</h6>
|
||||
|
||||
<div class="breakdown-row">
|
||||
<span class="breakdown-label">Total Amount Before Tax</span>
|
||||
<span class="breakdown-value" id="baseAmount">
|
||||
₹{{ number_format($invoice->final_amount, 2) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="breakdown-row">
|
||||
<span class="breakdown-label">Tax Type</span>
|
||||
<span class="breakdown-value text-primary">
|
||||
@if($invoice->tax_type === 'gst')
|
||||
GST (CGST + SGST)
|
||||
@else
|
||||
IGST
|
||||
@endif
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="breakdown-row">
|
||||
<span class="breakdown-label">Tax Percentage</span>
|
||||
<span class="breakdown-value text-primary">
|
||||
@if($invoice->tax_type === 'gst')
|
||||
{{ $invoice->cgst_percent + $invoice->sgst_percent }}%
|
||||
@else
|
||||
{{ $invoice->igst_percent }}%
|
||||
@endif
|
||||
{{ $taxTypeLabel }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -509,15 +458,8 @@
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="breakdown-row">
|
||||
<span class="breakdown-label">Charge Groups Total</span>
|
||||
<span class="breakdown-value text-info" id="chargeGroupsTotal">
|
||||
₹{{ number_format($invoice->charge_groups_total, 2) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="breakdown-row" style="border-top: 2px solid #e2e8f0; padding-top: 0.75rem;">
|
||||
<span class="breakdown-label fw-bold">Grand Total (Items + GST + Groups)</span>
|
||||
<span class="breakdown-label fw-bold">Grand Total (Charges + GST)</span>
|
||||
<span class="breakdown-value fw-bold text-dark" id="totalInvoiceWithGst">
|
||||
₹{{ number_format($invoice->grand_total_with_charges, 2) }}
|
||||
</span>
|
||||
@@ -538,13 +480,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Installment Summary (top cards) --}}
|
||||
{{-- Summary cards --}}
|
||||
<div class="summary-grid-compact">
|
||||
<div class="summary-card-compact total">
|
||||
<div class="summary-value-compact text-success" id="totalInvoiceWithGstCard">
|
||||
₹{{ number_format($invoice->grand_total_with_charges, 2) }}
|
||||
</div>
|
||||
<div class="summary-label-compact">Grand Total (Items + GST + Groups)</div>
|
||||
<div class="summary-label-compact">Grand Total (Charges + GST)</div>
|
||||
</div>
|
||||
<div class="summary-card-compact paid">
|
||||
<div class="summary-value-compact text-primary">
|
||||
@@ -789,15 +731,19 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
document.getElementById("remainingAmount").textContent = "₹" + formatINR(data.remaining);
|
||||
}
|
||||
if (document.getElementById("baseAmount")) {
|
||||
document.getElementById("baseAmount").textContent = "₹" + formatINR(data.baseAmount);
|
||||
document.getElementById("baseAmount").textContent = "₹" + formatINR(data.chargeGroupsTotal);
|
||||
}
|
||||
if (document.getElementById("gstAmount")) {
|
||||
document.getElementById("gstAmount").textContent = "₹" + formatINR(data.gstAmount);
|
||||
}
|
||||
// grand total आता finalAmountWithGst नाही, पण API अजून तेच key देत आहे,
|
||||
// त्यामुळे इथे फक्त card आणि breakdown value update करतो:
|
||||
|
||||
if (document.getElementById("totalInvoiceWithGst")) {
|
||||
document.getElementById("totalInvoiceWithGst").textContent = "₹" + formatINR(data.finalAmountWithGst);
|
||||
document.getElementById("totalInvoiceWithGst").textContent =
|
||||
"₹" + formatINR(data.grandTotal);
|
||||
}
|
||||
const totalCard = document.getElementById("totalInvoiceWithGstCard");
|
||||
if (totalCard) {
|
||||
totalCard.textContent = "₹" + formatINR(data.grandTotal);
|
||||
}
|
||||
|
||||
const paidCard = document.querySelector(".summary-card-compact.paid .summary-value-compact");
|
||||
@@ -858,13 +804,18 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
document.getElementById("remainingAmount").textContent = "₹" + formatINR(data.remaining);
|
||||
}
|
||||
if (document.getElementById("baseAmount")) {
|
||||
document.getElementById("baseAmount").textContent = "₹" + formatINR(data.baseAmount);
|
||||
document.getElementById("baseAmount").textContent = "₹" + formatINR(data.chargeGroupsTotal);
|
||||
}
|
||||
if (document.getElementById("gstAmount")) {
|
||||
document.getElementById("gstAmount").textContent = "₹" + formatINR(data.gstAmount);
|
||||
}
|
||||
if (document.getElementById("totalInvoiceWithGst")) {
|
||||
document.getElementById("totalInvoiceWithGst").textContent = "₹" + formatINR(data.finalAmountWithGst);
|
||||
document.getElementById("totalInvoiceWithGst").textContent =
|
||||
"₹" + formatINR(data.grandTotal);
|
||||
}
|
||||
const totalCard = document.getElementById("totalInvoiceWithGstCard");
|
||||
if (totalCard) {
|
||||
totalCard.textContent = "₹" + formatINR(data.grandTotal);
|
||||
}
|
||||
|
||||
const paidCard = document.querySelector(".summary-card-compact.paid .summary-value-compact");
|
||||
@@ -886,16 +837,15 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
alert("Something went wrong. Please try again.");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Auto due date = invoice date + 10 days
|
||||
const invoiceDateInput = document.querySelector('input[name="invoice_date"]');
|
||||
const dueDateInput = document.querySelector('input[name="due_date"]');
|
||||
|
||||
if (invoiceDateInput && dueDateInput) {
|
||||
invoiceDateInput.addEventListener('change', function() {
|
||||
const selectedDate = new Date(this.value);
|
||||
|
||||
|
||||
if (!isNaN(selectedDate.getTime())) {
|
||||
selectedDate.setDate(selectedDate.getDate() + 10);
|
||||
const year = selectedDate.getFullYear();
|
||||
|
||||
Reference in New Issue
Block a user