Skip to content

Commit

Permalink
chore!: removed deprecated fields
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Removes the renameRuleId field from transaction previews and the
month field from envelope month resources
  • Loading branch information
morremeyer committed Jan 1, 2024
1 parent fe59312 commit dcbafb3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
8 changes: 0 additions & 8 deletions pkg/controllers/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,10 @@ func match(transaction *importer.TransactionPreview, rules []models.MatchRule) {

if transaction.SourceAccountName != "" {
transaction.Transaction.SourceAccountID, transaction.MatchRuleID = replace(transaction.SourceAccountName)

// This is kept for backwards compatibility and will be removed with API version 3
// https://github.com/envelope-zero/backend/issues/763
transaction.RenameRuleID = transaction.MatchRuleID
}

if transaction.DestinationAccountName != "" {
transaction.Transaction.DestinationAccountID, transaction.MatchRuleID = replace(transaction.DestinationAccountName)

// This is kept for backwards compatibility and will be removed with API version 3
// https://github.com/envelope-zero/backend/issues/763
transaction.RenameRuleID = transaction.MatchRuleID
}
}

Expand Down
10 changes: 4 additions & 6 deletions pkg/importer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ type Transaction struct {
// TransactionPreview is used to preview transactions that will be imported to allow for editing.
type TransactionPreview struct {
Transaction models.TransactionCreate `json:"transaction"`
SourceAccountName string `json:"sourceAccountName" example:"Employer"` // Name of the source account from the CSV file
DestinationAccountName string `json:"destinationAccountName" example:"Deutsche Bahn"` // Name of the destination account from the CSV file
DuplicateTransactionIDs []uuid.UUID `json:"duplicateTransactionIds"` // IDs of transactions that this transaction duplicates
RenameRuleID uuid.UUID `json:"renameRuleId" example:"042d101d-f1de-4403-9295-59dc0ea58677"` // ID of the match rule that was applied to this transaction preview. This is kept for backwards compatibility and will be removed with API version 3

MatchRuleID uuid.UUID `json:"matchRuleId" example:"042d101d-f1de-4403-9295-59dc0ea58677"` // ID of the match rule that was applied to this transaction preview
SourceAccountName string `json:"sourceAccountName" example:"Employer"` // Name of the source account from the CSV file
DestinationAccountName string `json:"destinationAccountName" example:"Deutsche Bahn"` // Name of the destination account from the CSV file
DuplicateTransactionIDs []uuid.UUID `json:"duplicateTransactionIds"` // IDs of transactions that this transaction duplicates
MatchRuleID uuid.UUID `json:"matchRuleId" example:"042d101d-f1de-4403-9295-59dc0ea58677"` // ID of the match rule that was applied to this transaction preview
}

// transformV3 transforms a TransactionPreview to a TransactionPreviewV3.
Expand Down
10 changes: 4 additions & 6 deletions pkg/models/envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,19 +255,17 @@ type EnvelopeMonthLinks struct {
// EnvelopeMonth contains data about an Envelope for a specific month.
type EnvelopeMonth struct {
Envelope
Month types.Month `json:"month" example:"1969-06-01T00:00:00.000000Z" hidden:"deprecated"` // This is always set to 00:00 UTC on the first of the month. **This field is deprecated and will be removed in v2**
Spent decimal.Decimal `json:"spent" example:"73.12"` // The amount spent over the whole month
Balance decimal.Decimal `json:"balance" example:"12.32"` // The balance at the end of the monht
Allocation decimal.Decimal `json:"allocation" example:"85.44"` // The amount of money allocated
Links EnvelopeMonthLinks `json:"links"` // Linked resources
Spent decimal.Decimal `json:"spent" example:"73.12"` // The amount spent over the whole month
Balance decimal.Decimal `json:"balance" example:"12.32"` // The balance at the end of the monht
Allocation decimal.Decimal `json:"allocation" example:"85.44"` // The amount of money allocated
Links EnvelopeMonthLinks `json:"links"` // Linked resources
}

// Month calculates the month specific values for an envelope and returns an EnvelopeMonth and allocation ID for them.
func (e Envelope) Month(db *gorm.DB, month types.Month) (EnvelopeMonth, error) {
spent := e.Spent(db, month)
envelopeMonth := EnvelopeMonth{
Envelope: e,
Month: month,
Spent: spent,
Balance: decimal.NewFromFloat(0),
Allocation: decimal.NewFromFloat(0),
Expand Down

0 comments on commit dcbafb3

Please sign in to comment.