diff --git a/partials/frequent-questions.html b/partials/frequent-questions.html index 4d1019b..26e3518 100644 --- a/partials/frequent-questions.html +++ b/partials/frequent-questions.html @@ -99,17 +99,43 @@

Additional Questions

+

+ There are also some smaller factors which this calculator does not + currently take into account fully, but may be added in the future. These + include: +

+
diff --git a/src/ssa-parse.mjs b/src/ssa-parse.mjs index 5387aed..fcf3464 100644 --- a/src/ssa-parse.mjs +++ b/src/ssa-parse.mjs @@ -13,6 +13,10 @@ var dollarStringToNumber = function(dollar_string) { // yet been filed. Record this as a -1 sentinel for now. if (dollar_string === 'NotYetRecorded') return -1; + if (dollar_string === 'MedicareBeganIn1966') + return 0; + if (dollar_string === '') + return 0; var number_string = dollar_string.replace(/[$,]/g, ''); return Number(number_string); } @@ -26,7 +30,11 @@ var parseSsaGovTable = function(lines) { var record = new EarningRecord(); record.year = Number.parseInt(columns[0]); record.taxedEarnings = dollarStringToNumber(columns[1]); - record.taxedMedicareEarnings = dollarStringToNumber(columns[2]); + if (columns.length > 2) { + record.taxedMedicareEarnings = dollarStringToNumber(columns[2]); + } else { + record.taxedMedicareEarnings = 0; + } earningsRecords.push(record); } return earningsRecords; @@ -96,6 +104,10 @@ var parsePaste = function(paste) { // Some columns will include the string "Not yet recorded" which breaks // columns on spaces in the string. We replace these with "NotYetRecorded". replacedStr = replacedStr.replace(/not yet recorded+/gi, "NotYetRecorded"); + // Similarly, for records in 1965, the Medicare column will include the + // string "Medicare Began in 1966". We replace this with: + // "MedicareBeganIn1966". + replacedStr = replacedStr.replace(/medicare began in 1966+/gi, "MedicareBeganIn1966"); // Split based on newlines. let lines = replacedStr.split("\n"); diff --git a/tests/specs/ssa-parse_test.mjs b/tests/specs/ssa-parse_test.mjs index 474966f..709bb45 100644 --- a/tests/specs/ssa-parse_test.mjs +++ b/tests/specs/ssa-parse_test.mjs @@ -32,228 +32,245 @@ describe("parsePaste", function() { }); it("Parses ssa.tools own formatted table", function() { let pasteData = ( - 'Year\tAge\tTaxed Earnings\t\tMultiplier\tIndexed Earnings\t\t\n' + - '2016\t21\t$80,000\tx\t1.01\t=\t$80,900\tTop 35 Value\n' + - '2017\t22\t$90,000\tx\t1.00\t=\t$90,000\t\n' + - '2018\t23\t$100,000\tx\t1.00\t=\t$100,000\t\n'); + 'Year\tAge\tTaxed Earnings\t\tMultiplier\tIndexed Earnings\t\t\n' + + '2016\t21\t$80,000\tx\t1.01\t=\t$80,900\tTop 35 Value\n' + + '2017\t22\t$90,000\tx\t1.00\t=\t$90,000\t\n' + + '2018\t23\t$100,000\tx\t1.00\t=\t$100,000\t\n'); parsePasteExpect(parsePaste(pasteData)); }); it("Parses ssa.gov format (Chrome, Linux, Full Page)", function() { let pasteData = ( - 'KSkip to Content\n' + - 'my Social Security\n' + - 'Uncle Sam Sign Out\n' + - 'My Home Message Center Security Settings\n' + - 'Earnings Record\n' + - 'Overview\n' + - 'Estimated Benefits\n' + - 'Earnings Record\n' + - 'Replacement Documents\n' + - 'Social Security Statement\n' + - 'Your benefits are based on your earnings. If our records are wrong' + - 'you may not receive all the benefits to which you\'re entitled.\n' + - '\n' + - 'Review your earnings record carefully...\n' + - 'Limits on taxable earnings for Social Security...\n' + - 'Contact us about errors...\n' + - 'Work Year\n' + - 'Taxed Social Security Earnings\n' + - 'Taxed Medicare Earnings\n' + - '2018\t$100,000\t$100,000\n' + - '2017\t$90,000\t$90,000\n' + - '2016\t$80,000\t$80,000\n' + - 'Estimated Total Taxes Paid\n' + - 'For Social Security\n' + - 'Paid by you:\n' + - '$10,000\n' + - 'Paid by your employers:\n' + - '$10,000\n' + - 'For Medicare\n' + - 'Paid by you:\n' + - '$10,000\n' + - 'Paid by your employers:\n' + - '$10,000\n' + - 'Print / Save Your Full Statement\n' + - 'Get a copy of your Statement information in a convenient, '+ - 'print-friendly format.\n\n' + - 'Disclaimer\n' + - 'Download Your Statement Data\n' + - 'Save your Statement information as an XML file.\n\n' + - 'How to use this file.\n' + - 'Privacy PolicyAccessibility Help\n\n'); + 'KSkip to Content\n' + + 'my Social Security\n' + + 'Uncle Sam Sign Out\n' + + 'My Home Message Center Security Settings\n' + + 'Earnings Record\n' + + 'Overview\n' + + 'Estimated Benefits\n' + + 'Earnings Record\n' + + 'Replacement Documents\n' + + 'Social Security Statement\n' + + 'Your benefits are based on your earnings. If our records are wrong' + + 'you may not receive all the benefits to which you\'re entitled.\n' + + '\n' + + 'Review your earnings record carefully...\n' + + 'Limits on taxable earnings for Social Security...\n' + + 'Contact us about errors...\n' + + 'Work Year\n' + + 'Taxed Social Security Earnings\n' + + 'Taxed Medicare Earnings\n' + + '2018\t$100,000\t$100,000\n' + + '2017\t$90,000\t$90,000\n' + + '2016\t$80,000\t$80,000\n' + + 'Estimated Total Taxes Paid\n' + + 'For Social Security\n' + + 'Paid by you:\n' + + '$10,000\n' + + 'Paid by your employers:\n' + + '$10,000\n' + + 'For Medicare\n' + + 'Paid by you:\n' + + '$10,000\n' + + 'Paid by your employers:\n' + + '$10,000\n' + + 'Print / Save Your Full Statement\n' + + 'Get a copy of your Statement information in a convenient, ' + + 'print-friendly format.\n\n' + + 'Disclaimer\n' + + 'Download Your Statement Data\n' + + 'Save your Statement information as an XML file.\n\n' + + 'How to use this file.\n' + + 'Privacy PolicyAccessibility Help\n\n'); parsePasteExpect(parsePaste(pasteData)); }); it("Parses ssa.gov format (Chrome, Linux, Full Table)", function() { let pasteData = ( - 'Work Year\n' + - 'Taxed Social Security Earnings\n' + - 'Taxed Medicare Earnings\n' + - '2018\t$100,000\t$100,000\n' + - '2017\t$90,000\t$90,000\n' + - '2016\t$80,000\t$80,000\n') + 'Work Year\n' + + 'Taxed Social Security Earnings\n' + + 'Taxed Medicare Earnings\n' + + '2018\t$100,000\t$100,000\n' + + '2017\t$90,000\t$90,000\n' + + '2016\t$80,000\t$80,000\n'); parsePasteExpect(parsePaste(pasteData)); }); it("Parses ssa.gov format (Chrome, Linux, Table Rows)", function() { let pasteData = ( - '2018\t$100,000\t$100,000\n' + - '2017\t$90,000\t$90,000\n' + - '2016\t$80,000\t$80,000\n') + '2018\t$100,000\t$100,000\n' + + '2017\t$90,000\t$90,000\n' + + '2016\t$80,000\t$80,000\n'); parsePasteExpect(parsePaste(pasteData)); }); it("Parses ssa.gov format (Firefox, Linux, Full Page)", function() { let pasteData = ( - '\n' + - 'K\n' + - 'Skip to Content\n' + - 'my Social Security\n\n' + - ' Gregory A. Grothaus Sign Out \n\n' + - ' My Home Message Center Security Settings \n\n' + - 'Earnings Record\n' + - 'Overview\n' + - 'Estimated Benefits\n' + - 'Earnings Record\n' + - 'Replacement Documents\n' + - 'Social Security Statement\n\n' + - 'Your benefits are based on your earnings. If our records are wrong ' + - 'you may not receive all the benefits to which you\'re entitled.\n' + - 'Review your earnings record carefully...\n' + - 'Limits on taxable earnings for Social Security...\n' + - 'Contact us about errors...\n' + - 'Work Year\n\t\n' + - 'Taxed Social Security Earnings\n\t\n' + - 'Taxed Medicare Earnings\n' + - '2018 \t$100,000 \t$100,000\n' + - '2017 \t$90,000 \t$90,000\n' + - '2016 \t$80,000 \t$80,000\n' + - 'Estimated Total Taxes Paid\n' + - 'For Social Security\n' + - 'Paid by you:\n' + - '$100,082\n' + - 'Paid by your employers:\n' + - '$104,593\n' + - 'For Medicare\n' + - 'Paid by you:\n' + - '$104,437\n' + - 'Paid by your employers:\n' + - '$104,437\n' + - 'Print / Save Your Full Statement\n\n' + - 'Get a copy of your Statement information in a convenient, ' + - 'print-friendly format.\n' + - 'Disclaimer\n' + - 'Download Your Statement Data\n\n' + - 'Save your Statement information as an XML file.\n' + - 'How to use this file.\n\n' + - ' Privacy PolicyAccessibility Help\n\n\n') + '\n' + + 'K\n' + + 'Skip to Content\n' + + 'my Social Security\n\n' + + ' Gregory A. Grothaus Sign Out \n\n' + + ' My Home Message Center Security Settings \n\n' + + 'Earnings Record\n' + + 'Overview\n' + + 'Estimated Benefits\n' + + 'Earnings Record\n' + + 'Replacement Documents\n' + + 'Social Security Statement\n\n' + + 'Your benefits are based on your earnings. If our records are wrong ' + + 'you may not receive all the benefits to which you\'re entitled.\n' + + 'Review your earnings record carefully...\n' + + 'Limits on taxable earnings for Social Security...\n' + + 'Contact us about errors...\n' + + 'Work Year\n\t\n' + + 'Taxed Social Security Earnings\n\t\n' + + 'Taxed Medicare Earnings\n' + + '2018 \t$100,000 \t$100,000\n' + + '2017 \t$90,000 \t$90,000\n' + + '2016 \t$80,000 \t$80,000\n' + + 'Estimated Total Taxes Paid\n' + + 'For Social Security\n' + + 'Paid by you:\n' + + '$100,082\n' + + 'Paid by your employers:\n' + + '$104,593\n' + + 'For Medicare\n' + + 'Paid by you:\n' + + '$104,437\n' + + 'Paid by your employers:\n' + + '$104,437\n' + + 'Print / Save Your Full Statement\n\n' + + 'Get a copy of your Statement information in a convenient, ' + + 'print-friendly format.\n' + + 'Disclaimer\n' + + 'Download Your Statement Data\n\n' + + 'Save your Statement information as an XML file.\n' + + 'How to use this file.\n\n' + + ' Privacy PolicyAccessibility Help\n\n\n'); parsePasteExpect(parsePaste(pasteData)); }); it("Parses ssa.gov format (Firefox, Linux, Full Table)", function() { let pasteData = ( - 'Work Year\n\t\n' + - 'Taxed Social Security Earnings\n\t\n' + - 'Taxed Medicare Earnings\n' + - '2018 \t$100,000 \t$100,000\n' + - '2017 \t$90,000 \t$90,000\n' + - '2016 \t$80,000 \t$80,000\n') + 'Work Year\n\t\n' + + 'Taxed Social Security Earnings\n\t\n' + + 'Taxed Medicare Earnings\n' + + '2018 \t$100,000 \t$100,000\n' + + '2017 \t$90,000 \t$90,000\n' + + '2016 \t$80,000 \t$80,000\n'); parsePasteExpect(parsePaste(pasteData)); }); it("Parses ssa.gov format (Firefox, Linux, Table Rows)", function() { let pasteData = ( - '2018 \t$100,000 \t$100,000\n' + - '2017 \t$90,000 \t$90,000\n' + - '2016 \t$80,000 \t$80,000\n') + '2018 \t$100,000 \t$100,000\n' + + '2017 \t$90,000 \t$90,000\n' + + '2016 \t$80,000 \t$80,000\n'); parsePasteExpect(parsePaste(pasteData)); }); it("Parses ssa.gov format with trailing whitespace", function() { // User report here indicates that trailing whitespace breaks parsing: // http://www.early-retirement.org/forums/f28/fire-effect-on-ss-benefits-96343-3.html#post2196019 let pasteData = ( - 'Work Year \n' + - 'Taxed Social Security Earnings \n' + - 'Taxed Medicare Earnings \n' + - '2018\t$100,000\t$100,000 \n' + - '2017\t$90,000\t$90,000 \n' + - '2016\t$80,000\t$80,000 \n') + 'Work Year \n' + + 'Taxed Social Security Earnings \n' + + 'Taxed Medicare Earnings \n' + + '2018\t$100,000\t$100,000 \n' + + '2017\t$90,000\t$90,000 \n' + + '2016\t$80,000\t$80,000 \n'); parsePasteExpect(parsePaste(pasteData)); }); it("Parses ssa.gov format (Edge, Windows, Full Page)", function() { let pasteData = ( - 'K\n' + - 'Skip to Content\n' + - 'my Social Security\n' + - 'Uncle Sam Sign Out \n' + - 'My Home Message Center Security Settings \n' + - 'Earnings Record\n' + - 'Overview\n' + - 'Estimated Benefits\n' + - 'Earnings Record\n' + - 'Replacement Documents\n' + - '\n' + - 'Social Security Statement\n' + - 'Your benefits are based on your earnings. If our records are wrong ' + - 'you may not receive all the benefits to which you\'re entitled. \n' + - 'Review your earnings record carefully... \n' + - 'Limits on taxable earnings for Social Security... \n' + - 'Contact us about errors... \n' + - 'Work Year \n' + - 'Taxed Social Security Earnings \n' + - 'Taxed Medicare Earnings \n' + - '2018 \n' + - '$100,000 \n' + - '$100,000 \n' + - '2017 \n' + - '$90,000 \n' + - '$90,000 \n' + - '2016 \n' + - '$80,000 \n' + - '$80,000 \n' + - 'Estimated Total Taxes Paid\n' + - 'For Social Security \n' + - 'Paid by you: \n' + - '$000,000 \n' + - 'Paid by your employers: \n' + - '$000,000 \n' + - 'For Medicare \n' + - 'Paid by you: \n' + - '$000,000 \n' + - 'Paid by your employers: \n' + - '$000,000 \n' + - 'Print / Save Your Full Statement \n' + - 'Get a copy of your Statement information in a convenient, ' + - 'print-friendly format. \n' + - 'Disclaimer \n' + - 'Download Your Statement Data \n' + - 'Save your Statement information as an XML file. \n' + - 'How to use this file. \n' + - 'Privacy PolicyAccessibility Help'); + 'K\n' + + 'Skip to Content\n' + + 'my Social Security\n' + + 'Uncle Sam Sign Out \n' + + 'My Home Message Center Security Settings \n' + + 'Earnings Record\n' + + 'Overview\n' + + 'Estimated Benefits\n' + + 'Earnings Record\n' + + 'Replacement Documents\n' + + '\n' + + 'Social Security Statement\n' + + 'Your benefits are based on your earnings. If our records are wrong ' + + 'you may not receive all the benefits to which you\'re entitled. \n' + + 'Review your earnings record carefully... \n' + + 'Limits on taxable earnings for Social Security... \n' + + 'Contact us about errors... \n' + + 'Work Year \n' + + 'Taxed Social Security Earnings \n' + + 'Taxed Medicare Earnings \n' + + '2018 \n' + + '$100,000 \n' + + '$100,000 \n' + + '2017 \n' + + '$90,000 \n' + + '$90,000 \n' + + '2016 \n' + + '$80,000 \n' + + '$80,000 \n' + + 'Estimated Total Taxes Paid\n' + + 'For Social Security \n' + + 'Paid by you: \n' + + '$000,000 \n' + + 'Paid by your employers: \n' + + '$000,000 \n' + + 'For Medicare \n' + + 'Paid by you: \n' + + '$000,000 \n' + + 'Paid by your employers: \n' + + '$000,000 \n' + + 'Print / Save Your Full Statement \n' + + 'Get a copy of your Statement information in a convenient, ' + + 'print-friendly format. \n' + + 'Disclaimer \n' + + 'Download Your Statement Data \n' + + 'Save your Statement information as an XML file. \n' + + 'How to use this file. \n' + + 'Privacy PolicyAccessibility Help'); parsePasteExpect(parsePaste(pasteData)); }); it("Parses ssa.gov format (Edge, Windows, Full Table)", function() { let pasteData = ( - 'Work Year \n' + - 'Taxed Social Security Earnings \n' + - 'Taxed Medicare Earnings \n' + - '2018 \n' + - '$100,000 \n' + - '$100,000 \n' + - '2017 \n' + - '$90,000 \n' + - '$90,000 \n' + - '2016 \n' + - '$80,000 \n' + - '$80,000') + 'Work Year \n' + + 'Taxed Social Security Earnings \n' + + 'Taxed Medicare Earnings \n' + + '2018 \n' + + '$100,000 \n' + + '$100,000 \n' + + '2017 \n' + + '$90,000 \n' + + '$90,000 \n' + + '2016 \n' + + '$80,000 \n' + + '$80,000'); parsePasteExpect(parsePaste(pasteData)); }); it("Parses ssa.gov format (Edge, Windows, Table Rows)", function() { let pasteData = ( - '2018 \n' + - '$100,000 \n' + - '$100,000 \n' + - '2017 \n' + - '$90,000 \n' + - '$90,000 \n' + - '2016 \n' + - '$80,000 \n' + - '$80,000') + '2018 \n' + + '$100,000 \n' + + '$100,000 \n' + + '2017 \n' + + '$90,000 \n' + + '$90,000 \n' + + '2016 \n' + + '$80,000 \n' + + '$80,000'); parsePasteExpect(parsePaste(pasteData)); }); + it("Parses ssa.gov format before medicare", function() { + let pasteData = ( + '1966\t$2,966\t$2,966\n' + + '1965\t$2,965\tMedicare Began in 1966\n' + + '1964\t$2,964\n' + + '1963\t$2,963'); + const parsed = parsePaste(pasteData); + expect(parsed.length).toBe(4); + expect(parsed[0].year).toBe(1963); + expect(parsed[0].taxedEarnings).toBe(2963); + expect(parsed[1].year).toBe(1964); + expect(parsed[1].taxedEarnings).toBe(2964); + expect(parsed[2].year).toBe(1965); + expect(parsed[2].taxedEarnings).toBe(2965); + expect(parsed[3].year).toBe(1966); + expect(parsed[3].taxedEarnings).toBe(2966); + }); });