Skip to content

Commit

Permalink
Merge pull request #139 from eurofurence/issue-137-dues-reason
Browse files Browse the repository at this point in the history
add reason field to all transactions
  • Loading branch information
Jumpy-Squirrel authored Dec 10, 2024
2 parents 1567c74 + a81b781 commit f9d90f9
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/openapi-spec/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ components:
format: date-time
description: the time at which the transaction was created. Read only, ignored when receiving a transaction, because this is just the database timestamp.
example: '2022-06-24T11:12:13Z'
reason:
type: string
description: allows storing extra information as to why this transaction was created. Not processed in any way, but returned when querying transactions.
TransactionInitiator:
type: object
required:
Expand Down
2 changes: 2 additions & 0 deletions internal/entities/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type Transaction struct {
Deletion Deletion `gorm:"embedded;embeddedPrefix:deleted_"`
EffectiveDate sql.NullTime `gorm:"type:date;NOT NULL"`
DueDate sql.NullTime `gorm:"type:date;NULL;default:NULL"`
Reason string `gorm:"type:longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;default:NULL"`
}

type Amount struct {
Expand Down Expand Up @@ -108,5 +109,6 @@ func (t *Transaction) ToTransactionLog() TransactionLog {
},
EffectiveDate: t.EffectiveDate,
DueDate: t.DueDate,
Reason: t.Reason,
}
}
1 change: 1 addition & 0 deletions internal/entities/transactionlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type TransactionLog struct {
Deletion Deletion `gorm:"embedded;embeddedPrefix:deleted_"`
EffectiveDate sql.NullTime `gorm:"type:date;NOT NULL"`
DueDate sql.NullTime `gorm:"type:date;NULL;default:NULL"`
Reason string `gorm:"type:longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;default:NULL"`
}

// // TableName implements the Tabler interface to change from a pluarlized table name to
Expand Down
2 changes: 2 additions & 0 deletions internal/restapi/v1/transactions/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func ToV1Transaction(tran entities.Transaction) Transaction {
Info: make(map[string]interface{}), // TODO (no field)
PaymentStartUrl: tran.PaymentStartUrl,
EffectiveDate: tran.EffectiveDate.Time.Format("2006-01-02"),
Reason: tran.Reason,
}

if !tran.CreatedAt.IsZero() {
Expand Down Expand Up @@ -60,6 +61,7 @@ func ToTransactionEntity(tr Transaction) (*entities.Transaction, error) {
Valid: true,
Time: effDate,
},
Reason: tr.Reason,
}

if tr.DueDate != "" {
Expand Down
1 change: 1 addition & 0 deletions internal/restapi/v1/transactions/transaction_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type Transaction struct {
DueDate string `json:"due_date,omitempty"`
CreationDate *time.Time `json:"creation_date,omitempty"`
StatusHistory []StatusHistory `json:"status_history"`
Reason string `json:"reason"`
}

type TransactionInitiator struct {
Expand Down
1 change: 1 addition & 0 deletions internal/restapi/v1/transactions/transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func newTransaction(debID int64, tranID string,
Time: effDate,
Valid: true,
},
Reason: `{"for":"` + tranID + `"}`,
}
}

Expand Down

0 comments on commit f9d90f9

Please sign in to comment.