Back to list
steveclarke

syncbooks

by steveclarke

Set of scripts/config/utils so I can have all my computers on the same page

24🍴 0📅 Jan 23, 2026

SKILL.md


name: syncbooks description: Daily accounting reconciliation with FreeAgent, WHMCS, and Google Sheets. Use when user asks about invoices, contacts, accounting, FreeAgent, WHMCS, cash position, HST report, Google Sheets, spreadsheet updates, or financial reconciliation. Triggers on "syncbooks", "freeagent", "whmcs", "invoice", "contact", "accounting", "reconciliation", "cash position", "HST", "spreadsheet", "sheets", "sync my accounting".

SyncBooks

Daily accounting sync between FreeAgent, WHMCS, and Google Sheets.

Daily Use

# Sync all FreeAgent data to your Cash On-hand spreadsheet
scripts/syncbooks sync

# Quiet mode (minimal output)
scripts/syncbooks sync -q

# Quick status check (reads from spreadsheet)
scripts/syncbooks status

# Live status (fetches fresh data from FreeAgent)
scripts/syncbooks status --live

One command syncs everything. Zero 1Password prompts after initial setup.

What Gets Synced

The sync command updates these cells in the Cash On-hand spreadsheet:

CellFieldSource
E2HST CollectedInvoices + bank income transactions
E3HST ReclaimedBills + expenses + bank expense transactions
E6Available COHTotal balance across all bank accounts
E9FA InvoicesOpen + overdue invoices
B4Outstanding BillsOpen + overdue bills

HST is calculated from the configured period start date through today.

First-Time Setup

1. Cache credentials from 1Password

scripts/syncbooks setup

This fetches and caches these 1Password items:

  • FreeAgent API - SyncBooks (client ID, secret)
  • Google Sheets API - SyncBooks (client ID, secret, spreadsheet IDs)
  • WHMCS API - SyncBooks Daily Accounting (API URL, identifier, secret)

2. Authenticate OAuth services

scripts/syncbooks auth fa      # FreeAgent (opens browser)
scripts/syncbooks auth sheets  # Google Sheets (opens browser)

3. WHMCS IP Whitelisting

WHMCS requires your IP to be whitelisted:

  1. Go to WHMCS Admin → System Settings → General Settings → Security
  2. Add your IP to "API IP Access Restriction"
  3. Test with scripts/syncbooks whmcs test

Command Aliases

Short aliases for faster typing:

AliasExpands ToExample
shsheetssyncbooks sh summary
whwhmcssyncbooks wh transactions
faFreeAgent commandssyncbooks fa balance

HST Period Management

# Show current period
scripts/syncbooks hst-status

# Set period start (e.g., beginning of quarter)
scripts/syncbooks hst-set 2025-10-01

# After remitting quarterly HST, advance to next quarter
scripts/syncbooks hst-paid

Command Reference

Top-Level Commands

CommandDescriptionOptions
syncSync all data to Google Sheets-q quiet, --dev use dev spreadsheet
statusQuick financial position check--live fetch fresh data
setupCache 1Password credentials--refresh force re-fetch
balanceShow bank account totals
hstHST report for current period--from DATE, --to DATE
hst-statusShow HST period config
hst-set DATESet HST period start
hst-paidAdvance to next HST quarter--confirm skip prompt
invoicesList invoices--view (recent/open/overdue/draft), --json
invoice IDShow invoice details
contactsList contacts--view (active/all/clients/suppliers), --json
contact IDShow contact details
create-invoiceCreate new invoiceSee below
create-contactCreate new contactSee below
companyShow company info
projectsList projects--contact ID filter by contact

Create Invoice Options

scripts/syncbooks create-invoice \
  --contact "Client Name"    # or contact ID
  --description "Services"   # line item description
  --price 1000               # price per unit
  --quantity 1               # default: 1
  --tax-rate 15              # default: 15 (HST)
  --due-days 30              # default: 30
  --date 2025-01-15          # default: today
  --item-type Services       # Hours, Days, Services, Products
  --send                     # mark as sent (default: draft)

Create Contact Options

scripts/syncbooks create-contact \
  --organisation "Company Name"  # OR use --first-name/--last-name
  --email "billing@example.com"
  --phone "555-1234"
  --address "123 Main St"
  --town "Toronto"
  --region "Ontario"
  --postcode "M5V 1A1"
  --country "Canada"             # default: Canada
  --payment-terms 30             # default: 30

Auth Subcommands

CommandDescription
auth faFreeAgent OAuth authentication
auth sheetsGoogle Sheets OAuth authentication

Sheets Subcommands (sheets or sh)

CommandDescription
sh infoShow spreadsheet metadata
sh summaryShow cash position summary (formatted)
sh read RANGERead cells (e.g., "Main!E2:E10")
sh write RANGE VALUEWrite to cell (requires --force for production)
sh update:cohUpdate only Available Cash On Hand
sh update:hstUpdate only HST Collected/Reclaimed
sh update:receivablesUpdate only FA Invoices
sh update:billsUpdate only Outstanding Bills
sh update:allUpdate all metrics (same as sync)

All sheets commands support --dev to use the dev spreadsheet.

WHMCS Subcommands (whmcs or wh)

WHMCS integration is read-only - for viewing Sevenview Hosting billing data.

CommandDescriptionOptions
wh transactionsList recent transactions--limit N (default: 25), --json
wh invoicesList invoices--status (Paid/Unpaid/Cancelled), --limit N, --json
wh invoice IDShow invoice details
wh clientsList clients--search TEXT, --limit N, --json
wh client IDShow client details
wh testTest API connection

FreeAgent Alias (fa)

The fa subcommand provides shortcuts to top-level FreeAgent commands:

CommandSame As
fa balancebalance
fa invoicesinvoices
fa contactscontacts
fa hsthst
fa companycompany
fa projectsprojects

Configuration Files

FilePurpose
~/.config/syncbooks/config.jsonCached credentials, HST period, last sync
~/.local/share/syncbooks/credentials.jsonOAuth tokens (auto-refreshed)

Config Contents

{
  "freeagent_client_id": "...",
  "freeagent_client_secret": "...",
  "google_client_id": "...",
  "google_client_secret": "...",
  "spreadsheet_id": "...",
  "spreadsheet_id_dev": "...",
  "whmcs_api_url": "https://...",
  "whmcs_identifier": "...",
  "whmcs_secret": "...",
  "hst_period_start": "2025-01-01",
  "last_sync": "2025-01-23T12:00:00Z"
}

Troubleshooting

Re-fetch credentials from 1Password

scripts/syncbooks setup --refresh

Re-authenticate OAuth

scripts/syncbooks auth fa
scripts/syncbooks auth sheets

WHMCS "Invalid IP" error

Your IP needs to be whitelisted in WHMCS Admin → System Settings → General Settings → Security → API IP Access Restriction.

Token refresh failed

OAuth tokens auto-refresh, but if they become invalid:

  1. Delete ~/.local/share/syncbooks/credentials.json
  2. Re-run scripts/syncbooks auth fa or auth sheets

Notes

  • Contact names are matched case-insensitively when creating invoices
  • Invoices are created as Draft by default; use --send to mark as sent
  • Default currency is CAD, default tax rate is 15% (HST)
  • All table outputs support --json for machine-readable output
  • Sheets write operations require --force for production spreadsheet (safety check)
  • WHMCS integration is read-only (no posting transactions to FreeAgent yet)

Score

Total Score

50/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon