Skip to content

Commit f46bc7b

Browse files
committed
fix missing schemes when folios are not in proper order
1 parent b2d2e9a commit f46bc7b

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

casparser/process/cas_detailed.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,15 @@ def process_detailed_text(text):
162162
folios[current_folio].schemes.append(curr_scheme_data)
163163
curr_scheme_data = None
164164
current_folio = folio
165-
folios[folio] = Folio(
166-
folio=current_folio,
167-
amc=current_amc,
168-
PAN=(m.group(2) or "").strip(),
169-
KYC=None if m.group(3) is None else m.group(3).strip(),
170-
PANKYC=None if m.group(4) is None else m.group(4).strip(),
171-
schemes=[],
172-
)
165+
if folio not in folios:
166+
folios[folio] = Folio(
167+
folio=current_folio,
168+
amc=current_amc,
169+
PAN=(m.group(2) or "").strip(),
170+
KYC=None if m.group(3) is None else m.group(3).strip(),
171+
PANKYC=None if m.group(4) is None else m.group(4).strip(),
172+
schemes=[],
173+
)
173174
elif m := re.search(SCHEME_RE, line, re.DOTALL | re.MULTILINE | re.I):
174175
if current_folio is None:
175176
raise CASParseError("Layout Error! Scheme found before folio entry.")

tests/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def setup_class(cls):
3333
(cls.cams_file_name, cls.cams_password, 10, 14),
3434
(cls.new_cams_file_name, cls.cams_password, 14, 30),
3535
(cls.kfintech_file_name, cls.kfintech_password, 17, 30),
36-
(cls.new_kfintech_file_name, cls.kfintech_password, 14, 29),
36+
(cls.new_kfintech_file_name, cls.kfintech_password, 14, 30),
3737
]
3838

3939
def read_pdf(self, filename, password, output="dict"):

0 commit comments

Comments
 (0)