Skip to content

Commit

Permalink
adiciona recalculo do pm quando termina o feeder
Browse files Browse the repository at this point in the history
  • Loading branch information
tisanches committed May 12, 2022
1 parent 41efed9 commit 63e00f9
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/guru.feeder.investor.corporate.actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func init() {
func main() {
time_zone, _ := time.LoadLocation("America/Sao_Paulo")

//core.ApplyEvents("Ayqi8gfb")
//core.ApplyEvents("fzVzgo8b")
//core.ApplyEventsAfterInvestorSync("fzVzgo8b")
//core.Run()

Expand Down
2 changes: 2 additions & 0 deletions src/constants/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const (

const (
ManualSourceType = "REGULAR"
BonusOMSSourceType = "OMS"
BonusInvestorSourceType = "InvestorB3"
)

const (
Expand Down
3 changes: 3 additions & 0 deletions src/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func ApplyEvents(customerCode string) {
go doProceedsOMSEvents()
go doProceedsCEIEvents()
wg.Wait()

go repository.NewWalletConnector().ResyncAveragePrice()

fmt.Println("Finalizou")
}

Expand Down
12 changes: 6 additions & 6 deletions src/core/events/manual/inherited_bonus.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func ApplyInheritedBonusActionOMS(manualTransaction mapper.ManualTransaction, pr
manualTransaction.Price = constants.MinimalValue
manualTransaction.Amount = constants.MinimalValue
manualTransaction.Side = constants.Purchase
manualTransaction.TradeDate = proceed.PaymentDate // TODO - Validar com TOM
manualTransaction.SourceType = constants.ManualSourceType
manualTransaction.TradeDate = proceed.InitialDate // TODO - Validar com TOM
manualTransaction.SourceType = constants.BonusOMSSourceType
manualTransaction.EventDate = proceed.InitialDate
manualTransaction.EventName = proceed.Event

Expand All @@ -32,7 +32,7 @@ func ApplyInheritedBonusActionOMS(manualTransaction mapper.ManualTransaction, pr
manualTransaction.Price,
manualTransaction.Amount,
manualTransaction.Side,
manualTransaction.TradeDate.Format("02/01/2006"),
manualTransaction.TradeDate.String(),
manualTransaction.SourceType,
manualTransaction.EventDate.String(),
manualTransaction.EventName,
Expand All @@ -56,8 +56,8 @@ func ApplyInheritedBonusActionCEI(manualTransaction mapper.ManualTransaction, pr
manualTransaction.Price = constants.MinimalValue
manualTransaction.Amount = constants.MinimalValue
manualTransaction.Side = constants.Purchase
manualTransaction.TradeDate = proceed.PaymentDate // TODO - Validar com TOM
manualTransaction.SourceType = constants.ManualSourceType
manualTransaction.TradeDate = proceed.InitialDate // TODO - Validar com TOM
manualTransaction.SourceType = constants.BonusInvestorSourceType
manualTransaction.EventDate = proceed.InitialDate
manualTransaction.EventName = proceed.Event

Expand All @@ -70,7 +70,7 @@ func ApplyInheritedBonusActionCEI(manualTransaction mapper.ManualTransaction, pr
manualTransaction.Price,
manualTransaction.Amount,
manualTransaction.Side,
manualTransaction.TradeDate.Format("02/01/2006"),
manualTransaction.TradeDate.String(),
manualTransaction.SourceType,
manualTransaction.EventDate.String(),
manualTransaction.EventName,
Expand Down
5 changes: 5 additions & 0 deletions src/crossCutting/options/EndPointsOption.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package options

type EndPointsOption struct {
WalletSync string `json:"wallet-sync"`
}
3 changes: 2 additions & 1 deletion src/crossCutting/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (
var OPTIONS Options

type Options struct {
DATABASE DatabaseOption `json:"database"`
DATABASE DatabaseOption `json:"database"`
ENDPOINTS EndPointsOption `json:"endpoints"`
}

func (c *Options) Load() {
Expand Down
5 changes: 3 additions & 2 deletions src/repository/ConnectionRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ func (db *DatabaseConnection) connect() {

DATABASE := options.OPTIONS.DATABASE
dsn := fmt.Sprintf(
"user=%s password=%s dbname=%s host=%s port=%s",
"user=%s password=%s dbname=%s host=%s port=%s timezone=%s",
DATABASE.Username,
DATABASE.Password,
DATABASE.Database,
DATABASE.Url,
DATABASE.Port)
DATABASE.Port,
"America/Sao_Paulo")

newLogger := logger.New(
log.New(os.Stdout, "\r\n", log.LstdFlags), // io writer
Expand Down
31 changes: 31 additions & 0 deletions src/repository/WalletConnector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package repository

import (
"github.com/guru-invest/guru.feeder.investor.corporate.actions/src/crossCutting/options"
http_connector "github.com/guru-invest/guru.framework/src/infrastructure/http-connector"
)

type WalletConnector struct {
_baseURL string
}

func NewWalletConnector() WalletConnector {
return WalletConnector{
_baseURL: options.OPTIONS.ENDPOINTS.WalletSync,
}
}

func (t WalletConnector) ResyncAveragePrice() error {
uri := t._baseURL + "/all/recalcavg"
client := http_connector.HttpClient{}

header := map[string]string{
"Content-type": "application/json",
}
_, err := client.Post(uri, nil, header)
if err != nil {

return err
}
return nil
}

0 comments on commit 63e00f9

Please sign in to comment.