Class SwiftBalance
Collects all possible information from a SWIFT balance field.
public class SwiftBalance
- Inheritance
-
SwiftBalance
- Inherited Members
Remarks
This class is also suitable for collecting the balance information from a HBCI or FinTS data element group.
Constructors
SwiftBalance()
Creates a null balance.
public SwiftBalance()
SwiftBalance(decimal, string, SwiftDate)
Constructs a SwiftBalance instance with the given properties.
public SwiftBalance(decimal dcValue, string sCurrency, SwiftDate tDate)
Parameters
dcValue
decimalThe decimal balance value, which may be negative.
sCurrency
stringThe currency code.
tDate
SwiftDateThe date of this balance.
Exceptions
- ArgumentException
An invalid currency code was given.
Properties
Amount
The absolute amount of this balance.
public decimal Amount { get; }
Property Value
- decimal
The returned value is the absolute unsigned amount of the DecValue and therefore is always zero or positive.
Currency
The ISO currency code of the currency of this balance record.
public string Currency { get; set; }
Property Value
- string
An ISO currency code consisting of three upper case letters. If no currency code was set, or this property was set to
null
, then reading this property will return "XXX".
Exceptions
- ArgumentException
An attempt to set the currency code to a string that does not contain three upper case letters or digits will cause an ArgumentException to be thrown.
Date
The date of this balance record.
public SwiftDate Date { get; set; }
Property Value
- SwiftDate
This may be a null date.
DebitCreditFlag
The debit or credit flag of this balance.
public char DebitCreditFlag { get; }
Property Value
- char
The debit/credit flag is an upper case "C" for a credit (positive or zero balance) or an upper case "D" for a debit (negative non-zero balance).
DecValue
The actual decimal value of this balance.
public decimal DecValue { get; set; }
Property Value
- decimal
Any positive, negative or zero decimal value is allowed.
IsDebit
Indicates whether this is a positive or negative balance.
public bool IsDebit { get; }
Property Value
Time
The time of this balance record.
public SwiftTime Time { get; set; }
Property Value
Remarks
This property does not exist in ordinary SWIFT balance fields. It was added to the SwiftBalance as it does exist as an optional component in HBCI and FinTS balance data element groups.
Whenever the Time is not used or relevant it is set to the time 00:00:00 which also is its default value.
Methods
Add(decimal)
Add a decimal value to this balance.
public void Add(decimal dcValue)
Parameters
dcValue
decimalDecimal value to be added to this balance. This may be a negative value.
Clone()
Creates a copy of this balance.
public SwiftBalance Clone()
Returns
- SwiftBalance
New instance of SwiftBalance with all properties initialised to the same value as this instance.
Sub(decimal)
Subtract a decimal value from this balance.
public void Sub(decimal dcValue)
Parameters
dcValue
decimalDecimal value to be subtracted to this balance. This may be a negative value.
ToString()
Converts this balance into a SWIFT field content format.
public override string ToString()
Returns
- string
Balance formatted to fit as a SWIFT balance field content.
Remarks
Many SWIFT fields are defined to carry balance information. Most of these fields have all the same structure which is:
1!a6!n3!a15d
(D/C Mark) (Date) (Currency) (Amount)
A Debit/Credit Mark, followed by a date in the format YYMMDD, followed by a three letter currency code and finally the actual decimal amount.
This method generates a string according to this format. Note that any Time component is ignored in this representation.