bank

package
v0.0.0-...-f3f6071 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BICMinLength = 8
	BICMaxLength = 11
)
View Source
const (
	IBANMinLength = 15
	IBANMaxLength = 32
)

Variables

View Source
var BICFinder bicFinder
View Source
var IBANFinder ibanFinder

Functions

func StringIsBIC

func StringIsBIC(str string) bool

func StringIsIBAN

func StringIsIBAN(str string) bool

StringIsIBAN returns if a string can be parsed as IBAN.

Types

type AccountType

type AccountType string

AccountType holds the type of a bank account. AccountType implements the database/sql.Scanner and database/sql/driver.Valuer interfaces, and will treat an empty string AccountType as SQL NULL value.

var (
	// AccountTypeCurrent is a checking account type
	AccountTypeCurrent AccountType = "CURRENT"
	// AccountTypeSavings is a savings account type
	AccountTypeSavings AccountType = "SAVINGS"
)

func (*AccountType) Scan

func (t *AccountType) Scan(value any) error

Scan implements the database/sql.Scanner interface.

func (AccountType) Valid

func (t AccountType) Valid() bool

func (AccountType) Value

func (t AccountType) Value() (driver.Value, error)

Value implements the driver database/sql/driver.Valuer interface.

type BIC

type BIC string

BIC is a SWIFT Business Identifier Code (also know as SWIFT-Code). BIC implements the database/sql.Scanner and database/sql/driver.Valuer interfaces and will treat an empty BIC string as SQL NULL value.

func ValidateBIC

func ValidateBIC(str string) (BIC, error)

ValidateBIC returns str as valid BIC or an error.

func (BIC) CountryCode

func (bic BIC) CountryCode() country.Code

CountryCode of the BIC. May be invalid if the BIC is invalid.

func (BIC) IsPassiveSWIFT

func (bic BIC) IsPassiveSWIFT() bool

func (BIC) IsTestBIC

func (bic BIC) IsTestBIC() bool

func (BIC) Nullable

func (bic BIC) Nullable() NullableBIC

Nullable returns the BIC as NullableBIC

func (BIC) Parse

func (bic BIC) Parse() (bankCode string, countryCode country.Code, branchCode string, isValid bool)

func (BIC) ReceiverPaisFees

func (bic BIC) ReceiverPaisFees() bool

func (*BIC) Scan

func (bic *BIC) Scan(value any) error

Scan implements the database/sql.Scanner interface.

func (*BIC) ScanString

func (bic *BIC) ScanString(source string, validate bool) error

ScanString tries to parse and assign the passed source string as value of the implementing type.

If validate is true, the source string is checked for validity before it is assigned to the type.

If validate is false and the source string can still be assigned in some non-normalized way it will be assigned without returning an error.

func (BIC) TrimBranchCode

func (bic BIC) TrimBranchCode() BIC

func (BIC) Valid

func (bic BIC) Valid() bool

Valid returns if this is a valid SWIFT Business Identifier Code

func (BIC) Validate

func (bic BIC) Validate() error

Validate returns an error if this is not a valid SWIFT Business Identifier Code

func (BIC) Value

func (bic BIC) Value() (driver.Value, error)

Value implements the driver database/sql/driver.Valuer interface.

type BICParser

type BICParser struct{}

BICParser implements the strfmt.Parser interface for BICs.

func (BICParser) Parse

func (BICParser) Parse(str string, langHints ...language.Code) (normalized string, err error)

type CAMT53

type CAMT53 struct {
	MessageID            string          `xml:"BkToCstmrStmt>GrpHdr>MsgId"`
	Created              time.Time       `xml:"BkToCstmrStmt>GrpHdr>CreDtTm"`
	StatementID          string          `xml:"BkToCstmrStmt>Stmt>Id"`
	ElectronicSequenceNr string          `xml:"BkToCstmrStmt>Stmt>ElctrncSeqNb,omitempty"`
	LegalSequenceNr      string          `xml:"BkToCstmrStmt>Stmt>LglSeqNb,omitempty"`
	FromDate             time.Time       `xml:"BkToCstmrStmt>Stmt>FrToDt>FrDtTm"`
	ToDate               time.Time       `xml:"BkToCstmrStmt>Stmt>FrToDt>ToDtTm"`
	IBAN                 IBAN            `xml:"BkToCstmrStmt>Stmt>Acct>Id>IBAN"`
	Currency             money.Currency  `xml:"BkToCstmrStmt>Stmt>Acct>Ccy"`
	BankName             string          `xml:"BkToCstmrStmt>Stmt>Acct>Svcr>FinInstnId>Nm,omitempty"`
	BIC                  BIC             `xml:"BkToCstmrStmt>Stmt>Acct>Svcr>FinInstnId>BIC"`
	Balance              []CAMT53Balance `xml:"BkToCstmrStmt>Stmt>Bal"`
	Entries              []CAMT53Entry   `xml:"BkToCstmrStmt>Stmt>Ntry"`
}

func ParseCAMT53XML

func ParseCAMT53XML(ctx context.Context, file fs.File) (camt *CAMT53, err error)

type CAMT53Amount

type CAMT53Amount struct {
	Amount   money.Amount   `xml:",chardata"`
	Currency money.Currency `xml:"Ccy,attr"`
}

type CAMT53Balance

type CAMT53Balance struct {
	Type          string       `xml:"Tp>CdOrPrtry>Cd"` // PRCD: Endsaldo gebucht vorheriger Auszug   "MSIN" "CNFA" "DNFA" "CINV" "CREN" "DEBN" "HIRI" "SBIN" "CMCN" "SOAC" "DISP" "BOLD" "VCHR" "AROI" "TSUT"
	Proprietary   string       `xml:"Tp>CdOrPrtry>Prtry"`
	Amount        CAMT53Amount `xml:"Amt"`
	CreditOrDebit string       `xml:"CdtDbtInd"` // Soll (DBIT) oder Haben (CRDT)
	Date          date.Date    `xml:"Dt>Dt"`
}

type CAMT53Entry

type CAMT53Entry struct {
	Amount        CAMT53Amount `xml:"Amt"`
	CreditOrDebit string       `xml:"CdtDbtInd"` // Soll (DBIT) oder Haben (CRDT)
	Status        string       `xml:"Sts"`       // BOOK, PDNG, INFO
	BookingDate   date.Date    `xml:"BookgDt>Dt"`
	ValueDate     date.Date    `xml:"ValDt>Dt"`
	ReferenceCode string       `xml:"AcctSvcrRef"`
	// BkTxCd
	DebitorName  string   `xml:"NtryDtls>TxDtls>RltdPties>Dbtr>Nm"`
	DebitorAddr  []string `xml:"NtryDtls>TxDtls>RltdPties>Dbtr>PstlAdr>AdrLine,omitempty"`
	DebitorIBAN  IBAN     `xml:"NtryDtls>TxDtls>RltdPties>DbtrAcct>Id>IBAN"`
	CreditorName string   `xml:"NtryDtls>TxDtls>RltdPties>Cdtr>Nm"`
	CreditorAddr []string `xml:"NtryDtls>TxDtls>RltdPties>Cdtr>PstlAdr>AdrLine,omitempty"`
	CreditorIBAN IBAN     `xml:"NtryDtls>TxDtls>RltdPties>CdtrAcct>Id>IBAN"`
	DebitorBIC   BIC      `xml:"NtryDtls>TxDtls>RltdAgts>DbtrAgt>FinInstnId>BIC"`
	CreditorBIC  BIC      `xml:"NtryDtls>TxDtls>RltdAgts>CdtrAgt>FinInstnId>BIC"`
	Reference    string   `xml:"NtryDtls>TxDtls>RmtInf>Strd>CdtrRefInf>Ref"`
}

type IBAN

type IBAN string

IBAN is a International Bank Account Number. IBAN implements the database/sql.Scanner and database/sql/driver.Valuer interfaces, and will treat an empty IBAN string as SQL NULL value.

func NormalizeIBAN

func NormalizeIBAN(str string) (IBAN, error)

NormalizeIBAN returns str as normalized IBAN or an error.

func (*IBAN) BankAndAccountNumbers

func (iban *IBAN) BankAndAccountNumbers() (bankNo, accountNo string, err error)

func (IBAN) CountryCode

func (iban IBAN) CountryCode() country.Code

CountryCode returns the country code of the IBAN. May be invalid if the IBAN is invalid.

func (IBAN) Normalized

func (iban IBAN) Normalized() (IBAN, error)

Normalized returns the iban in normalized form, or an error if the format can't be detected.

func (IBAN) NormalizedOrNull

func (iban IBAN) NormalizedOrNull() NullableIBAN

func (IBAN) NormalizedOrUnchanged

func (iban IBAN) NormalizedOrUnchanged() IBAN

func (IBAN) NormalizedWithSpaces

func (iban IBAN) NormalizedWithSpaces() (IBAN, error)

NormalizedWithSpaces returns the iban in normalized form with spaces every 4 characters, or an error if the format can't be detected.

func (IBAN) Nullable

func (iban IBAN) Nullable() NullableIBAN

Nullable returns the IBAN as NullableIBAN

func (*IBAN) Scan

func (iban *IBAN) Scan(value any) error

Scan implements the database/sql.Scanner interface.

func (*IBAN) ScanString

func (iban *IBAN) ScanString(source string, validate bool) error

ScanString tries to parse and assign the passed source string as value of the implementing type.

If validate is true, the source string is checked for validity before it is assigned to the type.

If validate is false and the source string can still be assigned in some non-normalized way it will be assigned without returning an error.

func (IBAN) String

func (iban IBAN) String() string

String returns the normalized IBAN string if possible, else it will be returned unchanged as string. String implements the fmt.Stringer interface.

func (IBAN) Valid

func (iban IBAN) Valid() bool

Valid returns if this is a valid International Bank Account Number

func (IBAN) ValidAndNormalized

func (iban IBAN) ValidAndNormalized() bool

func (IBAN) Validate

func (iban IBAN) Validate() error

Validate returns an error if this is not a valid International Bank Account Number

func (IBAN) Value

func (iban IBAN) Value() (driver.Value, error)

Value implements the driver database/sql/driver.Valuer interface.

type IBANParser

type IBANParser struct{}

IBANParser implements the strfmt.Parser interface for IBANs.

func (IBANParser) Parse

func (IBANParser) Parse(str string, langHints ...language.Code) (normalized string, err error)

type NullableBIC

type NullableBIC string

NullableBIC is a BIC value which can hold an emtpy string ("") as the null value.

const BICNull NullableBIC = ""

BICNull is an empty string and will be treatet as SQL NULL.

func (NullableBIC) Get

func (bic NullableBIC) Get() BIC

Get returns the non nullable BIC value or panics if the NullableBIC is null. Note: check with IsNull before using Get!

func (NullableBIC) GetOr

func (bic NullableBIC) GetOr(defaultBIC BIC) BIC

GetOr returns the non nullable BIC value or the passed defaultBIC if the NullableBIC is null.

func (NullableBIC) IsNotNull

func (bic NullableBIC) IsNotNull() bool

func (NullableBIC) IsNull

func (bic NullableBIC) IsNull() bool

IsNull returns true if the NullableBIC is null. IsNull implements the nullable.Nullable interface.

func (NullableBIC) MarshalJSON

func (bic NullableBIC) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler by returning the JSON null value for an empty (null) string.

func (*NullableBIC) Scan

func (bic *NullableBIC) Scan(value any) error

Scan implements the database/sql.Scanner interface.

func (*NullableBIC) ScanString

func (bic *NullableBIC) ScanString(source string, validate bool) error

ScanString tries to parse and assign the passed source string as value of the implementing type.

If validate is true, the source string is checked for validity before it is assigned to the type.

If validate is false and the source string can still be assigned in some non-normalized way it will be assigned without returning an error.

func (*NullableBIC) Set

func (bic *NullableBIC) Set(id BIC)

Set sets an BIC for this NullableBIC

func (*NullableBIC) SetNull

func (bic *NullableBIC) SetNull()

SetNull sets the NullableBIC to null

func (NullableBIC) StringOr

func (bic NullableBIC) StringOr(defaultString string) string

StringOr returns the NullableBIC as string or the passed defaultString if the NullableBIC is null.

func (NullableBIC) Valid

func (bic NullableBIC) Valid() bool

Valid returns true if bic is null or a valid SWIFT Business Identifier Code

func (NullableBIC) ValidAndNotNull

func (bic NullableBIC) ValidAndNotNull() bool

ValidAndNotNull returns true if bic is not null and a valid SWIFT Business Identifier Code

func (NullableBIC) Validate

func (bic NullableBIC) Validate() error

Validate returns an error if this is not a valid SWIFT Business Identifier Code

func (NullableBIC) Value

func (bic NullableBIC) Value() (driver.Value, error)

Value implements the driver database/sql/driver.Valuer interface.

type NullableIBAN

type NullableIBAN string

NullableIBAN is a IBAN value which can hold an emtpy string ("") as the null value.

const IBANNull NullableIBAN = ""

IBANNull is an empty string and will be treatet as SQL NULL.

func (NullableIBAN) CountryCode

func (iban NullableIBAN) CountryCode() country.Code

CountryCode returns the country code of the IBAN

func (NullableIBAN) Get

func (iban NullableIBAN) Get() IBAN

Get returns the non nullable IBAN value or panics if the NullableIBAN is null. Note: check with IsNull before using Get!

func (NullableIBAN) GetOr

func (iban NullableIBAN) GetOr(defaultIBAN IBAN) IBAN

GetOr returns the non nullable IBAN value or the passed defaultIBAN if the NullableIBAN is null.

func (NullableIBAN) IsNotNull

func (iban NullableIBAN) IsNotNull() bool

func (NullableIBAN) IsNull

func (iban NullableIBAN) IsNull() bool

IsNull returns true if the NullableIBAN is null. IsNull implements the nullable.Nullable interface.

func (NullableIBAN) MarshalJSON

func (iban NullableIBAN) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler by returning the JSON null value for an empty (null) string.

func (NullableIBAN) Normalized

func (iban NullableIBAN) Normalized() (NullableIBAN, error)

Normalized returns the iban in normalized form, or an error if the format can't be detected.

func (NullableIBAN) NormalizedOrUnchanged

func (iban NullableIBAN) NormalizedOrUnchanged() NullableIBAN

NormalizedOrUnchanged returns the iban in normalized form, or unchanged if the format has an error.

func (NullableIBAN) NormalizedWithSpaces

func (iban NullableIBAN) NormalizedWithSpaces() (NullableIBAN, error)

NormalizedWithSpaces returns the iban in normalized form with spaces every 4 characters, or an error if the format can't be detected.

func (*NullableIBAN) Scan

func (iban *NullableIBAN) Scan(value any) error

Scan implements the database/sql.Scanner interface.

func (*NullableIBAN) ScanString

func (iban *NullableIBAN) ScanString(source string, validate bool) error

ScanString tries to parse and assign the passed source string as value of the implementing type.

If validate is true, the source string is checked for validity before it is assigned to the type.

If validate is false and the source string can still be assigned in some non-normalized way it will be assigned without returning an error.

func (*NullableIBAN) Set

func (iban *NullableIBAN) Set(id IBAN)

Set sets an IBAN for this NullableIBAN

func (*NullableIBAN) SetNull

func (iban *NullableIBAN) SetNull()

SetNull sets the NullableIBAN to null

func (NullableIBAN) String

func (iban NullableIBAN) String() string

String returns the normalized IBAN string if possible, else it will be returned unchanged as string. String implements the fmt.Stringer interface.

func (NullableIBAN) StringOr

func (iban NullableIBAN) StringOr(defaultString string) string

StringOr returns the NullableIBAN as string or the passed defaultString if the NullableIBAN is null.

func (NullableIBAN) Valid

func (iban NullableIBAN) Valid() bool

Valid returns true if iban is null or a valid International Bank Account Number

func (NullableIBAN) ValidAndNormalized

func (iban NullableIBAN) ValidAndNormalized() bool

func (NullableIBAN) ValidAndNotNull

func (iban NullableIBAN) ValidAndNotNull() bool

ValidAndNotNull returns true if iban is not null and a valid International Bank Account Number

func (NullableIBAN) Validate

func (iban NullableIBAN) Validate() error

Validate returns an error if this is not null and not a valid International Bank Account Number

func (NullableIBAN) Value

func (iban NullableIBAN) Value() (driver.Value, error)

Value implements the driver database/sql/driver.Valuer interface.

type PaymentStatus

type PaymentStatus string
const (
	PaymentStatusCreated  PaymentStatus = "CREATED"
	PaymentStatusFinished PaymentStatus = "FINISHED"
	PaymentStatusFailed   PaymentStatus = "FAILED"
)

type TransactionType

type TransactionType string
const (
	TransactionTypeIncoming TransactionType = "INCOMING"
	TransactionTypeOutgoing TransactionType = "OUTGOING"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL