Skip to content

BE-DP-19 · The money study: transfers, rebates and refunds, due dates and debt letters

ID BE-DP-19 · Level L0 · Pack Pack R2 · The money study · Run order row 2, after BE-DP-11; before or after BE-DP-18 · Issue #185

The rest of the study's counts are on #185: how v1's instalments become v2 payments with allocations, its rebates and refunds as adjustments, its due dates per bill kind, and its debts and claim letters as debt letters.

tools/migration/v1-copy/money-transfers.sql prints:

  • 4 · One transfer, one payment (D46): v1 records an instalment per bill, so a transfer that paid three bills is three instalments. The script groups a driver's instalments that share the same proof file, the same recordedAt, or the same tgl and rekPengirim, and counts for each way how many payments it would make, how many groups cover several bills or several kinds, and how many keys more than one driver shares (which would be no single transfer). The money step builds allocations as v1 recorded them (D72 applies only to payments recorded in v2); these counts say which grouping is v1's record.
  • 5 · Rebates and refunds: v2 keeps them as charge adjustments, each with an amount and a reason. The script counts rebates and refunds with and without a reason, a proof, who and when, and the ones that don't add up (a rebate above the bill's total, a refund above what was paid, a flag with no amount).
  • 6 · Due dates (D57): per bill kind, the days from tanggal to jatuhTempo (least, median, most, and how many are exactly 3), the dates the dated bills span, and the creation dates of the undated ones. Then rentalFreq and rentalDailyFee on the rent bills.
  • 7 · Debts and claim letters: whether debts.data.ref names a bill, and whether the letters' debtIds name debts, so the money step can make each letter's items point at charges; and which letters have a number twice, dates out of order, or a total that isn't the sum of its items.

It prints counts, sums over many rows, bands and forms, never a name, plate, account number, file name or one driver's amount (D15). It reads the copy and changes nothing in it.

  • BE-DP-11 is logged on #185.
  • docker ps --filter name=v1copy lists the copy as Up.
  • You are at the root of your clone, on main once this step's pull request is merged.
Terminal window
docker exec -i v1copy psql -qX -U postgres -d postgres < tools/migration/v1-copy/money-transfers.sql

Thirteen tables, in a minute or two, headed 4 to 4c, 5a and 5b (two tables each), 6 and 6b, 7a to 7c.

  • 4: three lines, one per way. instalments is the same on all three: the instalments not voided.
  • 5a and 5b: rebate above zero near BE-DP-11's 90 bills with a rebate, and refunded true near its 111.
  • 6: one line per bill kind, seven as in BE-DP-11.
  • 7c: letters 766.

Read 7b before posting: each form should be letters and digits only, such as 9 or a-9. If a line shows a word or a number as it is, delete that line and say you did.

Then post the tables on #185, as printed, as one comment or one per section.

  • ERROR: invalid input syntax: a date, number or flag in v1 has a form the script didn't expect. Post the line; it names the function or the type, not the value.
  • It runs for more than ten minutes: let it finish. If it seems stuck, docker exec v1copy psql -U postgres -c "select now() - query_start, left(query, 60) from pg_stat_activity where state = 'active'" shows how long it has run.
  • Anything else: post the ERROR line on #185.

Nothing to undo: it reads only, and its tables and functions are temporary.

Log each run as a comment on #185: date · who · result, with the tables.