Skip to main content

SimpleStatement

Struct SimpleStatement 

Source
pub struct SimpleStatement {
    pub account: String,
    pub currency: Option<String>,
    pub opening_date: NaiveDate,
    pub opening_amount: Decimal,
    pub closing_date: NaiveDate,
    pub closing_amount: Decimal,
    pub transactions: Vec<SimpleTransaction>,
}
Expand description

A statement: opening/closing balance plus the transactions in between.

Fields§

§account: String

IBAN (or other identification) of the account this statement belongs to.

§currency: Option<String>

Currency of the statement

§opening_date: NaiveDate

Date of the opening balance.

§opening_amount: Decimal

Opening balance, signed (negative when the account is overdrawn).

§closing_date: NaiveDate

Date of the closing balance.

§closing_amount: Decimal

Closing balance, signed (negative when the account is overdrawn).

§transactions: Vec<SimpleTransaction>

Transactions booked between the opening and closing balance.

Implementations§

Source§

impl SimpleStatement

Source

pub fn to_camt053(&self) -> Result<String, CamtError>

Renders this statement as a camt.053.001.02 XML document (a single Document/BkToCstmrStmt with one Stmt), including an XML declaration.

This is a minimal but schema-compliant mapping: every field of SimpleStatement and SimpleTransaction is represented, placed at the correct position of the camt.053.001.02 schema (see doc/camt.053.001.02.xsd), so no data is lost and the result validates against it. Elements that camt.053 requires but that have no equivalent in the simple model (such as bank transaction codes) are emitted as empty/minimal but valid placeholders.

§Errors

Returns CamtError::Xml if the XML serialization fails.

Source§

impl SimpleStatement

Source

pub fn from_statement(statement: &Statement) -> Result<Self, CamtError>

Builds a SimpleStatement from a raw schema::Statement, validating that the opening/closing balances match the transaction sum.

Source

pub fn from_document(doc: &Document) -> Result<Vec<SimpleStatement>, CamtError>

Converts a full camt.053 Document into a list of SimpleStatements.

Source§

impl SimpleStatement

Source

pub fn to_mt940(&self) -> String

Renders this statement as a single MT940 message.

Source

pub fn filename_940(&self) -> String

Suggested filename for the MT940 export of this statement, based on its opening and closing date.

Trait Implementations§

Source§

impl Clone for SimpleStatement

Source§

fn clone(&self) -> SimpleStatement

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SimpleStatement

Source§

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

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

impl<'a> IntoIterator for &'a SimpleStatement

Iterator for &SimpleStatement over its contained SimpleTransaction items.

Source§

type Item = &'a SimpleTransaction

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, SimpleTransaction>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for SimpleStatement

Source§

fn eq(&self, other: &SimpleStatement) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SimpleStatement

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> Same for T

Source§

type Output = T

Should always be Self
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.