customer

package
v0.0.0-...-e71251d Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID               string  `gorm:"primaryKey,default:gen_random_uuid()" json:"id"`
	AccountNumber    string  `json:"account_number" validate:"required"`
	TotalBalance     float64 `json:"total_balance" validate:"required,number"`
	AvaliableBalance float64 `json:"avaliable_balance" validate:"required,number"`
}

Account Area

func (*Account) AddMoney

func (account *Account) AddMoney(amount float64) error

func (*Account) GetAccountNumber

func (account *Account) GetAccountNumber() string

func (*Account) GetAvaliableBalance

func (account *Account) GetAvaliableBalance() float64

func (*Account) GetTotalBalance

func (account *Account) GetTotalBalance() float64

func (*Account) WithdrawMoney

func (account *Account) WithdrawMoney(amount float64) error

type BalanceInquiry

type BalanceInquiry struct {
	Transaction
	AccountId string `json:"account_id" validate:"required"`
}

func NewBalanceInquiry

func NewBalanceInquiry(accountId string, transaction Transaction) *BalanceInquiry

type Card

type Card struct {
	ID              string `gorm:"primaryKey,default:gen_random_uuid()" json:"id"`
	Number          string `json:"number"`
	CustomerName    string `json:"customer_name"`
	ExpirationMonth int    `json:"expiration_month"`
	ExpirationYear  int    `json:"expiration_year"`
	CVV             int    `json:"cvv"`
}

func NewCard

func NewCard(number, customerName string, expirationMonth, expirationYear, cvv int) *Card

func (*Card) Validate

func (c *Card) Validate() error

type CashDeposit

type CashDeposit struct {
	Deposit
	CashDepositLimit float64 `json:"cash_deposit_limit" validate:"required,number,gte=0"`
}

func NewCashDeposit

func NewCashDeposit(cashDepositLimit float64, deposit Deposit) *CashDeposit

type CheckDeposit

type CheckDeposit struct {
	Deposit
	CheckNumber string `json:"check_number" validate:"required"`
	BankCode    string `json:"bank_code" validate:"required"`
}

func NewCheckDeposit

func NewCheckDeposit(checkNumber, bankCode string, deposit Deposit) *CheckDeposit

type CheckingAccount

type CheckingAccount struct {
	Account
	DebitCardNumber string  `json:"debit_card_number"`
	WithdrawLimit   float64 `json:"withdraw_limit"`
}

type Customer

type Customer struct {
	ID        string               `gorm:"primaryKey,default:gen_random_uuid()" json:"id"`
	Name      string               `json:"name"`
	Email     string               `json:"email"`
	Phone     string               `json:"phone"`
	Status    CustomerStatus       `json:"status"`
	AddressID string               `json:"address_id"`
	Address   *valueObject.Address `json:"address"`
	AccountID string               `json:"account_id" `
	Account   IAccount             `json:"account" gorm:"-"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

func NewCustomer

func NewCustomer(name, email, phone string, address *valueObject.Address, card *Card, account IAccount) *Customer

func (*Customer) Validate

func (c *Customer) Validate() error

type CustomerStatus

type CustomerStatus string
const (
	ACTIVE      CustomerStatus = "Active"
	BLOCKED     CustomerStatus = "Blocked"
	BANNED      CustomerStatus = "Banned"
	COMPROMISED CustomerStatus = "Compromised"
	ARCHIVED    CustomerStatus = "Archived"
	CLOSED      CustomerStatus = "Closed"
	UNKNOWN     CustomerStatus = "Unknown"
)

type Deposit

type Deposit struct {
	Transaction
	Amount float64 `json:"amount" validate:"required,number,gt=0"`
}

func (*Deposit) CheckAmmount

func (d *Deposit) CheckAmmount() float64

type IAccount

type IAccount interface {
	AddMoney(amount float64) error
	WithdrawMoney(amount float64) error
	GetAccountNumber() string
	GetTotalBalance() float64
	GetAvaliableBalance() float64
}

func NewCheckingAccount

func NewCheckingAccount(accountNumber string, totalBalance, avaliableBalance float64, debitCardNumber string) IAccount

func NewSavingsAccount

func NewSavingsAccount(accountNumber string, totalBalance, avaliableBalance, withdrawLimit float64) IAccount

type IDeposit

type IDeposit interface {
	CheckAmmount() float64
}

type ITransaction

type ITransaction interface {
	DefineStatus(status TransactionStatus)
	CheckStatus() TransactionStatus
}

type SavingsAccount

type SavingsAccount struct {
	Account
	WithdrawLimit float64 `json:"withdraw_limit"`
}

SavingsAccount Area

type Transaction

type Transaction struct {
	ID        string            `json:"id" validate:"required" gorm:"primaryKey,default:gen_random_uuid()"`
	Status    TransactionStatus `json:"status" validate:"required"`
	CreatedAt time.Time         `json:"created_at"`
}

func (*Transaction) CheckStatus

func (t *Transaction) CheckStatus() TransactionStatus

func (*Transaction) DefineStatus

func (t *Transaction) DefineStatus(status TransactionStatus)

type TransactionStatus

type TransactionStatus string
const (
	SUCCESS     TransactionStatus = "Success"
	FAILURE     TransactionStatus = "Failure"
	INTERRUPTED TransactionStatus = "Interrupted"
	FULL        TransactionStatus = "Full"
	PARTIAL     TransactionStatus = "Partial"
	NONE        TransactionStatus = "None"
)

type Transfer

type Transfer struct {
	Transaction
	FromAccountNumber string  `json:"from_account_number" validate:"required"`
	ToAccountNumber   string  `json:"to_account_number" validate:"required"`
	Amount            float64 `json:"amount" validate:"required,number,gt=0"`
}

func NewTransfer

func NewTransfer(fromAccountNumber, toAccountNumber string, amount float64, transaction Transaction) *Transfer

type Withdrawal

type Withdrawal struct {
	Transaction
	Amount float64 `json:"amount" validate:"required,number,gt=0"`
}

func NewWithdrawal

func NewWithdrawal(transaction Transaction, amount float64) *Withdrawal

Jump to

Keyboard shortcuts

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