Home
Softono
i

iloveitaly

Professional software vendor delivering innovative solutions on the Softono platform. Specialized in both open-source and proprietary software development.

Total Products
2

Software by iloveitaly

lunchmoney-amazon
Open Source

lunchmoney-amazon

# Enhance and Categorize Amazon Transactions in LunchMoney [LunchMoney](https://mikebian.co/lunchmoney) is a indie-developed personal finance application. I spend a lot on Amazon, and always thought it would be neat to break open the massive black bucket of money that's funneled into Amazon to understand what categories of spending it represents. The trick is, Amazon doesn't have an order export. [There's a sneaky extension](https://github.com/philipmulcahy/azad) that allows you to export your orders to a CSV file. This tool ingests that CSV and categorizes your Amazon transactions in Lunch Money. However, in order to match orders to transactions in Lunch Money, you have to match orders not items, which eliminates a clear 1:1 mapping between transaction and category. To solve this, we pipe the list of items to OpenAI and ask it to categorize the items based on the categories available in your LunchMoney account. ## Features - Marked as gift if recipient is not the owner name passed to the CLI - GPT-4o-mini is used for transaction categorization. Be sure to add a clear description to categories! - Summary of items purchased and order number is added to the transaction notes. ## Setup `mise install` (if you don't have bun) and `bun install`. ## Usage 1. Use the [amazon order scraper](https://github.com/philipmulcahy/azad) to pull your amazon history. 1. You want order view, not items, so we can match up charges to orders.![azad example](azad.png) 2. Get a lunch money API key. Run `cp .env-example .env` and add your API key to `.env`, or input it directly via the command line. ```shell Usage: amazon-lunchmoney [options] Options: -v, --verbose output verbose logs -f, --file <path> amazon history file -k --lunch-money-key <key> lunch money api key -m --mapping-file <path> category mapping file -d, --dry-run dry run mode (default: false) -n, --owner-name <name> the name of the owner of the account, used to determine if a order is a gift -c, --default-category <category> default category -h, --help display help for command ``` Here's an example command: ```shell bun run.ts -f '~/Downloads/amazon_order_history.csv' -c Shopping -n "Michael Bianco" ``` You'll probably want to dry run it first, to setup missing categories. ```shell bun run.ts -f '~/Downloads/amazon_order_history.csv' -c Shopping -n "Michael Bianco" -d ``` ### OpenAI Costs The most amazing thing about this approach is it costs effectively nothing. In order to test the system, I ran this multiple times in dry-run mode against my full-year amazon transactions (~200). It consumed about 200k tokens, which is below the minimum billing threshold for OpenAI, so running this was free. Amazing. ## Development Update `run.ts` and run it. Or open up a repl and play around: ```javascript import { LunchMoney } from "lunch-money"; let lunchMoneyKey = process.env.LUNCH_MONEY_API_KEY; let client = new LunchMoney({ token: lunchMoneyKey }); import { readCSV } from "./util.js"; let allAmazonTransactions = await readCSV("path"); ``` You can log loudly as well: ```shell LOG_LEVEL=debug bun run.ts -f '~/Downloads/amazon_order_history.csv' -c Shopping -n "Michael Bianco" ``` ## TODO - [ ] Indicate which purchases are HSA/FSA eligible and maybe generate receipt? This would need to be added to the scraper - [ ] publish on npm - [ ] Should match up refunds and categorize them appropriately

AI Tools Personal Finance
27 Github Stars
lunchmoney-assets
Open Source

lunchmoney-assets

# Update Real Estate & Car Values in LunchMoney Tool to update real estate and car values in [LunchMoney](https://mikebian.co/lunchmoney). Supports scraping values from Zillow, Redfin, and Kelly Bluebook. Why build this tool rather than the existing scripts out there? - The Kelly Bluebook page structure changed and the existing logic wasn't working for me - I wanted a single tool to manage both real estate and cars - Wanted a good excuse to play around with puppeteer ## Usage I wrote this using node 17, but I imagine it will work with much older versions. Use `asdf install` to setup node if you haven't already. ```shell cp .env-example .env # generate a API key and add it to .env touch assets.json # add your assets to assets.json npm install node dist/index.js ``` Or, if you have a docker container setup, you can run it directly: ```shell docker exec -i ca32c16fa00e node dist/index.js ``` ### `assets.json` File Path The program first checks for the environment variable `ASSET_PATH` which should be a string path to the assets.json file to use. For example: `/home/assets.json`. If the environment variable doesn't exist, it then checks inside the current working directory of the node process. For docker deployments, this is inside the `/app` folder. ### `assets.json` Structure Specify the assets to be updated in the `assets.json` file. The key of the hash is the LunchMoney asset ID. ```json { "23760": { "__comment": "you can specify a zillow and redfin link to set the balance as the average of the two", "url": "https://www.zillow.com/homes/your-home/123/", "redfin": "https://www.redfin.com/STATE/CITY/yourhome/home/123" }, "23759": { "__comment": "kelly blue book link", "url": "https://www.kbb.com/your/car/year/model/?condition=good&intent=trade-in-sell&mileage=100000&modalview=false&options=6763005%7ctrue&pricetype=private-party", "mileageStart": 132800, "mileageDate": "11/29/23", "yearlyMileage": 8000 }, "23759": { "__comment": "a car that is more damaged than it looks", "url": "https://www.kbb.com/your/car/year/model/?condition=good&intent=trade-in-sell&mileage=100000&modalview=false&options=6763005%7ctrue&pricetype=private-party", "adjustment": -500 } } ``` Note that mileage can be optionally specified. If it is, the tool will calculate the depreciation based on the mileage and the date of the last update. ## Docker Deployment https://hub.docker.com/r/iloveitaly/lunchmoney-assets Here's the docker-compose file I use: ```yaml lunchmoney_assets: container_name: lunchmoney-assets image: iloveitaly/lunchmoney-assets:latest restart: unless-stopped environment: - SCHEDULE=@monthly - LUNCH_MONEY_API_KEY=THE_KEY ``` Copy your assets config into the container: ```shell docker compose cp ./lunch-money-assets.json lunchmoney_assets:./app/assets.json ``` Or, if you are using docker without compose: ```shell docker cp ./lunch-money-assets.json lunchmoney_assets:./app/assets.json ``` Set a `SCHEDULE` environment variable when starting the container to update the assets at a regular interval. The value should be a [cron expression](https://crontab.guru/). ```shell docker run -d --name lunchmoney-assets -e SCHEDULE="0 0 * * *" -e LUNCH_MONEY_API_KEY=thekey -v ./assets.json:/app/assets.json iloveitaly/lunchmoney-assets ``` ## Development Setup your env (I use [direnv](https://direnv.net)): ```shell cp .envrc-example .envrc ``` Compile typescript: ```shell npm run dev ``` Get a list of all accounts in your lunchmoney account: ```shell http GET https://dev.lunchmoney.app/v1/assets -A bearer -a $LUNCH_MONEY_API_KEY | jqp # or match against a specific account http GET https://dev.lunchmoney.app/v1/assets -A bearer -a $LUNCH_MONEY_API_KEY | jq '.assets | map(select(.name == "Camry"))' ``` ## TODO - [ ] throw a user-friendly error if `assets.json` is not defined - [ ] It seems as though the KBB logic only works for private party priced URLs. Not sure why. - [ ] Automatically calculate additional mileage based on time passed

Browser Automation Personal Finance
12 Github Stars