Overview
SpendWisely George uses Google Sheets as its primary database for expense tracking. The integration is powered by Google Apps Script, which provides:- RESTful API via Web App deployment
- Server-side data processing and calculations
- Settings persistence using Script Properties
- Transaction history with automatic balance calculation
Setup
Create Google Sheet
Create a new Google Sheet with the following structure:
Column Headers (Row 1):
| Date | Description | Amount | Category | Type |
|---|---|---|---|---|
| 2024-03-15 | Coffee | 200 | Food | DEBIT |
| 2024-03-15 | Salary | 50000 | Income | CREDIT |
- Column A: Date
- Column B: Description
- Column C: Amount
- Column D: Category (Food, Transport, Tech, Invest, Income, Misc)
- Column E: Type (CREDIT or DEBIT)
Install Apps Script
- Open your Google Sheet
- Go to Extensions → Apps Script
- Delete default code
- Paste the entire script from
google_script.js - Save the project
Deploy Web App
- Click Deploy → New deployment
- Select type: Web app
- Configure:
- Execute as: Me
- Who has access: Anyone
- Click Deploy
- Copy the Web App URL
API Endpoints
The Apps Script provides both GET and POST endpoints.GET - Fetch Data
Returns the last 50 transactions for performance. Adjust
startRow calculation on line 55 to change this limit.POST - Add/Modify Data
All POST requests use the same endpoint with differentaction values:
POST Actions
Save Settings
Settings are stored in Script Properties, not in the spreadsheet.
Delete Transaction
Add Transaction (Manual)
Process with AI
Balance Calculation
The script calculates balance server-side by iterating through all transactions:Script Properties
Persistent settings are stored usingPropertiesService:
Frontend Integration
The frontend communicates with Apps Script via fetch:Transaction Categories
Supported categories with their UI icons:| Category | Icon | Type |
|---|---|---|
| Income | 💰 | CREDIT |
| Food | 🍔 | DEBIT |
| Transport | ⛽ | DEBIT |
| Tech | ⚡ | DEBIT |
| Invest | 📈 | DEBIT/CREDIT |
| Misc | 🛍️ | DEBIT |
Permissions
These are automatically requested when deploying the Web App.Rate Limits
Google Apps Script quotas (as of 2024):| Resource | Free Tier Limit |
|---|---|
| Script runtime | 6 min/execution |
| Triggers | 90 min/day |
| URL Fetch calls | 20,000/day |
| Spreadsheet reads | 20,000 cells/day |
| Spreadsheet writes | 20,000 cells/day |
For high-frequency usage, consider upgrading to Google Workspace with higher quotas.
Debugging
Enable Logging
Add console logs to the script:- Apps Script Editor → Executions tab
- Click on any execution to see logs
Test in Apps Script
Create test functions:Troubleshooting
”Not Found” Error
Verify Web App deployment:- Check deployment URL is correct
- Ensure “Anyone” has access in deployment settings
- Redeploy if you made changes to the script
Balance Not Updating
The script recalculates balance on every operation. Check:- Column E (Type) has correct values (CREDIT/DEBIT)
- Column C (Amount) contains valid numbers
- No extra spaces or formatting issues
CORS Errors
Google Apps Script Web Apps automatically handle CORS. If you see CORS errors:- Ensure deployment is set to “Anyone can access”
- Check that you’re using the correct Web App URL (not the script editor URL)