All files / src/modules/implementations/commands/list-definitions/reports unrealized-gains.js

83.33% Statements 25/30
88.88% Branches 8/9
80% Functions 4/5
83.33% Lines 25/30

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3140x 40x 40x 768x 3x 768x 768x 95x 768x 768x           768x 768x 3x 3x 3x 4x 4x 4x 4x 4x 4x 4x 3x 768x 40x  
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
module.exports = ({ core: { appendTotal }, numeric: { decimal: { formatDecimalFixed, parseDecimal } } }) => ({
    loadFormatData(journal) {
        return journal.commodities({ usage: 'all' });
    },
    prepareOutput(rows, { includeTotal }, _format) {
        return includeTotal ? appendTotal(rows) : rows;
    },
    formatCsv(rows, _cliOptions, { formatCsvTable }) {
        return formatCsvTable(['account', 'amount', 'commodity'], rows.map((row) => [
            row.account,
            formatDecimalFixed(parseDecimal(row.quantity), 2),
            row.commodity,
        ]));
    },
    formatText(rows, _cliOptions, format, descriptions) {
        const { commodityFormats, displayQuantity, formatAlignedAmounts, parseCommodityFormat, } = format;
        const formats = commodityFormats(descriptions);
        return formatAlignedAmounts(rows.map((row) => ({
            quantity: displayQuantity(row.quantity, row.commodity, formats, 2),
            commodity: row.commodity,
            label: row.account,
            isTotal: row.isTotal,
            decimalSeparator: formats.has(row.commodity)
                ? parseCommodityFormat(formats.get(row.commodity))?.decimalSeparator
                : '.',
        })), true);
    },
});