{"id":77,"date":"2022-11-19T13:03:39","date_gmt":"2022-11-19T13:03:39","guid":{"rendered":"https:\/\/savingscorner.in\/?page_id=77"},"modified":"2026-05-24T07:26:33","modified_gmt":"2026-05-24T07:26:33","slug":"calculator","status":"publish","type":"page","link":"https:\/\/savingscorner.in\/index.php\/calculator\/","title":{"rendered":"calculator"},"content":{"rendered":"\n<!DOCTYPE html>\n<html>\n<head>\n    <title>CAS Analyzer<\/title>\n\n    <script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/pdf.js\/2.16.105\/pdf.min.js\"><\/script>\n\n    <style>\n\n        body{\n            font-family: Arial;\n            padding:20px;\n            background:#f4f8fb;\n        }\n\n        h2{\n            color:#1565c0;\n        }\n\n        table{\n            width:100%;\n            border-collapse: collapse;\n            margin-top:20px;\n            background:white;\n        }\n\n        th,td{\n            border:1px solid #ddd;\n            padding:10px;\n            font-size:14px;\n        }\n\n        th{\n            background:#1565c0;\n            color:white;\n        }\n\n        .upload-box{\n            padding:20px;\n            background:white;\n            border-radius:10px;\n        }\n\n    <\/style>\n\n<\/head>\n\n<body>\n\n<h2>Mutual Fund CAS Analyzer<\/h2>\n\n<div class=\"upload-box\">\n\n<input type=\"file\" id=\"pdfFile\" accept=\".pdf\">\n\n<p id=\"status\"><\/p>\n\n<\/div>\n\n<table id=\"resultTable\">\n\n<thead>\n<tr>\n<th>Scheme<\/th>\n<th>Investment Value<\/th>\n<th>Current Value<\/th>\n<th>XIRR<\/th>\n<th>ARN<\/th>\n<\/tr>\n<\/thead>\n\n<tbody><\/tbody>\n\n<\/table>\n\n<script>\n\npdfjsLib.GlobalWorkerOptions.workerSrc =\n'https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/pdf.js\/2.16.105\/pdf.worker.min.js';\n\ndocument.getElementById('pdfFile').addEventListener('change', async function(event){\n\n    const file = event.target.files[0];\n\n    if(!file) return;\n\n    document.getElementById('status').innerHTML = \"Reading PDF...\";\n\n    const reader = new FileReader();\n\n    reader.onload = async function(){\n\n        const typedarray = new Uint8Array(this.result);\n\n        const pdf = await pdfjsLib.getDocument(typedarray).promise;\n\n        let fullText = \"\";\n\n        for(let pageNum=1; pageNum<=pdf.numPages; pageNum++){\n\n            const page = await pdf.getPage(pageNum);\n\n            const textContent = await page.getTextContent();\n\n            const textItems = textContent.items.map(item => item.str);\n\n            fullText += textItems.join(\" \") + \"\\n\";\n        }\n\n        analyzeCAS(fullText);\n\n    };\n\n    reader.readAsArrayBuffer(file);\n\n});\n\nfunction analyzeCAS(text){\n\n    console.log(text);\n\n    const tbody = document.querySelector(\"#resultTable tbody\");\n\n    tbody.innerHTML = \"\";\n\n    const schemeBlocks = text.split(\"Closing Unit Balance:\");\n\n    let totalSchemes = 0;\n\n    schemeBlocks.forEach(block => {\n\n        try{\n\n            let schemeMatch = block.match(\/([A-Za-z0-9&\\-\\s]+Fund[^\\(]*)\/);\n\n            let arnMatch = block.match(\/ARN-\\d+\/);\n\n            let investmentMatch = block.match(\/Total Cost Value:\\s*([\\d,]+\\.\\d+)\/);\n\n            let currentValueMatch = block.match(\/Market Value on .*?: INR\\s*([\\d,]+\\.\\d+)\/);\n\n            if(\n                schemeMatch &&\n                investmentMatch &&\n                currentValueMatch\n            ){\n\n                const scheme =\n                    schemeMatch[1].trim();\n\n                const investment =\n                    parseFloat(\n                        investmentMatch[1].replace(\/,\/g,'')\n                    );\n\n                const currentValue =\n                    parseFloat(\n                        currentValueMatch[1].replace(\/,\/g,'')\n                    );\n\n                const arn =\n                    arnMatch ? arnMatch[0] : \"-\";\n\n                const xirr =\n                    calculateXIRR(\n                        investment,\n                        currentValue\n                    );\n\n                const row = `\n                    <tr>\n                        <td>${scheme}<\/td>\n                        <td>\u20b9${investment.toLocaleString()}<\/td>\n                        <td>\u20b9${currentValue.toLocaleString()}<\/td>\n                        <td>${xirr}%<\/td>\n                        <td>${arn}<\/td>\n                    <\/tr>\n                `;\n\n                tbody.innerHTML += row;\n\n                totalSchemes++;\n\n            }\n\n        }catch(err){\n\n            console.log(err);\n\n        }\n\n    });\n\n    document.getElementById('status').innerHTML =\n        totalSchemes + \" schemes extracted successfully.\";\n\n}\n\nfunction calculateXIRR(investment,currentValue){\n\n    const years = 3;\n\n    if(investment <=0) return 0;\n\n    let result =\n        (Math.pow(currentValue\/investment,1\/years)-1)*100;\n\n    return result.toFixed(2);\n\n}\n\n<\/script>\n\n<\/body>\n<\/html>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CAS Analyzer Mutual Fund CAS Analyzer Scheme Investment Value Current Value XIRR ARN<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-77","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/savingscorner.in\/index.php\/wp-json\/wp\/v2\/pages\/77","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savingscorner.in\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/savingscorner.in\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/savingscorner.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savingscorner.in\/index.php\/wp-json\/wp\/v2\/comments?post=77"}],"version-history":[{"count":7,"href":"https:\/\/savingscorner.in\/index.php\/wp-json\/wp\/v2\/pages\/77\/revisions"}],"predecessor-version":[{"id":3164,"href":"https:\/\/savingscorner.in\/index.php\/wp-json\/wp\/v2\/pages\/77\/revisions\/3164"}],"wp:attachment":[{"href":"https:\/\/savingscorner.in\/index.php\/wp-json\/wp\/v2\/media?parent=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}