-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jamie Peabody
committed
May 3, 2021
1 parent
d5ca33b
commit 253f2ef
Showing
75 changed files
with
2,501 additions
and
4,459 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
node_modules/ | ||
.nyc_output/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,23 @@ | ||
# irs-form-filler | ||
Form fill USA IRS documents | ||
|
||
A tool for filling out IRS income tax forms. | ||
|
||
# Warning | ||
|
||
_You_ are responsible for filing your taxes correctly, not the maintainers of **irs-form-filler**. If you know what you are doing, then this tool can help you. This tool is only a form filler to the best of its ability for the specific tax year. Do not rely only on this tool. The maintainers are developers, not tax experts. | ||
|
||
Specifically, this tool was designed to file taxes for US citizens who reside abroad, file their taxes within their country of residence and need to submit their taxes to the IRS with (hopefully) $0.00 amount owed. Some companies charge substiantial amounts for filing, and this is a punative tax on US citizens living abroad. | ||
|
||
# Initialize a new tax year project | ||
|
||
```bash | ||
$ mkdir tax-2020 | ||
$ cd tax-2020 | ||
$ npx irs-form-filler init | ||
``` | ||
|
||
# Fill out all forms for the tax year | ||
|
||
```bash | ||
$ npx irs-form-filler fill config.yaml | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require('path'); | ||
const yargs = require('yargs'); | ||
const chalk = require('chalk'); | ||
const fill = require('../src'); | ||
const year = `${new Date().getUTCFullYear() - 1}`; | ||
|
||
const { argv } = require('yargs') | ||
.command( | ||
'* [--only form] [-o output] [-d key] <config>', | ||
'Fill PDF tax forms.', | ||
(yargs) => { | ||
yargs.positional('config', { | ||
describe: 'The YAML config file to use when filling forms.', | ||
type: 'string', | ||
required: true | ||
}).option( | ||
'only', { | ||
description: 'Only fill the specified tax document', | ||
} | ||
).option( | ||
'output', { | ||
alias: 'o', | ||
description: 'The output directory for the filled forms.', | ||
default: 'filled' | ||
} | ||
).option( | ||
'debug', { | ||
alias: 'd', | ||
description: 'Debug a key, e.g. "part.2.line1". Use with --inspect-brk.' | ||
} | ||
).alias( | ||
'v', 'version' | ||
).alias( | ||
'h', 'help' | ||
); | ||
} | ||
); | ||
|
||
let only; | ||
if (typeof argv.only === 'string') { | ||
only = [ argv.only ]; | ||
} else { | ||
only = argv.only; | ||
} | ||
|
||
fill({ | ||
config: argv.config, | ||
output: argv.output, | ||
debug: argv.debug, | ||
only | ||
}).catch((ex) => { | ||
console.error(chalk.red(ex.stack)); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,39 @@ | ||
#!/usr/bin/env node | ||
|
||
const os = require('os'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const https = require('https'); | ||
const chalk = require('chalk'); | ||
const log = require('debug')('irs-tax-filler'); | ||
const fill = require('../src'); | ||
|
||
const IRS_URL = 'https://www.irs.gov/pub/irs-pdf'; | ||
const year = `${new Date().getUTCFullYear() - 1}`; | ||
const taxFormsPath = path.join(process.cwd(), 'tax-forms', year); | ||
const files = [ | ||
{ name: 'f1040.pdf' }, | ||
{ name: 'f1040s3.pdf' }, | ||
{ name: 'f8849.pdf' }, // was f1040s6 in 2018 tax year | ||
{ name: 'f1116.pdf', as: 'f1116amt.pdf' }, | ||
{ name: 'f1116.pdf' }, | ||
{ name: 'f6251.pdf' }, | ||
{ name: 'f8938.pdf' }, | ||
{ name: 'f8965.pdf' } | ||
]; | ||
|
||
async function download(url, dest) { | ||
return new Promise((resolve, reject) => { | ||
if (fs.existsSync(dest)) { | ||
return resolve(); | ||
const afs = fs.promises; | ||
|
||
const { argv } = require('yargs') | ||
.command( | ||
'* [--force]', | ||
'Initialize a new tax year project.', | ||
(yargs) => { | ||
yargs.alias('h', 'help') | ||
.option( | ||
'force', { | ||
type: 'boolean', | ||
alias: 'f', | ||
description: 'Force the generation of a new config file.', | ||
default: false | ||
} | ||
) | ||
} | ||
const file = fs.createWriteStream(dest); | ||
log(chalk.grey(`Downloading: ${url} into ${dest}`)); | ||
https.get(url, (response) => { | ||
response.pipe(file); | ||
file.on('finish', () => { | ||
file.close(); | ||
resolve(); | ||
}); | ||
}).on('error', (err) => { | ||
fs.unlink(dest); | ||
throw err; | ||
}); | ||
}); | ||
} | ||
|
||
function makeOutputDirectory() { | ||
return new Promise((resolve, reject) => { | ||
if (fs.existsSync(taxFormsPath)) { | ||
return resolve(); | ||
); | ||
|
||
async function init({ force }) { | ||
try { | ||
await afs.access('config.yaml', fs.constants.R_OK | fs.constants.W_OK); | ||
if (!force) { | ||
console.error('config.yaml already exists; use --force to overwrite.'); | ||
process.exit(-1); | ||
} | ||
fs.mkdir(taxFormsPath, { recursive: true }, (err) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
return resolve(); | ||
}); | ||
}); | ||
} | ||
|
||
function downloadIRSPDF() { | ||
if (!fs.existsSync(taxFormsPath)) { | ||
fs.mkdirSync(taxFormsPath, { recursive: true }); | ||
} catch (ex) { | ||
// okay, file does not exist | ||
} | ||
|
||
const promises = files | ||
.map(file => { | ||
return download( | ||
`${IRS_URL}/${file.name}`, | ||
path.join(taxFormsPath, file.as || file.name) | ||
); | ||
}); | ||
|
||
return Promise.all(promises); | ||
} | ||
|
||
function generateFormData() { | ||
return fill(year, path.resolve(__dirname, '..', 'example.yaml'), { | ||
generate: true | ||
}); | ||
const config = await afs.readFile(path.join(__dirname, '..', 'config.yaml')); | ||
afs.writeFile('config.yaml', config); | ||
} | ||
|
||
downloadIRSPDF(taxFormsPath) | ||
.then(makeOutputDirectory) | ||
.then(generateFormData) | ||
.catch(err => { | ||
console.error(chalk.red(err)); | ||
process.exit(-1); | ||
}); | ||
init(argv).catch(console.err); |
Oops, something went wrong.