Skip to content

Commit

Permalink
Unpaid
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed May 29, 2024
1 parent 9f74728 commit beefc45
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions bin/export-unpaid.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

set -eu

DB_FILE="$1"
CSV_FILE="$2"

sqlite3 "$DB_FILE" <<EOF
.headers on
.mode csv
.bail on
.output $CSV_FILE
with money as (
select reference, sum(amount) as amount
from payments
group by reference
)
select
users.email as email,
users.name as name
from users
left join
applications on applications.user_id = users.id
left join
money on money.reference = applications.payment_reference
where
money.reference is null
order by name;
.quit
EOF

0 comments on commit beefc45

Please sign in to comment.