fix(qsl): separate the QSL manager from the routing method (#16)
QSL_VIA is the manager. QSL_SENT_VIA and QSL_RCVD_VIA are the ADIF "QSL Via"
enumeration — B bureau, D direct, E electronic, M manager (import-only) —
and say how a card travelled. OpsLog had one column for all three:
- the import folded QSL_SENT_VIA into QSL_VIA whenever QSL_VIA was empty,
which is exactly a Log4OM export (it defaults QSL_SENT_VIA to E), so
OE6CLD saw "E" everywhere OpsLog shows the manager;
- QSL_RCVD_VIA was listed in adifPromoted with no column behind it, so it
was not stored, not kept among the extras, and not exported — dropped
outright on import;
- neither was ever written on export, so an import followed by an export
destroyed both;
- and OpsLog polluted the field itself: the QSL Manager panel wrote
"Bureau" / "Direct" / "Electronic", in full words, into QSL_VIA.
Two columns added (migration 0027), carried through the five places a
promoted ADIF field has to touch, with round-trip tests pinning the reported
case. The QSL panel now offers Bureau / Direct / Electronic for each
direction and stores the enumeration; the manager field is labelled as the
manager and holds only that. M is kept when a file gives it and never
written back out.
Existing logs hold a mixture of the two in one column. The repair is offered,
not performed: the count is shown once per log with a plain question, and a
"no" is remembered. It moves only where QSL_SENT_VIA is still empty, and only
values that normalise to the enumeration — a manager is a callsign and can
never be one of those six words, which a test pins against real manager calls.
This commit is contained in:
@@ -119,3 +119,85 @@ func renderRecord(q qso.QSO, includeApp bool) string {
|
||||
bw.Flush()
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// TestQSLViaFieldsRoundTrip covers the case reported as issue #16: a log
|
||||
// exported by another logger carries a manager in QSL_VIA and a routing method
|
||||
// in QSL_SENT_VIA, and the two must stay apart.
|
||||
//
|
||||
// Before this, QSL_SENT_VIA was folded into QSL_VIA whenever QSL_VIA was empty
|
||||
// — so a Log4OM log, which defaults QSL_SENT_VIA to E, showed "E" wherever
|
||||
// OpsLog displays the manager — and QSL_RCVD_VIA was thrown away outright: it
|
||||
// was listed as a promoted field with no column behind it, so it was not even
|
||||
// kept among the extras. Neither was ever exported, which made an import
|
||||
// followed by an export destroy both.
|
||||
func TestQSLViaFieldsRoundTrip(t *testing.T) {
|
||||
in := qso.QSO{
|
||||
Callsign: "3B9FR", Band: "20m", Mode: "CW",
|
||||
QSODate: time.Date(2026, 6, 6, 12, 0, 0, 0, time.UTC),
|
||||
QSLVia: "M0OXO", // the manager
|
||||
QSLSentVia: "D", // sent direct
|
||||
QSLRcvdVia: "B", // came back via the bureau
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
bw := bufio.NewWriter(&buf)
|
||||
bw.WriteString("<EOH>\n")
|
||||
writeRecord(bw, in, true, nil)
|
||||
bw.Flush()
|
||||
|
||||
var rec Record
|
||||
if err := Parse(strings.NewReader(buf.String()), func(r Record) error { rec = r; return nil }); err != nil {
|
||||
t.Fatalf("parse: %v", err)
|
||||
}
|
||||
out, ok := recordToQSO(rec)
|
||||
if !ok {
|
||||
t.Fatal("recordToQSO returned !ok")
|
||||
}
|
||||
for name, c := range map[string]struct{ got, want string }{
|
||||
"QSL_VIA": {out.QSLVia, in.QSLVia},
|
||||
"QSL_SENT_VIA": {out.QSLSentVia, in.QSLSentVia},
|
||||
"QSL_RCVD_VIA": {out.QSLRcvdVia, in.QSLRcvdVia},
|
||||
} {
|
||||
if c.got != c.want {
|
||||
t.Errorf("%s: got %q, want %q", name, c.got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestQSLSentViaDoesNotBecomeManager pins the exact shape a Log4OM export has:
|
||||
// no QSL_VIA at all, QSL_SENT_VIA defaulted to E. The manager field must come
|
||||
// back empty rather than holding "E".
|
||||
func TestQSLSentViaDoesNotBecomeManager(t *testing.T) {
|
||||
const rec = "<CALL:5>OE6CLD<QSO_DATE:8>20260606<TIME_ON:4>1200<BAND:3>20m<MODE:2>CW" +
|
||||
"<QSL_SENT_VIA:1>E<EOR>\n"
|
||||
var got Record
|
||||
if err := Parse(strings.NewReader("<EOH>\n"+rec), func(r Record) error { got = r; return nil }); err != nil {
|
||||
t.Fatalf("parse: %v", err)
|
||||
}
|
||||
q, ok := recordToQSO(got)
|
||||
if !ok {
|
||||
t.Fatal("recordToQSO returned !ok")
|
||||
}
|
||||
if q.QSLVia != "" {
|
||||
t.Errorf("QSL_VIA = %q — the routing method leaked into the manager field again", q.QSLVia)
|
||||
}
|
||||
if q.QSLSentVia != "E" {
|
||||
t.Errorf("QSL_SENT_VIA = %q, want %q", q.QSLSentVia, "E")
|
||||
}
|
||||
}
|
||||
|
||||
// M is import-only in the ADIF QSL Via enumeration: keep it when given, never
|
||||
// write it back out.
|
||||
func TestQSLViaManagerIsImportOnly(t *testing.T) {
|
||||
in := qso.QSO{
|
||||
Callsign: "3B9FR", Band: "20m", Mode: "CW",
|
||||
QSODate: time.Date(2026, 6, 6, 12, 0, 0, 0, time.UTC),
|
||||
QSLSentVia: "M", QSLRcvdVia: "M",
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
bw := bufio.NewWriter(&buf)
|
||||
writeRecord(bw, in, true, nil)
|
||||
bw.Flush()
|
||||
if s := buf.String(); strings.Contains(s, "QSL_SENT_VIA") || strings.Contains(s, "QSL_RCVD_VIA") {
|
||||
t.Errorf("exported an import-only value:\n%s", s)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user