queueShadowCreditTransaction queues a shadow transaction to track credited funds from a provider. Parameters: - ctx context.Context: The context for the operation. - txn *model.Transaction: The original credit transaction. - destBalance *model.Balance: The destination balance. - provider string: Th
(ctx context.Context, txn *model.Transaction, destBalance *model.Balance, provider string, shadowBalance, aggregateBalance *model.Balance, identityID string)
| 351 | // Returns: |
| 352 | // - error: An error if the shadow transaction could not be queued. |
| 353 | func (l *LedgerForge) queueShadowCreditTransaction(ctx context.Context, txn *model.Transaction, destBalance *model.Balance, provider string, shadowBalance, aggregateBalance *model.Balance, identityID string) error { |
| 354 | shadowTxn := &model.Transaction{ |
| 355 | Source: shadowBalance.BalanceID, |
| 356 | Destination: aggregateBalance.BalanceID, |
| 357 | Amount: txn.Amount, |
| 358 | PreciseAmount: new(big.Int).Set(txn.PreciseAmount), |
| 359 | Currency: destBalance.Currency, |
| 360 | Precision: txn.Precision, |
| 361 | Reference: fmt.Sprintf("%s_shadow_%s", txn.Reference, provider), |
| 362 | Description: fmt.Sprintf("Shadow credit from %s", provider), |
| 363 | MetaData: map[string]interface{}{ |
| 364 | "_shadow_for": txn.TransactionID, |
| 365 | "_provider": provider, |
| 366 | "_identity_id": identityID, |
| 367 | "_lineage_type": "credit", |
| 368 | "_main_balance": destBalance.BalanceID, |
| 369 | }, |
| 370 | AllowOverdraft: true, |
| 371 | SkipQueue: true, |
| 372 | Inflight: txn.Inflight, |
| 373 | } |
| 374 | |
| 375 | _, err := l.QueueTransaction(ctx, shadowTxn) |
| 376 | if err != nil { |
| 377 | return fmt.Errorf("failed to queue shadow credit transaction: %w", err) |
| 378 | } |
| 379 | |
| 380 | return nil |
| 381 | } |
| 382 | |
| 383 | // processLineageDebit processes a debit transaction for fund lineage tracking. |
| 384 | // It allocates funds from shadow balances based on the configured allocation strategy. |
no test coverage detected