Skip to content
Snippets Groups Projects
Commit c03b078d authored by DmitriiPetrov's avatar DmitriiPetrov
Browse files

Plaid sync transactions

parent e3d2bca9
Branches fix-build
Tags
No related merge requests found
......@@ -6,7 +6,6 @@ import (
"fmt"
"io"
"math"
"time"
"go.mongodb.org/mongo-driver/mongo"
......@@ -186,21 +185,11 @@ func (srv *serviceImpl) pullTransactions(ctx context.Context, accessToken string
func renderTransactions(plaidTxs []plaid.Transaction) (txs []*plaidapi.Transaction, err error) {
for _, tx := range plaidTxs {
date, err := time.Parse("2006-01-02 15:04:05", tx.GetDate())
if err != nil {
date, err = time.Parse("2006-01-02", tx.GetDate())
if err != nil {
return nil, err
}
date = date.Truncate(24 * time.Hour)
}
txs = append(txs, &plaidapi.Transaction{
Type: renderTransactionType(tx.GetAmount()),
Status: renderTransactionStatus(tx.GetPending()),
Description: tx.GetName(),
CreatedAt: timestamppb.New(date),
CreatedAt: timestamppb.New(tx.GetDatetime()),
Amount: &plaidapi.Amount{
Currency: tx.GetIsoCurrencyCode(),
Value: math.Abs(tx.GetAmount()),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment