Store incoming bank transfers as pending transactions

parent f8e27c1c
......@@ -5,12 +5,11 @@ import (
"math/big"
"github.com/davecgh/go-spew/spew"
"github.com/kr/pretty"
"github.com/spf13/cobra"
"github.com/umsatz/go-aqbanking"
"gitlab.techcultivation.org/sangha/mq"
"gitlab.techcultivation.org/sangha/sangha/config"
"gitlab.techcultivation.org/sangha/sangha/db"
)
var (
......@@ -39,6 +38,10 @@ func (p Pin) Pin() string {
}
func executeFetch() error {
context := (&db.APIContext{
Config: *config.Settings,
}).NewAPIContext().(*db.APIContext)
// Create a client instance
aq, err := aqbanking.DefaultAQBanking()
if err != nil {
......@@ -105,10 +108,24 @@ func executeFetch() error {
}
for _, transaction := range transactions {
spew.Dump(transaction)
valuei, _ := big.NewFloat(float64(transaction.Total) * 100.0).Int64()
t := db.Transaction{
BudgetID: 6,
Amount: valuei,
CreatedAt: transaction.ValutaDate,
RemotePurpose: transaction.Purpose,
RemoteAccount: transaction.RemoteAccountNumber,
RemoteBankID: transaction.RemoteBankCode,
RemoteName: transaction.RemoteName,
}
err = t.Save(context)
if err != nil {
panic(err)
}
spew.Dump(transaction)
t := mq.Payment{
/*t := mq.Payment{
Name: transaction.RemoteName,
DateTime: transaction.ValutaDate,
......@@ -125,7 +142,7 @@ func executeFetch() error {
err = t.Process()
if err != nil {
panic(err)
}
}*/
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment