【问题标题】:How to display the sum of the rest of the Transaction types如何显示其余交易类型的总和
【发布时间】:2023-03-06 19:49:02
【问题描述】:

我正在列出当天每种交易类型的总金额我根据给定的规则为每种交易类型做了一个案例陈述,但我需要显示其他交易的总和未指定

  var flagged = from c in db.vw_BMO_Daily
  group c by c.DatePosted into dateGroup
  select new AccountingSum()
  {

      Date = dateGroup.Key,
      Year = dateGroup.Key.Year,
      Month = dateGroup.Key.Month,
      Store = dateGroup.Select(x=>x.Store_Id),
      BridgeLoan = dateGroup.Sum(x => x.TransactionType == "Miscellaneous Debit" && x.TransactionDescription.Contains("Bridge Loan") ? x.DebitAmount : 0),
      FloorPlanPayout = dateGroup.Sum(x => x.TransactionType == "Miscellaneous Debit" && !x.TransactionDescription.Contains("Bridge Loan") ? x.DebitAmount : 0),
      FloorPlanEquity = dateGroup.Sum(X => X.TransactionType == "Miscellaneous Credit"? X.CreditAmount:0),
      ZBA_Debit_Credit = dateGroup.Sum(x => x.TransactionType.Contains("Zero Balance") ? x.DebitAmount + x.CreditAmount : 0),
      ACH = dateGroup.Sum(x => x.TransactionType.Contains("ACH") ? x.CreditAmount + x.DebitAmount : 0),
      IncomingWires = dateGroup.Sum(x => x.TransactionType == "Incoming Money Transfer" ? x.CreditAmount : 0),
      AccountAnalysis = dateGroup.Sum(x => x.TransactionType == "Account Analysis Fee" ? x.DebitAmount : 0),
      CheckPaid = dateGroup.Sum(x => x.TransactionType == "Check Paid" ? x.DebitAmount : 0),
      DebitReversal = dateGroup.Sum(x => x.TransactionType == "Debit Reversal" ? x.CreditAmount : 0)

 };

最后 2 笔交易的总和“CheckPaid”和“DebitReversal”应进入“Other”列

【问题讨论】:

  • 问题应该更清楚了。什么“其他”栏目?它只是 CheckPaid 和 DebitReversal 的总和吗?
  • 所以你想要其他列中的 2 个值?您可以即时创建元组。其他 = (dateGroup.Sum(x => x.TransactionType == "支票支付" ? x.DebitAmount : 0), dateGroup.Sum(x => x.TransactionType == "借方冲销" ? x.CreditAmount : 0) )

标签: c# asp.net-mvc linq


【解决方案1】:

我发现我只是在类上计算了 2 个 Transaction 类型的总和

 public decimal Other { get { return CheckPaid + DebitReversal; } set { } }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-19
    • 2015-11-09
    • 2021-07-01
    • 1970-01-01
    • 2020-11-15
    • 2019-03-28
    • 2022-07-16
    相关资源
    最近更新 更多