Skip to content

Commit

Permalink
fix: make sec, format, tidy and lint 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinezAvellan committed Oct 2, 2024
1 parent 05f19a5 commit 11b9d97
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 42 deletions.
12 changes: 6 additions & 6 deletions common/constant/transaction.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package constant

const (
CREATED = "CREATED"
APPROVED = "APPROVED"
PRE_APPROVED = "PRE_APPROVED"
SENT = "SENT"
CANCELED = "CANCELED"
DECLINED = "DECLINED"
CREATED = "CREATED"
APPROVED = "APPROVED"
PREAPPROVED = "PRE_APPROVED"
SENT = "SENT"
CANCELED = "CANCELED"
DECLINED = "DECLINED"
)
1 change: 1 addition & 0 deletions common/mgrpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (c *GRPCConnection) Connect() error {
fmt.Println("Connected to gRPC ✅ ")

c.Conn = conn

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func (t *AccountPostgreSQLModel) FromEntity(account *Account) {

// ToProto converts entity Account to a response protobuf proto
func (e *Account) ToProto() *proto.Account {

status := proto.Status{
Code: e.Status.Code,
Description: *e.Status.Description,
Expand Down Expand Up @@ -213,9 +212,11 @@ func (e *Account) ToProto() *proto.Account {
if e.DeletedAt != nil {
account.DeletedAt = e.DeletedAt.String()
}

if !e.UpdatedAt.IsZero() {
account.UpdatedAt = e.UpdatedAt.String()
}

if !e.CreatedAt.IsZero() {
account.CreatedAt = e.CreatedAt.String()
}
Expand Down
11 changes: 5 additions & 6 deletions components/ledger/internal/ports/grpc/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package grpc

import (
"context"

"github.com/google/uuid"

"github.com/LerianStudio/midaz/common"
Expand All @@ -23,7 +24,7 @@ type AccountProto struct {
func (ap *AccountProto) GetAccountsByIds(ctx context.Context, ids *proto.AccountsID) (*proto.AccountsResponse, error) {
logger := mlog.NewLoggerFromContext(ctx)

var uuids []uuid.UUID
uuids := make([]uuid.UUID, len(ids.GetIds()))
for _, id := range ids.GetIds() {
uuids = append(uuids, uuid.MustParse(id))
}
Expand All @@ -38,7 +39,7 @@ func (ap *AccountProto) GetAccountsByIds(ctx context.Context, ids *proto.Account
}
}

var accounts []*proto.Account
accounts := make([]*proto.Account, len(acc))

for _, ac := range acc {
accounts = append(accounts, ac.ToProto())
Expand All @@ -65,7 +66,7 @@ func (ap *AccountProto) GetAccountsByAliases(ctx context.Context, aliases *proto
}
}

var accounts []*proto.Account
accounts := make([]*proto.Account, len(acc))

for _, ac := range acc {
accounts = append(accounts, ac.ToProto())
Expand All @@ -82,10 +83,9 @@ func (ap *AccountProto) GetAccountsByAliases(ctx context.Context, aliases *proto
func (ap *AccountProto) UpdateAccounts(ctx context.Context, update *proto.AccountsRequest) (*proto.AccountsResponse, error) {
logger := mlog.NewLoggerFromContext(ctx)

var accounts []*proto.Account
accounts := make([]*proto.Account, len(update.GetAccounts()))

for _, account := range update.GetAccounts() {

if common.IsNilOrEmpty(&account.Id) {
logger.Errorf("Failed to update Accounts because id is empty")

Expand All @@ -112,7 +112,6 @@ func (ap *AccountProto) UpdateAccounts(ctx context.Context, update *proto.Accoun
}

accounts = append(accounts, acu.ToProto())

}

response := proto.AccountsResponse{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package command

import (
"context"
"github.com/LerianStudio/midaz/common"
m "github.com/LerianStudio/midaz/components/transaction/internal/domain/metadata"
"reflect"
"strconv"
"time"

"github.com/LerianStudio/midaz/common"
"github.com/LerianStudio/midaz/common/constant"
gold "github.com/LerianStudio/midaz/common/gold/transaction/model"
"github.com/LerianStudio/midaz/common/mlog"
m "github.com/LerianStudio/midaz/components/transaction/internal/domain/metadata"
t "github.com/LerianStudio/midaz/components/transaction/internal/domain/transaction"
"github.com/google/uuid"
)
Expand Down
51 changes: 26 additions & 25 deletions components/transaction/internal/domain/operation/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package operation

import (
"database/sql"
"github.com/google/uuid"
"time"

"github.com/google/uuid"
)

// OperationPostgreSQLModel represents the entity OperationPostgreSQLModel into SQL context in Database
Expand Down Expand Up @@ -145,34 +146,34 @@ func (t *OperationPostgreSQLModel) ToEntity() *Operation {
}

// FromEntity converts an entity Operation to OperationPostgreSQLModel
func (t *OperationPostgreSQLModel) FromEntity(Operation *Operation) {
func (t *OperationPostgreSQLModel) FromEntity(operation *Operation) {
*t = OperationPostgreSQLModel{
ID: uuid.New().String(),
TransactionID: Operation.TransactionID,
Description: Operation.Description,
Type: Operation.Type,
InstrumentCode: Operation.InstrumentCode,
ChartOfAccounts: Operation.ChartOfAccounts,
Amount: Operation.Amount.Amount,
AmountScale: Operation.Amount.Scale,
BalanceScale: Operation.Balance.Scale,
OnHoldBalance: Operation.Balance.OnHold,
AvailableBalance: Operation.Balance.Available,
BalanceScaleAfter: Operation.BalanceAfter.Scale,
AvailableBalanceAfter: Operation.BalanceAfter.Available,
OnHoldBalanceAfter: Operation.BalanceAfter.Scale,
Status: Operation.Status.Code,
StatusDescription: Operation.Status.Description,
AccountID: Operation.AccountID,
AccountAlias: Operation.AccountAlias,
LedgerID: Operation.LedgerID,
OrganizationID: Operation.OrganizationID,
CreatedAt: Operation.CreatedAt,
UpdatedAt: Operation.UpdatedAt,
TransactionID: operation.TransactionID,
Description: operation.Description,
Type: operation.Type,
InstrumentCode: operation.InstrumentCode,
ChartOfAccounts: operation.ChartOfAccounts,
Amount: operation.Amount.Amount,
AmountScale: operation.Amount.Scale,
BalanceScale: operation.Balance.Scale,
OnHoldBalance: operation.Balance.OnHold,
AvailableBalance: operation.Balance.Available,
BalanceScaleAfter: operation.BalanceAfter.Scale,
AvailableBalanceAfter: operation.BalanceAfter.Available,
OnHoldBalanceAfter: operation.BalanceAfter.Scale,
Status: operation.Status.Code,
StatusDescription: operation.Status.Description,
AccountID: operation.AccountID,
AccountAlias: operation.AccountAlias,
LedgerID: operation.LedgerID,
OrganizationID: operation.OrganizationID,
CreatedAt: operation.CreatedAt,
UpdatedAt: operation.UpdatedAt,
}

if Operation.DeletedAt != nil {
deletedAtCopy := *Operation.DeletedAt
if operation.DeletedAt != nil {
deletedAtCopy := *operation.DeletedAt
t.DeletedAt = sql.NullTime{Time: deletedAtCopy, Valid: true}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package operation

import (
"context"

"github.com/google/uuid"
)

Expand Down
2 changes: 1 addition & 1 deletion components/transaction/internal/ports/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (handler *TransactionHandler) CreateTransaction(c *fiber.Ctx) error {
return c.Status(http.StatusBadRequest).JSON("Type assertion failed")
}

var alias []string
alias := make([]string, len(transactionParsed.Send.Source.From)+len(transactionParsed.Distribute.To))
for _, from := range transactionParsed.Send.Source.From {
alias = append(alias, from.Account)
}
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
Expand Down

0 comments on commit 11b9d97

Please sign in to comment.