Automated tax processing system for Nusii Proposals S.L. that handles expense tracking, invoice processing, and integration with Stripe, Quaderno, and other financial services.
- Stripe Report Downloads: Automatically download balance and payout reports in multiple currencies
- PDF Invoice Processing: Extract data from PDF invoices using OpenAI's GPT-4
- Quaderno Integration: Upload processed expenses to Quaderno with proper categorization
- Automated Filing: Organize processed invoices into monthly tax folders
- Ruby 3.0 or higher
- Bundler
- API keys for:
- Stripe
- OpenAI
- Quaderno
- Clone this repository:
git clone [repository-url]
cd code- Install dependencies:
bundle install- Copy the environment variables template:
cp .env.example .env- Edit
.envand add your API keys and configuration:
# Company Configuration
COMPANY_NAME=YourCompanyName
# Comma-separated list of currencies for Stripe reports (e.g., usd,eur or usd,eur,gbp)
STRIPE_CURRENCIES=usd
# Required API keys
STRIPE_API_KEY=your_stripe_api_key
OPENAI_API_KEY=your_openai_api_key
QUADERNO_API_KEY=your_quaderno_api_key
QUADERNO_API_URL=https://your_account.quadernoapp.com/api/
# Paths
DROPBOX_FOLDER=/path/to/your/dropbox/taxes/folder
EMAIL_ATTACHMENTS_FOLDER=/path/to/your/email/attachments/folder
CODE_ROOT=/path/to/this/code/directoryRun the main tax processor:
ruby taxes.rbThe interactive menu provides these options:
- Download Stripe reports - Downloads monthly reports for all configured currencies
- Process PDF invoices - Extracts data from PDFs in your Email Attachments folder
- Show expenses JSON file - Display the processed expense data
- Upload to Quaderno - Uploads processed invoices to Quaderno
- Compress tax folder - Creates a zip file of the monthly tax folder
- Exit - Quit the application
- Place PDF invoices in your Email Attachments folder
- Run
ruby taxes.rb - Select "Complete tax workflow"
- Choose the month to process
- The system will:
- Download Stripe reports to the appropriate monthly folder
- Process all PDF invoices and extract expense data
- Upload expenses to Quaderno with proper categorization
- Move processed PDFs to the monthly tax folder
Processed files are organized as follows:
Dropbox/Taxes/
├── 2024/
│ ├── 2024-01 CompanyName Taxes/
│ │ ├── invoices/ # Processed PDF invoices
│ │ ├── Balance_summary_*.csv
│ │ └── Payouts_summary_*.csv
│ └── 2024-02 CompanyName Taxes/
│ └── ...
- COMPANY_NAME: Your company name (used in zip file naming)
- STRIPE_CURRENCIES: Comma-separated list of currencies to download Stripe reports for (e.g.,
usd,usd,eur,usd,eur,gbp)
The system automatically categorizes invoices from known vendors using the config/category_mappings.yml file. This YAML configuration defines:
- Vendor names and their Quaderno contact IDs
- Item descriptions for each vendor
- Payment methods (credit_card, direct_debit, etc.)
- Mappings for vendor name variations
To add a new vendor, edit config/category_mappings.yml and add an entry under the vendors section.
The system uses a temp/ directory for intermediate processing:
temp/expenses.json- Extracted invoice data before uploading to Quaderno
- Ensure PDFs are readable and not password-protected
- Check that the OpenAI API key has sufficient credits
- Review
temp/expenses.jsonfor extraction results
- Verify the Quaderno API key and URL are correct
- Check that vendor categories match those in
config/category_mappings.yml - Ensure the Quaderno contact IDs are valid
Run bundle install to ensure all gems are installed.
- Edit
config/category_mappings.yml - Add the vendor under the
vendorssection:
vendors:
new_vendor:
contact_id: 12345678
contact_full_name: "Vendor Name"
item_description: "Service description"
payment_method: "credit_card"- Update the AI prompt in
prompt.txtto recognize the vendor in invoice processing
- Never commit the
.envfile to version control - Keep API keys secure and rotate them regularly
- The
.gitignorefile is configured to exclude sensitive data