<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport"…
- User
* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Poppins', sans-serif; background-color: #f5f7fb; color: var(--dark-color); line-height: 1.6; } .container { max-width: 1200px; margin: 0 auto; padding: 2rem; } header { text-align: center; margin-bottom: 3rem; position: relative; } .logo { font-size: 2rem; font-weight: 700; color: var(--primary-color); margin-bottom: 0.5rem; } .tagline { font-size: 1rem; color: #6c757d; } .card { background-color: white; border-radius: var(--border-radius); box-shadow: var(--box-shadow); padding: 2rem; margin-bottom: 2rem; transition: var(--transition); } .card:hover { transform: translateY(-5px); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12); } h1, h2, h3 { color: var(--primary-color); margin-bottom: 1rem; } .upload-area { border: 2px dashed #d1d5db; border-radius: var(--border-radius); padding: 2rem; text-align: center; cursor: pointer; margin-bottom: 1.5rem; transition: var(--transition); } .upload-area:hover, .upload-area.dragover { border-color: var(--primary-color); background-color: rgba(67, 97, 238, 0.05); } .upload-icon { font-size: 3rem; color: var(--primary-color); margin-bottom: 1rem; } .btn { display: inline-block; padding: 0.75rem 1.5rem; font-size: 1rem; font-weight: 500; text-align: center; text-decoration: none; color: white; background-color: var(--primary-color); border: none; border-radius: var(--border-radius); cursor: pointer; transition: var(--transition); } .btn:hover { background-color: var(--secondary-color); transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); } .btn-outline { background-color: transparent; border: 2px solid var(--primary-color); color: var(--primary-color); } .btn-outline:hover { background-color: var(--primary-color); color: white; } input[type="file"] { display: none; } .file-list { max-height: 300px; overflow-y: auto; margin-bottom: 1.5rem; } .file-item { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem; border-bottom: 1px solid #eee; } .file-name { font-size: 0.9rem; flex-grow: 1; margin-right: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .file-status { font-size: 0.8rem; padding: 0.25rem 0.5rem; border-radius: 12px; font-weight: 500; } .status-pending { background-color: #fff3cd; color: #856404; } .status-processing { background-color: #cce5ff; color: #004085; } .status-success { background-color: #d4edda; color: #155724; } .status-error { background-color: #f8d7da; color: #721c24; } .remove-file { color: var(--danger-color); background: none; border: none; cursor: pointer; font-size: 1.2rem; transition: var(--transition); } .remove-file:hover { transform: scale(1.2); } .progress-container { width: 100%; background-color: #e9ecef; border-radius: 12px; margin-bottom: 1.5rem; height: 10px; } .progress-bar { height: 100%; background-color: var(--primary-color); border-radius: 12px; width: 0%; transition: width 0.3s ease; } .results-section { display: none; } .controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; } .report-tabs { display: flex; border-bottom: 1px solid #dee2e6; margin-bottom: 1.5rem; } .tab { padding: 0.75rem 1.5rem; cursor: pointer; border-bottom: 3px solid transparent; transition: var(--transition); } .tab.active { border-bottom: 3px solid var(--primary-color); color: var(--primary-color); font-weight: 500; } .tab:hover:not(.active) { background-color: rgba(67, 97, 238, 0.05); } .report-content { overflow-x: auto; } table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; } th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid #dee2e6; } th { background-color: #f8f9fa; font-weight: 600; } tr:hover { background-color: rgba(67, 97, 238, 0.03); } .summary-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; } .summary-card { background-color: white; border-radius: var(--border-radius); box-shadow: var(--box-shadow); padding: 1.5rem; } .summary-title { font-size: 0.9rem; color: #6c757d; margin-bottom: 0.5rem; } .summary-value { font-size: 1.5rem; font-weight: 600; color: var(--primary-color); } .gstr-table { border: 1px solid #dee2e6; border-radius: var(--border-radius); overflow: hidden; } .gstr-table th { background-color: var(--primary-color); color: white; } .footer { text-align: center; margin-top: 3rem; padding-top: 2rem; border-top: 1px solid #dee2e6; color: #6c757d; } .notification { position: fixed; top: 20px; right: 20px; padding: 1rem; background-color: white; border-radius: var(--border-radius); box-shadow: var(--box-shadow); transition: transform 0.3s ease, opacity 0.3s ease; transform: translateX(150%); opacity: 0; z-index: 1000; display: flex; align-items: center; } .notification.show { transform: translateX(0); opacity: 1; } .notification-success { border-left: 4px solid var(--success-color); } .notification-error { border-left: 4px solid var(--danger-color); } .notification-icon { margin-right: 0.75rem; font-size: 1.2rem; } .notification-success .notification-icon { color: var(--success-color); } .notification-error .notification-icon { color: var(--danger-color); } .notification-message { flex-grow: 1; } .notification-close { background: none; border: none; cursor: pointer; font-size: 1.2rem; margin-left: 0.75rem; color: #6c757d; } @media (max-width: 768px) { .controls { flex-direction: column; gap: 1rem; } .summary-cards { grid-template-columns: 1fr; } .container { padding: 1rem; } } </style><div class="card"> <h2>Upload GSTR-3B JSON Files</h2> <p>Upload up to 20 JSON files to generate your GSTR-3B reports. Drag and drop files or click to browse.</p> <div class="upload-area" id="uploadArea"> <div class="upload-icon">📤</div> <h3>Drag & Drop Files Here</h3> <p>or</p> <label for="fileInput" class="btn">Browse Files</label> <input type="file" id="fileInput" accept=".json" multiple> </div> <div class="progress-container" id="progressContainer"> <div class="progress-bar" id="progressBar"></div> </div> <div class="file-list" id="fileList"> <!-- File items will be added here dynamically --> </div> <div class="controls"> <button id="uploadBtn" class="btn" disabled>Process Files</button> <button id="clearBtn" class="btn btn-outline">Clear All</button> </div> </div> <div class="results-section" id="resultsSection"> <div class="card"> <h2>GSTR-3B Report Results</h2> <div class="summary-cards" id="summaryCards"> <!-- Summary cards will be added here dynamically --> </div> <div class="report-tabs"> <div class="tab active" data-tab="outward-supplies">Outward Supplies</div> <div class="tab" data-tab="inter-state-supplies">Inter-State Supplies</div> <div class="tab" data-tab="itc-details">ITC Details</div> <div class="tab" data-tab="tax-payment">Tax Payment</div> </div> <div class="report-content"> <div class="tab-content active" id="outward-supplies"> <table class="gstr-table"> <thead> <tr> <th>GSTIN</th> <th>Period</th> <th>Nature of Supplies</th> <th>Taxable Value</th> <th>IGST</th> <th>CGST</th> <th>SGST</th> <th>Cess</th> </tr> </thead> <tbody id="outwardSuppliesBody"> <!-- Outward supplies data will be added here dynamically --> </tbody> </table> </div> <div class="tab-content" id="inter-state-supplies"> <table class="gstr-table"> <thead> <tr> <th>GSTIN</th> <th>Period</th> <th>Type</th> <th>Place of Supply</th> <th>Taxable Value</th> <th>Amount</th> </tr> </thead> <tbody id="interStateSuppliesBody"> <!-- Inter-state supplies data will be added here dynamically --> </tbody> </table> </div> <div class="tab-content" id="itc-details"> <table class="gstr-table"> <thead> <tr> <th>GSTIN</th> <th>Period</th> <th>ITC Type</th> <th>IGST</th> <th>CGST</th> <th>SGST</th> <th>Cess</th> </tr> </thead> <tbody id="itcDetailsBody"> <!-- ITC details data will be added here dynamically --> </tbody> </table> </div> <div class="tab-content" id="tax-payment"> <table class="gstr-table"> <thead> <tr> <th>GSTIN</th> <th>Period</th> <th>Tax Type</th> <th>Mode of Payment</th> <th>Amount</th> <th>Date</th> </tr> </thead> <tbody id="taxPaymentBody"> <!-- Tax payment data will be added here dynamically --> </tbody> </table> </div> </div> <div class="controls"> <button id="downloadBtn" class="btn">Download Report</button> <button id="backBtn" class="btn btn-outline">Back to Upload</button> </div> </div> </div> <div class="footer"> <p>© 2023 GSTR-3B Report Generator | Simplifying GST Compliance</p> </div> </div> <div class="notification" id="notification"> <span class="notification-icon">✓</span> <div class="notification-message">Operation completed successfully!</div> <button class="notification-close">×</button> </div> <script> document.addEventListener('DOMContentLoaded', function() { // DOM elements const uploadArea = document.getElementById('uploadArea'); const fileInput = document.getElementById('fileInput'); const fileList = document.getElementById('fileList'); const uploadBtn = document.getElementById('uploadBtn'); const clearBtn = document.getElementById('clearBtn'); const progressBar = document.getElementById('progressBar'); const progressContainer = document.getElementById('progressContainer'); const resultsSection = document.getElementById('resultsSection'); const downloadBtn = document.getElementById('downloadBtn'); const backBtn = document.getElementById('backBtn'); const tabs = document.querySelectorAll('.tab'); const tabContents = document.querySelectorAll('.tab-content'); const notification = document.getElementById('notification'); const notificationClose = document.querySelector('.notification-close'); const summaryCards = document.getElementById('summaryCards'); // Table bodies const outwardSuppliesBody = document.getElementById('outwardSuppliesBody'); const interStateSuppliesBody = document.getElementById('interStateSuppliesBody'); const itcDetailsBody = document.getElementById('itcDetailsBody'); const taxPaymentBody = document.getElementById('taxPaymentBody'); // File collection and counter let files = []; const MAX_FILES = 20; // Event Listeners uploadArea.addEventListener('click', () => fileInput.click()); fileInput.addEventListener('change', handleFileSelection); uploadArea.addEventListener('dragover', handleDragOver); uploadArea.addEventListener('dragleave', handleDragLeave); uploadArea.addEventListener('drop', handleDrop); uploadBtn.addEventListener('click', processFiles); clearBtn.addEventListener('click', clearFiles); downloadBtn.addEventListener('click', downloadReport); backBtn.addEventListener('click', goBackToUpload); notificationClose.addEventListener('click', hideNotification); // Tab functionality tabs.forEach(tab => { tab.addEventListener('click', () => { tabs.forEach(t => t.classList.remove('active')); tab.classList.add('active'); tabContents.forEach(content => content.classList.remove('active')); document.getElementById(tab.dataset.tab).classList.add('active'); }); }); // Functions function handleFileSelection(e) { const selectedFiles = Array.from(e.target.files); addFiles(selectedFiles); } function handleDragOver(e) { e.preventDefault(); uploadArea.classList.add('dragover'); } function handleDragLeave(e) { e.preventDefault(); uploadArea.classList.remove('dragover'); } function handleDrop(e) { e.preventDefault(); uploadArea.classList.remove('dragover'); const droppedFiles = Array.from(e.dataTransfer.files); addFiles(droppedFiles); } function addFiles(newFiles) { const jsonFiles = newFiles.filter(file => file.type === 'application/json' || file.name.endsWith('.json')); if (jsonFiles.length === 0) { showNotification('Please select valid JSON files.', 'error'); return; } if (files.length + jsonFiles.length > MAX_FILES) { showNotification(`You can only upload up to ${MAX_FILES} files at once.`, 'error'); return; } // Add files to the collection jsonFiles.forEach(file => { const fileExists = files.some(f => f.name === file.name && f.size === file.size); if (!fileExists) { files.push(file); addFileToUI(file); } }); updateUploadButtonState(); } function addFileToUI(file) { const fileItem = document.createElement('div'); fileItem.className = 'file-item'; fileItem.innerHTML = ` <div class="file-name">${file.name}</div> <span class="file-status status-pending">Pending</span> <button class="remove-file" data-name="${file.name}" data-size="${file.size}">×</button> `; fileList.appendChild(fileItem); // Add event listener to remove button const removeBtn = fileItem.querySelector('.remove-file'); removeBtn.addEventListener('click', function() { const fileName = this.dataset.name; const fileSize = this.dataset.size; files = files.filter(f => !(f.name === fileName && f.size == fileSize)); fileItem.remove(); updateUploadButtonState(); }); } function updateUploadButtonState() { uploadBtn.disabled = files.length === 0; } function clearFiles() { files = []; fileList.innerHTML = ''; updateUploadButtonState(); } function processFiles() { if (files.length === 0) { showNotification('Please select at least one file to process.', 'error'); return; } // Show progress progressContainer.style.display = 'block'; // Process each file let processedCount = 0; const reports = []; files.forEach((file, index) => { const fileItem = fileList.children[index]; const statusElem = fileItem.querySelector('.file-status'); statusElem.className = 'file-status status-processing'; statusElem.textContent = 'Processing...'; const reader = new FileReader(); reader.onload = function(e) { try { const jsonData = JSON.parse(e.target.result); reports.push(jsonData); statusElem.className = 'file-status status-success'; statusElem.textContent = 'Success'; } catch (error) { statusElem.className = 'file-status status-error'; statusElem.textContent = 'Error'; console.error(`Error processing ${file.name}:`, error); } processedCount++; const progress = (processedCount / files.length) * 100; progressBar.style.width = `${progress}%`; if (processedCount === files.length) { finishProcessing(reports); } }; reader.onerror = function() { statusElem.className = 'file-status status-error'; statusElem.textContent = 'Error'; processedCount++; const progress = (processedCount / files.length) * 100; progressBar.style.width = `${progress}%`; if (processedCount === files.length) { finishProcessing(reports); } }; // Add a small delay between processing files to show progress setTimeout(() => { reader.readAsText(file); }, index * 100); }); } function finishProcessing(reports) { if (reports.length === 0) { showNotification('No valid reports found in the uploaded files.', 'error'); return; } try { generateReport(reports); showResultsSection(); showNotification('Reports generated successfully!', 'success'); } catch (error) { console.error('Error generating reports:', error); showNotification('Error generating reports. Please check the console for details.', 'error'); } } function generateReport(reports) { // Clear previous data outwardSuppliesBody.innerHTML = ''; interStateSuppliesBody.innerHTML = ''; itcDetailsBody.innerHTML = ''; taxPaymentBody.innerHTML = ''; summaryCards.innerHTML = ''; // Aggregate data let totalTaxableValue = 0; let totalIGST = 0; let totalCGST = 0; let totalSGST = 0; let totalCess = 0; let totalITC = 0; // Process each report reports.forEach(report => { // Outward Supplies if (report.sup_details && report.sup_details.osup_det) { const osup = report.sup_details.osup_det; totalTaxableValue += parseFloat(osup.txval || 0); totalIGST += parseFloat(osup.iamt || 0); totalCGST += parseFloat(osup.camt || 0); totalSGST += parseFloat(osup.samt || 0); totalCess += parseFloat(osup.csamt || 0); const row = document.createElement('tr'); row.innerHTML = ` <td>${report.gstin || 'N/A'}</td> <td>${report.ret_period || 'N/A'}</td> <td>Taxable Outward Supplies</td> <td>₹${formatNumber(osup.txval || 0)}</td> <td>₹${formatNumber(osup.iamt || 0)}</td> <td>₹${formatNumber(osup.camt || 0)}</td> <td>₹${formatNumber(osup.samt || 0)}</td> <td>₹${formatNumber(osup.csamt || 0)}</td> `; outwardSuppliesBody.appendChild(row); } // Zero-rated supplies if (report.sup_details && report.sup_details.osup_zero) { const osupZero = report.sup_details.osup_zero; const row = document.createElement('tr'); row.innerHTML = ` <td>${report.gstin || 'N/A'}</td> <td>${report.ret_period || 'N/A'}</td> <td>Zero-rated Supplies</td> <td>₹${formatNumber(osupZero.txval || 0)}</td> <td>₹${formatNumber(osupZero.iamt || 0)}</td> <td>₹${formatNumber(osupZero.camt || 0)}</td> <td>₹${formatNumber(osupZero.samt || 0)}</td> <td>₹${formatNumber(osupZero.csamt || 0)}</td> `; outwardSuppliesBody.appendChild(row); } // Nil-rated, exempted supplies if (report.sup_details && report.sup_details.osup_nil_exmp) { const osupNil = report.sup_details.osup_nil_exmp; const row = document.createElement('tr'); row.innerHTML = ` <td>${report.gstin || 'N/A'}</td> <td>${report.ret_period || 'N/A'}</td> <td>Nil-rated, Exempted Supplies</td> <td>₹${formatNumber(osupNil.txval || 0)}</td> <td>₹${formatNumber(osupNil.iamt || 0)}</td> <td>₹${formatNumber(osupNil.camt || 0)}</td> <td>₹${formatNumber(osupNil.samt || 0)}</td> <td>₹${formatNumber(osupNil.csamt || 0)}</td> `; outwardSuppliesBody.appendChild(row); } // Reverse charge supplies if (report.sup_details && report.sup_details.isup_rev) { const isupRev = report.sup_details.isup_rev; const row = document.createElement('tr'); row.innerHTML = ` <td>${report.gstin || 'N/A'}</td> <td>${report.ret_period || 'N/A'}</td> <td>Reverse Charge Supplies</td> <td>₹${formatNumber(isupRev.txval || 0)}</td> <td>₹${formatNumber(isupRev.iamt || 0)}</td> <td>₹${formatNumber(isupRev.camt || 0)}</td> <td>₹${formatNumber(isupRev.samt || 0)}</td> <td>₹${formatNumber(isupRev.csamt || 0)}</td> Complete this code - Assistant
Certainly! Below is the completion and enhancement of the
generateReportfunction as well as other necessary parts to properly generate the remaining report sections (inter-state supplies,ITC details, andtax payment), and finalize rendering the summary cards.function generateReport(reports) { // Clear previous data outwardSuppliesBody.innerHTML = ''; interStateSuppliesBody.innerHTML = ''; itcDetailsBody.innerHTML = ''; taxPaymentBody.innerHTML = ''; summaryCards.innerHTML = ''; // Aggregate data for summary let totalTaxableValue = 0; let totalIGST = 0; let totalCGST = 0; let totalSGST = 0; let totalCess = 0; let totalITC_IGST = 0; let totalITC_CGST = 0; let totalITC_SGST = 0; let totalITC_Cess = 0; let totalTaxPaid = 0; // Process each report reports.forEach(report => { const gstin = report.gstin || 'N/A'; const period = report.ret_period || 'N/A'; // ----- Outward Supplies ----- // Taxable outward supplies (osup_det) if (report.sup_details && report.sup_details.osup_det) { const osup = report.sup_details.osup_det; totalTaxableValue += parseFloat(osup.txval || 0); totalIGST += parseFloat(osup.iamt || 0); totalCGST += parseFloat(osup.camt || 0); totalSGST += parseFloat(osup.samt || 0); totalCess += parseFloat(osup.csamt || 0); const row = document.createElement('tr'); row.innerHTML = ` <td>${gstin}</td> <td>${period}</td> <td>Taxable Outward Supplies</td> <td>₹${formatNumber(osup.txval || 0)}</td> <td>₹${formatNumber(osup.iamt || 0)}</td> <td>₹${formatNumber(osup.camt || 0)}</td> <td>₹${formatNumber(osup.samt || 0)}</td> <td>₹${formatNumber(osup.csamt || 0)}</td> `; outwardSuppliesBody.appendChild(row); } // Zero-rated supplies (osup_zero) if (report.sup_details && report.sup_details.osup_zero) { const osupZero = report.sup_details.osup_zero; const row = document.createElement('tr'); row.innerHTML = ` <td>${gstin}</td> <td>${period}</td> <td>Zero-rated Supplies</td> <td>₹${formatNumber(osupZero.txval || 0)}</td> <td>₹${formatNumber(osupZero.iamt || 0)}</td> <td>₹${formatNumber(osupZero.camt || 0)}</td> <td>₹${formatNumber(osupZero.samt || 0)}</td> <td>₹${formatNumber(osupZero.csamt || 0)}</td> `; outwardSuppliesBody.appendChild(row); } // Nil-rated, exempted supplies (osup_nil_exmp) if (report.sup_details && report.sup_details.osup_nil_exmp) { const osupNil = report.sup_details.osup_nil_exmp; const row = document.createElement('tr'); row.innerHTML = ` <td>${gstin}</td> <td>${period}</td> <td>Nil-rated, Exempted Supplies</td> <td>₹${formatNumber(osupNil.txval || 0)}</td> <td>₹${formatNumber(osupNil.iamt || 0)}</td> <td>₹${formatNumber(osupNil.camt || 0)}</td> <td>₹${formatNumber(osupNil.samt || 0)}</td> <td>₹${formatNumber(osupNil.csamt || 0)}</td> `; outwardSuppliesBody.appendChild(row); } // Reverse charge supplies (isup_rev) if (report.sup_details && report.sup_details.isup_rev) { const isupRev = report.sup_details.isup_rev; const row = document.createElement('tr'); row.innerHTML = ` <td>${gstin}</td> <td>${period}</td> <td>Reverse Charge Supplies</td> <td>₹${formatNumber(isupRev.txval || 0)}</td> <td>₹${formatNumber(isupRev.iamt || 0)}</td> <td>₹${formatNumber(isupRev.camt || 0)}</td> <td>₹${formatNumber(isupRev.samt || 0)}</td> <td>₹${formatNumber(isupRev.csamt || 0)}</td> `; outwardSuppliesBody.appendChild(row); } // ----- Inter-State Supplies ----- // Inter-state supplied data (isup_intr) if (report.sup_details && report.sup_details.isup_intr && Array.isArray(report.sup_details.isup_intr)) { report.sup_details.isup_intr.forEach(supply => { // Extract values or defaults const type = supply.ty || 'N/A'; const placeOfSupply = supply.pos || 'N/A'; const txval = parseFloat(supply.txval || 0); const amt = parseFloat(supply.iamt || 0) + parseFloat(supply.camt || 0) + parseFloat(supply.samt || 0); // Sum of IGST+CGST+SGST or use amt as given const row = document.createElement('tr'); row.innerHTML = ` <td>${gstin}</td> <td>${period}</td> <td>${type}</td> <td>${placeOfSupply}</td> <td>₹${formatNumber(txval)}</td> <td>₹${formatNumber(amt)}</td> `; interStateSuppliesBody.appendChild(row); }); } // ----- ITC Details ----- // ITC details (itc_det) - assuming array if (report.itc_details && Array.isArray(report.itc_details)) { report.itc_details.forEach(itc => { const itcType = itc.itc_typ || 'N/A'; const igst = parseFloat(itc.iamt || 0); const cgst = parseFloat(itc.camt || 0); const sgst = parseFloat(itc.samt || 0); const cess = parseFloat(itc.csamt || 0); totalITC_IGST += igst; totalITC_CGST += cgst; totalITC_SGST += sgst; totalITC_Cess += cess; const row = document.createElement('tr'); row.innerHTML = ` <td>${gstin}</td> <td>${period}</td> <td>${itcType}</td> <td>₹${formatNumber(igst)}</td> <td>₹${formatNumber(cgst)}</td> <td>₹${formatNumber(sgst)}</td> <td>₹${formatNumber(cess)}</td> `; itcDetailsBody.appendChild(row); }); } else if (report.itc_summary) { // fallback for single itc summary object const itc = report.itc_summary; const itcType = 'ITC Details'; const igst = parseFloat(itc.iamt || 0); const cgst = parseFloat(itc.camt || 0); const sgst = parseFloat(itc.samt || 0); const cess = parseFloat(itc.csamt || 0); totalITC_IGST += igst; totalITC_CGST += cgst; totalITC_SGST += sgst; totalITC_Cess += cess; const row = document.createElement('tr'); row.innerHTML = ` <td>${gstin}</td> <td>${period}</td> <td>${itcType}</td> <td>₹${formatNumber(igst)}</td> <td>₹${formatNumber(cgst)}</td> <td>₹${formatNumber(sgst)}</td> <td>₹${formatNumber(cess)}</td> `; itcDetailsBody.appendChild(row); } // ----- Tax Payment Details ----- // Tax payment (tax_det) or similar if (report.tax_details && Array.isArray(report.tax_details)) { report.tax_details.forEach(payment => { const taxType = payment.txn || 'N/A'; const modeOfPayment = payment.mop || 'N/A'; const amount = parseFloat(payment.amt || 0); const date = payment.dt || 'N/A'; totalTaxPaid += amount; const row = document.createElement('tr'); row.innerHTML = ` <td>${gstin}</td> <td>${period}</td> <td>${taxType}</td> <td>${modeOfPayment}</td> <td>₹${formatNumber(amount)}</td> <td>${date}</td> `; taxPaymentBody.appendChild(row); }); } else if (report.tax_payment_summary) { // fallback single payment summary const payment = report.tax_payment_summary; const taxType = payment.txn || 'N/A'; const modeOfPayment = payment.mop || 'N/A'; const amount = parseFloat(payment.amt || 0); const date = payment.dt || 'N/A'; totalTaxPaid += amount; const row = document.createElement('tr'); row.innerHTML = ` <td>${gstin}</td> <td>${period}</td> <td>${taxType}</td> <td>${modeOfPayment}</td> <td>₹${formatNumber(amount)}</td> <td>${date}</td> `; taxPaymentBody.appendChild(row); } }); // Add summary cards (adjust titles and amounts as needed) const summaries = [ { title: 'Total Taxable Value', value: `₹${formatNumber(totalTaxableValue)}` }, { title: 'Total IGST', value: `₹${formatNumber(totalIGST)}` }, { title: 'Total CGST', value: `₹${formatNumber(totalCGST)}` }, { title: 'Total SGST', value: `₹${formatNumber(totalSGST)}` }, { title: 'Total Cess', value: `₹${formatNumber(totalCess)}` }, { title: 'Total ITC IGST', value: `₹${formatNumber(totalITC_IGST)}` }, { title: 'Total ITC CGST', value: `₹${formatNumber(totalITC_CGST)}` }, { title: 'Total ITC SGST', value: `₹${formatNumber(totalITC_SGST)}` }, { title: 'Total ITC Cess', value: `₹${formatNumber(totalITC_Cess)}` }, { title: 'Total Tax Paid', value: `₹${formatNumber(totalTaxPaid)}` }, ]; summaries.forEach(s => { const card = document.createElement('div'); card.className = 'summary-card'; card.innerHTML = ` <div class="summary-title">${s.title}</div> <div class="summary-value">${s.value}</div> `; summaryCards.appendChild(card); }); } // Utility function for formatting numbers with thousand separators and two decimals function formatNumber(num) { return Number(num).toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }); }
Explanation
- Outward Supplies: Added rows for
osup_det,osup_zero,osup_nil_exmp, andisup_revfromsup_details. - Inter-State Supplies (
isup_intr): Assumed it's an array, iterated and created rows showing the type, place of supply, taxable value, and amount (summed IGST+CGST+SGST). - ITC Details: If an array
itc_detailsexists, iterated and added rows showing ITC type and amounts for IGST, CGST, SGST, and Cess. Added fallback for possible singularitc_summaryobject. - Tax Payment: Used
tax_detailsarray or fallbacktax_payment_summaryto populate the tax payment table. - Summary Cards: Created cards to display sums of taxable value, taxes, ITC, and tax payments.
formatNumberutility formats numbers suitably in Indian format with 2 decimals.
Additional Notes
- Adjust the field names inside the JSON (
sup_details,itc_details,tax_details, etc.) based on actual data structure. - If the JSON has a different nested structure, update the code accordingly.
- Consider adding error checking and fallback defaults.
- The rest of your code for processing uploads, UI interactions, and notifications looks complete and well-structured.
Let me know if you want me to help implement the
downloadReportfunction or any other features! - Outward Supplies: Added rows for
- User
Continue page till end
- Assistant
Certainly! Below is the continuation of your existing
<script>code, completing thedownloadReportfunction, thegoBackToUploadfunction,showResultsSection,showNotification,hideNotification, and any other utility code to make the page fully functional till the end.// Show the results section and hide upload area function showResultsSection() { document.querySelector('.card').style.display = 'none'; // Hide upload card resultsSection.style.display = 'block'; // Show results section progressContainer.style.display = 'none'; progressBar.style.width = '0%'; } // Handle Back to Upload button click function goBackToUpload() { resultsSection.style.display = 'none'; document.querySelector('.card').style.display = 'block'; clearFiles(); // Clear all files and reset UI } // Show notification with message and type ('success' or 'error') function showNotification(message, type = 'success') { if (!notification) return; notification.className = 'notification show'; const iconSpan = notification.querySelector('.notification-icon'); const messageDiv = notification.querySelector('.notification-message'); messageDiv.textContent = message; if (type === 'success') { notification.classList.add('notification-success'); notification.classList.remove('notification-error'); iconSpan.textContent = '✓'; iconSpan.style.color = getComputedStyle(document.documentElement).getPropertyValue('--success-color'); } else if (type === 'error') { notification.classList.add('notification-error'); notification.classList.remove('notification-success'); iconSpan.textContent = '⚠'; iconSpan.style.color = getComputedStyle(document.documentElement).getPropertyValue('--danger-color'); } else { // Reset styling if other types given notification.classList.remove('notification-success', 'notification-error'); iconSpan.textContent = ''; } // Auto-hide after 4 seconds clearTimeout(notification._timeout); notification._timeout = setTimeout(() => { hideNotification(); }, 4000); } // Hide notification popup function hideNotification() { if (!notification) return; notification.classList.remove('show'); } // Download the current report data as a JSON file function downloadReport() { try { // Gather all displayed data into a single JSON object for export const reportData = { outwardSupplies: [], interStateSupplies: [], itcDetails: [], taxPayment: [], summary: [] }; // Helper to parse row data cells stripping ₹ and commas and convert to number function parseCurrency(str) { return parseFloat(str.replace(/₹|,/g, '').trim()) || 0; } // Extract Outward Supplies data outwardSuppliesBody.querySelectorAll('tr').forEach(tr => { const cells = tr.children; reportData.outwardSupplies.push({ gstin: cells[0].textContent, period: cells[1].textContent, natureOfSupplies: cells[2].textContent, taxableValue: parseCurrency(cells[3].textContent), IGST: parseCurrency(cells[4].textContent), CGST: parseCurrency(cells[5].textContent), SGST: parseCurrency(cells[6].textContent), Cess: parseCurrency(cells[7].textContent) }); }); // Extract Inter-State Supplies data interStateSuppliesBody.querySelectorAll('tr').forEach(tr => { const cells = tr.children; reportData.interStateSupplies.push({ gstin: cells[0].textContent, period: cells[1].textContent, type: cells[2].textContent, placeOfSupply: cells[3].textContent, taxableValue: parseCurrency(cells[4].textContent), amount: parseCurrency(cells[5].textContent) }); }); // Extract ITC Details data itcDetailsBody.querySelectorAll('tr').forEach(tr => { const cells = tr.children; reportData.itcDetails.push({ gstin: cells[0].textContent, period: cells[1].textContent, itcType: cells[2].textContent, IGST: parseCurrency(cells[3].textContent), CGST: parseCurrency(cells[4].textContent), SGST: parseCurrency(cells[5].textContent), Cess: parseCurrency(cells[6].textContent) }); }); // Extract Tax Payment data taxPaymentBody.querySelectorAll('tr').forEach(tr => { const cells = tr.children; reportData.taxPayment.push({ gstin: cells[0].textContent, period: cells[1].textContent, taxType: cells[2].textContent, modeOfPayment: cells[3].textContent, amount: parseCurrency(cells[4].textContent), date: cells[5].textContent }); }); // Extract Summary cards data summaryCards.querySelectorAll('.summary-card').forEach(card => { const title = card.querySelector('.summary-title').textContent; const value = card.querySelector('.summary-value').textContent; reportData.summary.push({ title, value }); }); // Prepare data as JSON blob const dataStr = JSON.stringify(reportData, null, 2); const blob = new Blob([dataStr], { type: 'application/json' }); const url = URL.createObjectURL(blob); // Create a temporary anchor to trigger download const a = document.createElement('a'); a.href = url; a.download = `GSTR-3B_Report_${new Date().toISOString().slice(0,10)}.json`; document.body.appendChild(a); a.click(); setTimeout(() => { document.body.removeChild(a); URL.revokeObjectURL(url); }, 0); showNotification('Report downloaded successfully!', 'success'); } catch (error) { console.error('Error downloading report:', error); showNotification('Failed to download report. Check console for details.', 'error'); } }
Explanation of Added Code:
- showResultsSection: Hides the upload card and displays the report results section, resetting the progress UI.
- goBackToUpload: Switches back to file upload UI, clears any uploaded files and resets the interface.
- showNotification & hideNotification: Show/hide notification popup with appropriate icon, message, and styling for success/error.
- downloadReport: Collects data from all tables and summary cards, formats them into a JSON object, and triggers a JSON file download.
This completes your JavaScript functionality for:
- Uploading, processing, displaying, and interacting with the GSTR-3B JSON reports
- Switching views between upload and results
- Notifications for success and error messages
- Downloading the generated report for further use or backup
If you want me to provide the full final code or additional details (for example, how to improve UX or add validation), just let me know!
- User
continue
- Assistant
The previous completion covered the full logic inside your existing script, including the core UI flow, processing, tab switching, file handling, report generation, notifications, and report download.
Here’s a complete wrap-up of any potentially missing elements needed to fully complete your page’s functionality, presented as continuations or additions to your existing script:
1. Ensure
progressContaineris hidden initiallyAdd at the start of your script or inside
DOMContentLoadedto avoid showing the progress bar before processing:progressContainer.style.display = 'none';
2. Optional: Prevent default browser behavior on drag events on the entire window
So files don’t open in browser on accidental drops outside upload area:
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => { window.addEventListener(eventName, e => e.preventDefault()); });
3. Accessibility improvements: keyboard support for upload area click
(Optional)
uploadArea.setAttribute('tabindex', '0'); uploadArea.addEventListener('keydown', e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); fileInput.click(); } });
4. Reset file input value on clearing files to allow re-upload of same files
Inside
clearFiles()add:fileInput.value = '';
5. Debounce notifications to prevent stacking multiple toasts rapidly (Already handled with timeout)
6. Robustness notes:
- Your
generateReportassumes certain JSON property names (sup_details,itc_details, ...), so validate JSON structure before processing or add error fallback as needed. - You could optionally improve user feedback by disabling the upload button while processing.
7. Optional: Scroll tabs to top of results content when switching tabs
You can add inside your tab click handler:
tab.addEventListener('click', () => { tabs.forEach(t => t.classList.remove('active')); tab.classList.add('active'); tabContents.forEach(content => content.classList.remove('active')); const activeTab = document.getElementById(tab.dataset.tab); activeTab.classList.add('active'); // Scroll table container to top activeTab.scrollTop = 0; });
8. Final snippet putting it all together inside your DOMContentLoaded listener:
document.addEventListener('DOMContentLoaded', function() { // ... your existing code ... // Hide progress bar initially progressContainer.style.display = 'none'; // Prevent default drag/drop on window to avoid undesired behavior ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => { window.addEventListener(eventName, e => e.preventDefault()); }); // Accessibility keyboard support for upload area uploadArea.setAttribute('tabindex', '0'); uploadArea.addEventListener('keydown', e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); fileInput.click(); } }); // (Other event listeners and your functions already defined) // Wrap up with existing logic... });
Summary
At this stage, your page is fully functional for:
- Drag & drop/multi-select upload limited to 20 JSON files
- Processing JSON files with progress bar and per-file status
- Comprehensive display of GSTR-3B data in multiple tabs & summary cards
- Downloading the compiled report as JSON
- Notifications for all success or error states
- Clear all & navigation between upload and results views
- Basic accessibility enhancements and UX refinements
If you want, I can help generate the full final combined script or help with any other feature, optimization, or export format (like CSV or Excel) — just ask!
- Your