mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07: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))
|
.orElse(Cursor.createGlobal(RECURRING_BILLING, START_OF_TIME))
|
||||||
.getCursorTime());
|
.getCursorTime());
|
||||||
|
|
||||||
if (yearMonth.getMonthOfYear() >= currentCursorTime.getMonthOfYear()) {
|
if (!YearMonth.fromDateFields(currentCursorTime.toDate()).isAfter(yearMonth)) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Latest billing events expansion cycle hasn't finished yet, terminating invoicing"
|
"Latest billing events expansion cycle hasn't finished yet, terminating invoicing"
|
||||||
+ " pipeline");
|
+ " pipeline");
|
||||||
|
|
|
@ -168,4 +168,28 @@ class GenerateInvoicesActionTest extends BeamActionTestBase {
|
||||||
+ " terminating invoicing pipeline");
|
+ " terminating invoicing pipeline");
|
||||||
cloudTasksHelper.assertNoTasksEnqueued("beam-reporting");
|
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