Skip to content

t1k:marketing:monetization:cashflow

FieldValue
Modulemonetization
Version1.49.21
Efforthigh
Tools—
/t1k:marketing:monetization:cashflow

Tracks cash that landed, which is a different question from the one the reporting APIs answer. MAX, AdMob and CloudX report revenue earned. This skill reports revenue received — the wire that cleared, from which legal entity, against which revenue month, and whether it was on time.

The two diverge constantly: a network’s estimate is trued up at payout, terms run from 10 to 71 days, and a month below a partner’s minimum payout is not paid at all but rolls forward. None of that is visible from the earned side.

Mostly judgment-light bookkeeping: the Apps Script and scripts/ tests run the mechanical steps; the agent only interprets results (routing SSOT: rules/orchestration-rules.md § “Task-Type → Agent Routing”):

StepAgent
Run scripts/tests/*.mjs and report pass/failt1k-tester
Tally paid vs due per partner from the ledger the script emitst1k-metrics-reporter
Decide whether a late payment is a real problem or a net-days/minimum artefactstays on a reasoning tier
  • “Did AppLovin pay for August?” · “When did we last get money from Mintegral?”
  • “Who owes us right now?” · “Is anything overdue?”
  • Reconciling a deposit against what a network said it would pay.
  • Standing up the same tracking for another studio entity or bank account.

Not for earned-revenue pulls — that is t1k:marketing:analytics:crawldata (spend + revenue per app per day).

Three facts decide everything, and two of them usually live only in a spreadsheet nobody automated:

netdays after the revenue month ends before payment is due
minminimum payout; a month below it rolls into the next
observed laghow long the partner actually takes, measured from dated payments

Without net and min, every unpaid month reads as missing. On one real book that flagged $49,206 across ten partners as outstanding when none of it was even due, while burying the one partner genuinely late.

Observed beats stated. One partner’s book said net 60; it pays in 18. Using the stated figure would have placed the chase six weeks after the money was actually late. Six of twenty-one partners diverged by more than five days.

No credentials, no Cloud project, no API keys. The deposit path uses only built-in Apps Script services.

  1. Open the target Google Sheet → Extensions ▸ Apps Script.
  2. Paste scripts/appsscript/*.js as separate script files (Apps Script calls them .gs; they are stored as .js here so the kit’s origin gate covers them, and clasp push converts them). Apps Script puts every .gs in one shared global scope.
  3. Manifest scopes — Apps Script infers these, but declaring them is clearer: gmail.readonly, script.send_mail, userinfo.email, spreadsheets.currentonly, script.scriptapp.
  4. Run scanAirwallexDeposits once. Approve the consent screen.
  5. Run enableDepositWatch to arm the daily 09:00 trigger.

Nothing runs on its own until step 5. Check the Triggers page to confirm.

TabOwnerContents
Cashflowscriptone row per deposit — date, amount, fee, currency, partner, reference, deposit ID
By Partnerscriptone row per partner — status, last payment, days ago, months paid, total per currency, pays-in, next expected
Deposit Sendersyoubank remitter substring → partner. A new payer is a row here, never a code change
Payment Historyyouimported ledger: partner × revenue month × amount, with the payment date where known
Airwallex emails you → Gmail
↓ 09:00, on its own
scanAirwallexDeposits
↓
Cashflow tab · By Partner tab · one-line notification

Each run: searches from:airwallex.com + "You received a deposit of" over the last 30 days · skips messages already logged by message id · parses the notice · attributes the sender · appends · rebuilds By Partner · notifies only if something new arrived. Silent on quiet days, so a notice that does arrive means something.

Notification goes to Discord when DISCORD_WEBHOOK_URL is set, and by e-mail otherwise — a dead webhook falls back to e-mail rather than going quiet. A single deposit puts the whole line in the subject:

15/09/2026 - +2,468.10 USD - GAMMA NETWORK SOLUTIONS FZ
→ Yandex · net 60 · min $150

An Airwallex notice is a sequence of labelled blocks — label alone on its line, value beneath:

Deposit amount Fee From
12,345.00 USD 37.04 USD ALPHAADSCORPORATION
Created at Deposit ID Reference
2026-09-16 10:36:59 (Asia/Hong_Kong) 652139ad-… INVOICE UI 000001 …

Read every field from its label. An earlier version scraped ALL-CAPS runs instead and, against a real mailbox, attributed 8 of 25 deposits to the payment narrative — INVOICE UI 000002 VENDOR PAYMENT INSTRUCTED AMT USD 11111.11 — because a long narrative line outscores a short company name.

Consequences worth keeping:

  • Created at is the deposit date, not the mail’s send time. A notice can arrive the day after the money does; the ledger dates the money.
  • Match on From alone. The Reference line carries text like … UNITY MONETIZATION PAYMENT …, and matching the whole body attributed a OMICRON PTE. LTD deposit to Unity.
  • Deposit ID is the real handle — a UUID. Reference is free text the sender chose: an invoice number, EDI PYMNTS NTE, or just -.
  • Fee gets its own column, so what a network says it paid reconciles against what landed.
  • Gmail’s subject: operator matches loosely — re-check the subject as a substring in code, or a “Your deposit was reversed” notice logs as cash in.
  • The sender is matched on the domain (airwallex.com), because notices come from support@info.airwallex.com. Pinning the exact address found nothing at all, silently. The real address is then re-checked in code so a mail merely displaying the domain in its From name cannot reach a money log.

Bank remitters are legal entities (DIGITAL TURBINE (IL) LTD); partner names are trade names (DT). Neither contains the other, so trade names alone attributed 8 of 25 real deposits. Deposit Senders maps substring → partner and KNOWN_REMITTERS seeds the confirmed ones in code so the mapping survives a rebuilt tab or a second spreadsheet.

Outcomes:

  • exactly one partner matched → attributed
  • several aliases, all one partner → agreement (names compare case- and space-insensitively, so Applovin and AppLovin are one partner)
  • zero or two-plus different partners → row is still written, partner blank, Note says why. A deposit that landed must never be invisible because we could not name the payer.

Deposits from senders that are not monetisation partners are classified (not monetisation) rather than left blank, so they stop reporting as unfinished work.

Guardrails — the traps that cost real data

Section titled “Guardrails — the traps that cost real data”

Each of these was a live bug, not a hypothetical:

  • Never double-count. A deposit already in the imported ledger is skipped — matched by date, or by exact amount for the undated rows, which are most of them. The ledger’s dates were read off the very emails the log also holds.
  • Re-attribution must never overwrite a hand-set partner on a row whose Payer is blank. Airwallex omits the sender entirely on some deposits (no From block, prose reads “received a deposit via your … Account”), so those can only be set by hand — and a rerun would silently un-attribute the money.
  • Build the summary before the quiet-day exit. By Partner summarises the whole log, not the run; gating it on “something new arrived” means it is never built on the normal case — a scan over an already-complete log.
  • Sheets parses 2024-08 as a Date on paste. A reader that tests for the text rejects the entire ledger and silently does nothing.
  • Status in words, not colour alone — On track, Overdue 12d, Never paid, Retired. A status has to survive being printed, read by someone colour-blind, or skimmed. Colour reinforces the word on that one cell; filling whole rows buries the numbers.
  • Gmail reaches back 30 days. Anything older must be imported, not crawled — that window made partners with years of payments read as never having paid.

Rendered as a standalone HTML page on the user’s machine: three sections (trend, UA spend, Monet partner grid), the overrides layer and edit persistence are in references/dashboard.md. Never publish the page as a claude.ai Artifact: it holds finance figures, and an Artifact is viewable by anyone it is shared with.

PathWhat
scripts/appsscript/Cashflow.jsthe deposit watcher — parsing, attribution, By Partner
scripts/appsscript/Payments.jsnetwork payout notices, staged for approval
scripts/appsscript/MoneyFlow.jsearned-vs-received ledger, per payer per month
scripts/appsscript/Config.js, Lib.jscredential store and shared helpers
scripts/appsscript/Crawl.jsthe Ad Data menu that reaches every function
scripts/appsscript/Connectors*.js, Merge.js, Monthly.jsthe crawl half of the same project
scripts/tests/test-*.mjsNode harnesses stubbing the Apps Script runtime
scripts/dashboard/build-dashboard.pythe dashboard generator (trend chart, UA spend grid, Monet grid)
scripts/ua-spend/crawl-month.mjsmonthly UA spend crawler: Mintegral, Google Ads, Unity, AppLovin
examples/payment-history.example.txtthe ledger import format
examples/track.example.jsonthe dataset shape the dashboard consumes
examples/overrides.example.jsonthe Monet corrections shape --overrides consumes

Paste all of scripts/appsscript/, not just Cashflow.js. Apps Script puts every .gs in one shared global scope, and the deposit watcher calls into Config.js (CFG), Lib.js (logLine, n, ymd), MoneyFlow.js (fmtMoney) and Payments.js (distinctPayers). Pasting the one file produces a project that saves cleanly and then throws on first run.

These files are shared with t1k:marketing:analytics:crawldata — the two skills are two halves of one Apps Script project, earned and received. Ship them together; if you only want cashflow, the crawl connectors sit idle and cost nothing but the paste.

Run the tests with bun scripts/tests/test-cashflow.mjs from scripts/ — they need no network, no Sheet and no credentials.

  • t1k:marketing:analytics:crawldata — the earned side (spend + revenue per app)
  • t1k:marketing:monetization:mediation-strategy — who the partners are
  • rules/ad-network-mcp-write-safety.md — money-risk guardrail for writes