Skip to content

Commit

Permalink
Merge pull request #461 from LerianStudio/feature/MIDAZ-420
Browse files Browse the repository at this point in the history
Feature/MIDAZ-420
  • Loading branch information
MartinezAvellan authored Jan 15, 2025
2 parents e252b42 + acc57a3 commit de4590f
Show file tree
Hide file tree
Showing 34 changed files with 995 additions and 377 deletions.
2 changes: 1 addition & 1 deletion chocolatey/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$version = 'v1.44.1'
$version = 'v1.45.0'

$ErrorActionPreference = 'Stop';

Expand Down
2 changes: 1 addition & 1 deletion components/audit/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# ENV_NAME=production

# APP
VERSION=v1.44.1
VERSION=v1.45.0
SERVER_PORT=3005
SERVER_ADDRESS=:${SERVER_PORT}

Expand Down
2 changes: 1 addition & 1 deletion components/ledger/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ENV_NAME=production

# APP
VERSION=v1.44.1
VERSION=v1.45.0
SERVER_PORT=3000
SERVER_ADDRESS=:${SERVER_PORT}

Expand Down
2 changes: 1 addition & 1 deletion components/ledger/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ ps:
# App Commands
.PHONY: grpc-ledger-gen
grpc-ledger-gen:
@protoc --proto_path=../../common/mgrpc --go-grpc_out=../../common/mgrpc --go_out=../../common/mgrpc ../../common/mgrpc/account/account.proto
@protoc --proto_path=../../pkg/mgrpc --go-grpc_out=../../pkg/mgrpc --go_out=../../pkg/mgrpc ../../pkg/mgrpc/account/account.proto

.PHONY: run
run:
Expand Down
34 changes: 32 additions & 2 deletions components/ledger/internal/adapters/grpc/in/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ func (ap *AccountProto) GetAccountsByAliases(ctx context.Context, aliases *accou
return &response, nil
}

// UpdateAccounts is a method that update Account balances by a given ids.
func (ap *AccountProto) UpdateAccounts(ctx context.Context, update *account.AccountsRequest) (*account.AccountsResponse, error) {
// UpdateAccountsByIDS is a method that update Account balances by a given ids.
func (ap *AccountProto) UpdateAccountsByIDS(ctx context.Context, update *account.AccountsRequest) (*account.AccountsResponse, error) {
logger := pkg.NewLoggerFromContext(ctx)
tracer := pkg.NewTracerFromContext(ctx)

Expand Down Expand Up @@ -196,3 +196,33 @@ func (ap *AccountProto) UpdateAccounts(ctx context.Context, update *account.Acco

return &response, nil
}

// UpdateAccounts is a method that update Account balances by a given ids.
func (ap *AccountProto) UpdateAccounts(ctx context.Context, update *account.AccountsRequest) (*account.AccountsResponse, error) {
logger := pkg.NewLoggerFromContext(ctx)
tracer := pkg.NewTracerFromContext(ctx)

ctx, span := tracer.Start(ctx, "handler.UpdateAccounts")
defer span.End()

organizationID, err := uuid.Parse(update.OrganizationId)
if err != nil {
return nil, pkg.ValidateBusinessError(constant.ErrInvalidPathParameter, reflect.TypeOf(mmodel.Account{}).Name(), organizationID)
}

ledgerID, err := uuid.Parse(update.LedgerId)
if err != nil {
return nil, pkg.ValidateBusinessError(constant.ErrInvalidPathParameter, reflect.TypeOf(mmodel.Account{}).Name(), ledgerID)
}

err = ap.Command.UpdateAccounts(ctx, organizationID, ledgerID, update.GetAccounts())
if err != nil {
mopentelemetry.HandleSpanError(&span, "Failed to update balance in Account by id", err)

logger.Errorf("Failed to update balance in Account by id for organizationId %v and ledgerId %v in grpc, Error: %v", organizationID, ledgerID, err.Error())

return nil, err
}

return nil, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type AccountPostgreSQLModel struct {
AllowReceiving bool
Alias *string
Type string
Version int64
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt sql.NullTime
Expand Down Expand Up @@ -63,6 +64,7 @@ func (t *AccountPostgreSQLModel) ToEntity() *mmodel.Account {
AllowReceiving: &t.AllowReceiving,
Alias: t.Alias,
Type: t.Type,
Version: t.Version,
CreatedAt: t.CreatedAt,
UpdatedAt: t.UpdatedAt,
DeletedAt: nil,
Expand Down Expand Up @@ -94,6 +96,7 @@ func (t *AccountPostgreSQLModel) FromEntity(account *mmodel.Account) {
StatusDescription: account.Status.Description,
Alias: account.Alias,
Type: account.Type,
Version: account.Version,
CreatedAt: account.CreatedAt,
UpdatedAt: account.UpdatedAt,
}
Expand Down
124 changes: 69 additions & 55 deletions components/ledger/internal/adapters/postgres/account/account.mock.go

Large diffs are not rendered by default.

Loading

0 comments on commit de4590f

Please sign in to comment.