GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - chasebuilds/sheets-automations: Google Apps Script automations for small businesses in TypeScript: form cleanup, summary emails, invoice PDFs, overdue reminders, low-stock alerts. Unit-tested logic.

BranchesTags
Open more actions menu

Latest commit

 

History

9 Commits
9 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
demo
demo
 
 
docs
docs
 
 
samples
samples
 
 
scripts
scripts
 
 
src
src
 
 
tests
tests
 
 
.clasp.json.example
.clasp.json.example
 
 
.claspignore
.claspignore
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
LIMITATIONS.md
LIMITATIONS.md
 
 
README.md
README.md
 
 
eslint.config.mjs
eslint.config.mjs
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
vitest.config.ts
vitest.config.ts
 
 

Repository files navigation

sheets-automations

ci

Live demo: try it in your browser. Run the five automations on sample sheet data, or paste your own CSV. The real TypeScript logic runs in the page; Apps Script services (Sheets, Gmail, Docs, Drive) are mocked and labelled, so nothing is sent.

The live demo after running the low-stock alert: the updated sheet, the email preview and the mocked Apps Script calls

Five Google Apps Script automations that small businesses ask for, written in TypeScript and deployed with clasp. The business rules live in plain functions with no Apps Script dependency, so they are unit-tested in Node with fakes for SpreadsheetApp, GmailApp and the Docs/Drive calls.

# Automation What it does
1 Form cleanup Moves new Google Form rows into a Master sheet: trims names, formats US phones, lowercases emails, skips duplicates, sends bad rows to Rejected with a reason
2 Summary email Emails yesterday's totals (daily) or the previous 7 days (weekly) from a Sales tab: orders, revenue, average, status split, top 3 items
3 Invoice PDF Select a row, click a menu item. Fills a Google Docs template, saves a PDF, writes the link and Invoiced status back to the row
4 Overdue reminders Emails overdue, unpaid invoices. Respects an opt-out column, spaces reminders out, stops after a limit, caps each run, keeps a send log
5 Low-stock alert One email per run listing items at or below their reorder point, grouped by supplier. A Last Alert column stops daily repeats

What it looks like

Screenshots are the real automation code run against the sample data in samples/. They show the sheet layout each automation expects, then the sheet and email after it runs.

Form cleanup Summary email
Invoice PDF Overdue reminders
Low stock

Sample sheets

samples/sample-workbook.xlsx has one tab per input sheet with the exact headers each script needs. Matching CSVs are in the same folder. Import the workbook into Google Sheets (File, Import) and you can try every automation. Header names are matched without regard to case or surrounding spaces. Column order does not matter.

Tab Required columns
Form Responses 1 Timestamp, Name, Email, Phone, Message
Sales Date, Item, Amount, Status (Customer is optional)
Invoices Invoice #, Date, Client, Description, Qty, Unit Price, Tax %, Status, PDF Link (Client Email optional)
Invoices Due Client, Email, Invoice #, Amount, Due Date, Paid, Opt Out, Last Reminded
Inventory SKU, Item, On Hand, Reorder Point, Supplier, Last Alert

Master, Rejected and Send Log are created on first run.

Setup

You need Node 20 or newer and a Google account that owns the sheet.

  1. Clone this repo and run npm install, then npm run build. This writes dist/Code.js and dist/appsscript.json.

  2. Create or open the Google Sheet. Add the tabs above (or import the sample workbook).

  3. In the sheet, choose Extensions, Apps Script. Note the Script ID under Project Settings.

  4. Install clasp (npm install -g @google/clasp), run clasp login, then copy .clasp.json.example to .clasp.json and paste the Script ID.

  5. Run clasp push. Reload the sheet. An Automations menu appears.

  6. In Project Settings, Script Properties, add the ones you need:

    Property Used by Default
    BUSINESS_NAME all emails My Business
    NOTIFY_EMAIL summary, stock alert the script owner
    INVOICE_TEMPLATE_ID invoices none, required
    TZ_OFFSET_MINUTES all date logic 0 (UTC)
    REMINDER_MIN_DAYS reminders 7
    REMINDER_MAX reminders 3
    REMINDER_MAX_PER_RUN reminders 50
    STOCK_REPEAT_DAYS stock alert 7
  7. Run installTriggers once from the editor and approve the permissions. It sets: form cleanup hourly, summary daily at 7, stock check daily at 8, reminders daily at 9. Edit that function to change times.

Invoice template

Make a Google Doc with these placeholders anywhere in the text, then put its ID (the long string in its URL) in INVOICE_TEMPLATE_ID:

{{invoice_number}} {{date}} {{client}} {{client_email}} {{description}} {{qty}} {{unit_price}} {{subtotal}} {{tax_percent}} {{tax}} {{total}}

Try reminders safely

Use Preview overdue reminders (no email) first. It shows how many would be sent and skipped and writes nothing.

How it is built

src/core/       pure functions: parsing, dedupe, totals, who gets a reminder
src/services/   one function per automation, takes an Env (sheets, mail, docs, props, clock)
src/gas/main.ts the only file that touches Apps Script globals; builds the Env, adds the menu and triggers
tests/          Vitest, with in-memory fakes for a spreadsheet, Gmail, Docs/Drive and script properties
scripts/build.mjs  bundles main.ts into dist/Code.js with esbuild and adds top-level function stubs

Design choices:

  • Money is integer cents so 19.99 x 3 never becomes 59.970000000000006.
  • "Today" is injected, so date logic is tested without touching the real clock.
  • Safe to re-run. Form cleanup remembers the last row it handled and dedupes against Master. Reminders read the send log. Stock alerts stamp Last Alert only after the email goes out, so a failed send retries on the next run.
  • Failed sends are logged, do not count toward the reminder limit, and do not stop the rest of the run.

Development

npm run typecheck   # tsc --noEmit, strict
npm run lint        # eslint, typescript-eslint strict-type-checked
npm test            # vitest with coverage
npm run build       # dist/Code.js
npm run samples     # regenerate samples/ (screenshots are rendered from the same run)

The suite has 61 tests. Coverage on src/core and src/services is 99.6% of statements and 92.5% of branches. src/gas/main.ts is the thin glue layer and is not covered by unit tests.

Limitations

See LIMITATIONS.md. The main one: this repo was never deployed to a live Google account, so src/gas/main.ts has been type-checked and bundled but not run against real Google services.

License

MIT, Chase Builds.

More from Chase Builds

  • appointment-booking-api: Online booking that never double-books and gets time zones right. (live demo)
  • small-business-county-study: How small businesses are doing in 31 Eastern Kentucky counties, from free Census data. (live demo)
  • web-data-extractor: Public web pages to a checked spreadsheet, only where the site allows it.

All projects, sorted by industry · chasebuilds.github.io

About

Google Apps Script automations for small businesses in TypeScript: form cleanup, summary emails, invoice PDFs, overdue reminders, low-stock alerts. Unit-tested logic.

chasebuilds.github.io/sheets-automations/

Topics

automationgoogle-apps-scriptgoogle-sheetssmall-businesstypescript

Resources

Readme
MIT license

Contributing

Contributing

Security policy

Security policy
Activity

Stars

2 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.