fix(sp28): align Batch.kind filter with prod ('837p' not '837')
The SP28 helpers (batch_envelope_index + lookup_claims_for_ack_set_response + two _batch_lookup closures in handle_ta1 + api.py) all filter Batch.kind == "837", but prod Batch rows are persisted with kind="837p" (lowercase p — see api.py:443 / store/records.py:58). Result: the D10 batch-envelope index was empty on prod and zero 999 / 277CA / TA1 acks auto-linked to their claims via Pass 1 (ST02 via batch.envelope.control_number). Pass 2 (PCN) was the only path firing, which on this codebase matches 0 acks (Gainwell's 999 echoes the 837's ST02, not its CLM01 — see spec §D10). Fix: 4 production sites swapped to Batch.kind == "837p". 3 test files updated to use the prod value (test_apply_claim_ack_links.py + test_api_claim_acks.py + test_e2e_999_to_claim_drawer.py). All 25 SP28 tests + 20 handler tests pass. Expected prod effect: claim t991102989o1c120d's 143 incoming 999 AK2 acks now auto-link via the batch with envelope.control_number=991102989 (Pass 1), plus 727/1,398 total acks across all batches.
This commit is contained in:
@@ -941,7 +941,7 @@ async def parse_ta1_endpoint(
|
|||||||
rows = (
|
rows = (
|
||||||
link_s.query(Batch)
|
link_s.query(Batch)
|
||||||
.filter(
|
.filter(
|
||||||
Batch.kind == "837",
|
Batch.kind == "837p",
|
||||||
Batch.raw_result_json.isnot(None),
|
Batch.raw_result_json.isnot(None),
|
||||||
)
|
)
|
||||||
.order_by(Batch.parsed_at.desc())
|
.order_by(Batch.parsed_at.desc())
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ def lookup_claims_for_ack_set_response(
|
|||||||
# callers SHOULD pass the index.
|
# callers SHOULD pass the index.
|
||||||
rows = (
|
rows = (
|
||||||
session.query(Batch.id, Batch.raw_result_json)
|
session.query(Batch.id, Batch.raw_result_json)
|
||||||
.filter(Batch.kind == "837")
|
.filter(Batch.kind == "837p")
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
for bid, raw in rows:
|
for bid, raw in rows:
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ def handle(
|
|||||||
rows = (
|
rows = (
|
||||||
session.query(db.Batch)
|
session.query(db.Batch)
|
||||||
.filter(
|
.filter(
|
||||||
db.Batch.kind == "837",
|
db.Batch.kind == "837p",
|
||||||
db.Batch.raw_result_json.isnot(None),
|
db.Batch.raw_result_json.isnot(None),
|
||||||
)
|
)
|
||||||
.order_by(db.Batch.parsed_at.desc())
|
.order_by(db.Batch.parsed_at.desc())
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ def batch_envelope_index() -> dict[str, str]:
|
|||||||
with db.SessionLocal()() as s:
|
with db.SessionLocal()() as s:
|
||||||
rows = (
|
rows = (
|
||||||
s.query(Batch.id, Batch.raw_result_json)
|
s.query(Batch.id, Batch.raw_result_json)
|
||||||
.filter(Batch.kind == "837")
|
.filter(Batch.kind == "837p")
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
for bid, raw in rows:
|
for bid, raw in rows:
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ def _seed_batch_envelope(*, batch_id: str, envelope_control: str):
|
|||||||
with db.SessionLocal()() as s:
|
with db.SessionLocal()() as s:
|
||||||
b = Batch(
|
b = Batch(
|
||||||
id=batch_id,
|
id=batch_id,
|
||||||
kind="837",
|
kind="837p",
|
||||||
input_filename=f"{batch_id}.txt",
|
input_filename=f"{batch_id}.txt",
|
||||||
parsed_at=datetime(2026, 7, 2, 12, 0, tzinfo=timezone.utc),
|
parsed_at=datetime(2026, 7, 2, 12, 0, tzinfo=timezone.utc),
|
||||||
raw_result_json={
|
raw_result_json={
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ def _seed_batch(
|
|||||||
``batch_envelope_index``."""
|
``batch_envelope_index``."""
|
||||||
b = Batch(
|
b = Batch(
|
||||||
id=batch_id,
|
id=batch_id,
|
||||||
kind="837",
|
kind="837p",
|
||||||
input_filename=f"{batch_id}.txt",
|
input_filename=f"{batch_id}.txt",
|
||||||
parsed_at=datetime(2026, 7, 2, 12, 0, tzinfo=timezone.utc),
|
parsed_at=datetime(2026, 7, 2, 12, 0, tzinfo=timezone.utc),
|
||||||
raw_result_json={
|
raw_result_json={
|
||||||
@@ -378,7 +378,7 @@ def test_ta1_links_to_most_recent_matching_batch():
|
|||||||
def _batch_lookup(sender_id, receiver_id):
|
def _batch_lookup(sender_id, receiver_id):
|
||||||
rows = (
|
rows = (
|
||||||
s.query(Batch)
|
s.query(Batch)
|
||||||
.filter(Batch.kind == "837")
|
.filter(Batch.kind == "837p")
|
||||||
.order_by(Batch.parsed_at.desc())
|
.order_by(Batch.parsed_at.desc())
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ def _seed_batch_envelope(*, batch_id: str, envelope_control: str):
|
|||||||
with db.SessionLocal()() as s:
|
with db.SessionLocal()() as s:
|
||||||
b = Batch(
|
b = Batch(
|
||||||
id=batch_id,
|
id=batch_id,
|
||||||
kind="837",
|
kind="837p",
|
||||||
input_filename=f"{batch_id}.txt",
|
input_filename=f"{batch_id}.txt",
|
||||||
parsed_at=datetime(2026, 7, 2, 12, 0, tzinfo=timezone.utc),
|
parsed_at=datetime(2026, 7, 2, 12, 0, tzinfo=timezone.utc),
|
||||||
raw_result_json={
|
raw_result_json={
|
||||||
|
|||||||
Reference in New Issue
Block a user