Skip to content

Conversation

Copy link

Copilot AI commented Sep 18, 2025

Fixes #6 by adding a new RemittanceInformationFull field that captures all <Ustrd> elements from CAMT.053 remittance information sections, while maintaining backward compatibility.

Problem

The current implementation only extracts the first <Ustrd> element from <RmtInf> sections using find(), missing important remittance information that spans multiple lines. This is particularly problematic for international transactions where banks often include detailed transaction information across multiple unstructured remittance lines.

For example, with this XML structure:

<RmtInf>
    <Ustrd>Ref..      1234567890123456</Ustrd>
    <Ustrd>Betrag EUR            69,06</Ustrd>
    <Ustrd>/ADRS CH/Basel,1234</Ustrd>
    <Ustrd>7185) Peter Pan</Ustrd>
    <Ustrd>Urspr. EUR            69,06</Ustrd>
</RmtInf>

Previously only "Ref.. 1234567890123456" was captured, losing critical transaction details.

Solution

Added a new RemittanceInformationFull field alongside the existing RemittanceInformation field:

  • RemittanceInformation: Unchanged - contains only the first <Ustrd> element (backward compatibility)
  • RemittanceInformationFull: New - contains all <Ustrd> elements joined with spaces

The implementation uses findall() to collect all unstructured remittance elements, strips whitespace, filters out empty elements, and joins them with spaces for a clean, comprehensive result.

Changes

  • Modified _extract_transaction_details() in pycamt/parser.py to add the new field
  • Added comprehensive test coverage for multiple scenarios:
    • Multiple remittance lines (main use case)
    • Single remittance line (backward compatibility)
    • No remittance information (edge case)
  • Updated documentation to explain both fields and their use cases
  • Enhanced docstrings to document the new functionality

Backward Compatibility

Fully backward compatible - all existing code continues to work unchanged. The original RemittanceInformation field is preserved with identical behavior. All existing tests pass without modification.

Example Usage

transactions = parser.get_transactions()
transaction = transactions[0]

# Original field (backward compatibility)
print(transaction["RemittanceInformation"])
# Output: "Ref..      1234567890123456"

# New comprehensive field  
print(transaction["RemittanceInformationFull"])
# Output: "Ref..      1234567890123456 Betrag EUR            69,06 /ADRS CH/Basel,1234 7185) Peter Pan Urspr. EUR            69,06"

This enhancement is particularly valuable for international transactions and banks that don't fully support structured CAMT.053 formats, ensuring no critical transaction information is lost during parsing.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits September 18, 2025 10:43
…ixes #6

Co-authored-by: ODAncona <71207824+ODAncona@users.noreply.github.com>
Co-authored-by: ODAncona <71207824+ODAncona@users.noreply.github.com>
Copilot AI changed the title [WIP] fix #6 Add RemittanceInformationFull field to capture all remittance information lines - fixes #6 Sep 18, 2025
Copilot AI requested a review from ODAncona September 18, 2025 10:45
Copilot finished work on behalf of ODAncona September 18, 2025 10:45
Copy link
Owner

@ODAncona ODAncona left a comment

Choose a reason for hiding this comment

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

lgtm

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.

Only only the first line from RemittanceInformation in get_transactions() is given.

2 participants