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>
33 lines
706 B
Go
33 lines
706 B
Go
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]) + "…"
|
|
}
|