Adds TransactionDataset.GetValue(bool, string accountId), which negates the value when the given account is the transaction's origin (paying out) so the account's own transaction list and charts show a minus sign for outgoing money, regardless of account class. Removes the old Activa-only sign flip baked into ViewService.GetTransactionViewListAsync(accountId), which would have double-negated Activa bookings against the new accountId-aware GetValue. ChartService's booking-text totals now sum through the same accountId-aware GetValue instead of filtering to inbound transactions only, so a booking text nets its in/out transactions correctly.
47 lines
No EOL
1.4 KiB
C#
47 lines
No EOL
1.4 KiB
C#
using System;
|
|
using Schaad.Accounting.Models;
|
|
|
|
namespace Schaad.Accounting.Datasets
|
|
{
|
|
public class TransactionDataset : Transaction
|
|
{
|
|
public Account OriginAccount { get; set; }
|
|
|
|
public Account TargetAccount { get; set; }
|
|
|
|
public TransactionDataset(Transaction transaction, Account originAccount, Account targetAccout)
|
|
{
|
|
this.BankTransactionId = transaction.BankTransactionId;
|
|
this.Id = transaction.Id;
|
|
this.OriginAccountId = transaction.OriginAccountId;
|
|
this.TargetAccountId = transaction.TargetAccountId;
|
|
this.Text = transaction.Text;
|
|
this.Value = transaction.Value;
|
|
this.FxRate = transaction.FxRate;
|
|
this.ValueDate = transaction.ValueDate;
|
|
this.BookingDate = transaction.BookingDate;
|
|
this.OriginAccount = originAccount;
|
|
this.TargetAccount = targetAccout;
|
|
}
|
|
|
|
public decimal GetValue(bool withFxRate)
|
|
{
|
|
if (withFxRate && FxRate != 0)
|
|
{
|
|
return Math.Round(Value / FxRate.Value, 2);
|
|
}
|
|
else
|
|
return Value;
|
|
}
|
|
|
|
public decimal GetValue(bool withFxRate, string accountId)
|
|
{
|
|
if (accountId == OriginAccountId)
|
|
{
|
|
return -1 * GetValue(withFxRate);
|
|
}
|
|
|
|
return GetValue(withFxRate);
|
|
}
|
|
}
|
|
} |