I understand why dry run is calculated as if it is at reference time, I do not understand why it should also always run at that time, considering you can manually trigger dry run at whatever time it is.
In fact, if you set dry run configuration to for example, 1h, the dry run will be run at the same time (after the invoice due to how current notification queue is handled) with the target date of 3 hour after the reference time. To illustrate, if the bill is DAILY (or MONTHLY/ANNUAL), reference time is 00:00:00 at 1st January, then the sequence at 00:00:00 1/1 is: invoice run for 00:00:00 1/1 -> dry run for 03:00:00 1/1.
Killbill will automatically augment the target date to 00:00:00 2nd for dry run calculation.
Killbill has a slight optimization to check for the target date and skip if it is past invoice time. That seems fair enough. What isn't fair is why dry run for notification is supposed to be ran at reference time? Change the effective date to 21:00:00 31/12 with target date to 00:00:00 1/1 would make the semantic much more intuitive, at least for me. I found nothing, but this may kill some cache, although the current way of running 1 day before doesn't preserve any cache anyway.
Another slightly weird thing is how with enough credit, the invoice balance will be cancelled out, although an invoice did happen, since its balance is 0, no INVOICE_NOTIFICATION is fired, although an INVOICE_CREATION event is fired as normal. There is a check for that specific condition. This optimization is understandable but the semantic should be documented more clearly.
Did I missed something? If the new semantic is desirable, I can create a Github Issues and a PR.