@nqminds/fin-genie-gl-reconciliator
Version:
A databot for general ledger reconciliation for FinGenie
110 lines (104 loc) • 1.6 kB
JavaScript
"use strict";
/**
* A pipeline for grouping gl entries into transactions.
* This does not make any guarantee about the accuracy, only that the produced
* chains are likely matches
*/
const po = [
{
$match: {
trnTyp: {$ne: "Non SLA"},
po: {$ne: ""},
},
},
{
$group: {
_id: "$po",
glEntries: {
$push: {
ac: "$ac",
id: "$id",
bal: "$bal",
po: "$po",
inv: "$inv",
cc: "$cc",
splr: "$splr",
},
},
},
},
{
$project: {
po: "$_id",
glEntries: "$glEntries",
_id: 0,
},
},
];
const inv = [
{
$match: {
trnTyp: {$ne: "Non SLA"},
po: {$eq: ""},
inv: {$ne: ""},
},
},
{
$group: {
_id: "$inv",
glEntries: {
$push: {
ac: "$ac",
id: "$id",
bal: "$bal",
po: "$po",
inv: "$inv",
cc: "$cc",
splr: "$splr",
},
},
},
},
{
$project: {
inv: "$_id",
glEntries: "$glEntries",
_id: 0,
},
},
];
const jrn = [
{
$match: {
trnTyp: "Non SLA",
},
},
{
$group: {
_id: "$jrnDsc",
glEntries: {
$push: {
ac: "$ac",
id: "$id",
bal: "$bal",
po: "$po",
inv: "$inv",
cc: "$cc",
splr: "$splr",
},
},
},
},
{
$project: {
jrnDsc: "$_id",
glEntries: "$glEntries",
_id: 0,
},
},
];
module.exports = {
po,
inv,
jrn,
};