예제 #1
0
        public void CreateDebitTransaction(AccountTransaction transaction)
        {
            if (transaction.Type == TransactionType.Debit)
            {
                if (!CreateTransaction(transaction))
                {
                    return;
                }
            }

            if (transaction.Currency.Equals(transaction.TransferCurrency))
            {
                // If FX is not needed, just move the money to the holding account.
                ledger.Post(AccountTransfer.NewBuilder()
                            .From(transaction.From)
                            .To(config.GetHoldAccount(transaction.Currency))
                            .WithAmount(
                                transaction.Amount,
                                transaction.Currency)
                            .Build());
            }
            else
            {
                // With FX.
                // Create two transfers to account for FX.
                // 1) DB customer, credit FX in the customer account currency.
                // 2) DB FX, credit hold account in the settlement account currency.
                // Note that we are not accounting for the spread with this
                // transaction pair, it goes 'nowhere'.
                ledger.Post(
                    AccountTransfer.NewBuilder()
                    .From(transaction.From)
                    .To(config.GetFxAccount(transaction.Currency))
                    .WithAmount(
                        transaction.Amount,
                        transaction.Currency)
                    .Build(),
                    AccountTransfer.NewBuilder()
                    .From(config.GetFxAccount(transaction.TransferCurrency))
                    .To(config.GetHoldAccount(transaction.TransferCurrency))
                    .WithAmount(
                        transaction.TransferAmount,
                        transaction.TransferCurrency)
                    .Build());
            }
        }
예제 #2
0
 internal void Post(AccountTransfer transfer)
 {
     Post(new List <AccountTransfer> {
         transfer
     });
 }