domain

package
v0.0.0-...-3ca87c7 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountNotFound = errors.New("account not found")

	ErrAccountOriginNotFound = errors.New("account origin not found")

	ErrAccountDestinationNotFound = errors.New("account destination not found")

	ErrInsufficientBalance = errors.New("origin account does not have sufficient Balance")
)
View Source
var (
	ErrBranchNotFound = errors.New("Branch not found")
)
View Source
var (
	ErrCharityMrysNotFound = errors.New("CharityMrys not found")
)
View Source
var (
	ErrReceiptLunarDetailNotFound = errors.New("ReceiptLunarDetail not found")
)
View Source
var (
	ErrReceiptLunarNotFound = errors.New("ReceiptLunar not found")
)

Functions

func DeleteAccountBalance

func DeleteAccountBalance(success bool) bool

func DeleteBranch

func DeleteBranch(success bool) bool

func DeleteCharityMrys

func DeleteCharityMrys(success bool) bool

func DeleteReceiptLunar

func DeleteReceiptLunar(success bool) bool

func DeleteReceiptLunarDetail

func DeleteReceiptLunarDetail(success bool) bool

func IsValidUUID

func IsValidUUID(uuid string) bool

func NewUUID

func NewUUID() string

Types

type Account

type Account struct {
	Id        AccountID `json:"id" example:"1"`
	Name      string    `json:"name" example:"Leo Messi"`
	Cpf       string    `json:"Cpf" example:"00.00.111.11"`
	Balance   Money     `json:"Balance" example:"40000"`
	CreatedAt time.Time `json:"created_at" example:"2019-11-09T21:21:46+00:00"`
}

func NewAccount

func NewAccount(ID AccountID, name, CPF string, balance Money, createdAt time.Time) Account

func NewAccountBalance

func NewAccountBalance(balance Money) Account

func (*Account) Deposit

func (a *Account) Deposit(amount Money)

func (Account) ID

func (a Account) ID() AccountID

func (*Account) Withdraw

func (a *Account) Withdraw(amount Money) error

type AccountID

type AccountID string

func (AccountID) String

func (a AccountID) String() string

type AccountRepository

type AccountRepository interface {
	Create(context.Context, Account) (Account, error)
	UpdateBalance(context.Context, AccountID, Money) error
	FindAll(context.Context) ([]Account, error)
	FindByID(context.Context, AccountID) (Account, error)
	DeleteByID(context.Context, AccountID) (bool, error)
	FindBalance(context.Context, AccountID) (Account, error)
}

type Branch

type Branch struct {
	Id          string    `gorm:"primaryKey" json:"id" example:"953c294b-4535-4656-9fd8-be58zzd0402a9a1x"`
	Code        string    `json:"code" example:"PTK"`
	Name        string    `json:"name" example:"Pontianak"`
	Address     string    `json:"address" example:"Pontianak"`
	Description string    `json:"Description" example:"description"`
	CreatedAt   time.Time `json:"created_at" example:"2019-11-09T21:21:46+00:00"`
}

func (Branch) TableName

func (Branch) TableName() string

type BranchAll

type BranchAll struct {
	Data []Branch `json:"data"`
}

type BranchPagination

type BranchPagination struct {
	Data []Branch       `json:"data"`
	Meta MetaPagination `json:"meta"`
}

type BranchRepository

type BranchRepository interface {
	Create(context.Context, Branch) (Branch, error)
	Update(context.Context, Branch, string) (Branch, error)
	FindPagination(context.Context, int, int, string, string) (BranchPagination, error)
	FindAll(context.Context) (BranchAll, error)
	FindByID(context.Context, string) (Branch, error)
	DeleteByID(context.Context, string) (bool, error)
}

type CharityMrys

type CharityMrys struct {
	Id          string    `gorm:"primaryKey" json:"id" example:"1"`
	Name        string    `json:"name" example:"Leo Messi"`
	Amount      Money     `json:"Amount" example:"40000"`
	Month       int32     `json:"Month" example:"1"`
	Year        int32     `json:"Year" example:"2021"`
	Description string    `json:"Description" example:"description"`
	UserID      string    `json:"user_id" example:"1"`
	Username    string    `json:"Userame" example:"usename"`
	BranchId    string    `json:"-"`
	Branch      Branch    `json:"branch" gorm:"foreignKey:BranchId;branch:ID"`
	CreatedAt   time.Time `json:"created_at" example:"2019-11-09T21:21:46+00:00"`
}

func NewCharityMrys

func NewCharityMrys(ID string, Name string, Amount Money, Month int32, Year int32, Description string, Branch Branch, createdAt time.Time) CharityMrys

type CharityMrysAll

type CharityMrysAll struct {
	Data []CharityMrys `json:"data"`
}

type CharityMrysPagination

type CharityMrysPagination struct {
	Data []CharityMrys  `json:"data"`
	Meta MetaPagination `json:"meta"`
}

type DeleteMessage

type DeleteMessage struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

type MetaPagination

type MetaPagination struct {
	PerPage     int    `json:"perPage"`
	CurrentPage int    `json:"currentPage"`
	TotalPage   int    `json:"totalPage"`
	Total       int64  `json:"total"`
	Offset      int    `json:"offset"`
	Sort        string `json:"sort"`
}

type Money

type Money int64

func (Money) Float64

func (m Money) Float64() float64

func (Money) Int64

func (m Money) Int64() int64

type ReceiptLunar

type ReceiptLunar struct {
	Id                 string               `gorm:"primaryKey" json:"id" example:"1"`
	InternationalDate  time.Time            `json:"internation_date" example:"2021-08-04"`
	LunarDate          string               `json:"lunar_date" example:"2021-08-04"`
	Description        string               `json:"description"`
	Total              Money                `json:"total" example:"40000"`
	UserID             string               `json:"user_id" example:"1"`
	Username           string               `json:"username" example:"username"`
	BranchId           string               `json:"-"`
	Branch             Branch               `json:"branch" gorm:"foreignKey:BranchId;branch:ID"`
	ReceiptLunarDetail []ReceiptLunarDetail `json:"receipt_lunar_detail"`
	CreatedAt          time.Time            `json:"created_at" example:"2019-11-09T21:21:46+00:00"`
}

func NewReceiptLunar

func NewReceiptLunar(Id string, InternationalDate time.Time, LunarDate string, Description string, Branch Branch, ReceiptLunarDetail []ReceiptLunarDetail, createdAt time.Time) ReceiptLunar

func (ReceiptLunar) ProcessDetail

func (r ReceiptLunar) ProcessDetail(ReceiptLunarDetailList []ReceiptLunarDetail) ReceiptLunar

type ReceiptLunarAll

type ReceiptLunarAll struct {
	Data []ReceiptLunar `json:"data"`
}

type ReceiptLunarDetail

type ReceiptLunarDetail struct {
	Id             string       `gorm:"primaryKey" json:"id" example:"1"`
	Name           string       `json:"name"`
	Description    string       `json:"description"`
	Total          Money        `json:"total" example:"40000"`
	ReceiptLunarId string       `json:"-"`
	ReceiptLunar   ReceiptLunar `json:"receipt_lunar" gorm:"foreignKey:ReceiptLunarId;receipt_lunar:ID"`
	CreatedAt      time.Time    `json:"created_at" example:"2019-11-09T21:21:46+00:00"`
}

func NewReceiptLunarDetail

func NewReceiptLunarDetail(Id string, Name string, Description string, Total Money, ReceiptLunar ReceiptLunar, createdAt time.Time) ReceiptLunarDetail

type ReceiptLunarDetailAll

type ReceiptLunarDetailAll struct {
	Data []ReceiptLunarDetail `json:"data"`
}

type ReceiptLunarDetailRepository

type ReceiptLunarDetailRepository interface {
	CreateBulk(context.Context, []ReceiptLunarDetail) ([]ReceiptLunarDetail, error)
	DeleteByReceiptLunarId(context.Context, string) (bool, error)
}

type ReceiptLunarPagination

type ReceiptLunarPagination struct {
	Data []ReceiptLunar `json:"data"`
	Meta MetaPagination `json:"meta"`
}

type ReceiptLunarRepository

type ReceiptLunarRepository interface {
	Create(context.Context, ReceiptLunar) (ReceiptLunar, error)
	// Update(context.Context, ReceiptLunar, string) (ReceiptLunar, error)
	FindPagination(context.Context, int, int, string, string) (ReceiptLunarPagination, error)
	FindByID(context.Context, string) (ReceiptLunar, error)
}

type Transfer

type Transfer struct {
	// contains filtered or unexported fields
}

func NewTransfer

func NewTransfer(
	ID TransferID,
	accountOriginID AccountID,
	accountDestinationID AccountID,
	amount Money,
	createdAt time.Time,
) Transfer

func (Transfer) AccountDestinationID

func (t Transfer) AccountDestinationID() AccountID

func (Transfer) AccountOriginID

func (t Transfer) AccountOriginID() AccountID

func (Transfer) Amount

func (t Transfer) Amount() Money

func (Transfer) CreatedAt

func (t Transfer) CreatedAt() time.Time

func (Transfer) ID

func (t Transfer) ID() TransferID

type TransferID

type TransferID string

func (TransferID) String

func (t TransferID) String() string

type TransferRepository

type TransferRepository interface {
	Create(context.Context, Transfer) (Transfer, error)
	FindAll(context.Context) ([]Transfer, error)
	WithTransaction(context.Context, func(context.Context) error) error
}

type UserJwt

type UserJwt struct {
	Username string `json:"username"`
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

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