Composition Invoice (Without Watermark)
Composition Invoice (No Watermark)
| Description | HSN | Qty | Rate (₹) | Tax % | Amount (₹) | Action |
|---|
Invoice
Date:
Invoice No:
Place of Supply:
| Description | HSN | Qty | Rate (₹) | Tax % | Amount (₹) |
|---|
Thank you for your business.
');
printWindow.document.close();
setTimeout(()=> { printWindow.print(); printWindow.close(); wrapper.style.display='none'; }, 500);
}, 300);
});resetBtn.addEventListener('click', () => {
if(!confirm('Reset all fields and items?')) return;
sellerName.value=''; sellerAddress.value=''; sellerGstin.value='';
buyerName.value=''; buyerAddress.value=''; buyerGstin.value='';
placeOfSupply.value=''; logoPreview.src='';
itemsBody.innerHTML=''; addItemRow();
setDefaultInvoiceMeta();
recalcAll();
});/* ---------------------------
Logo preview handling
----------------------------*/
logoInput.addEventListener('change', (e) => {
const f = e.target.files[0];
if(!f) return;
const reader = new FileReader();
reader.onload = function(ev) {
logoPreview.src = ev.target.result;
};
reader.readAsDataURL(f);
});/* ---------------------------
Helpers: number to words (Indian)
Source: adapted for Indian numbering (crore, lakh)
----------------------------*/
function toIndianCurrencyWords(num) {
if (num === 0) return 'Zero Rupees';
const a = ['', 'One','Two','Three','Four','Five','Six','Seven','Eight','Nine','Ten','Eleven','Twelve','Thirteen','Fourteen','Fifteen','Sixteen','Seventeen','Eighteen','Nineteen'];
const b = ['', '', 'Twenty','Thirty','Forty','Fifty','Sixty','Seventy','Eighty','Ninety'];function twoDigit(n){
if (n < 20) return a[n];
const tens = Math.floor(n/10);
const rest = n % 10;
return b[tens] + (rest ? ' ' + a[rest] : '');
}function threeDigit(n){
const hundred = Math.floor(n/100);
const rest = n % 100;
return (hundred ? a[hundred] + ' Hundred ' : '') + (rest ? twoDigit(rest) : '');
}const numStr = Math.floor(num).toString();
let n = parseInt(numStr,10);const crore = Math.floor(n / 10000000); n = n % 10000000;
const lakh = Math.floor(n / 100000); n = n % 100000;
const thousand = Math.floor(n / 1000); n = n % 1000;
const hundredRest = n;let words = '';
if (crore) words += threeDigit(crore) + ' Crore ';
if (lakh) words += threeDigit(lakh) + ' Lakh ';
if (thousand) words += threeDigit(thousand) + ' Thousand ';
if (hundredRest) words += threeDigit(hundredRest);
words = (words + ' Rupees').replace(/\s+/g,' ').trim();
return words + ' Only';
}/* ---------------------------
Utility: start with one empty row & compute
----------------------------*/
addItemRow('Sample Item','9983',1,1000,1);
recalcAll();/* ---------------------------
Small security: escape inputs for preview
----------------------------*/
function sanitizeAllInputs() {
// Not strictly necessary because we escape when inserting into preview,
// but you can run additional sanitation here if saving to backend.
} /* ===============================
SELLER SAVE / LOAD / DELETE
================================*/function saveSeller() {
let list = JSON.parse(localStorage.getItem("sellerList") || "[]");let obj = {
name: seller_name.value,
address: seller_address.value,
gst: seller_gstin.value
};list.push(obj);
localStorage.setItem("sellerList", JSON.stringify(list));
loadSellerDropdown();
alert("Seller details saved!");
}function loadSeller() {
let list = JSON.parse(localStorage.getItem("sellerList") || "[]");
let index = seller_list.selectedIndex;if (index < 0) return;seller_name.value = list[index].name;
seller_address.value = list[index].address;
seller_gstin.value = list[index].gst;
}function deleteSeller() {
let list = JSON.parse(localStorage.getItem("sellerList") || "[]");
let index = seller_list.selectedIndex;if (index < 0) return alert("Select a seller to delete!");list.splice(index, 1);
localStorage.setItem("sellerList", JSON.stringify(list));
loadSellerDropdown();
alert("Seller deleted!");
}function loadSellerDropdown() {
let list = JSON.parse(localStorage.getItem("sellerList") || "[]");
seller_list.innerHTML = list.map(x => `
`).join("");
}/* ===============================
BUYER SAVE / LOAD / DELETE
================================*/function saveBuyer() {
let list = JSON.parse(localStorage.getItem("buyerList") || "[]");let obj = {
name: buyer_name.value,
address: buyer_address.value,
gst: buyer_gstin.value
};list.push(obj);
localStorage.setItem("buyerList", JSON.stringify(list));
loadBuyerDropdown();
alert("Buyer details saved!");
}function loadBuyer() {
let list = JSON.parse(localStorage.getItem("buyerList") || "[]");
let index = buyer_list.selectedIndex;if (index < 0) return;buyer_name.value = list[index].name;
buyer_address.value = list[index].address;
buyer_gstin.value = list[index].gst;
}function deleteBuyer() {
let list = JSON.parse(localStorage.getItem("buyerList") || "[]");
let index = buyer_list.selectedIndex;if (index < 0) return alert("Select a buyer to delete!");list.splice(index, 1);
localStorage.setItem("buyerList", JSON.stringify(list));
loadBuyerDropdown();
alert("Buyer deleted!");
}function loadBuyerDropdown() {
let list = JSON.parse(localStorage.getItem("buyerList") || "[]");
buyer_list.innerHTML = list.map(x => `
`).join("");
}/* Load dropdowns on page load */
loadSellerDropdown();
loadBuyerDropdown();/* End of script */