52 lines
1.7 KiB
Go
52 lines
1.7 KiB
Go
package srequest
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/tech/sendico/pkg/merrors"
|
|
"github.com/tech/sendico/pkg/model"
|
|
)
|
|
|
|
type LedgerAccountType string
|
|
|
|
const (
|
|
LedgerAccountTypeUnspecified LedgerAccountType = "unspecified"
|
|
LedgerAccountTypeAsset LedgerAccountType = "asset"
|
|
LedgerAccountTypeLiability LedgerAccountType = "liability"
|
|
LedgerAccountTypeRevenue LedgerAccountType = "revenue"
|
|
LedgerAccountTypeExpense LedgerAccountType = "expense"
|
|
)
|
|
|
|
type LedgerAccountStatus string
|
|
|
|
const (
|
|
LedgerAccountStatusUnspecified LedgerAccountStatus = "unspecified"
|
|
LedgerAccountStatusActive LedgerAccountStatus = "active"
|
|
LedgerAccountStatusFrozen LedgerAccountStatus = "frozen"
|
|
)
|
|
|
|
type CreateLedgerAccount struct {
|
|
AccountCode string `json:"accountCode"`
|
|
AccountType LedgerAccountType `json:"accountType"`
|
|
Currency string `json:"currency"`
|
|
Status LedgerAccountStatus `json:"status,omitempty"`
|
|
AllowNegative bool `json:"allowNegative,omitempty"`
|
|
IsSettlement bool `json:"isSettlement,omitempty"`
|
|
Metadata map[string]string `json:"metadata,omitempty"`
|
|
Describable model.Describable `json:"describable"`
|
|
IsOrgWallet bool `json:"isOrgWallet"`
|
|
}
|
|
|
|
func (r *CreateLedgerAccount) Validate() error {
|
|
if strings.TrimSpace(r.AccountCode) == "" {
|
|
return merrors.InvalidArgument("accountCode is required", "accountCode")
|
|
}
|
|
if strings.TrimSpace(r.Currency) == "" {
|
|
return merrors.InvalidArgument("currency is required", "currency")
|
|
}
|
|
if strings.TrimSpace(string(r.AccountType)) == "" || strings.EqualFold(string(r.AccountType), string(LedgerAccountTypeUnspecified)) {
|
|
return merrors.InvalidArgument("accountType is required", "accountType")
|
|
}
|
|
return nil
|
|
}
|