190 lines
6.6 KiB
Go
190 lines
6.6 KiB
Go
package domain
|
|
|
|
import "time"
|
|
|
|
type ShopTransactionType int
|
|
|
|
const (
|
|
TRANSACTION_CASHOUT ShopTransactionType = iota
|
|
TRANSACTION_DEPOSIT
|
|
TRANSACTION_BET
|
|
)
|
|
|
|
type PaymentOption int64
|
|
|
|
const (
|
|
CASH_TRANSACTION PaymentOption = iota
|
|
TELEBIRR_TRANSACTION
|
|
ARIFPAY_TRANSACTION
|
|
BANK
|
|
)
|
|
|
|
// ShopTransaction only represents branch transactions
|
|
// This is only used for statistic data
|
|
type ShopTransaction struct {
|
|
ID int64
|
|
Amount Currency
|
|
BranchID int64
|
|
CompanyID int64
|
|
UserID int64
|
|
Type ShopTransactionType
|
|
PaymentOption PaymentOption
|
|
FullName string
|
|
PhoneNumber string
|
|
// Payment Details for bank
|
|
BankCode ValidString
|
|
BeneficiaryName ValidString
|
|
AccountName ValidString
|
|
AccountNumber ValidString
|
|
ReferenceNumber ValidString
|
|
Verified bool
|
|
ApprovedBy ValidInt64
|
|
UpdatedAt time.Time
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
type ShopTransactionRes struct {
|
|
ID int64 `json:"id" example:"1"`
|
|
Amount float32 `json:"amount" example:"100.0"`
|
|
BranchID int64 `json:"branch_id" example:"1"`
|
|
BranchName string `json:"branch_name" example:"Branch Name"`
|
|
BranchLocation string `json:"branch_location" example:"Branch Location"`
|
|
CompanyID int64 `json:"company_id" example:"1"`
|
|
UserID int64 `json:"user_id" example:"1"`
|
|
CreatorFirstName string `json:"creator_first_name" example:"John"`
|
|
CreatorLastName string `json:"creator_last_name" example:"Smith"`
|
|
CreatorPhoneNumber string `json:"creator_phone_number" example:"0911111111"`
|
|
CashierName string `json:"cashier_name" example:"John Smith"`
|
|
Type int64 `json:"type" example:"1"`
|
|
PaymentOption PaymentOption `json:"payment_option" example:"1"`
|
|
FullName string `json:"full_name" example:"John Smith"`
|
|
PhoneNumber string `json:"phone_number" example:"0911111111"`
|
|
BankCode string `json:"bank_code"`
|
|
BeneficiaryName string `json:"beneficiary_name"`
|
|
AccountName string `json:"account_name"`
|
|
AccountNumber string `json:"account_number"`
|
|
ReferenceNumber string `json:"reference_number"`
|
|
Verified bool `json:"verified" example:"true"`
|
|
ApprovedBy int64 `json:"approved_by" example:"1"`
|
|
ApproverFirstName string `json:"approver_first_name" example:"John"`
|
|
ApproverLastName string `json:"approver_last_name" example:"Smith"`
|
|
ApproverPhoneNumber string `json:"approver_phone_number" example:"0911111111"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type ShopTransactionDetail struct {
|
|
ID int64
|
|
Amount Currency
|
|
BranchID int64
|
|
BranchName string
|
|
BranchLocation string
|
|
CompanyID int64
|
|
UserID int64
|
|
CreatorFirstName string
|
|
CreatorLastName string
|
|
CreatorPhoneNumber string
|
|
Type ShopTransactionType
|
|
PaymentOption PaymentOption
|
|
FullName string
|
|
PhoneNumber string
|
|
// Payment Details for bank
|
|
BankCode ValidString
|
|
BeneficiaryName ValidString
|
|
AccountName ValidString
|
|
AccountNumber ValidString
|
|
ReferenceNumber ValidString
|
|
Verified bool
|
|
ApprovedBy ValidInt64
|
|
ApproverFirstName ValidString
|
|
ApproverLastName ValidString
|
|
ApproverPhoneNumber ValidString
|
|
UpdatedAt time.Time
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
type ShopTransactionFilter struct {
|
|
CompanyID ValidInt64
|
|
BranchID ValidInt64
|
|
UserID ValidInt64
|
|
Query ValidString
|
|
CreatedBefore ValidTime
|
|
CreatedAfter ValidTime
|
|
}
|
|
type CreateShopTransaction struct {
|
|
Amount Currency
|
|
BranchID int64
|
|
CompanyID int64
|
|
UserID int64
|
|
Type ShopTransactionType
|
|
PaymentOption PaymentOption
|
|
FullName string
|
|
PhoneNumber string
|
|
// Payment Details for bank
|
|
BankCode ValidString
|
|
BeneficiaryName ValidString
|
|
AccountName ValidString
|
|
AccountNumber ValidString
|
|
ReferenceNumber ValidString
|
|
Verified bool
|
|
ApprovedBy ValidInt64
|
|
}
|
|
|
|
func ConvertShopTransaction(transaction ShopTransaction) ShopTransactionRes {
|
|
newTransaction := ShopTransactionRes{
|
|
ID: transaction.ID,
|
|
Amount: transaction.Amount.Float32(),
|
|
BranchID: transaction.BranchID,
|
|
CompanyID: transaction.CompanyID,
|
|
UserID: transaction.UserID,
|
|
Type: int64(transaction.Type),
|
|
PaymentOption: transaction.PaymentOption,
|
|
FullName: transaction.FullName,
|
|
PhoneNumber: transaction.PhoneNumber,
|
|
BankCode: transaction.BankCode.Value,
|
|
BeneficiaryName: transaction.BeneficiaryName.Value,
|
|
AccountName: transaction.AccountName.Value,
|
|
AccountNumber: transaction.AccountNumber.Value,
|
|
ReferenceNumber: transaction.ReferenceNumber.Value,
|
|
Verified: transaction.Verified,
|
|
ApprovedBy: transaction.ApprovedBy.Value,
|
|
CreatedAt: transaction.CreatedAt,
|
|
UpdatedAt: transaction.UpdatedAt,
|
|
}
|
|
|
|
return newTransaction
|
|
}
|
|
|
|
func ConvertShopTransactionDetail(transaction ShopTransactionDetail) ShopTransactionRes {
|
|
newTransaction := ShopTransactionRes{
|
|
ID: transaction.ID,
|
|
Amount: transaction.Amount.Float32(),
|
|
BranchID: transaction.BranchID,
|
|
BranchName: transaction.BranchName,
|
|
BranchLocation: transaction.BranchLocation,
|
|
CompanyID: transaction.CompanyID,
|
|
UserID: transaction.UserID,
|
|
CreatorFirstName: transaction.CreatorFirstName,
|
|
CreatorLastName: transaction.CreatorLastName,
|
|
CreatorPhoneNumber: transaction.CreatorPhoneNumber,
|
|
Type: int64(transaction.Type),
|
|
PaymentOption: transaction.PaymentOption,
|
|
FullName: transaction.FullName,
|
|
PhoneNumber: transaction.PhoneNumber,
|
|
BankCode: transaction.BankCode.Value,
|
|
BeneficiaryName: transaction.BeneficiaryName.Value,
|
|
AccountName: transaction.AccountName.Value,
|
|
AccountNumber: transaction.AccountNumber.Value,
|
|
ReferenceNumber: transaction.ReferenceNumber.Value,
|
|
Verified: transaction.Verified,
|
|
ApprovedBy: transaction.ApprovedBy.Value,
|
|
ApproverFirstName: transaction.ApproverFirstName.Value,
|
|
ApproverLastName: transaction.ApproverLastName.Value,
|
|
ApproverPhoneNumber: transaction.ApproverPhoneNumber.Value,
|
|
CreatedAt: transaction.CreatedAt,
|
|
UpdatedAt: transaction.UpdatedAt,
|
|
}
|
|
|
|
return newTransaction
|
|
}
|