transfer

package
v0.0.0-...-81673a4 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package transfer implements required logic to transfer money between accounts

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountInfo

type AccountInfo struct {
	Account      models.Account
	Currency     models.Currency
	ExchangeRate decimal.Decimal // ExchangeRate from Transfer Currency into Account Currency
}

type Result

type Result struct {
	From           models.Account
	To             models.Account
	TransferAmount decimal.Decimal
}

func BetweenAccounts

func BetweenAccounts(t Transfer) (*Result, error)

BetweenAccounts - transfers money between accounts. Supports transfering in/between different currencies. Actually transfer can be done in three(From Account Currency, To Account Currency, Transfer Currency) different currencies. It return error in next cases: - Transfering between same account - Negative transfer amount - From Account doesn't have enough money

type Transfer

type Transfer struct {
	From     AccountInfo
	To       AccountInfo
	Amount   decimal.Decimal
	Currency models.Currency
}

Jump to

Keyboard shortcuts

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