-
-
Notifications
You must be signed in to change notification settings - Fork 151
Current reconciliation algorithm
Erik Huelsmann edited this page Jan 21, 2023
·
3 revisions
Visualization of https://github.com/ledgersmb/LedgerSMB/blob/8d552700ab5fdcfdabea0f2ed0baf617df4da891/sql/modules/Reconciliation.sql#L354-L507
flowchart TD
start[Get check prefix from config]
checkScn{{'scn' not null and not empty?}}
checkScnNumeric{{'scn' numeric only?}}
prepScn[Add check prefix to 'scn']
checkScnTxn{{Any uncleared txn-s with scn and post date? 'match 1'}}
scnNoMatch[Create a recon line using amount/source/balance/date/type]
scnExactMatch[Update matching item with entry balance & date]
scnMultiMatch{{Same, with same balance amount? 'match 2' }}
scnMMNoBalance[Match smallest balance item from 'match 1']
scnMMMultiBalance[Match first item from 'match 2']
scnMMUpdate[Update matched item with entry data]
checkNoScnBalanceMatch{{Any uncleared txn-s with matching balance and post date? 'match 3'}}
noScnNoMatch[Create a recon line using amount/source/balance/date]
noScnUpdate[Update matching item using amount/balance/date/type]
noScnMultiMatch[Match first item from 'match 3' ]
start --> checkScn
checkScn -->|yes| checkScnNumeric
checkScn -->|no| checkNoScnBalanceMatch
checkScnNumeric -->|yes| prepScn
prepScn --> checkScnTxn
checkScnNumeric -->|no| checkScnTxn
checkScnTxn -->|count=0| scnNoMatch
checkScnTxn -->|count=1| scnExactMatch
checkScnTxn -->|count>1| scnMultiMatch
scnMultiMatch -->|count=0| scnMMNoBalance
scnMMNoBalance --> scnMMUpdate
scnMultiMatch -->|count=1| scnMMUpdate
scnMultiMatch -->|count>1| scnMMMultiBalance
scnMMMultiBalance --> scnMMUpdate
checkNoScnBalanceMatch -->|count=0| noScnNoMatch
checkNoScnBalanceMatch -->|count=1| noScnUpdate
checkNoScnBalanceMatch -->|count>1| noScnMultiMatch
noScnMultiMatch --> noScnUpdate
noScnUpdate --> final
scnMMUpdate --> final
noScnNoMatch --> final
scnNoMatch --> final
scnExactMatch --> final