Skip to content

Commit

Permalink
show heading for transaction view
Browse files Browse the repository at this point in the history
closes gh-136
  • Loading branch information
hrj committed Feb 15, 2017
1 parent f87fdce commit fbcf267
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
18 changes: 7 additions & 11 deletions base/src/main/scala/co/uproot/abandon/Report.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import scala.xml.Elem
case class BalanceReportEntry(accName: Option[AccountName], render: String)
case class BalanceReport(leftEntries:Seq[BalanceReportEntry], rightEntries:Seq[BalanceReportEntry], totalLeft:String, totalRight:String)

case class RegisterReportEntry(txns: Seq[DetailedPost], render: String)
case class RegisterReportEntry(accountName: String, txns: Seq[DetailedPost], render: String)
case class RegisterReportGroup(groupTitle: String, entries: Seq[RegisterReportEntry])

case class LedgerExportEntry(accountName: AccountName, amount: BigDecimal)
Expand Down Expand Up @@ -163,14 +163,12 @@ object Reports {
case (accountName, amount) =>
val myPostings = txnGroup.flatMap(_.children).filter(_.name equals accountName)
val render = "%-50s %20.2f %20.2f" format (accountName, sumDeltas(myPostings), amount)
(accountName, myPostings, render)
RegisterReportEntry(accountName.toString, myPostings, render)
}

val sortedTotalDeltasPerAccount = totalDeltasPerAccount.toSeq.sortBy(_._1.toString)
val sortedTotalDeltasPerAccount = totalDeltasPerAccount.toSeq.sortBy(_.accountName)

reportGroups :+= RegisterReportGroup(
groupName,
sortedTotalDeltasPerAccount.map { case (accountName, postings, render) => RegisterReportEntry(postings, render) })
reportGroups :+= RegisterReportGroup(groupName, sortedTotalDeltasPerAccount)
}
reportGroups
}
Expand All @@ -193,14 +191,12 @@ object Reports {
case (accountName, amount) =>
val myTxns = monthlyGroup.flatMap(_.children).filter(_.name equals accountName)
val render = "%-50s %20.2f %20.2f" format (accountName, myTxns.foldLeft(Zero)(_ + _.delta), amount)
(accountName, myTxns, render)
RegisterReportEntry(accountName.toString, myTxns, render)
}

val sortedTotalDeltasPerAccount = totalDeltasPerAccount.toSeq.sortBy(_._1.toString)
val sortedTotalDeltasPerAccount = totalDeltasPerAccount.toSeq.sortBy(_.accountName)

reportGroups :+= RegisterReportGroup(
formatGroupingDate(month),
sortedTotalDeltasPerAccount.map { case (accountName, txns, render) => RegisterReportEntry(txns, render) })
reportGroups :+= RegisterReportGroup(formatGroupingDate(month), sortedTotalDeltasPerAccount)
}
reportGroups
}
Expand Down
14 changes: 10 additions & 4 deletions gui/src/main/scala/co/uproot/abandon/RegReport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ object RegUIReport extends UIReport {
def mkRegisterReport(appState: AppState, reportSettings: RegisterReportSettings) = {
val registers = Reports.registerReport(appState, reportSettings)
val registerItems = registers.map { rg =>
new TreeItem(RegisterReportEntry(Nil, rg.groupTitle)) {
new TreeItem(RegisterReportEntry(null, Nil, rg.groupTitle)) {
children = rg.entries.map(new TreeItem(_))
expanded = true
}
}
val reportRoot = new TreeItem(RegisterReportEntry(Nil, "Register report (account, delta, total)")) {
val reportRoot = new TreeItem(RegisterReportEntry(null, Nil, "Register report (account, change during period, balance at end of period)")) {
children = registerItems
expanded = true
}
Expand All @@ -33,7 +33,13 @@ object RegUIReport extends UIReport {
if (e.character equals "\r") {
val selectedItemOpt = selectionModel().getSelectedItems().headOption
selectedItemOpt foreach { selectedItem =>
// println(e)
val heading =
if (selectedItem.getValue.accountName == null) {
selectedItem.getValue.render
} else {
selectedItem.getParent.getValue.render + " / " + selectedItem.getValue.accountName
}

val txStage = new Stage() {
scene = new Scene(800, 600) {
root = new ScrollPane {
Expand All @@ -42,7 +48,7 @@ object RegUIReport extends UIReport {
stylesheets += "default_theme.css"
}
initModality(Modality.ApplicationModal)
title = "Transactions"
title = "Transactions for " + heading
}
txStage.show
}
Expand Down

0 comments on commit fbcf267

Please sign in to comment.