accounting/pkg/database/constants.go

42 lines
1 KiB
Go
Raw Permalink Normal View History

2024-01-15 22:49:29 +00:00
package database
2024-01-16 15:13:04 +00:00
import (
"fmt"
"math"
"strconv"
2024-01-15 22:49:29 +00:00
2024-01-16 15:13:04 +00:00
"github.com/google/uuid"
)
const constAcctIDNamespace = "00000000-0000-0000-0000-%012s"
2024-01-15 22:49:29 +00:00
var (
// UnallocatedMoney is a category UUID which is automatically created
// during database migration phase and therefore always available
2024-01-16 15:13:04 +00:00
UnallocatedMoney = makeConstAcctID(1)
// StartingBalance is a category UUID which is automatically created
// and hidden during database migration and used in frontend as constant
StartingBalance = makeConstAcctID(2) //nolint:gomnd
2024-01-15 22:49:29 +00:00
2024-01-16 15:13:04 +00:00
invalidAcc = makeConstAcctID(math.MaxUint32)
migrateCreateAccounts = []Account{
{
BaseModel: BaseModel{ID: UnallocatedMoney},
Hidden: false,
Name: "Unallocated Money",
Type: AccountTypeCategory,
},
{
BaseModel: BaseModel{ID: StartingBalance},
Hidden: true,
Name: "Starting Balance",
Type: AccountTypeCategory,
},
}
2024-01-15 22:49:29 +00:00
)
2024-01-16 15:13:04 +00:00
func makeConstAcctID(fixedNumber uint32) uuid.UUID {
return uuid.MustParse(fmt.Sprintf(constAcctIDNamespace, strconv.FormatUint(uint64(fixedNumber), 16)))
}