This was observed on the start of a new year. For the existing sample data with FY records only for FY18 and FY19, there was no ledgerFY record present. Hence the insertion of transaction records was failing with ledgerFY record not being present.
We need to handle the scenario of making the ledgerFY record available for past years.
Currently we are creating ledgerFY records for FYs where, periodEnd > now
Upon creation of a fiscal year, check if there any ledgers using that FY series. If so, create a ledgerFY record, regardless of the periodEnd value.
Upon creation of a ledger, create ledgerFY records for each FY in the series, regardless of whether they're in the past, present or future.
- LedgerFY records are always created as needed (upon FY and Ledger creation)
- Unit tests are updated