getSourceAggregateBalance retrieves or creates the aggregate balance for the source identity. Parameters: - ctx context.Context: The context for the operation. - sourceBalance *model.Balance: The source balance. Returns: - *model.Balance: The aggregate balance. - error: An error if the balance cou
(ctx context.Context, sourceBalance *model.Balance)
| 531 | // - *model.Balance: The aggregate balance. |
| 532 | // - error: An error if the balance could not be retrieved or created. |
| 533 | func (l *LedgerForge) getSourceAggregateBalance(ctx context.Context, sourceBalance *model.Balance) (*model.Balance, error) { |
| 534 | sourceIdentity, err := l.datasource.GetIdentityByID(sourceBalance.IdentityID) |
| 535 | if err != nil { |
| 536 | return nil, fmt.Errorf("failed to get source identity: %w", err) |
| 537 | } |
| 538 | |
| 539 | sourceIdentifier := l.getIdentityIdentifier(sourceIdentity) |
| 540 | sourceAggIndicator := fmt.Sprintf("@%s_lineage", sourceIdentifier) |
| 541 | |
| 542 | sourceAggBalance, err := l.getOrCreateBalanceByIndicator(ctx, sourceAggIndicator, sourceBalance.Currency) |
| 543 | if err != nil { |
| 544 | return nil, fmt.Errorf("failed to get source aggregate balance: %w", err) |
| 545 | } |
| 546 | |
| 547 | return sourceAggBalance, nil |
| 548 | } |
| 549 | |
| 550 | // processAllocations processes fund allocations by queuing release and receive transactions. |
| 551 | // |
no test coverage detected