Verified Commit f4859bdb authored by 35V LG84's avatar 35V LG84

Equity export: create equity txns in fixed order

Create equity transactions in sorting order of commodities and
record commodity on equity txn's subject line.
Signed-off-by: 35V LG84's avatar35V LG84 <35vlg84-x4e6b92@e257.fi>
parent 89a534c3
......@@ -17,7 +17,9 @@ New features and changes in this release:
** 3.8.0 is not binary compatible with
link:https://github.com/pathikrit/better-files/issues/301[better-files 3.7.0]
* CLI: Raport Git commit id and working copy state with version info for `--help` and `--version` commands
* ...
* Equity export
** Create equity transactions in sorting order of commodities
** Record commodity on equity txn's subject line
** ...
......
......@@ -37,22 +37,32 @@ class EquityExporter(val settings: Settings) extends ExporterLike {
Nil
} else {
val lastTxn = txnData.txns.last
val eqTxnHeader = TxnTS.isoZonedTS(lastTxn.header.timestamp) + " " + lastTxn.header.uuid.map(u => "'Equity: last txn (uuid): " + u.toString).getOrElse("'Equity")
def eqTxnHeader(commStr: String) = {
val c = if (commStr.isEmpty) {
""
} else {
" for " + commStr
}
TxnTS.isoZonedTS(lastTxn.header.timestamp) + " " + "'Equity" + c + lastTxn.header.uuid.map(u => ": last txn (uuid): " + u.toString).getOrElse("")
}
bal.bal.groupBy(b => b.acctn.commStr).flatMap({ case (_, bs) =>
bal.bal
.groupBy(b => b.acctn.commStr)
.toSeq.sortBy({ case (commStr, _) => commStr }) // Scala 2.12 vs. 2.13: fix order sorting by commodity
.flatMap({ case (commStr, bs) =>
val eqBalRow = if (bs.map(b => b.accountSum).sum === 0.0) {
Nil
} else {
List(" " + "Equity:Balance")
}
List(eqTxnHeader) ++
List(eqTxnHeader(commStr)) ++
bal.metadata.map(md => md.mkString(" ; ", "\n ; ", "")).toList ++
bs.map(acc => {
" " + acc.acctn.account + " " + acc.accountSum.toString() + acc.acctn.commodity.map(c => " " + c.name).getOrElse("")
}) ++ eqBalRow ++ List("")
}).toSeq
})
}
}
......
2017-05-02T00:00:00Z 'Equity
2017-05-02T00:00:00Z 'Equity for EUR
a -11 EUR
e 11 EUR
2017-05-04T00:00:00Z 'Equity
a -11 EUR
e 11 EUR
2017-05-04T00:00:00Z 'Equity
a -300
e 300
2017-05-04T00:00:00Z 'Equity for EUR
a -11 EUR
e 11 EUR
2017-05-06T00:00:00Z 'Equity
a -300
e 300
2017-05-06T00:00:00Z 'Equity for EUR
a -11 EUR
e 11 EUR
2017-05-06T00:00:00Z 'Equity
2017-05-06T00:00:00Z 'Equity for USD
a -3000 USD
e 3000 USD
2017-05-06T00:00:00Z 'Equity
a -300
e 300
2017-05-06T00:00:00Z 'Equity
a -300
e 300
2017-05-06T00:00:00Z 'Equity for EUR
a -11 EUR
e 11 EUR
2017-05-06T00:00:00Z 'Equity
2017-05-06T00:00:00Z 'Equity for USD
a -3000 USD
e 3000 USD
2017-05-06T00:00:00Z 'Equity
a -300
e 300
2017-05-06T00:00:00Z 'Equity
a -300
e 300
2017-05-06T00:00:00Z 'Equity for EUR
a -11 EUR
e 11 EUR
2017-05-06T00:00:00Z 'Equity
2017-05-06T00:00:00Z 'Equity for USD
a -3000 USD
e 3000 USD
2017-05-06T00:00:00Z 'Equity
a -300
e 300
......@@ -2,14 +2,14 @@
REGISTER
--------
2017-05-06Z 'Equity
a -300.00 -300.00
e 300.00 300.00
----------------------------------------------------------------------------------
2017-05-06Z 'Equity for EUR
a -11.00 -11.00 EUR
e 11.00 11.00 EUR
--------------------------------------------------------------------------------------
2017-05-06Z 'Equity
2017-05-06Z 'Equity for USD
a -3000.00 -3000.00 USD
e 3000.00 3000.00 USD
--------------------------------------------------------------------------------------
2017-05-06Z 'Equity
a -300.00 -300.00
e 300.00 300.00
----------------------------------------------------------------------------------
2017-05-06T00:00:00Z 'Equity
a -300
e 300
2017-05-06T00:00:00Z 'Equity for EUR
a -11 EUR
e 11 EUR
2017-05-06T00:00:00Z 'Equity
2017-05-06T00:00:00Z 'Equity for USD
a -3000 USD
e 3000 USD
2017-05-06T00:00:00Z 'Equity
a -300
e 300
2017-05-06T00:00:00Z 'Equity
a -300
e 300
2017-05-06T00:00:00Z 'Equity for EUR
a -11 EUR
e 10 EUR
e:b:c 1 EUR
2017-05-06T00:00:00Z 'Equity
2017-05-06T00:00:00Z 'Equity for USD
a -3000 USD
e:b 1000 USD
e:b:c 2000 USD
2017-05-06T00:00:00Z 'Equity
a -300
e 300
2017-05-08T00:00:00Z 'Equity
2017-05-08T00:00:00Z 'Equity for EUR
a -22 EUR
e:b 1 EUR
e:c 6 EUR
......
2017-05-02T00:00:00Z 'Equity
a -1 EUR
e:b:c 1 EUR
2017-05-02T00:00:00Z 'Equity
EUR:a -2
EUR:e:b:c 2
2017-05-02T00:00:00Z 'Equity for EUR
a -1 EUR
e:b:c 1 EUR
2017-05-02T00:00:00Z 'Equity
2017-05-02T00:00:00Z 'Equity for EUR
a -11 EUR
Equity:Balance
2017-05-04T00:00:00Z 'Equity
a -11 EUR
a -300
Equity:Balance
2017-05-04T00:00:00Z 'Equity
a -300
2017-05-04T00:00:00Z 'Equity for EUR
a -11 EUR
Equity:Balance
2017-05-06T00:00:00Z 'Equity
a -11 EUR
a -300
Equity:Balance
2017-05-06T00:00:00Z 'Equity
a -3000 USD
2017-05-06T00:00:00Z 'Equity for EUR
a -11 EUR
Equity:Balance
2017-05-06T00:00:00Z 'Equity
a -300
2017-05-06T00:00:00Z 'Equity for USD
a -3000 USD
Equity:Balance
2019-01-26T00:00:00Z 'Equity
2019-01-26T00:00:00Z 'Equity for JPY
a -10 JPY
e 10 JPY
2017-05-04T00:00:00Z 'Equity
Assets:Cash -359.75 EUR
2017-05-04T00:00:00Z 'Equity for ACME
Assets:Stocks 3 ACME
Equity:Balance
2017-05-04T00:00:00Z 'Equity
Assets:Stocks 3 ACME
2017-05-04T00:00:00Z 'Equity for EUR
Assets:Cash -359.75 EUR
Equity:Balance
2019-04-05T00:00:00Z 'Equity
a -321 €
2019-04-05T00:00:00Z 'Equity for $
e 351 $
Equity:Balance
2019-04-05T00:00:00Z 'Equity
e 351 $
2019-04-05T00:00:00Z 'Equity for ACME
Assets:Stocks 3 ACME
Equity:Balance
2019-04-05T00:00:00Z 'Equity
2019-04-05T00:00:00Z 'Equity for EUR
Assets:Cash -111.6 EUR
Equity:Balance
2019-04-05T00:00:00Z 'Equity
Assets:Stocks 3 ACME
2019-04-05T00:00:00Z 'Equity for €
a -321 €
Equity:Balance
2019-04-05T00:00:00Z 'Equity
a -321 €
2019-04-05T00:00:00Z 'Equity for $
e 351 $
Equity:Balance
2019-04-05T00:00:00Z 'Equity
e 351 $
2019-04-05T00:00:00Z 'Equity for ACME
Assets:Stocks 3 ACME
Equity:Balance
2019-04-05T00:00:00Z 'Equity
2019-04-05T00:00:00Z 'Equity for EUR
Assets:Cash -111.6 EUR
Equity:Balance
2019-04-05T00:00:00Z 'Equity
Assets:Stocks 3 ACME
2019-04-05T00:00:00Z 'Equity for €
a -321 €
Equity:Balance
2019-04-02T00:00:00Z 'Equity
e 1 €
Equity:Balance
2019-04-02T00:00:00Z 'Equity
2019-04-02T00:00:00Z 'Equity for $
a -1.2 $
Equity:Balance
2019-04-02T00:00:00Z 'Equity
2019-04-02T00:00:00Z 'Equity for EUR
e 100 EUR
Equity:Balance
2019-04-02T00:00:00Z 'Equity
2019-04-02T00:00:00Z 'Equity for USD
a -120 USD
Equity:Balance
2019-04-02T00:00:00Z 'Equity for €
e 1 €
Equity:Balance
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment