From c5e6537cd3e7792ea65f0042bfd8751d9ef1c13a Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Mon, 6 Mar 2023 18:39:51 +0000 Subject: [PATCH] Handle empty supplementary bill runs https://eaflood.atlassian.net/browse/WATER-3923 From the charge version we generate transaction lines. For each charge element (reference) we look at the charge purposes connected to it and calculate the billable days. If that result is 0, we skip adding the transaction to the bill run. This means there is often a case where having calculated and rejected all the transaction lines, the bill run is 'empty'. The legacy process will update the status of the bill run to `empty`, and remove any `billing_invoice` and `billing_invoice_licence` records created. We need to do the same, though we intend to take a different approach. We'll process all the transaction lines first and only create `billing_invoice` and `billing_invoice_licence` records for those that remain. Should there be none, we'll go straight to marking the bill run as `empty` and stop the process there. Our intent is to remove needless calls to the DB and simplify the process.