card

package
v0.0.0-...-b080cc2 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const PercentBonus int = 3

Variables

This section is empty.

Functions

func AddBonus

func AddBonus(card *types.Card, percent int, daysInMonth int, daysInYear int)
Example (Inactive)
card := types.Card{Balance: 20_000_00, Active: false}
AddBonus(&card, PercentBonus, 30, 365)
fmt.Println(card.Balance)
Output:

2000000
Example (Limit)
card := types.Card{Balance: 3_000_000_00, Active: true}
AddBonus(&card, PercentBonus, 30, 365)
fmt.Println(card.Balance)
Output:

300500000
Example (NoMoney)
card := types.Card{Balance: -10, Active: true}
AddBonus(&card, PercentBonus, 30, 365)
fmt.Println(card.Balance)
Output:

-10
Example (Positive)
card := types.Card{Balance: 10_000_00, Active: true}
AddBonus(&card, PercentBonus, 30, 365)
fmt.Println(card.Balance)
Output:

1002465

func Deposit

func Deposit(card *types.Card, amount types.Money)
Example (Inactive)
card := types.Card{Balance: 20_000_00, Active: false}
Deposit(&card, 10_000_00)
fmt.Println(card.Balance)
Output:

2000000
Example (Limit)
card := types.Card{Balance: 200_000_00, Active: true}
Deposit(&card, 60_000_00)
fmt.Println(card.Balance)
Output:

20000000
Example (Positive)
card := types.Card{Balance: 20_000_00, Active: true}
Deposit(&card, 10_000_00)
fmt.Println(card.Balance)
Output:

3000000

func IssueCard

func IssueCard(currency types.Currency, color string, name string) types.Card

func PaymentSources

func PaymentSources(cards []types.Card) []types.PaymentSource
Example
cards := []types.Card{
	{
		Balance: 10_000_00,
		Active:  true,
		PAN:     "12121 21212 1212",
	},
	{
		Balance: 50_000_00,
		Active:  true,
		PAN:     "12121 12 1212",
	},
	{
		Balance: -10_000_00,
		Active:  false,
		PAN:     "12121 21212 1212",
	},
}
paymentSources := PaymentSources(cards)

fmt.Println(len(paymentSources))
Output:

2

func Total

func Total(cards []types.Card) types.Money
Example
cards := []types.Card{
	{
		Balance: 10_000_00,
		Active:  true,
	},
	{
		Balance: 10_000_00,
		Active:  false,
	},
	{
		Balance: -10_000_00,
		Active:  false,
	},
}
fmt.Println(Total(cards))
Output:

1000000

func Withdraw

func Withdraw(card *types.Card, amount types.Money)
Example (Inactive)
card := types.Card{Balance: 20_000_00, Active: false}
Withdraw(&card, 10_000_00)
fmt.Println(card.Balance)
Output:

2000000
Example (Limit)
card := types.Card{Balance: 200_000_00, Active: true}
Withdraw(&card, 30_000_00)
fmt.Println(card.Balance)
Output:

20000000
Example (NoMoney)
card := types.Card{Balance: 0, Active: true}
Withdraw(&card, 10_000_00)
fmt.Println(card.Balance)
Output:

0
Example (Positive)
card := types.Card{Balance: 20_000_00, Active: true}
Withdraw(&card, 10_000_00)
fmt.Println(card.Balance)
Output:

1000000

Types

This section is empty.

Jump to

Keyboard shortcuts

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