diff --git a/core/src/main/java/google/registry/reporting/billing/GenerateInvoicesAction.java b/core/src/main/java/google/registry/reporting/billing/GenerateInvoicesAction.java index 9b839f077..b9aceeaa8 100644 --- a/core/src/main/java/google/registry/reporting/billing/GenerateInvoicesAction.java +++ b/core/src/main/java/google/registry/reporting/billing/GenerateInvoicesAction.java @@ -120,7 +120,7 @@ public class GenerateInvoicesAction implements Runnable { .orElse(Cursor.createGlobal(RECURRING_BILLING, START_OF_TIME)) .getCursorTime()); - if (yearMonth.getMonthOfYear() >= currentCursorTime.getMonthOfYear()) { + if (!YearMonth.fromDateFields(currentCursorTime.toDate()).isAfter(yearMonth)) { throw new IllegalStateException( "Latest billing events expansion cycle hasn't finished yet, terminating invoicing" + " pipeline"); diff --git a/core/src/test/java/google/registry/reporting/billing/GenerateInvoicesActionTest.java b/core/src/test/java/google/registry/reporting/billing/GenerateInvoicesActionTest.java index 60be99f53..fafb4f09b 100644 --- a/core/src/test/java/google/registry/reporting/billing/GenerateInvoicesActionTest.java +++ b/core/src/test/java/google/registry/reporting/billing/GenerateInvoicesActionTest.java @@ -168,4 +168,28 @@ class GenerateInvoicesActionTest extends BeamActionTestBase { + " terminating invoicing pipeline"); cloudTasksHelper.assertNoTasksEnqueued("beam-reporting"); } + + @Test + void testSucceedsToGenerateInvoicesFirstDayOfTheYear() throws Exception { + persistResource(Cursor.createGlobal(RECURRING_BILLING, DateTime.parse("2017-01-01T13:15:00Z"))); + action = + new GenerateInvoicesAction( + "test-project", + "test-region", + "staging_bucket", + "billing_bucket", + "REG-INV", + false, + new YearMonth(2016, 12), + emailUtils, + cloudTasksUtils, + clock, + response, + dataflow); + action.run(); + assertThat(response.getContentType()).isEqualTo(MediaType.PLAIN_TEXT_UTF_8); + assertThat(response.getStatus()).isEqualTo(SC_OK); + assertThat(response.getPayload()).isEqualTo("Launched invoicing pipeline: jobid"); + cloudTasksHelper.assertNoTasksEnqueued("beam-reporting"); + } }