-
Notifications
You must be signed in to change notification settings - Fork 2
Cash Matching
Home > Features > Record Matching > Cash Matching
Reconciliation should run daily for each SBC location. For each location, the cash_deposit table is queried for a list of deposit dates specific to the location, and then for each date on which a deposit has occured, the cash match reconciliation service is called. Cash deposits may have more than one deposit on a single deposit date, but each deposit must have only one corresponding transaction fiscal-close_date. The sum of all cash payments from one fiscal close date for a location is matched to the deposit amount.
Payments and deposits match many -> 1 and so the corresponding payments are found by aggregating the sum of payments per fiscal_close_date, per location. They must match on all of the following heuristics. If no match is found the status will update to IN_PROGRESS for both payment and deposit. If not match is found after 2 subsequent deposit dates for the location then the payment status is updated to EXCEPTION. If a deposit does not match to any corresponding payments after 2 subsequent deposit dates then the deposit status is set as EXCEPTION.
- Status (PENDING or IN_PROGRESS)
- Location (cash_deposit.pt_location_id ---> payment.transaction.location_id)
- Transaction Date (cash_depsoit.deposit_date ---> payment.transaction.fiscal_close_date)
- Amount (cash_deposit.deposit_amt_cdn ---> _SUM(payment.amount))
- CashDepositEntity
- TDI17 (cash/chq/us_funds/etc) deposit
- cash_deposit table
- TransactionEntity
- Transaction JSON from SBC sftp server (will come from API in the future)
- transaction table
- one transactions -> many payments
- PaymentEntity
- Payment entry from the payments array of a transaction
- payment table
- aggregate of payment rows match to one cash_deposit row
- MasterLocationEntity
- Lookup table to find corresponding location
- master_location_data table
- cash_deposit pt_location_id will match to a corresponding location_id in this table
{
dateRange: {
from_date: 2023-01-01, <--- stays the same (for now)
to_date: today -2 <--- configurable
},
program: 'SBC',
locations: [1,2,3...] or []
}
- Query for all locations.
- Filter by Program.
- Filter location_id (if provided, otherwise, all locations)
- Generate a list of all dates between the from_date and to_date
- Loop over the locations
- For each location, loop through the dates
- For each location query the cash_deposit tabel for the list of distinct deposit dates which occured between the event input from_date and to_date
(For each location, for each deposit date, passed down from the reconcile lambda)
{
location: Location Entity,
date: date,
program: 'SBC' (this is the current default)
}
- Using the passed in deposit date, find the previous deposit date (or if there is not one then default to the fiscal_start_date)
- Query for the deposit(s) which match the current deposit date. filter by location/status/program. Order by amount.
- Query for the payments which are less than or equal to the current deposit date and greater than or equal to the previous deposit_date. Filter by location and status. Order by date/ amount.
- Aggregate all payments of the same fiscal_close_date
- Loop over all deposits
- For each deposit, loop through the aggregated payments.
- Match the aggregated payment to a deposit 1-1
-
Match by:
- Status (PENDING or IN_PROGRESS)
- Location (implicitly done by querying by location)
- Date (payment.transaction.fidcal-close_dtae must be less than or equal to current deposit date)
- Amount (sum of payment amount per fiscal close date to the deposit_amt_cdn)
- If Match, update the list entry for both Payments and Deposits to a be 'MATCH' in order to not attempt to match this entry again.
- If Match, assign the corresponding cash_deposit_match to the aggregated payment
after running the method(s) to match cash deposits to payments, the list of deposits and the list of aggregated payments should be identical in quantity and order to the original list. The specific entries which have been matched should be altered to show a status of MATCH and have the corresponding matched id.
- Filter out matched for both lists
- Filter out unmatched for both lists
- Map through the matched list of aggregated payments and change each payment so that the status is MATCH and the cash_match_id is the set as the aggregated payment cash_match_id
- Map through the unmatched aggregated payments and change each payment so that the status is IN_PROGRESS
- Map through the unmatched list of deposits and change the status to IN_PROGRESS for each entry
You should now have four lists: payments matched: - status: MATCH - pos_deposit_match: (uuid for the corresponding deposit) payment exceptions: - status: EXCEPTION deposits matched - status: MATCH deposit exceptions - status: EXCEPTION
- Update cash_deposit entities in the DB
- Update payment entities in the DB
- After the cash reconciliation service has been called and all payment and deposit entries for the corresponding deposit date have been either matched or set to in progress, call the method to find any exceptions relative to the corresponding deposit date
- TODO - explain cash exceptions with more detail
- Repeat steps 1-18 for each date and location
Discrepancy Report On Payments