Skip to content

Axis

pipelines.extraction.pdf.banks.axis

Summary

Axis bank-specific port implementations (pdf statement path).


Banks EXTEND the concrete Impl* classes — they never reinvent the ABC contracts. Each Axis* class overrides only the behavior that DIFFERS from the common Impl*; anything shared is inherited. The pipeline root AxisPdfExtractionPipeline pins only the stage slots that differ.

Classes

AxisAmountBalancePort

Bases: ImplAmountBalancePort

Axis amount/balance leaf — pins the Axis number leaf.

Functions
adjust_balance
adjust_balance(balance: float, line: str) -> float

Adjust an OCR balance (no-op base).

Parameters:

Name Type Description Default
balance float

OCR balance.

required
line str

Transaction line.

required

Returns:

Name Type Description
float float

The balance, unmodified.

missing_number_candidates
missing_number_candidates(ctx)

Provide candidates for one-number lines (no-op base).

Parameters:

Name Type Description Default
ctx

The active ResolutionContext.

required

Returns:

Type Description

None.

resolve
resolve(amount, balance, prev_balance, line, numbers=None)

Resolve (amount, balance) via ResolutionContext.

Parameters:

Name Type Description Default
amount

OCR amount.

required
balance

OCR balance (adjusted first).

required
prev_balance

Previous transaction balance.

required
line

Raw transaction line.

required
numbers

Extracted numbers; default None.

None

Returns:

Type Description

(signed amount, resolved balance) tuple.

AxisBucketFinderPort

Bases: ImplBucketFinderPort

Axis bucket finder — pins the Axis number leaf.

Functions
get_opening_balance_buckets
1
2
3
get_opening_balance_buckets(
    lines, *, limit_first=False, line_offset=0
)

Divide raw lines into opening-balance buckets.

Parameters:

Name Type Description Default
lines

Raw text lines.

required
limit_first

Keep only the first bucket.

False
line_offset

Offset added to starting indices.

0

Returns:

Type Description

List of (start, end, opening_balance) triples.

AxisDescPort

Bases: ImplDescPort

Axis description leaf — slices at UPI/IMPS/NEFT/ACH/2A markers.

Attributes:

Name Type Description
starters List[str]

Description starter markers.

Functions
extract_description
extract_description(description: str) -> str

Extract and clean the transaction description.

Parameters:

Name Type Description Default
description str

Raw description text.

required

Returns:

Name Type Description
str str

Cleaned description.

Raises:

Type Description
NotImplementedError

When no starters are configured.

fix_ocr
fix_ocr(text: str) -> str

Fix OCR artifacts in the description text (no-op base).

Parameters:

Name Type Description Default
text str

Text to fix.

required

Returns:

Name Type Description
str str

Fixed text.

AxisNumberPort

Bases: ImplNumberPort

Axis number leaf — returns every number in the line.

Functions
get_numbers
get_numbers(line: str) -> List[float]

Extract every cleaned number from the line.

Parameters:

Name Type Description Default
line str

Text line to scan.

required

Returns:

Type Description
List[float]

List[float]: All cleaned numbers in the line.

get_opening_balance
get_opening_balance(line: str) -> Optional[float]

Return the last number as the opening balance.

Parameters:

Name Type Description Default
line str

Text line to scan.

required

Returns:

Type Description
Optional[float]

Optional[float]: The last number, else None.

AxisPdfExtractionPipeline

Bases: ImplPDFExtractionPipeline

Axis pdf graph root — pins the Axis txn-blocks and txn-dicts stages.

Attributes:

Name Type Description
txn_blocks AxisTxnBlocksPort

Axis txn-blocks stage.

txn_dicts AxisTxnDictsPort

Axis txn-dicts stage.

Functions
run
run(source)

Run the pdf extraction chain end-to-end.

Parameters:

Name Type Description Default
source

Raw extraction source.

required

Returns:

Type Description

List of raw expense records.

AxisSplitterPort

Bases: ImplSplitterPort

Axis splitter — pins the Axis number leaf.

Functions
split_blocks
1
2
3
4
5
6
7
split_blocks(
    lines,
    *,
    has_header=False,
    min_numbers=3,
    detect_date_ranges=False
)

Split bucket lines into transaction blocks.

Parameters:

Name Type Description Default
lines

Bucket lines.

required
has_header

Whether a header precedes the rows.

False
min_numbers

Minimum numbers for a split.

3
detect_date_ranges

Detect date-range lines.

False

Returns:

Type Description

List of transaction block texts.

AxisTransactionParserPort

Bases: ImplTransactionParserPort

Axis transaction parser — pins Axis-stage leaves and min_numbers=2.

Attributes:

Name Type Description
number AxisNumberPort

Axis number leaf.

desc AxisDescPort

Axis description leaf.

amount_balance AxisAmountBalancePort

Axis amount/balance leaf.

min_numbers int

Minimum numbers for a block.

Functions
parse
parse(txn_text, prev_date_str, prev_balance)

Parse a transaction block into a txn dict.

Parameters:

Name Type Description Default
txn_text

Transaction block text.

required
prev_date_str

Previous transaction date string.

required
prev_balance

Running balance from the previous transaction.

required

Returns:

Type Description

Txn dict, or None when the block has no usable date/numbers.

AxisTxnBlocksPort

Bases: ImplTxnBlocksPort

Axis txn-blocks stage — header-scanning, date-range, min_numbers=2.

Attributes:

Name Type Description
bucket_finder AxisBucketFinderPort

Axis bucket finder.

splitter AxisSplitterPort

Axis splitter.

has_header bool

Header scan enabled.

min_numbers int

Minimum numbers for a block.

detect_date_ranges bool

Date-range detection enabled.

Functions
extract
extract(raw_lines)

Extract txn blocks keyed by opening balance.

Parameters:

Name Type Description Default
raw_lines

Raw OCR text lines.

required

Returns:

Type Description

Dict[float, List[str]]: Opening balance → block texts.

AxisTxnDictsPort

Bases: ImplTxnDictsPort

Axis txn-dicts stage — pins the Axis transaction parser.

Functions
extract
extract(txn_blocks)

Extract balance-chained txn dicts from blocks.

Parameters:

Name Type Description Default
txn_blocks

Opening balance → block texts.

required

Returns:

Type Description

List of txn dicts.

Functions