Skip to content

Commit

Permalink
rtp: pad bankField in InstructionID when short
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Dec 14, 2023
1 parent e609e98 commit 0b53ee6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/rtp/instruction_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
func InstructionID(ts time.Time, participantID, bankField string) string {
timestamp := ts.Format("20060102")
partID := fmt.Sprintf("%011.11s", participantID)
bank := fmt.Sprintf("%4.4s", bankField)
bank := fmt.Sprintf("%04.4s", bankField)
serial := NumericSerialNumber(11)

return fmt.Sprintf("%s%sB%s%011.11s", timestamp, partID, bank, serial)
Expand Down
8 changes: 8 additions & 0 deletions pkg/rtp/instruction_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ func TestInstructionID(t *testing.T) {
}
require.Equal(t, 35, len(instID))
require.Contains(t, instID, "44445566667B1238")

// Short bankField
instID = rtp.InstructionID(time.Now(), "44445566667", "238")
if testing.Verbose() {
t.Log(instID)
}
require.Equal(t, 35, len(instID))
require.Contains(t, instID, "44445566667B0238")
}

0 comments on commit 0b53ee6

Please sign in to comment.