use cleared balance instead of balance
	
		
			
	
		
	
	
		
	
		
			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:
		@@ -54,11 +54,11 @@ func (c *Client) SetAccountBalance(accountID string, balance int) error {
 | 
				
			|||||||
		return fmt.Errorf("failed to get ynab account with id '%s': %v", accountID, err)
 | 
							return fmt.Errorf("failed to get ynab account with id '%s': %v", accountID, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if balance == ynabAccount.Data.Account.Balance {
 | 
						if balance == ynabAccount.Data.Account.ClearedBalance {
 | 
				
			||||||
		return nil // The YNAB account already has the balance we're requesting, so there is no need to do anything
 | 
							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 := balance - ynabAccount.Data.Account.ClearedBalance
 | 
				
			||||||
	balanceDelta += ynabTransactionAmount // Take into account the existing transaction
 | 
						balanceDelta += ynabTransactionAmount // Take into account the existing transaction
 | 
				
			||||||
	if balanceDelta == 0 {
 | 
						if balanceDelta == 0 {
 | 
				
			||||||
		return nil // If balanceDelta is 0 do not create a transaction i.e. market is closed today
 | 
							return nil // If balanceDelta is 0 do not create a transaction i.e. market is closed today
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user