avoid extra API call if not required
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
81672fbd19
commit
5eea9ede3a
@ -54,6 +54,10 @@ func (c *Client) SetAccountBalance(accountID string, balance int) error {
|
||||
return fmt.Errorf("failed to get ynab account with id '%s': %v", accountID, err)
|
||||
}
|
||||
|
||||
if balance == ynabAccount.Data.Account.Balance {
|
||||
return nil // The YNAB account already has the balance we're requesting, so there is no need to do anything
|
||||
}
|
||||
|
||||
balanceDelta := balance - ynabAccount.Data.Account.Balance
|
||||
balanceDelta += ynabTransactionAmount // Take into account the existing transaction
|
||||
if balanceDelta == 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user