@@ -157,22 +157,24 @@ func ingestAccountsBatch(
157157 RawData : raw ,
158158 })
159159
160- balance := account .Balance
161- balanceTimestamp , err := ParseAtlarTimestamp (balance .Timestamp )
162- if err != nil {
163- return err
160+ if account .Balance != nil {
161+ balance := account .Balance
162+ balanceTimestamp , err := ParseAtlarTimestamp (balance .Timestamp )
163+ if err != nil {
164+ return err
165+ }
166+ balanceBatch = append (balanceBatch , & models.Balance {
167+ AccountID : models.AccountID {
168+ Reference : * account .ID ,
169+ ConnectorID : connectorID ,
170+ },
171+ Asset : currency .FormatAsset (supportedCurrenciesWithDecimal , * balance .Amount .Currency ),
172+ Balance : big .NewInt (* balance .Amount .Value ),
173+ CreatedAt : balanceTimestamp ,
174+ LastUpdatedAt : time .Now ().UTC (),
175+ ConnectorID : connectorID ,
176+ })
164177 }
165- balanceBatch = append (balanceBatch , & models.Balance {
166- AccountID : models.AccountID {
167- Reference : * account .ID ,
168- ConnectorID : connectorID ,
169- },
170- Asset : currency .FormatAsset (supportedCurrenciesWithDecimal , * balance .Amount .Currency ),
171- Balance : big .NewInt (* balance .Amount .Value ),
172- CreatedAt : balanceTimestamp ,
173- LastUpdatedAt : time .Now ().UTC (),
174- ConnectorID : connectorID ,
175- })
176178 }
177179
178180 if err := ingester .IngestAccounts (ctx , accountsBatch ); err != nil {
0 commit comments