Skip to content

Commit

Permalink
fix: add PortfolioID to account update functionality ✨ ✨ 🐛 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Peixoto authored and peixotoleonardo committed Jan 23, 2025
1 parent 8da523d commit ad04b2b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"context"
"database/sql"
"errors"
"github.com/LerianStudio/midaz/pkg/mgrpc/account"
"reflect"
"strconv"
"strings"
"sync"
"time"

"github.com/LerianStudio/midaz/pkg/mgrpc/account"

"github.com/LerianStudio/midaz/pkg/mpointers"
"github.com/LerianStudio/midaz/pkg/net/http"

Expand Down Expand Up @@ -701,6 +702,11 @@ func (r *AccountPostgreSQLRepository) Update(ctx context.Context, organizationID
args = append(args, record.ProductID)
}

if !pkg.IsNilOrEmpty(acc.PortfolioID) {
updates = append(updates, "portfolio_id = $"+strconv.Itoa(len(args)+1))
args = append(args, record.PortfolioID)
}

record.UpdatedAt = time.Now()

updates = append(updates, "updated_at = $"+strconv.Itoa(len(args)+1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (uc *UseCase) UpdateAccount(ctx context.Context, organizationID, ledgerID u
Status: uai.Status,
Alias: uai.Alias,
ProductID: uai.ProductID,
PortfolioID: uai.PortfolioID,
AllowSending: uai.AllowSending,
AllowReceiving: uai.AllowReceiving,
Metadata: uai.Metadata,
Expand Down
1 change: 1 addition & 0 deletions pkg/mmodel/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type UpdateAccountInput struct {
AllowReceiving *bool `json:"allowReceiving" example:"true"`
Alias *string `json:"alias" validate:"omitempty,max=100,prohibitedexternalaccountprefix" example:"@person1"`
ProductID *string `json:"productId" validate:"omitempty,uuid" example:"00000000-0000-0000-0000-000000000000"`
PortfolioID *string `json:"portfolioId" validate:"omitempty,uuid" example:"00000000-0000-0000-0000-000000000000"`
Metadata map[string]any `json:"metadata" validate:"dive,keys,keymax=100,endkeys,nonested,valuemax=2000"`
} // @name UpdateAccountInput

Expand Down

0 comments on commit ad04b2b

Please sign in to comment.