-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from LerianStudio/develop
Develop to Main
- Loading branch information
Showing
35 changed files
with
1,659 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
components/ledger/internal/app/command/update-account-id.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package command | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"reflect" | ||
|
||
"github.com/LerianStudio/midaz/common" | ||
"github.com/LerianStudio/midaz/common/mlog" | ||
"github.com/LerianStudio/midaz/components/ledger/internal/app" | ||
a "github.com/LerianStudio/midaz/components/ledger/internal/domain/portfolio/account" | ||
"github.com/google/uuid" | ||
) | ||
|
||
// UpdateAccountByID update an account from the repository by given id. | ||
func (uc *UseCase) UpdateAccountByID(ctx context.Context, id string, balance *a.Balance) (*a.Account, error) { | ||
logger := mlog.NewLoggerFromContext(ctx) | ||
logger.Infof("Trying to update account by id: %v", id) | ||
|
||
account := &a.Account{ | ||
Balance: *balance, | ||
} | ||
|
||
accountUpdated, err := uc.AccountRepo.UpdateAccountByID(ctx, uuid.MustParse(id), account) | ||
if err != nil { | ||
logger.Errorf("Error updating account on repo by id: %v", err) | ||
|
||
if errors.Is(err, app.ErrDatabaseItemNotFound) { | ||
return nil, common.EntityNotFoundError{ | ||
EntityType: reflect.TypeOf(a.Account{}).Name(), | ||
Message: fmt.Sprintf("Account with id %s was not found", id), | ||
Code: "ACCOUNT_NOT_FOUND", | ||
Err: err, | ||
} | ||
} | ||
|
||
return nil, err | ||
} | ||
|
||
return accountUpdated, nil | ||
} |
Oops, something went wrong.