feat(go): add --print-fio-table flag to fuj sync --dry-run
All checks were successful
Deploy to K8s / deploy (push) Successful in 7s
All checks were successful
Deploy to K8s / deploy (push) Successful in 7s
Prints an aligned tabwriter table of every Fio transaction in the look-back window, with a STATUS column showing NEW (would be appended) or DUP (already in sheet). Only fires when --dry-run is also set, so it can't affect real syncs. Refactors Sync ID computation into a single pre-pass shared by both the table printer and the row builder. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
32
go/internal/services/banksync/fio_table.go
Normal file
32
go/internal/services/banksync/fio_table.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package banksync
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"text/tabwriter"
|
||||
|
||||
"fuj-management/go/internal/io/fio"
|
||||
)
|
||||
|
||||
func printFioTable(w io.Writer, txns []fio.Transaction, syncIDs []string, existing map[string]bool) {
|
||||
tw := tabwriter.NewWriter(w, 0, 0, 2, ' ', 0)
|
||||
fmt.Fprintln(tw, "DATE\tAMOUNT\tSENDER\tVS\tMESSAGE\tBANKID\tSTATUS")
|
||||
for i, tx := range txns {
|
||||
status := "NEW"
|
||||
if existing[syncIDs[i]] {
|
||||
status = "DUP"
|
||||
}
|
||||
fmt.Fprintf(tw, "%s\t%.2f\t%s\t%s\t%s\t%s\t%s\n",
|
||||
tx.Date, tx.Amount, tx.Sender, tx.VS,
|
||||
truncRunes(tx.Message, 40), tx.BankID, status)
|
||||
}
|
||||
_ = tw.Flush()
|
||||
}
|
||||
|
||||
func truncRunes(s string, n int) string {
|
||||
rs := []rune(s)
|
||||
if len(rs) <= n {
|
||||
return s
|
||||
}
|
||||
return string(rs[:n-1]) + "…"
|
||||
}
|
||||
Reference in New Issue
Block a user