daniel-san
Version:
a node-based budget-projection engine that helps your routines and finances find balance. The program features aggregates, terminal and file-based reporting output, multi-currency conversion capability and multi-frequency accounting triggers, including: o
1,327 lines (1,180 loc) • 103 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var moment = require('moment-timezone');
var _require = require('../timeZone'),
createTimeZone = _require.createTimeZone,
convertTimeZone = _require.convertTimeZone;
var _require2 = require('../utility/validation'),
isUndefinedOrNull = _require2.isUndefinedOrNull;
var _require3 = require('../utility/dataStructures'),
deepCopy = _require3.deepCopy;
var _require4 = require('./asciiArt'),
danielSanAsciiArt = _require4.danielSanAsciiArt;
var _require5 = require('./quoteGenerator'),
getRandomMiyagiQuote = _require5.getRandomMiyagiQuote;
var _require6 = require('../utility/fileIo'),
createStream = _require6.createStream,
closeStream = _require6.closeStream;
var _require7 = require('../timeStream'),
TimeStream = _require7.TimeStream;
var _require8 = require('../core/validation'),
validateConfig = _require8.validateConfig,
validateRules = _require8.validateRules;
var selectAggregateFunction = require('../analytics/aggregateSelector');
var _require9 = require('../analytics'),
sortEventsForReports = _require9.sortEventsForReports,
sortAggregates = _require9.sortAggregates,
findEventsWithinXPercentOfValue = _require9.findEventsWithinXPercentOfValue,
filterEventsByKeysAndValues = _require9.filterEventsByKeysAndValues,
filterEventsByFlowDirection = _require9.filterEventsByFlowDirection,
findCriticalSnapshots = _require9.findCriticalSnapshots,
findRulesToRetire = _require9.findRulesToRetire,
findIrrelevantRules = _require9.findIrrelevantRules,
findEventsWithProperty = _require9.findEventsWithProperty,
findEventsByPropertyKeyAndValues = _require9.findEventsByPropertyKeyAndValues,
findEventsWithPropertyKeyContainingSubstring = _require9.findEventsWithPropertyKeyContainingSubstring,
findSnapshotsGreaterThanSupport = _require9.findSnapshotsGreaterThanSupport,
findSnapshotsLessThanResistance = _require9.findSnapshotsLessThanResistance,
findGreatestValueSnapshots = _require9.findGreatestValueSnapshots,
sumAllPositiveEventAmounts = _require9.sumAllPositiveEventAmounts,
sumAllNegativeEventAmounts = _require9.sumAllNegativeEventAmounts;
var _require10 = require('../constants'),
STANDARD_OUTPUT = _require10.STANDARD_OUTPUT,
VERBOSE = _require10.VERBOSE,
CONCISE = _require10.CONCISE,
SHY = _require10.SHY,
POSITIVE = _require10.POSITIVE,
NEGATIVE = _require10.NEGATIVE,
BOTH = _require10.BOTH,
EVENTS_BY_GROUP = _require10.EVENTS_BY_GROUP,
EVENTS_BY_GROUPS = _require10.EVENTS_BY_GROUPS,
EVENTS_BY_NAME = _require10.EVENTS_BY_NAME,
EVENTS_BY_NAMES = _require10.EVENTS_BY_NAMES,
EVENTS_BY_TYPE = _require10.EVENTS_BY_TYPE,
EVENTS_BY_TYPES = _require10.EVENTS_BY_TYPES,
EVENTS_BY_KEYS_AND_VALUES = _require10.EVENTS_BY_KEYS_AND_VALUES,
EVENTS = _require10.EVENTS,
CRITICAL_SNAPSHOTS = _require10.CRITICAL_SNAPSHOTS,
DISCARDED_EVENTS = _require10.DISCARDED_EVENTS,
IMPORTANT_EVENTS = _require10.IMPORTANT_EVENTS,
TIME_EVENTS = _require10.TIME_EVENTS,
ROUTINE = _require10.ROUTINE,
REMINDER = _require10.REMINDER,
ROUTINE_EVENTS = _require10.ROUTINE_EVENTS,
REMINDER_EVENTS = _require10.REMINDER_EVENTS,
ROUTINE_AND_REMINDER_EVENTS = _require10.ROUTINE_AND_REMINDER_EVENTS,
RULES_TO_RETIRE = _require10.RULES_TO_RETIRE,
IRRELEVANT_RULES = _require10.IRRELEVANT_RULES,
SUM_OF_ALL_POSITIVE_EVENT_AMOUNTS = _require10.SUM_OF_ALL_POSITIVE_EVENT_AMOUNTS,
SUM_OF_ALL_POSITIVE_EVENT_FLOWS = _require10.SUM_OF_ALL_POSITIVE_EVENT_FLOWS,
SUM_OF_ALL_NEGATIVE_EVENT_AMOUNTS = _require10.SUM_OF_ALL_NEGATIVE_EVENT_AMOUNTS,
SUM_OF_ALL_NEGATIVE_EVENT_FLOWS = _require10.SUM_OF_ALL_NEGATIVE_EVENT_FLOWS,
EVENT_FLOWS_GREATER_THAN_TARGET = _require10.EVENT_FLOWS_GREATER_THAN_TARGET,
EVENT_FLOWS_LESS_THAN_TARGET = _require10.EVENT_FLOWS_LESS_THAN_TARGET,
NEGATIVE_EVENT_FLOWS_GREATER_THAN_TARGET = _require10.NEGATIVE_EVENT_FLOWS_GREATER_THAN_TARGET,
NEGATIVE_EVENT_FLOWS_LESS_THAN_TARGET = _require10.NEGATIVE_EVENT_FLOWS_LESS_THAN_TARGET,
POSITIVE_EVENT_FLOWS_GREATER_THAN_TARGET = _require10.POSITIVE_EVENT_FLOWS_GREATER_THAN_TARGET,
POSITIVE_EVENT_FLOWS_LESS_THAN_TARGET = _require10.POSITIVE_EVENT_FLOWS_LESS_THAN_TARGET,
BALANCE_ENDING_SNAPSHOTS_GREATER_THAN_TARGET = _require10.BALANCE_ENDING_SNAPSHOTS_GREATER_THAN_TARGET,
BALANCE_ENDING_SNAPSHOTS_LESS_THAN_TARGET = _require10.BALANCE_ENDING_SNAPSHOTS_LESS_THAN_TARGET,
GREATEST_BALANCE_ENDING_SNAPSHOTS = _require10.GREATEST_BALANCE_ENDING_SNAPSHOTS,
LEAST_BALANCE_ENDING_SNAPSHOTS = _require10.LEAST_BALANCE_ENDING_SNAPSHOTS,
GREATEST_EVENT_FLOWS = _require10.GREATEST_EVENT_FLOWS,
LEAST_EVENT_FLOWS = _require10.LEAST_EVENT_FLOWS,
GREATEST_POSITIVE_EVENT_FLOWS = _require10.GREATEST_POSITIVE_EVENT_FLOWS,
LEAST_POSITIVE_EVENT_FLOWS = _require10.LEAST_POSITIVE_EVENT_FLOWS,
GREATEST_NEGATIVE_EVENT_FLOWS = _require10.GREATEST_NEGATIVE_EVENT_FLOWS,
LEAST_NEGATIVE_EVENT_FLOWS = _require10.LEAST_NEGATIVE_EVENT_FLOWS,
EVENT_FLOWS_WITHIN_X_PERCENT_OF_TARGET = _require10.EVENT_FLOWS_WITHIN_X_PERCENT_OF_TARGET,
NEGATIVE_EVENT_FLOWS_WITHIN_X_PERCENT_OF_TARGET = _require10.NEGATIVE_EVENT_FLOWS_WITHIN_X_PERCENT_OF_TARGET,
POSITIVE_EVENT_FLOWS_WITHIN_X_PERCENT_OF_TARGET = _require10.POSITIVE_EVENT_FLOWS_WITHIN_X_PERCENT_OF_TARGET,
BALANCE_ENDING_SNAPSHOTS_WITHIN_X_PERCENT_OF_TARGET = _require10.BALANCE_ENDING_SNAPSHOTS_WITHIN_X_PERCENT_OF_TARGET,
AGGREGATES = _require10.AGGREGATES,
REPORT = _require10.REPORT,
AGGREGATE_GROUP = _require10.AGGREGATE_GROUP,
CURRENCY_DEFAULT = _require10.CURRENCY_DEFAULT,
DEFAULT_JSON_SPACING = _require10.DEFAULT_JSON_SPACING,
UTC = _require10.UTC,
LOCAL = _require10.LOCAL,
ASCENDING = _require10.ASCENDING,
DEFAULT_SELECTION_LIMIT = _require10.DEFAULT_SELECTION_LIMIT,
getDefaultParamsForDecimalFormatter = _require10.getDefaultParamsForDecimalFormatter,
getWeekdayString = _require10.getWeekdayString;
var BOUNDARY_LIMIT = 144;
var rightPadToBoundary = function rightPadToBoundary(_ref) {
var leftSideOfHeading = _ref.leftSideOfHeading,
reportCharWidth = _ref.reportCharWidth,
character = _ref.character;
var rightSideOfHeading = '';
var boundaryLimit = reportCharWidth || BOUNDARY_LIMIT;
var length = boundaryLimit - leftSideOfHeading.length < 0 ? 0 : boundaryLimit - leftSideOfHeading.length;
for (var looper = 0; looper < length; looper++) {
rightSideOfHeading = "".concat(rightSideOfHeading).concat(character);
}
var fullLineHeading = rightSideOfHeading ? "".concat(leftSideOfHeading).concat(rightSideOfHeading) : leftSideOfHeading;
return fullLineHeading;
};
var reportingBoundary = function reportingBoundary(_ref2) {
var _ref2$loops = _ref2.loops,
loops = _ref2$loops === void 0 ? 1 : _ref2$loops,
_ref2$char = _ref2["char"],
_char = _ref2$char === void 0 ? '*' : _ref2$char,
reportCharWidth = _ref2.reportCharWidth,
writeStream = _ref2.writeStream;
for (var looper = 0; looper < loops; looper++) {
var leftSideOfHeading = '';
var fullHeading = rightPadToBoundary({
leftSideOfHeading: leftSideOfHeading,
character: _char,
reportCharWidth: reportCharWidth
}); // eslint-disable-next-line no-console
writeStream("".concat(fullHeading, "\n"));
}
};
var lineHeading = function lineHeading(_ref3) {
var heading = _ref3.heading,
_ref3$char = _ref3["char"],
_char2 = _ref3$char === void 0 ? '*' : _ref3$char,
reportCharWidth = _ref3.reportCharWidth,
writeStream = _ref3.writeStream;
var leadingChars = "".concat(_char2).concat(_char2).concat(_char2).concat(_char2).concat(_char2).concat(_char2).concat(_char2).concat(_char2);
var leftSideOfHeading = "".concat(leadingChars).concat(heading);
var fullLineHeading = rightPadToBoundary({
leftSideOfHeading: leftSideOfHeading,
character: _char2,
reportCharWidth: reportCharWidth
}); // eslint-disable-next-line no-console
writeStream("".concat(fullLineHeading, "\n"));
};
var lineSeparator = function lineSeparator(_ref4) {
var _ref4$loops = _ref4.loops,
loops = _ref4$loops === void 0 ? 1 : _ref4$loops,
reportCharWidth = _ref4.reportCharWidth,
writeStream = _ref4.writeStream;
for (var looper = 0; looper < loops; looper++) {
var leftSideOfHeading = '';
var fullHeading = rightPadToBoundary({
leftSideOfHeading: leftSideOfHeading,
character: '-',
reportCharWidth: reportCharWidth
}); // eslint-disable-next-line no-console
writeStream("".concat(fullHeading, "\n"));
}
};
var eventCountHeading = function eventCountHeading(_ref5) {
var events = _ref5.events,
reportCharWidth = _ref5.reportCharWidth,
writeStream = _ref5.writeStream;
lineHeading({
heading: " event count: ".concat(events.length, " "),
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
};
var showNothingToDisplay = function showNothingToDisplay(_ref6) {
var reportCharWidth = _ref6.reportCharWidth,
writeStream = _ref6.writeStream;
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
}); // eslint-disable-next-line quotes
lineHeading({
heading: " nothing to display ",
"char": '-',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
};
var shyOutput = function shyOutput(_ref7) {
var event = _ref7.event,
reportingConfig = _ref7.reportingConfig,
currencySymbol = _ref7.currencySymbol,
reportCharWidth = _ref7.reportCharWidth,
writeStream = _ref7.writeStream;
var _getDefaultParamsForD = getDefaultParamsForDecimalFormatter(reportingConfig.formatting || {}),
formattingFunction = _getDefaultParamsForD.formattingFunction,
minIntegerDigits = _getDefaultParamsForD.minIntegerDigits,
minDecimalDigits = _getDefaultParamsForD.minDecimalDigits,
maxDecimalDigits = _getDefaultParamsForD.maxDecimalDigits,
locale = _getDefaultParamsForD.locale,
style = _getDefaultParamsForD.style; // eslint-disable-next-line no-console
if (!isUndefinedOrNull(event.name)) writeStream("name: ".concat(event.name, "\n")); // eslint-disable-line quotes
// eslint-disable-next-line no-console
if (!isUndefinedOrNull(event.amount)) {
// eslint-disable-next-line no-console
writeStream("amount: ".concat(formattingFunction(event.amount, {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: event.currencySymbol || CURRENCY_DEFAULT
}), "\n"));
}
if (!isUndefinedOrNull(event.amount) && !isUndefinedOrNull(event.balanceEnding)) {
// eslint-disable-next-line no-console
writeStream("balanceEnding: ".concat(formattingFunction(event.balanceEnding, {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: currencySymbol || CURRENCY_DEFAULT
}), "\n"));
} // eslint-disable-next-line no-console
if (event.dateStart) writeStream("dateStart: ".concat(event.dateStart, "\n")); // eslint-disable-line quotes
// eslint-disable-next-line no-console
if (event.timeStart) writeStream("timeStart: ".concat(event.timeStart, "\n"));
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
};
var conciseOutput = function conciseOutput(_ref8) {
var event = _ref8.event,
reportingConfig = _ref8.reportingConfig,
currencySymbol = _ref8.currencySymbol,
reportCharWidth = _ref8.reportCharWidth,
writeStream = _ref8.writeStream;
var _getDefaultParamsForD2 = getDefaultParamsForDecimalFormatter(reportingConfig.formatting || {}),
formattingFunction = _getDefaultParamsForD2.formattingFunction,
minIntegerDigits = _getDefaultParamsForD2.minIntegerDigits,
minDecimalDigits = _getDefaultParamsForD2.minDecimalDigits,
maxDecimalDigits = _getDefaultParamsForD2.maxDecimalDigits,
locale = _getDefaultParamsForD2.locale,
style = _getDefaultParamsForD2.style; // eslint-disable-next-line no-console
if (!isUndefinedOrNull(event.name)) writeStream("name: ".concat(event.name, "\n")); // eslint-disable-next-line no-console
if (!isUndefinedOrNull(event.group)) writeStream("group: ".concat(event.group, "\n"));
if (!isUndefinedOrNull(event.amount)) {
// eslint-disable-next-line no-console
writeStream("amount: ".concat(formattingFunction(event.amount, {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: event.currencySymbol || CURRENCY_DEFAULT
}), "\n"));
}
if (!isUndefinedOrNull(event.amount) && !isUndefinedOrNull(event.balanceEnding)) {
// eslint-disable-next-line no-console
writeStream("balanceEnding: ".concat(formattingFunction(event.balanceEnding, {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: currencySymbol || CURRENCY_DEFAULT
}), "\n"));
} // eslint-disable-next-line no-console
if (event.dateStart) writeStream("dateStart: ".concat(event.dateStart, "\n")); // eslint-disable-next-line no-console
if (event.dateEnd) writeStream("dateEnd: ".concat(event.dateEnd, "\n")); // eslint-disable-next-line no-console
if (event.timeStart) writeStream("timeStart: ".concat(event.timeStart, "\n")); // eslint-disable-next-line no-console
if (event.timeEnd) writeStream("timeEnd: ".concat(event.timeEnd, "\n")); // eslint-disable-next-line no-console
if (!isUndefinedOrNull(event.weekdayStart)) {
var weekdayString = getWeekdayString(event.weekdayStart);
writeStream("weekdayStart: ".concat(weekdayString, "\n")); // eslint-disable-line no-console
}
if (!isUndefinedOrNull(event.weekdayEnd)) {
var _weekdayString = getWeekdayString(event.weekdayEnd);
writeStream("weekdayEnd: ".concat(_weekdayString, "\n")); // eslint-disable-line no-console
} // eslint-disable-next-line no-console
if (!isUndefinedOrNull(event.notes)) writeStream("notes: ".concat(event.notes, "\n")); // eslint-disable-line quotes
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
};
var verboseOutput = function verboseOutput(_ref9) {
var event = _ref9.event,
reportingConfig = _ref9.reportingConfig,
currencySymbol = _ref9.currencySymbol,
reportCharWidth = _ref9.reportCharWidth,
writeStream = _ref9.writeStream;
var _getDefaultParamsForD3 = getDefaultParamsForDecimalFormatter(reportingConfig.formatting || {}),
formattingFunction = _getDefaultParamsForD3.formattingFunction,
minIntegerDigits = _getDefaultParamsForD3.minIntegerDigits,
minDecimalDigits = _getDefaultParamsForD3.minDecimalDigits,
maxDecimalDigits = _getDefaultParamsForD3.maxDecimalDigits,
locale = _getDefaultParamsForD3.locale,
style = _getDefaultParamsForD3.style;
var ttyMessageStack = [];
var dataBouncer = function dataBouncer(message, order) {
ttyMessageStack.push({
message: message,
order: order
});
};
Object.entries(event).forEach(function (_ref10) {
var _ref11 = (0, _slicedToArray2["default"])(_ref10, 2),
key = _ref11[0],
value = _ref11[1];
if (key !== 'specialAdjustments' && key !== 'exclusions' && key !== 'processDate' && key !== 'frequency' && key !== 'ruleModification' && key !== 'transientData') {
if (key === 'name' && event.name != null) {
dataBouncer("name: ".concat(event.name), 10); // eslint-disable-line quotes
} else if (key === 'entityType') {
dataBouncer("entityType: ".concat(event.entityType), 15);
} else if (key === 'type') {
dataBouncer("type: ".concat(event.type), 20);
} else if (key === 'frequency' && typeof event.frequency === 'string') {
dataBouncer("frequency: ".concat(event.frequency), 30); // code check: this line might be redundant, check to see if we are deleting frequency (if not a string) from the event printing process
} else if (key === 'context') {
dataBouncer("context: ".concat(event.context), 40);
} else if (key === 'currencySymbol' && !isUndefinedOrNull(event.amount)) {
dataBouncer("currencySymbol: ".concat(event.currencySymbol), 50);
} else if (key === 'amount') {
dataBouncer("amount: ".concat(formattingFunction(event.amount, {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: event.currencySymbol || CURRENCY_DEFAULT
})), 60);
} else if (key === 'balanceBeginning' && !isUndefinedOrNull(event.amount)) {
dataBouncer("balanceBeginning: ".concat(formattingFunction(event.balanceBeginning, {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: currencySymbol || CURRENCY_DEFAULT
})), 80);
} else if (key === 'balanceEnding' && !isUndefinedOrNull(event.amount)) {
dataBouncer("balanceEnding: ".concat(formattingFunction(event.balanceEnding, {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: currencySymbol || CURRENCY_DEFAULT
})), 90);
} else if (key === 'sortPriority' && key.sortPriority != null) {
dataBouncer("sortPriority: ".concat(event.sortPriority), 150);
} else if (key === 'timeZone') {
dataBouncer("timeZone: ".concat(event.timeZone), 160);
} else if (key === 'timeZoneType') {
dataBouncer("timeZoneType: ".concat(event.timeZoneType), 170);
} else if (key === 'timeStart' && event.timeStart != null) {
dataBouncer("timeStart: ".concat(event.timeStart), 180);
} else if (key === 'timeEnd' && event.timeEnd != null) {
dataBouncer("timeEnd: ".concat(event.timeEnd), 190);
} else if (key === 'dateStart' && event.dateStart != null) {
dataBouncer("dateStart: ".concat(event.dateStart), 200);
} else if (key === 'dateEnd' && event.dateEnd != null) {
dataBouncer("dateEnd: ".concat(event.dateEnd), 210);
} else if (key === 'weekdayStart' && event.weekdayStart != null) {
var weekdayString = getWeekdayString(event.weekdayStart);
dataBouncer("weekdayStart: ".concat(weekdayString), 220);
} else if (key === 'weekdayEnd' && event.weekdayEnd != null) {
var _weekdayString2 = getWeekdayString(event.weekdayEnd);
dataBouncer("weekdayEnd: ".concat(_weekdayString2), 230);
} else if (key === 'spanningDays' && event.spanningDays != null) {
dataBouncer("spanningDays: ".concat(event.spanningDays), 231);
} else if (key === 'spanningHours' && event.spanningHours != null) {
dataBouncer("spanningHours: ".concat(event.spanningHours), 232);
} else if (key === 'spanningMinutes' && event.spanningMinutes != null) {
dataBouncer("spanningMinutes: ".concat(event.spanningMinutes), 233);
} else if (key === 'cycle' && event.cycle != null) {
dataBouncer("cycle: ".concat(event.cycle), 234);
} else if (key === 'modulus' && event.modulus != null) {
dataBouncer("modulus: ".concat(event.modulus), 235);
} else if (key === 'anchorSyncDate' && event.anchorSyncDate != null) {
dataBouncer("anchorSyncDate: ".concat(event.anchorSyncDate), 236);
} else if (key === 'effectiveDateStart' && event.effectiveDateStart != null) {
dataBouncer("effectiveDateStart: ".concat(event.effectiveDateStart), 240);
} else if (key === 'effectiveDateEnd' && event.effectiveDateEnd != null) {
dataBouncer("effectiveDateEnd: ".concat(event.effectiveDateEnd), 250);
} else if (key === 'eventSourceCurrencySymbol' && event.eventSourceCurrencySymbol != null && !isUndefinedOrNull(event.amount)) {
dataBouncer("eventSourceCurrencySymbol: ".concat(event.eventSourceCurrencySymbol), 252);
} else if (key === 'eventSourceCurrencyAmount' && event.eventSourceCurrencyAmount != null && !isUndefinedOrNull(event.amount)) {
dataBouncer("eventSourceCurrencyAmount: ".concat(event.eventSourceCurrencyAmount), 254);
} else if (key === 'eventSourceTimeZoneType' && event.eventSourceTimeZoneType != null) {
dataBouncer("eventSourceTimeZoneType: ".concat(event.eventSourceTimeZoneType), 260);
} else if (key === 'eventSourceTimeZone' && event.eventSourceTimeZone != null) {
dataBouncer("eventSourceTimeZone: ".concat(event.eventSourceTimeZone), 270);
} else if (key === 'dateTimeStartEventSource' && event.dateTimeStartEventSource != null) {
dataBouncer("dateTimeStartEventSource: ".concat(event.dateTimeStartEventSource), 280);
} else if (key === 'dateTimeObserverSource' && event.dateTimeObserverSource != null) {
dataBouncer("dateTimeObserverSource: ".concat(event.dateTimeObserverSource), 290);
} else if (key !== 'name' && key !== 'entityType' && key !== 'type' && key !== 'frequency' && key !== 'context' && key !== 'currencySymbol' && key !== 'amount' && key !== 'balanceBeginning' && key !== 'balanceEnding' && key !== 'sortPriority' && key !== 'timeZone' && key !== 'timeZoneType' && key !== 'timeStart' && key !== 'timeEnd' && key !== 'dateStart' && key !== 'dateEnd' && key !== 'weekdayStart' && key !== 'weekdayEnd' && key !== 'spanningDays' && key !== 'spanningHours' && key !== 'spanningMinutes' && key !== 'cycle' && key !== 'modulus' && key !== 'anchorSyncDate' && key !== 'effectiveDateStart' && key !== 'effectiveDateEnd' && key !== 'eventSourceCurrencySymbol' && key !== 'eventSourceCurrencyAmount' && key !== 'eventSourceTimeZoneType' && key !== 'eventSourceTimeZone' && key !== 'dateTimeStartEventSource' && key !== 'dateTimeObserverSource') {
// eslint-disable-next-line no-console
dataBouncer("".concat(key, ": ").concat(value), 300);
}
}
});
var ttyMessageStackOrdered = ttyMessageStack.slice().sort(function (a, b) {
if (a.order > b.order) {
return 1;
} else if (a.order < b.order) {
return -1; // eslint-disable-next-line no-else-return
} else {
return 0;
}
});
ttyMessageStackOrdered.forEach(function (obj) {
writeStream("".concat(obj.message, "\n")); // eslint-disable-line no-console
});
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
};
var eventsLogger = function eventsLogger(_ref12) {
var events = _ref12.events,
reportingConfig = _ref12.reportingConfig,
currencySymbol = _ref12.currencySymbol,
_ref12$showNothingToD = _ref12.showNothingToDisplaySwitch,
showNothingToDisplaySwitch = _ref12$showNothingToD === void 0 ? true : _ref12$showNothingToD,
reportCharWidth = _ref12.reportCharWidth,
_ref12$leadingLineSep = _ref12.leadingLineSeparator,
leadingLineSeparator = _ref12$leadingLineSep === void 0 ? true : _ref12$leadingLineSep,
writeStream = _ref12.writeStream;
if (events && events.length > 0) {
if (leadingLineSeparator) {
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
switch (reportingConfig.mode) {
case VERBOSE:
events.forEach(function (event) {
verboseOutput({
event: event,
reportingConfig: reportingConfig,
currencySymbol: currencySymbol,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
});
break;
case CONCISE:
events.forEach(function (event) {
conciseOutput({
event: event,
reportingConfig: reportingConfig,
currencySymbol: currencySymbol,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
});
break;
case SHY:
events.forEach(function (event) {
shyOutput({
event: event,
reportingConfig: reportingConfig,
currencySymbol: currencySymbol,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
});
break;
default:
break;
}
eventCountHeading({
events: events,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
} else if (showNothingToDisplaySwitch) {
showNothingToDisplay({
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
};
var aggregateHeader = function aggregateHeader(_ref13) {
var aggregateConfig = _ref13.aggregateConfig,
reportCharWidth = _ref13.reportCharWidth,
writeStream = _ref13.writeStream;
reportingBoundary({
loops: 1,
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineHeading({
heading: " begin aggregate group: ",
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
if (!isUndefinedOrNull(aggregateConfig.name)) {
lineHeading({
heading: " name: ".concat(aggregateConfig.name, " "),
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
if (!isUndefinedOrNull(aggregateConfig.type)) {
lineHeading({
heading: " type: ".concat(aggregateConfig.type, " "),
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
if (!isUndefinedOrNull(aggregateConfig.frequency)) {
lineHeading({
heading: " frequency: ".concat(aggregateConfig.frequency, " "),
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
if (!isUndefinedOrNull(aggregateConfig.propertyKey)) {
lineHeading({
heading: " propertyKey: ".concat(aggregateConfig.propertyKey, " "),
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
if (!isUndefinedOrNull(aggregateConfig.sortKey)) {
lineHeading({
heading: " sortKey: ".concat(aggregateConfig.sortKey, " "),
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
if (!isUndefinedOrNull(aggregateConfig.sortDirection)) {
lineHeading({
heading: " sortDirection: ".concat(aggregateConfig.sortDirection, " "),
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
if (!isUndefinedOrNull(aggregateConfig.flowDirection)) {
lineHeading({
heading: " flowDirection: ".concat(aggregateConfig.flowDirection, " "),
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
if (!isUndefinedOrNull(aggregateConfig.selectionLimit)) {
lineHeading({
heading: " selectionLimit: ".concat(aggregateConfig.selectionLimit, " "),
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
if (!isUndefinedOrNull(aggregateConfig.modeMax)) {
lineHeading({
heading: " modeMax: ".concat(aggregateConfig.modeMax, " "),
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
if (aggregateConfig.xPercentRange) {
lineHeading({
heading: " xPercentRange: ".concat(aggregateConfig.xPercentRange, " "),
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
if (!isUndefinedOrNull(aggregateConfig.dayCycles)) {
lineHeading({
heading: " dayCycles: ".concat(aggregateConfig.dayCycles, " "),
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
reportingBoundary({
loops: 1,
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
};
var aggregateFooter = function aggregateFooter(_ref14) {
var aggregateConfig = _ref14.aggregateConfig,
reportCharWidth = _ref14.reportCharWidth,
writeStream = _ref14.writeStream;
reportingBoundary({
loops: 1,
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineHeading({
heading: " end aggregate group: ",
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
if (!isUndefinedOrNull(aggregateConfig.name)) {
lineHeading({
heading: " name: ".concat(aggregateConfig.name, " "),
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
if (!isUndefinedOrNull(aggregateConfig.type)) {
lineHeading({
heading: " type: ".concat(aggregateConfig.type, " "),
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
reportingBoundary({
loops: 1,
"char": '%',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
};
var getStringOfValues = function getStringOfValues(_ref15) {
var data = _ref15.data,
formattingFunction = _ref15.formattingFunction,
minIntegerDigits = _ref15.minIntegerDigits,
minDecimalDigits = _ref15.minDecimalDigits,
maxDecimalDigits = _ref15.maxDecimalDigits,
locale = _ref15.locale,
style = _ref15.style,
currencySymbol = _ref15.currencySymbol;
var stringOfValues = '';
if (typeof data === 'number') {
stringOfValues = "".concat(formattingFunction(data, {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: currencySymbol || CURRENCY_DEFAULT
}));
} else {
// arraay
data.forEach(function (val, i) {
stringOfValues += "".concat(formattingFunction(val, {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: currencySymbol || CURRENCY_DEFAULT
}));
if (i !== data.length - 1) {
stringOfValues += ', ';
}
});
}
return stringOfValues;
};
var aggregateLogger = function aggregateLogger(_ref16) {
var aggregateConfig = _ref16.aggregateConfig,
aggregate = _ref16.aggregate,
reportingConfig = _ref16.reportingConfig,
currencySymbol = _ref16.currencySymbol,
reportCharWidth = _ref16.reportCharWidth,
writeStream = _ref16.writeStream;
// adding
var _getDefaultParamsForD4 = getDefaultParamsForDecimalFormatter(reportingConfig.formatting || {}),
formattingFunction = _getDefaultParamsForD4.formattingFunction,
minIntegerDigits = _getDefaultParamsForD4.minIntegerDigits,
minDecimalDigits = _getDefaultParamsForD4.minDecimalDigits,
maxDecimalDigits = _getDefaultParamsForD4.maxDecimalDigits,
locale = _getDefaultParamsForD4.locale,
style = _getDefaultParamsForD4.style;
if (!isUndefinedOrNull(aggregateConfig.name)) {
writeStream("group: ".concat(aggregateConfig.name, "\n"));
}
if (reportingConfig.mode === CONCISE) {
writeStream("type: ".concat(aggregateConfig.type, "\n"));
} else if (reportingConfig.mode === VERBOSE) {
writeStream("entityType: ".concat(aggregate.entityType, "\n"));
writeStream("type: ".concat(aggregateConfig.type, "\n"));
}
writeStream("dateStart: ".concat(aggregate.dateStart, "\n")); // eslint-disable-line quotes
writeStream("dateEnd: ".concat(aggregate.dateEnd, "\n")); // eslint-disable-line quotes
writeStream("eventCount: ".concat(aggregate.eventCount, "\n")); // eslint-disable-line quotes
if (!isUndefinedOrNull(aggregate.sum)) {
// eslint-disable-next-line no-console
writeStream("sum: ".concat(formattingFunction(aggregate.sum, {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: currencySymbol || CURRENCY_DEFAULT
}), "\n"));
}
if (!isUndefinedOrNull(aggregate.average)) {
// eslint-disable-next-line no-console
writeStream("average: ".concat(formattingFunction(aggregate.average, {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: currencySymbol || CURRENCY_DEFAULT
}), "\n"));
}
if (!isUndefinedOrNull(aggregate.min)) {
writeStream("min: ".concat(formattingFunction(aggregate.min, {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: currencySymbol || CURRENCY_DEFAULT
}), "\n"));
}
if (!isUndefinedOrNull(aggregate.max)) {
writeStream("max: ".concat(formattingFunction(aggregate.max, {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: currencySymbol || CURRENCY_DEFAULT
}), "\n"));
}
if (!isUndefinedOrNull(aggregate.medians)) {
var stringOfValues = getStringOfValues({
data: aggregate.medians,
formattingFunction: formattingFunction,
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currencySymbol: currencySymbol
});
writeStream("medians: ".concat(stringOfValues, "\n")); // eslint-disable-line quotes
}
if (!isUndefinedOrNull(aggregate.modes)) {
var _stringOfValues = getStringOfValues({
data: aggregate.modes,
formattingFunction: formattingFunction,
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currencySymbol: currencySymbol
});
writeStream("modes: ".concat(_stringOfValues, "\n")); // eslint-disable-line quotes
}
if (!isUndefinedOrNull(aggregate.greatestValues)) {
var _stringOfValues2 = getStringOfValues({
data: aggregate.greatestValues,
formattingFunction: formattingFunction,
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currencySymbol: currencySymbol
});
writeStream("greatestValues: ".concat(_stringOfValues2, "\n")); // eslint-disable-line quotes
}
if (!isUndefinedOrNull(aggregate.leastValues)) {
var _stringOfValues3 = getStringOfValues({
data: aggregate.leastValues,
formattingFunction: formattingFunction,
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currencySymbol: currencySymbol
});
writeStream("leastValues: ".concat(_stringOfValues3, "\n")); // eslint-disable-line quotes
}
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
};
var standardHeader = function standardHeader(_ref17) {
var reportingConfig = _ref17.reportingConfig,
dateString = _ref17.dateString,
timeString = _ref17.timeString,
weekdayString = _ref17.weekdayString,
reportCharWidth = _ref17.reportCharWidth,
writeStream = _ref17.writeStream;
reportingBoundary({
loops: 3,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineHeading({
heading: ' daniel-san: astral-projecting your budget with a crane-kick to the face ',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineHeading({
heading: ' must find balance ',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
reportingBoundary({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
if (!isUndefinedOrNull(reportingConfig.name)) {
lineHeading({
heading: " report name: ".concat(reportingConfig.name, " "),
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
lineHeading({
heading: " report mode: ".concat(reportingConfig.mode, " "),
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineHeading({
heading: " report date: ".concat(weekdayString, ", ").concat(dateString, " ").concat(timeString, " local time "),
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
reportingBoundary({
loops: 3,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
}); // eslint-disable-next-line no-console
writeStream("".concat(getRandomMiyagiQuote(), "\n"));
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
};
var standardSubheader = function standardSubheader(_ref18) {
var danielSan = _ref18.danielSan,
reportingConfig = _ref18.reportingConfig,
reportCharWidth = _ref18.reportCharWidth,
writeStream = _ref18.writeStream;
var _getDefaultParamsForD5 = getDefaultParamsForDecimalFormatter(reportingConfig.formatting || {}),
formattingFunction = _getDefaultParamsForD5.formattingFunction,
minIntegerDigits = _getDefaultParamsForD5.minIntegerDigits,
minDecimalDigits = _getDefaultParamsForD5.minDecimalDigits,
maxDecimalDigits = _getDefaultParamsForD5.maxDecimalDigits,
locale = _getDefaultParamsForD5.locale,
style = _getDefaultParamsForD5.style;
lineHeading({
heading: " config ",
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
if (!isUndefinedOrNull(danielSan['balanceBeginning'])) {
lineHeading({
heading: " currencySymbol: ".concat(danielSan.config.currencySymbol, " "),
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineHeading({
heading: " balanceBeginning: ".concat(formattingFunction(danielSan['balanceBeginning'], {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: danielSan.config.currencySymbol || CURRENCY_DEFAULT
}), " "),
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
if (!isUndefinedOrNull(danielSan['balanceEnding'])) {
lineHeading({
heading: " balanceEnding: ".concat(formattingFunction(danielSan['balanceEnding'], {
minIntegerDigits: minIntegerDigits,
minDecimalDigits: minDecimalDigits,
maxDecimalDigits: maxDecimalDigits,
locale: locale,
style: style,
currency: danielSan.config.currencySymbol || CURRENCY_DEFAULT
}), " "),
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
if (!isUndefinedOrNull(danielSan.config.timeZoneType)) {
lineHeading({
heading: " timeZoneType: ".concat(danielSan.config.timeZoneType, " "),
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
if (!isUndefinedOrNull(danielSan.config.timeZone)) {
lineHeading({
heading: " timeZone: ".concat(danielSan.config.timeZone, " "),
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
lineHeading({
heading: " effectiveDateStart: ".concat(danielSan.config.effectiveDateStart, " "),
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
if (danielSan.config.timeStart) {
lineHeading({
heading: " timeStart: ".concat(danielSan.config.timeStart, " "),
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
lineHeading({
heading: " effectiveDateEnd: ".concat(danielSan.config.effectiveDateEnd, " "),
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
if (danielSan.config.timeEnd) {
lineHeading({
heading: " timeEnd: ".concat(danielSan.config.timeEnd, " "),
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
};
var filterOutRoutinesAndReminders = function filterOutRoutinesAndReminders(events) {
return events.filter(function (event) {
return !event.type.includes(ROUTINE) && !event.type.includes(REMINDER);
});
};
var showRulesToRetire = function showRulesToRetire(_ref19) {
var danielSan = _ref19.danielSan,
reportingConfig = _ref19.reportingConfig,
rule = _ref19.rule,
reportCharWidth = _ref19.reportCharWidth,
writeStream = _ref19.writeStream;
var preSortedRules = findRulesToRetire(danielSan);
var rulesToRetire = sortEventsForReports({
sortKey: rule.sortKey,
sortDirection: rule.sortDirection,
selectionLimit: rule.selectionLimit,
uniqueKey: rule.uniqueKey,
events: preSortedRules
});
if (!reportingConfig.rawJson) {
if (rulesToRetire && rulesToRetire.length > 0) {
lineHeading({
heading: ' the following rules have obsolete effectiveDateEnd values ',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
eventsLogger({
events: rulesToRetire,
reportingConfig: reportingConfig,
currencySymbol: danielSan.config.currencySymbol || CURRENCY_DEFAULT,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
} else {
return rulesToRetire || [];
}
};
var showIrrelevantRules = function showIrrelevantRules(_ref20) {
var danielSan = _ref20.danielSan,
reportingConfig = _ref20.reportingConfig,
rule = _ref20.rule,
reportCharWidth = _ref20.reportCharWidth,
writeStream = _ref20.writeStream;
// when executing in this context, there is a chance that the config/rules have not yet been validated (both are validated prior to calling findIrrelevantRules during the normal projection phase)
validateConfig(danielSan);
var timeStream = new TimeStream({
effectiveDateStartString: danielSan.config.effectiveDateStart,
effectiveDateEndString: danielSan.config.effectiveDateEnd,
timeStartString: danielSan.config.timeStart,
timeEndString: danielSan.config.timeEnd,
timeZone: danielSan.config.timeZone,
timeZoneType: danielSan.config.timeZoneType
}); // we will pass false for skipTimeTravel for simplicity, since whether or not the time zones in the config are identical to the time zones in rules,
// the performance overhead is minor in this case
validateRules({
danielSan: danielSan,
date: timeStream.effectiveDateStart,
skipTimeTravel: false
});
var _findIrrelevantRules = findIrrelevantRules(danielSan),
preSortedRules = _findIrrelevantRules.irrelevantRules;
var irrelevantRules = sortEventsForReports({
sortKey: rule.sortKey,
sortDirection: rule.sortDirection,
selectionLimit: rule.selectionLimit,
uniqueKey: rule.uniqueKey,
events: preSortedRules
});
if (!reportingConfig.rawJson) {
if (irrelevantRules && irrelevantRules.length > 0) {
lineHeading({
heading: ' the following rules would not be triggered via the current configuration ',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
eventsLogger({
events: irrelevantRules,
reportingConfig: reportingConfig,
currencySymbol: danielSan.config.currencySymbol || CURRENCY_DEFAULT,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
} else {
return irrelevantRules || [];
}
};
var showDiscardedEvents = function showDiscardedEvents(_ref21) {
var danielSan = _ref21.danielSan,
reportingConfig = _ref21.reportingConfig,
_ref21$showNothingToD = _ref21.showNothingToDisplaySwitch,
showNothingToDisplaySwitch = _ref21$showNothingToD === void 0 ? true : _ref21$showNothingToD,
rule = _ref21.rule,
reportCharWidth = _ref21.reportCharWidth,
_ref21$leadingLineSep = _ref21.leadingLineSeparator,
leadingLineSeparator = _ref21$leadingLineSep === void 0 ? true : _ref21$leadingLineSep,
_ref21$trailingFooter = _ref21.trailingFooter,
trailingFooter = _ref21$trailingFooter === void 0 ? false : _ref21$trailingFooter,
writeStream = _ref21.writeStream;
var discardedEvents = sortEventsForReports({
sortKey: rule.sortKey,
sortDirection: rule.sortDirection,
selectionLimit: rule.selectionLimit,
uniqueKey: rule.uniqueKey,
events: danielSan.discardedEvents
});
if (!reportingConfig.rawJson) {
if (discardedEvents && discardedEvents.length > 0) {
if (leadingLineSeparator) {
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
reportingBoundary({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineHeading({
heading: ' these events were excluded for residing beyond the provided date range ',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
reportingBoundary({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
eventsLogger({
events: discardedEvents,
reportingConfig: reportingConfig,
currencySymbol: danielSan.config.currencySymbol || CURRENCY_DEFAULT,
showNothingToDisplaySwitch: showNothingToDisplaySwitch,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
if (trailingFooter) {
lineHeading({
heading: ' end discarded events ',
"char": '-',
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
lineSeparator({
loops: 2,
reportCharWidth: reportCharWidth,
writeStream: writeStream
});
}
}
} else {
return discardedEvents || [];
}
};
var showCriticalSnapshots = function showCriticalSnapshots(_ref22) {
var danielSan = _ref22.danielSan,
events = _ref22.events,
reportingConfig = _ref22.reportingConfig,
rule = _ref22.rule,
_ref22$showNothingToD = _ref22.showNothingToDisplaySwitch,
showNothingToDisplaySwitch = _ref22$showNothingToD === void 0 ? true : _ref22$showNothingToD,
reportCharWidth = _ref22.reportCharWidth,
_ref22$leadingLineSep = _ref22.leadingLineSeparator,
leadingLineSeparator = _ref22$leadingLineSep === void 0 ? true : _ref22$leadingLineSep,
writeStream = _ref22.writeStream;
var preSortedSnapshots = findCriticalSnapshots({
events: events,
criticalThreshold: rule.criticalThreshold
});
var criticalSnapshots = sortEventsForReports({
sortKey: rule.sortKey,
sortDirection: rule.sortDirection,
selectionLimit: rule.selectionLimit,
uniqueKey: rule.uniqueKey,
events: preSortedSnapshots
});
if (!reportingConfig.rawJson) {
if (criticalSnapshots && criticalSnapshots.length > 0) {
var _getDefaultParamsForD6 = getDefaultParamsForDecimalFormatter(reportingConfig.formatting || {}),
formattingF