Skip to main content
  • For: treasurers
  • You get: a Refunds tab with each money-out bank line still to reconcile, a dropdown of the payments it could refund, and a button that records the ones you pick
  • Time: about twenty minutes the first time, then a few minutes each month
  • Scopes: accounting:read, accounting:write and payments:read. Add accounting.people:read to see who each bank line paid, and payments.people:read to see which family each payment came from.
When a camp is cancelled, you pay families back by bank transfer. Each refund then arrives in the bank inbox as money out, and the payment it reverses still reads as paid. Scoutworks’ reconcile step links the two. This recipe does that for a month’s refunds at once: it lists the lines, you choose the payment for each, and one button records them. No money moves. The refund has already left your bank. Recording it links the bank line to the payment, takes the line out of the inbox and nets the payment’s income down in the books, exactly as Match as refund in the Bank Inbox does. The API never issues a refund through GoCardless.
Recording changes your books, so the read-only sandbox key cannot run that part. Use your own key, and try it on one line first.

1. Try the requests

Paste these into a terminal to see the demo group’s bank inbox and payments:
Each bank inbox line is in the transaction shape: id, date, amount and the bankAccountId. A refund is recorded against a payment (GET /payments: a Direct Debit collection, or a cycle marked paid by hand), or against a payment request paid by hand (GET /payment-requests with status=paid_manually), which has no payment.

2. Add the script

Make a Google Sheet for it, choose Extensions → Apps Script, delete what is there, paste the script below and choose Save. Then add a script property SCOUTWORKS_API_KEY with your key, in Project Settings → Script Properties.
Code.gs

3. List the lines

Choose listRefunds and press Run. The first time, Google asks you to allow the script to reach an outside service. The Refunds tab fills with each money-out line in the bank inbox. For each one that is a refund, pick the payment it refunds in Refund of. Leave the others empty: a card payment to the Scout Shop is not a refund. Amount to record starts at the whole bank line. Make it smaller when one transfer refunds part of a payment.

4. Try it on one line

1

Pick one

Choose a payment for one line only. Leave the rest empty.
2

Record it

Choose recordRefunds and press Run. Result says Recorded and the refund’s id.
3

Check it in Scoutworks

The line has left the Bank Inbox, and the payment shows as refunded on its payments page.
4

Undo it, if it is wrong

Send DELETE /refunds/manual/{id} with the refund’s id from Result. The line goes back to the inbox. To record it again, clear Result and Key on that row, fix the payment or amount, and run it again. Or leave it, if it was right.

5. Record the rest

Pick a payment for each refund and choose Run on recordRefunds. A row that already has a result is skipped, so run it as often as you like. Choose listRefunds again next month: the lines you recorded have left the inbox.

Why nothing is recorded twice

Each row’s first try makes an Idempotency-Key and keeps it in Key. If the network drops after Scoutworks recorded it, the next run sends the same key and gets the same answer back, not a second refund. And a line already matched has left the inbox, so Scoutworks refuses it.

If something goes wrong

  • 409 over_refund: the amount is more than the bank line, or more than is left to refund on that payment (it may have been refunded already). Read GET /refunds with the payment’s id as paymentId to see what is already refunded.
  • 400 invalid_request: usually a line that is not money out, was not imported from a statement, or has already been reconciled, or a payment that is not your group’s. The message says which.
  • 409 period_closed: the bank line is dated in an accounting year that is closed.
  • 403 insufficient_scope: recording needs accounting:write and payments:read, as well as accounting:read.
  • 409 source_locked when undoing: only a refund the API recorded can be unlinked through the API. Unmatch it in the Bank Inbox instead.
The sheet holds who your group paid and, with payments.people:read, parents’ names. Share it only with the treasurer and the trustees who need it. See Errors for every code.