Skip to content

Conversation

@adamdecaf
Copy link
Member

No description provided.

@adamdecaf adamdecaf mentioned this pull request Oct 21, 2025
Comment on lines +102 to +105
// Validate 80-byte limit for TXP addenda
if len(paymentInfo) > 80 {
return nil, ErrInvalidTXPFormat
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String lengths should always use utf8.RuneCountInString

@adamdecaf
Copy link
Member Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for TXP Addenda05 strings, which is a valuable addition. The implementation includes parsing, serialization, and comprehensive unit tests that cover various scenarios, including NACHA examples and edge cases. The code is well-structured. I have a couple of suggestions to improve maintainability by removing an unused field and making the tests more consistent and concise. Overall, great work.

Comment on lines +44 to +45
// TaxInformationIDNumber is a unique identifier for the tax information
TaxInformationIDNumber string

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The TaxInformationIDNumber field is defined in the TXP struct but it is not populated during parsing in ParseTXP or used during serialization in String(). This appears to be unused code. To improve maintainability and avoid confusion, this field should be removed.

Comment on lines +272 to +295
if result.TaxIdentificationNumber != tt.expected.TaxIdentificationNumber {
t.Errorf("TaxIdentificationNumber: expected %s, got %s", tt.expected.TaxIdentificationNumber, result.TaxIdentificationNumber)
}
if result.TaxPaymentTypeCode != tt.expected.TaxPaymentTypeCode {
t.Errorf("TaxPaymentTypeCode: expected %s, got %s", tt.expected.TaxPaymentTypeCode, result.TaxPaymentTypeCode)
}
if result.Date != tt.expected.Date {
t.Errorf("Date: expected %s, got %s", tt.expected.Date, result.Date)
}
if len(result.TaxAmounts) != len(tt.expected.TaxAmounts) {
t.Errorf("TaxAmounts length: expected %d, got %d", len(tt.expected.TaxAmounts), len(result.TaxAmounts))
} else {
for i, expectedAmount := range tt.expected.TaxAmounts {
if result.TaxAmounts[i].AmountCents != expectedAmount.AmountCents {
t.Errorf("TaxAmounts[%d].AmountCents: expected %s, got %s", i, expectedAmount.AmountCents, result.TaxAmounts[i].AmountCents)
}
if result.TaxAmounts[i].AmountType != expectedAmount.AmountType {
t.Errorf("TaxAmounts[%d].AmountType: expected %s, got %s", i, expectedAmount.AmountType, result.TaxAmounts[i].AmountType)
}
}
}
if result.TaxpayerVerification != tt.expected.TaxpayerVerification {
t.Errorf("TaxpayerVerification: expected %s, got %s", tt.expected.TaxpayerVerification, result.TaxpayerVerification)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The testify/require package is already imported and used in TestTXPToStringRoundTrip. For consistency and to make tests more concise, you can replace these manual if checks with require.Equal(). This simplifies the test and provides more detailed failure messages. A similar refactoring can be applied to the other test functions in this file that use t.Errorf.

			require.Equal(t, tt.expected, result)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants