Skip to content

BE-DP-39 · What the money step needs from v1: debts, accounts, refunds and letters

ID BE-DP-39 · Level L0 · Pack Row 5 · The domain steps · Run order row 5, before the money step's tests · Issue #306

The money step's open questions on #306 each wait for a count no earlier read gives. tools/migration/v1-copy/money-step-read.sql prints them from the copy:

  • 1 · Debts against Klaim Panel bills: how many debts have a bill for the same checkpoint and amount. Those are one charge, loaded from the bill (D34). The rest are the case that may need its own charge, and the read shows whether their money sits on another bill.
  • 2 · Where payments went: the accounts in rekTujuan and rek_tujuan. No step loads company_bank_accounts yet, so these rows are what the money step has to map.
  • 3 · Refunds: how many sit on bills paid in full, part paid and unpaid, how dibayar carries them, and how many drivers go negative if a refund lowers the balance as R-MON-06 says.
  • 4 · Bills paid above their total: count and summed excess (R-MON-15).
  • 5 · Shared proof files: how many groups span two bills, repeat a bill, or span days or accounts.
  • 6 · Rent and rentals: how many days a rent bill covers, which would collide on a rental and day (R-MON-03), and which bills find an onboarding row on their plate.
  • 7 · Bills on leads that may not load, and the odd bills.
  • 8 · Claim letters: whether a letter's text and plate agree with its bills' lead, and whether its v1 total equals its bills' sum.
  • 9 · The letter numbers used twice: whether created_at orders each pair, and whether a v1 number can meet R-NUM-10's.

It prints counts, and sums over five rows or more, never a name, a plate, a file name or one driver's amount (D15). rekTujuan is free text and can hold a holder's name, so it never prints as it is: only a known bank word and the last four digits, with bracketed text and anything after a.n. stripped first, and only where five rows or more share it. Any other first word prints as (other word). The read changes nothing in the copy.

  • docker ps --filter name=v1copy lists the copy as Up.
  • You are at the root of your clone, on the branch or integration holding tools/migration/v1-copy/money-step-read.sql.
  • Block 2 only: your local stack still holds a night on this copy, such as BE-DP-38's. If it doesn't, skip block 2 and say so. Run block 2 before any pnpm supabase db reset: a reset removes the night, and the db tests need one first.
Terminal window
mkdir -p ../opleet-private
docker exec -i v1copy psql -qX -U postgres -d postgres < tools/migration/v1-copy/money-step-read.sql > ../opleet-private/money-step-read.txt
wc -l ../opleet-private/money-step-read.txt
Terminal window
docker exec -i supabase_db_opleet psql -qX -U postgres -d postgres -v ON_ERROR_STOP=1 <<'SQL'
select case when m.v2_id is null then 'its driver did not load' else 'its driver loaded' end as bills,
count(*) as bills_n, count(distinct b.data ->> 'lead_id') as drivers,
case when count(*) >= 5 then sum((b.data ->> 'total')::numeric) end as billed,
case when count(*) >= 5 then sum((b.data ->> 'dibayar')::numeric) end as dibayar
from legacy.bills b
left join migration.id_map m on m.entity = 'driver' and m.v1_key = b.data ->> 'lead_id'
group by 1 order by 1;
SQL

Twenty-odd short tables, in a minute or so, headed 1a to 9b. The counts in this list are from earlier copies; v1 moves (D75), so a difference here isn't a failure. Post it as printed.

  • 1b: debts add up to about 645, near 624 of them with a cp-panel ref. Whatever falls in 3a, 3b or 4 is what the money step still has to place.
  • 1d: bills add up to about 643.
  • 2a: (none) near 25,953, and three accounts or fewer. 2b: (none) near 25,900.
  • 3a: refunds add up to about 106. 3b: the flag table reads about 104, 2 and 1.
  • 4: the first line near 52 bills.
  • 5: about 83 groups over two or three bills. proofs_of_two_drivers_or_more near 67.
  • 7a: in leads holds nearly all bills. 7b: line 4 is near 1, line 6 near 6, line 7 near 8, line 9 near 40 and line 10 near 1.
  • 8a: letters add up to about 1,071, with about 85 no_plate.
  • 8e: the second table is nearly all total_equals_items.
  • 9a: numbers near 26 and identical near 1. 9b: one main form, a/a/9/9, and a_suffixed_number_already_taken 0.
  • Block 2: two lines. its driver did not load is a small number of drivers.

Before you post, read 1a, 2a, 2b, 6a and 9b in ../opleet-private/money-step-read.txt. They are the only tables that print a label from v1.

  • 1a and 9b print forms: letters as a, digits as 9. 1a also prints the code cp-panel.
  • 6a prints Daily, Weekly, Monthly or a form.
  • 2a and 2b print a bank word and … with four digits, or (other word), (none), (rare) or (no number).

If any line shows a person's name or a whole account number, don't post it. Post the table's heading and say what it looks like, with no value.

  • ERROR: column … does not exist: v1's table isn't the one the money study read. Post the line on #306.
  • ERROR: relation "legacy.bills" does not exist in block 2: the local stack holds no night. Skip block 2 and say so.
  • ERROR: invalid input syntax: a key holds a value the read didn't expect. Post the line. It names the type, not the value.
  • Anything else: post the ERROR line.

Nothing to undo: it reads only, and its tables and functions are temporary. ../opleet-private/money-step-read.txt stays on your Mac.

Log each run as a comment on #306: date · who · the copy's date · the tables, once you've read them as Check says.