How to Use the Extension
Monitoring Sales
When you make a sale on any supported platform, the extension will automatically:
- Detect the order confirmation page
- Extract order value and details
- Calculate applicable GST (CGST, SGST, IGST)
- Store the transaction in local database
- Update your GST summary
Tracking Returns & RTO
When products are returned or marked RTO:
- The extension monitors returns pages
- Automatically adjusts GST liability
- Maintains accurate net taxable value
- Provides clear return statistics
Viewing GST Summary
Click the extension icon to view:
- Total sales value for the period
- Total GST collected
- Returns and adjustments
- Breakdown by GST type (CGST/SGST/IGST)
- Net taxable value
Exporting GSTR-1 Data
When ready to file GST returns:
- Click the "Export GSTR-1 Data" button
- Download a CSV file with all transaction details
- Use this file to easily fill your GSTR-1 form
- Data is formatted to match GST portal requirements
Extension Code Files
Below are all the code files needed for the extension. Create these files in your extension folder.
manifest.json
{
"manifest_version": 3,
"name": "GST Tax Tracker for E-Commerce",
"version": "1.0",
"description": "Automated GST tracking and reporting for e-commerce sellers",
"permissions": [
"storage",
"activeTab",
"scripting",
"notifications",
"webNavigation"
],
"host_permissions": [
"https://*.amazon.in/*",
"https://*.flipkart.com/*",
"https://*.myntra.com/*",
"https://*.meesho.com/*",
"https://gst.gov.in/*"
],
"background": {
"service_worker": "background.js"
},
"content_scripts": [
{
"matches": [
"https://*.amazon.in/*",
"https://*.flipkart.com/*",
"https://*.myntra.com/*",
"https://*.meesho.com/*"
],
"js": ["content.js"]
}
],
"action": {
"default_popup": "popup.html",
"default_title": "GST Tracker"
},
"options_page": "options.html"
}
background.js
class GSTTaxTracker {
constructor() {
this.salesData = [];
this.returnsData = [];
this.init();
}
init() {
this.loadData();
this.setupListeners();
}
setupListeners() {
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
switch (request.action) {
case 'newSale':
this.processSale(request.data);
break;
case 'newReturn':
this.processReturn(request.data);
break;
case 'getGSTSummary':
sendResponse(this.getGSTSummary());
break;
case 'exportGSTR1':
sendResponse({csvData: this.exportToCSV()});
break;
}
});
}
processSale(saleData) {
const gstData = this.calculateGST(saleData);
const completeSale = { ...saleData, ...gstData, timestamp: new Date() };
this.salesData.push(completeSale);
this.saveData();
this.showNotification(`New Sale: ₹${saleData.amount} - GST: ₹${gstData.totalGST}`);
}
processReturn(returnData) {
const adjustedGST = this.calculateGSTAdjustment(returnData);
this.returnsData.push({
...returnData,
timestamp: new Date(),
adjustedGST: adjustedGST
});
this.saveData();
this.showNotification(`Return Processed: ₹${returnData.amount}`);
}
calculateGST(saleData) {
const { amount, productCategory, state } = saleData;
// GST rates based on product category
const gstRates = {
'electronics': 0.18,
'clothing': 0.05,
'books': 0.00,
'furniture': 0.12,
'default': 0.18
};
const rate = gstRates[productCategory] || gstRates.default;
const taxableValue = amount / (1 + rate);
const cgst = taxableValue * (rate / 2);
const sgst = taxableValue * (rate / 2);
const igst = state === 'interstate' ? taxableValue * rate : 0;
return {
taxableValue: parseFloat(taxableValue.toFixed(2)),
cgst: parseFloat(cgst.toFixed(2)),
sgst: parseFloat(sgst.toFixed(2)),
igst: parseFloat(igst.toFixed(2)),
totalGST: parseFloat((cgst + sgst + igst).toFixed(2)),
gstRate: rate
};
}
calculateGSTAdjustment(returnData) {
// Calculate GST adjustment for returns
const originalSale = this.salesData.find(sale => sale.orderId === returnData.originalOrderId);
if (originalSale) {
return {
cgst: originalSale.cgst * (returnData.amount / originalSale.amount),
sgst: originalSale.sgst * (returnData.amount / originalSale.amount),
igst: originalSale.igst * (returnData.amount / originalSale.amount)
};
}
return { cgst: 0, sgst: 0, igst: 0 };
}
getGSTSummary() {
const totalSales = this.salesData.reduce((sum, sale) => sum + sale.taxableValue, 0);
const totalGST = this.salesData.reduce((sum, sale) => sum + sale.totalGST, 0);
const totalReturns = this.returnsData.reduce((sum, ret) => sum + ret.amount, 0);
const gstByType = {
CGST: this.salesData.reduce((sum, sale) => sum + sale.cgst, 0),
SGST: this.salesData.reduce((sum, sale) => sum + sale.sgst, 0),
IGST: this.salesData.reduce((sum, sale) => sum + sale.igst, 0)
};
// Adjust for returns
this.returnsData.forEach(ret => {
if (ret.adjustedGST) {
gstByType.CGST -= ret.adjustedGST.cgst;
gstByType.SGST -= ret.adjustedGST.sgst;
gstByType.IGST -= ret.adjustedGST.igst;
totalGST -= (ret.adjustedGST.cgst + ret.adjustedGST.sgst + ret.adjustedGST.igst);
}
});
return {
totalSales: parseFloat(totalSales.toFixed(2)),
totalGST: parseFloat(totalGST.toFixed(2)),
totalReturns: parseFloat(totalReturns.toFixed(2)),
gstByType,
totalTransactions: this.salesData.length,
totalReturnsCount: this.returnsData.length,
netTaxableValue: parseFloat((totalSales - totalReturns).toFixed(2))
};
}
exportToCSV() {
let csv = 'Order ID,Date,Platform,Amount,Taxable Value,CGST,SGST,IGST,Total GST,Product Category\\n';
this.salesData.forEach(sale => {
csv += `${sale.orderId},${sale.date},${sale.platform},${sale.amount},${sale.taxableValue},${sale.cgst},${sale.sgst},${sale.igst},${sale.totalGST},${sale.productCategory}\\n`;
});
return csv;
}
saveData() {
chrome.storage.local.set({
salesData: this.salesData,
returnsData: this.returnsData
});
}
async loadData() {
const data = await chrome.storage.local.get(['salesData', 'returnsData']);
this.salesData = data.salesData || [];
this.returnsData = data.returnsData || [];
}
showNotification(message) {
chrome.notifications.create({
type: 'basic',
iconUrl: 'icon48.png',
title: 'GST Tracker',
message: message
});
}
}
const tracker = new GSTTaxTracker();
popup.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body { width: 400px; padding: 15px; font-family: Arial, sans-serif; }
.summary-card { background: #f8f9fa; padding: 15px; margin: 10px 0; border-radius: 8px; }
.gst-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.gst-item { background: white; padding: 8px; border-radius: 4px; text-align: center; }
.positive { color: #28a745; }
.negative { color: #dc3545; }
button { width: 100%; padding: 10px; margin: 5px 0; background: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; }
button:hover { background: #0056b3; }
</style>
</head>
<body>
<h3>🛃 GST Tax Tracker</h3>
<div class="summary-card">
<h4>Current Period Summary</h4>
<div id="summary">
<div>Total Sales: <span id="totalSales" class="positive">₹0</span></div>
<div>Total GST: <span id="totalGST" class="positive">₹0</span></div>
<div>Returns: <span id="totalReturns" class="negative">₹0</span></div>
<div>Net Taxable: <span id="netTaxable">₹0</span></div>
</div>
</div>
<div class="gst-breakdown">
<div class="gst-item">CGST: <span id="cgstAmount">₹0</span></div>
<div class="gst-item">SGST: <span id="sgstAmount">₹0</span></div>
<div class="gst-item">IGST: <span id="igstAmount">₹0</span></div>
<div class="gst-item">Transactions: <span id="transactionCount">0</span></div>
</div>
<button id="exportBtn">Export GSTR-1 Data</button>
<button id="settingsBtn">Settings</button>
<button id="refreshBtn">Refresh Data</button>
<script src="popup.js"></script>
</body>
</html>
Note: The complete extension requires additional files (content.js, options.html, options.js, popup.js) which are included in the full package. Due to space constraints, we've shown the most critical files here.
Comments
Post a Comment