Skip to main content

BankTransaction

Struct BankTransaction 

Source
pub struct BankTransaction {
Show 34 fields pub transaction_id: Uuid, pub account_id: Uuid, pub timestamp_initiated: DateTime<Utc>, pub timestamp_booked: DateTime<Utc>, pub timestamp_settled: Option<DateTime<Utc>>, pub amount: Decimal, pub currency: String, pub direction: Direction, pub channel: TransactionChannel, pub category: TransactionCategory, pub counterparty: CounterpartyRef, pub mcc: Option<MerchantCategoryCode>, pub reference: String, pub balance_before: Option<Decimal>, pub balance_after: Option<Decimal>, pub original_currency: Option<String>, pub original_amount: Option<Decimal>, pub fx_rate: Option<Decimal>, pub location_country: Option<String>, pub location_city: Option<String>, pub device_id: Option<String>, pub ip_address: Option<String>, pub is_authorized: bool, pub auth_code: Option<String>, pub status: TransactionStatus, pub parent_transaction_id: Option<Uuid>, pub is_suspicious: bool, pub suspicion_reason: Option<AmlTypology>, pub laundering_stage: Option<LaunderingStage>, pub case_id: Option<String>, pub is_spoofed: bool, pub spoofing_intensity: Option<f64>, pub scenario_id: Option<String>, pub scenario_sequence: Option<u32>,
}
Expand description

A bank transaction with full metadata and ground truth labels.

Fields§

§transaction_id: Uuid

Unique transaction identifier

§account_id: Uuid

Account ID

§timestamp_initiated: DateTime<Utc>

Timestamp when transaction was initiated

§timestamp_booked: DateTime<Utc>

Timestamp when transaction was booked

§timestamp_settled: Option<DateTime<Utc>>

Timestamp when transaction was settled

§amount: Decimal

Transaction amount (always positive)

§currency: String

Transaction currency (ISO 4217)

§direction: Direction

Transaction direction (inbound/outbound)

§channel: TransactionChannel

Transaction channel

§category: TransactionCategory

Transaction category

§counterparty: CounterpartyRef

Counterparty reference

§mcc: Option<MerchantCategoryCode>

Merchant category code (for card transactions)

§reference: String

Transaction reference/description

§balance_before: Option<Decimal>

Balance before transaction

§balance_after: Option<Decimal>

Balance after transaction

§original_currency: Option<String>

Original currency (if FX conversion)

§original_amount: Option<Decimal>

Original amount (if FX conversion)

§fx_rate: Option<Decimal>

FX rate applied

§location_country: Option<String>

Location (country code)

§location_city: Option<String>

Location (city)

§device_id: Option<String>

Device fingerprint (for online/mobile)

§ip_address: Option<String>

IP address (masked for output)

§is_authorized: bool

Whether transaction was authorized

§auth_code: Option<String>

Authorization code

§status: TransactionStatus

Transaction status

§parent_transaction_id: Option<Uuid>

Parent transaction ID (for reversals, fees)

§is_suspicious: bool

Whether transaction is suspicious (ground truth)

§suspicion_reason: Option<AmlTypology>

Suspicion reason (AML typology)

§laundering_stage: Option<LaunderingStage>

Money laundering stage

§case_id: Option<String>

Case ID linking suspicious transactions

§is_spoofed: bool

Whether transaction is spoofed (adversarial mode)

§spoofing_intensity: Option<f64>

Spoofing intensity (0.0-1.0)

§scenario_id: Option<String>

Scenario ID for linked transactions

§scenario_sequence: Option<u32>

Transaction sequence number within scenario

Implementations§

Source§

impl BankTransaction

Source

pub fn new( transaction_id: Uuid, account_id: Uuid, amount: Decimal, currency: &str, direction: Direction, channel: TransactionChannel, category: TransactionCategory, counterparty: CounterpartyRef, reference: &str, timestamp: DateTime<Utc>, ) -> Self

Create a new transaction.

Source

pub fn mark_suspicious(self, reason: AmlTypology, case_id: &str) -> Self

Mark as suspicious.

Source

pub fn with_laundering_stage(self, stage: LaunderingStage) -> Self

Set laundering stage.

Source

pub fn mark_spoofed(self, intensity: f64) -> Self

Mark as spoofed.

Source

pub fn with_scenario(self, scenario_id: &str, sequence: u32) -> Self

Set scenario information.

Source

pub fn with_mcc(self, mcc: MerchantCategoryCode) -> Self

Set MCC.

Source

pub fn with_location(self, country: &str, city: Option<&str>) -> Self

Set location.

Source

pub fn with_fx_conversion( self, original_currency: &str, original_amount: Decimal, rate: Decimal, ) -> Self

Set FX conversion.

Source

pub fn with_balance(self, before: Decimal, after: Decimal) -> Self

Set balance information.

Source

pub fn calculate_risk_score(&self) -> u8

Calculate risk score for the transaction.

Source

pub fn is_cash(&self) -> bool

Check if this is a cash transaction.

Source

pub fn is_cross_border(&self) -> bool

Check if this is a cross-border transaction.

Trait Implementations§

Source§

impl Clone for BankTransaction

Source§

fn clone(&self) -> BankTransaction

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BankTransaction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BankTransaction

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for BankTransaction

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,