From 3b18a15494f2f0c669ee4704a29573a474921133 Mon Sep 17 00:00:00 2001 From: Muyao CHEN Date: Wed, 16 Oct 2024 00:13:38 +0200 Subject: [PATCH] feat: add event and expense BOs --- internal/howmuch/model/event.go | 38 ++++++++++++++++++++++++++++ internal/howmuch/model/expense.go | 42 +++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 internal/howmuch/model/event.go create mode 100644 internal/howmuch/model/expense.go diff --git a/internal/howmuch/model/event.go b/internal/howmuch/model/event.go new file mode 100644 index 0000000..b4ce516 --- /dev/null +++ b/internal/howmuch/model/event.go @@ -0,0 +1,38 @@ +// MIT License +// +// Copyright (c) 2024 vinchent +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package model + +import "time" + +type Event struct { + ID int + Name string + Description string + Users []*User + Expenses []*Expense + TotalAmount Money + DefaultCurrency Currency + CreatedBy User + CreatedAt time.Time + UpdatedAt time.Time +} diff --git a/internal/howmuch/model/expense.go b/internal/howmuch/model/expense.go new file mode 100644 index 0000000..862bfdd --- /dev/null +++ b/internal/howmuch/model/expense.go @@ -0,0 +1,42 @@ +// MIT License +// +// Copyright (c) 2024 vinchent +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package model + +import "time" + +type ExpenseDetail struct { + Name string + Place string +} + +type Expense struct { + ID int + Amount Money + Currency Currency + PayerIDs []int + RecipientIDs []int + EventID int + Detail ExpenseDetail + CreatedAt time.Time + UpdatedAt time.Time +}