Beispiel #1
0
 internal Transaction(AccountId accId, TransactionId id, TransactionLabel label, ITransactionAmount amount, TransactionMetadata meta, TransactionDescription descr, DateTime createdOn, DateTime updatedOn)
 {
     AccountId   = accId;
     Id          = id;
     Label       = label;
     Amount      = amount;
     Metadata    = meta;
     Description = descr;
     CreatedOn   = createdOn;
     UpdatedOn   = updatedOn;
 }
Beispiel #2
0
        public Transaction To()
        {
            var descr = new TransactionDescription();

            foreach (var kv in Description)
            {
                descr.Add(kv.Key, kv.Value);
            }

            var metadata = new TransactionMetadata();

            foreach (var kv in Metadata)
            {
                metadata.Add(kv.Key, kv.Value);
            }

            var am = AmountFactory.New(AmountValue, AmountCurrency);
            ITransactionAmount amount = AmountType switch
            {
                _completedIncome => new AmountIncomeCompleted(am),
                _cancelledOutcome => new AmountOutcomeCancelled(am),
                _processingOutcome => new AmountOutcomeProcessing(am),
                _completedOutcome => new AmountOutcomeCompleted(am),
                _ => throw new InvalidOperationException("Invalid transaction status")
            };

            return(new Transaction(
                       new AccountId(new UniqId(AccountId)),
                       new TransactionId(new UniqId(Id)),
                       new TransactionLabel(Label),
                       amount,
                       metadata,
                       descr,
                       CreatedOn,
                       UpdateOn
                       ));
        }