mirror of
https://github.com/google/nomulus.git
synced 2025-04-29 19:47:51 +02:00
Fix billing pipeline first month scheduling (#1891)
* Fix billing pipeline first month scheduling * compare to expansion next month * use yoda date comparison * update cursor time to be mid of day
This commit is contained in:
parent
9d38328caa
commit
b7bbf85ad2
2 changed files with 25 additions and 1 deletions
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue