BAI2 Citi Bank
Describes how the Citibank BAI2 parser identifies and parses Citi Bank and Amagi variant files, including record structure, currency and fund-type handling, configuration parameters, and additional regex-based capabilities for original amounts, FX rates, and bank charges.
How to identify this file
First line ends with 2/. Currency appears in the bank header record (02,) at field index 6.
Record Parsing
02 – Bank Header
Bank ID, as-of date, currency → [2], [4], [6]
03 – Account Header
Account number, currency, sign → [1], [2], [4]
16 – Transaction Detail
Type code, amount, fund type, refs → [1]–[5] (varies)
88 – Continuation
Narrative appended to previous record → full line
Fund Type Handling (16 Record)
Z / 0 / 1 / 2 / blank
Date: Bank header
Bank ref [4], Customer ref [5]
V (Value date)
Date: From record
Value date [4], time [5], Bank ref [6], Customer ref [7]
S (Scheduled)
Date: Bank header
Immediate [4], +1 [5], +2 [6], Bank ref [7], Customer ref [8]
Currency handling: Citibank is the only BAI2 parser that reads currency from the bank header (token[6] of the 02 record). Account-level currency overrides it if present. Decimal places are derived from the Java platform's standard Currency class.
Amount sign: If the account header amount sign starts with +, the + prefix is stripped from the transaction amount before parsing.
Special behavior — INR files: If the file-level currency (from bank header) is INR, the customer account reference number is used as the payment reference instead of the bank reference number. This is specific to Indian customer payments.
Configuration parameters
allowed_detail_type_codes: Process only specified transaction type codes; others are skipped
remove_preceding_zeroes_from_bank_account_no: Strips leading zeros from account number
detail_type_code_to_mode_map: Maps detail type codes to payment modes (e.g., wire, ACH)
source_field_to_custom_field_mapping: Maps parsed fields (e.g., bank ref) to system custom fields
exchange_rate_regex: Regex for extracting FX rate (Amagi variant only)
original_amount_regex: Regex for extracting original amount (Amagi variant only)
bank_charge_regexes: Regex patterns for extracting bank charges (Amagi variant only)
What is parsed: Transaction amount, currency, date, bank account number, bank reference number, customer reference number, detail type code, narrative description (from 88, continuation records), raw data
What is not parsed: File header (01), account/batch/file trailers (49, 98, 99), account summary records, opening/closing balances, FX rates (standard variant)
Amagi Variant: Amagi Citibank BAI2
How to identify this file: Identical file format to Citibank BAI2. This is not a different file format — it is the same Citibank BAI2 parser with additional post-processing applied on top. The difference is entirely in how the parsed transaction data is then processed.
Additional capabilities on top of Citibank BAI2
A. Original Amount Extraction (via original_amount_regex)
The transaction description (from 88, continuation records) is scanned with a regex. The regex must produce two capture groups: group 1 = original currency code, group 2 = original amount (integer, same encoding as BAI2 amounts). If matched, the originalCurrency and originalAmount are set on the payment record.
B. Exchange Rate Extraction (via exchange_rate_regex)
The description is scanned for an FX rate. If found, it is stored as the chart-of-account exchange rate on the payment.
C. Bank Charge Computation (via bank_charge_regexes, feature-flag controlled)
Multiple regexes can be configured. Each regex scans the description for a currency code (group 1) + charge amount (group 2). All matched charges are summed and stored as a BANK_CHARGE adjustment against the payment.
D. Back-Computation of Original Transaction Details
If original currency ≠ received currency, the parser uses the extracted exchange rate (or calls the exchange rate service) to convert the received amount back to the original currency, adjusting the payment amount and currency accordingly.
E. Feature flag
BANK_CHARGE_ADJUSTMENT must be enabled for bank charge parsing and back-computation to run. If the flag is off, only original amount and FX rate extraction run.
What is parsed (on top of base Citibank BAI2): Original payment currency and amount (extracted from description text), FX rate, bank charges as adjustments
What is not parsed: Bank charges when the feature flag is disabled; FX computations when no exchange rate regex is configured