BE-DP-18 · The money study: balances, and what v2 requires that v1 lacks
ID BE-DP-18 · Level L0 · Pack Pack R2 · The money study · Run order row 2, after BE-DP-11 · Issue #185
The counts are on #185 that the money step and DOC's rules for migrated_from wait for: each driver's balance built from the instalments inside bills (D34), and how many of v1's bills and instalments lack what a v2 charge or payment requires.
BE-DP-11 found the instalments in bills.data.pembayaran[]: 31,662 of them in 4,914 of the 23,505 bills, with jumlah, tgl, bukti, rekTujuan, rekPengirim and voided. tools/migration/v1-copy/money-balances.sql reads them and prints:
- 1 · The balance of record: bills, drivers and instalments; the sums of totals, of instalments not voided, of v1's own
dibayarand of rebates; the same per bill kind (jenis); the bills wheredibayarorstatus(Lunas, Cicil, Belum Bayar) disagree with the instalments; and how many drivers fall in each balance band. - 2 · What v2 requires that v1 lacks: for a charge, a date, a due date, an amount above zero and a driver (
bills.data.lead_id, checked againstleadsandonboarding); for a payment, an amount and a date, a proof (R-MON-22), a bank account unless cash (R-MON-23) and a void's reason (R-MON-21). Then the forms ofrekTujuan, and the instalments with no proof by bill kind. - 3 · v1's payments table: D34 makes it no source, so it is matched to the instalments by bill, amount and day, and the script counts what each side has that the other doesn't.
The CTO and zuki chose payments.migrated_from on #185 (option a, 2026-10-22): R-MON-21 to R-MON-23 hold for every payment recorded in v2, and a migrated payment is exempt. Section 2's counts are the exceptions DOC writes, so they must be exact.
It prints counts, sums over many drivers, bands and forms (a 9 for a bank's name and an account number), never a name, plate, account number, file name or one driver's amount (D15). It reads the copy and changes nothing in it.
Before
Section titled “Before”- BE-DP-11 is logged on #185.
docker ps --filter name=v1copylists the copy as Up.- You are at the root of your clone, on main once this step's pull request is merged.
1 · Balances and gaps
Section titled “1 · Balances and gaps”docker exec -i v1copy psql -qX -U postgres -d postgres < tools/migration/v1-copy/money-balances.sqlExpect
Section titled “Expect”Eleven tables, in a minute or two, headed 1a to 1d, 2a to 2e and 3 and 3b.
- 1a:
bills23505 andinstalments31662, as BE-DP-11 found. - 1d: seven bands at most, from
1 · in creditto7 · over 5M, with a count of drivers each. - 2c:
instalments not voidedis 1a's instalments less the voided ones. - 3:
payments rows31499. The match is by bill, amount and day, so a payment and its instalment recorded on different days count on both sides.
Read 2d before posting: each form should be letters and digits only, such as a 9 or a a 9. If a line shows a word or a number as it is, delete that line and say you did.
Then post all eleven tables on #185, as printed. If they're too long for one comment, post sections 1, 2 and 3 as three comments.
If it fails
Section titled “If it fails”ERROR: invalid input syntax for type timestamp with time zone: atgl,tanggalorjatuhTempolooks like a date but isn't one. Post the line; it names the function, not the value.ERROR: invalid input syntax for type boolean: avoidedkey holds something other than true or false. Post the line.- 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
ERRORline 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.