@nqminds/fin-genie-gl-reconciliator
Version:
A databot for general ledger reconciliation for FinGenie
34 lines (27 loc) • 1.01 kB
JavaScript
;
const {financialRound} = require("./utils");
/**
* @typedef GlEntry
* @property {string} ac - account code for entry
* @property {string} id - unique identifier
* @property {number} bal - balance associated with entry
* @property {string} po - purchase order for entry
* @property {string} inv - invoice id for entry
* @property {string} cc- cost centre fore entry
*/
/**
* @typedef TransactionChain
* @property {string} id - the value on which this transaction chain was grouped
* @property {GlEntry[]} glEntries - array of general ledger entries
*/
/**
* Verifies whether a series of gl entries form a valid transaction chain
*
* @param {TransactionChain} transaction - details of a transaction to verify
* @returns {boolean} true if chain is valid, false otherwise
*/
function verifyTransactionComplete(transaction) {
const total = financialRound(transaction.glEntries.reduce((sum, {bal}) => sum += bal, 0));
return !total;
}
module.exports = verifyTransactionComplete;