Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logic for identifying start/end does not always work in EDI #17

Closed
zavoraad opened this issue Nov 4, 2024 · 0 comments · Fixed by #16
Closed

Logic for identifying start/end does not always work in EDI #17

zavoraad opened this issue Nov 4, 2024 · 0 comments · Fixed by #16
Assignees

Comments

@zavoraad
Copy link
Contributor

zavoraad commented Nov 4, 2024

#
# Find all locations of a transaction
#
def _transaction_locations(self):
return [(i - int(x.element(1))+1,i+1) for i,x in self.segments_by_name_index("SE")]
#
# Fold left, given a
# @param functional_group = tuple (i,x)
# @param where i = start location in file of trailer segment
# @param where x = number of transactions in the functional group
#
# @return a tuple of the start/end locations of the transactions
#
def _functional_segments_trx_list(self, functional_group):
l = ()
f = lambda trxs, x, fg: x if len(trxs) <= fg[1] and x[1] <= fg[0] else None
return functools.reduce(lambda a,b: (min(a[0], b[0]), max(a[1], b[1])),
filter(
lambda y: y is not None, [l := f(l, x, functional_group) for x in self._transaction_locations()]
)
)

@zavoraad zavoraad self-assigned this Nov 4, 2024
@zavoraad zavoraad linked a pull request Nov 11, 2024 that will close this issue
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 a pull request may close this issue.

1 participant