Add timezone env
This commit is contained in:
parent
6c5c3a36c9
commit
aba24171b8
@ -2,6 +2,8 @@ CONFIG_PATH=/opt/bin/monobank-firefly3-bot/config.json
|
|||||||
|
|
||||||
LISTEN=:8080
|
LISTEN=:8080
|
||||||
|
|
||||||
|
TIMEZONE_HOURS_DIFF=2
|
||||||
|
|
||||||
FIREFLY3_API_URL=https://firefly3.stuzer.link/api
|
FIREFLY3_API_URL=https://firefly3.stuzer.link/api
|
||||||
FIREFLY3_TOKEN=
|
FIREFLY3_TOKEN=
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"gitea.stuzer.link/stuzer05/go-monobank"
|
"gitea.stuzer.link/stuzer05/go-monobank"
|
||||||
"github.com/antihax/optional"
|
"github.com/antihax/optional"
|
||||||
"math"
|
"math"
|
||||||
|
"os"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@ -19,6 +20,8 @@ func ImportTransaction(monobankTransaction monobank.WebHookResponse) error {
|
|||||||
firefly3TransactionTypeDeposit := firefly3.DEPOSIT_TransactionTypeProperty
|
firefly3TransactionTypeDeposit := firefly3.DEPOSIT_TransactionTypeProperty
|
||||||
firefly3TransactionTypeTransfer := firefly3.TRANSFER_TransactionTypeProperty
|
firefly3TransactionTypeTransfer := firefly3.TRANSFER_TransactionTypeProperty
|
||||||
|
|
||||||
|
timezoneHoursDiff, _ := strconv.Atoi(os.Getenv("TIMEZONE_HOURS_DIFF"))
|
||||||
|
|
||||||
// get body json string (for logging)
|
// get body json string (for logging)
|
||||||
monobankTransactionJson, err := json.Marshal(monobankTransaction)
|
monobankTransactionJson, err := json.Marshal(monobankTransaction)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -93,7 +96,7 @@ func ImportTransaction(monobankTransaction monobank.WebHookResponse) error {
|
|||||||
|
|
||||||
// create firefly3 transaction
|
// create firefly3 transaction
|
||||||
firefly3Transaction := firefly3.TransactionSplitStore{
|
firefly3Transaction := firefly3.TransactionSplitStore{
|
||||||
Date: time.Unix(int64(*monobankTransaction.Data.StatementItem.Time), 0).Add(time.Hour * 2),
|
Date: time.Unix(int64(*monobankTransaction.Data.StatementItem.Time), 0).Add(time.Hour * time.Duration(timezoneHoursDiff)),
|
||||||
Notes: string(monobankTransactionJson),
|
Notes: string(monobankTransactionJson),
|
||||||
Amount: strconv.Itoa(int(math.Abs(math.Round(float64(*monobankTransaction.Data.StatementItem.Amount/100)))) - int(math.Abs(math.Round(float64(*monobankTransaction.Data.StatementItem.CommissionRate/100))))),
|
Amount: strconv.Itoa(int(math.Abs(math.Round(float64(*monobankTransaction.Data.StatementItem.Amount/100)))) - int(math.Abs(math.Round(float64(*monobankTransaction.Data.StatementItem.CommissionRate/100))))),
|
||||||
SourceName: account.Firefly3Name,
|
SourceName: account.Firefly3Name,
|
||||||
@ -135,7 +138,7 @@ func ImportTransaction(monobankTransaction monobank.WebHookResponse) error {
|
|||||||
if *monobankTransaction.Data.StatementItem.CommissionRate > 0 {
|
if *monobankTransaction.Data.StatementItem.CommissionRate > 0 {
|
||||||
firefly3Transactions = append(firefly3Transactions, firefly3.TransactionSplitStore{
|
firefly3Transactions = append(firefly3Transactions, firefly3.TransactionSplitStore{
|
||||||
Type_: &firefly3TransactionTypeWithdrawal,
|
Type_: &firefly3TransactionTypeWithdrawal,
|
||||||
Date: time.Unix(int64(*monobankTransaction.Data.StatementItem.Time), 0).Add(time.Hour * 2),
|
Date: time.Unix(int64(*monobankTransaction.Data.StatementItem.Time), 0).Add(time.Hour * time.Duration(timezoneHoursDiff)),
|
||||||
Notes: string(monobankTransactionJson),
|
Notes: string(monobankTransactionJson),
|
||||||
Description: "Transfer fee",
|
Description: "Transfer fee",
|
||||||
Amount: strconv.Itoa(int(math.Abs(math.Round(float64(*monobankTransaction.Data.StatementItem.CommissionRate / 100))))),
|
Amount: strconv.Itoa(int(math.Abs(math.Round(float64(*monobankTransaction.Data.StatementItem.CommissionRate / 100))))),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user