mirror of
https://github.com/google/nomulus
synced 2025-12-23 06:15:42 +00:00
Remove registrar id from invoice grouping key (#2749)
* Remove registrar id from invoice grouping key * Fix formatting issues * Update BillingEventTests
This commit is contained in:
@@ -172,7 +172,7 @@ public record BillingEvent(
|
|||||||
.minusDays(1)
|
.minusDays(1)
|
||||||
.toString(),
|
.toString(),
|
||||||
billingId(),
|
billingId(),
|
||||||
registrarId(),
|
"",
|
||||||
String.format("%s | TLD: %s | TERM: %d-year", action(), tld(), years()),
|
String.format("%s | TLD: %s | TERM: %d-year", action(), tld(), years()),
|
||||||
amount(),
|
amount(),
|
||||||
currency(),
|
currency(),
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class BillingEventTest {
|
|||||||
assertThat(invoiceKey.startDate()).isEqualTo("2017-10-01");
|
assertThat(invoiceKey.startDate()).isEqualTo("2017-10-01");
|
||||||
assertThat(invoiceKey.endDate()).isEqualTo("2022-09-30");
|
assertThat(invoiceKey.endDate()).isEqualTo("2022-09-30");
|
||||||
assertThat(invoiceKey.productAccountKey()).isEqualTo("12345-CRRHELLO");
|
assertThat(invoiceKey.productAccountKey()).isEqualTo("12345-CRRHELLO");
|
||||||
assertThat(invoiceKey.usageGroupingKey()).isEqualTo("myRegistrar");
|
assertThat(invoiceKey.usageGroupingKey()).isEqualTo("");
|
||||||
assertThat(invoiceKey.description()).isEqualTo("RENEW | TLD: test | TERM: 5-year");
|
assertThat(invoiceKey.description()).isEqualTo("RENEW | TLD: test | TERM: 5-year");
|
||||||
assertThat(invoiceKey.unitPrice()).isEqualTo(20.5);
|
assertThat(invoiceKey.unitPrice()).isEqualTo(20.5);
|
||||||
assertThat(invoiceKey.unitPriceCurrency()).isEqualTo("USD");
|
assertThat(invoiceKey.unitPriceCurrency()).isEqualTo("USD");
|
||||||
@@ -106,7 +106,7 @@ class BillingEventTest {
|
|||||||
assertThat(invoiceKey.toCsv(3L))
|
assertThat(invoiceKey.toCsv(3L))
|
||||||
.isEqualTo(
|
.isEqualTo(
|
||||||
"2017-10-01,2022-09-30,12345-CRRHELLO,61.50,USD,10125,1,PURCHASE,"
|
"2017-10-01,2022-09-30,12345-CRRHELLO,61.50,USD,10125,1,PURCHASE,"
|
||||||
+ "myRegistrar,3,RENEW | TLD: test | TERM: 5-year,20.50,USD,");
|
+ ",3,RENEW | TLD: test | TERM: 5-year,20.50,USD,");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -116,7 +116,7 @@ class BillingEventTest {
|
|||||||
assertThat(invoiceKey.toCsv(3L))
|
assertThat(invoiceKey.toCsv(3L))
|
||||||
.isEqualTo(
|
.isEqualTo(
|
||||||
"2017-10-01,,12345-CRRHELLO,61.50,USD,10125,1,PURCHASE,"
|
"2017-10-01,,12345-CRRHELLO,61.50,USD,10125,1,PURCHASE,"
|
||||||
+ "myRegistrar,3,RENEW | TLD: test | TERM: 0-year,20.50,USD,");
|
+ ",3,RENEW | TLD: test | TERM: 0-year,20.50,USD,");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -199,6 +199,36 @@ class InvoicingPipelineTest {
|
|||||||
0,
|
0,
|
||||||
"USD",
|
"USD",
|
||||||
20.0,
|
20.0,
|
||||||
|
""),
|
||||||
|
google.registry.beam.billing.BillingEvent.create(
|
||||||
|
15,
|
||||||
|
DateTime.parse("2017-10-02T00:00:00.0Z"),
|
||||||
|
DateTime.parse("2017-10-04T00:00:00.0Z"),
|
||||||
|
"theRegistrarCopy",
|
||||||
|
"234",
|
||||||
|
"",
|
||||||
|
"test",
|
||||||
|
"CREATE",
|
||||||
|
"mydomainfromanotherclient.test",
|
||||||
|
"REPO-ID",
|
||||||
|
5,
|
||||||
|
"JPY",
|
||||||
|
70.0,
|
||||||
|
""),
|
||||||
|
google.registry.beam.billing.BillingEvent.create(
|
||||||
|
16,
|
||||||
|
DateTime.parse("2017-10-04T00:00:00Z"),
|
||||||
|
DateTime.parse("2017-10-04T00:00:00Z"),
|
||||||
|
"theRegistrarCopy",
|
||||||
|
"234",
|
||||||
|
"",
|
||||||
|
"test",
|
||||||
|
"RENEW",
|
||||||
|
"mydomain2fromanotherclient.test",
|
||||||
|
"REPO-ID",
|
||||||
|
3,
|
||||||
|
"USD",
|
||||||
|
20.5,
|
||||||
""));
|
""));
|
||||||
|
|
||||||
private static final ImmutableMap<String, ImmutableList<String>> EXPECTED_DETAILED_REPORT_MAP =
|
private static final ImmutableMap<String, ImmutableList<String>> EXPECTED_DETAILED_REPORT_MAP =
|
||||||
@@ -224,18 +254,26 @@ class InvoicingPipelineTest {
|
|||||||
"invoice_details_2017-10_anotherRegistrar_test.csv",
|
"invoice_details_2017-10_anotherRegistrar_test.csv",
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
"5,2017-10-04 00:00:00 UTC,2017-10-04 00:00:00 UTC,anotherRegistrar,789,,"
|
"5,2017-10-04 00:00:00 UTC,2017-10-04 00:00:00 UTC,anotherRegistrar,789,,"
|
||||||
+ "test,CREATE,mydomain5.test,REPO-ID,1,USD,0.00,SUNRISE ANCHOR_TENANT"));
|
+ "test,CREATE,mydomain5.test,REPO-ID,1,USD,0.00,SUNRISE ANCHOR_TENANT"),
|
||||||
|
"invoice_details_2017-10_theRegistrarCopy_test.csv",
|
||||||
|
ImmutableList.of(
|
||||||
|
"15,2017-10-02 00:00:00 UTC,2017-10-04 00:00:00"
|
||||||
|
+ " UTC,theRegistrarCopy,234,,test,CREATE,mydomainfromanotherclient.test,REPO-ID,5,JPY,70.00,",
|
||||||
|
"16,2017-10-04 00:00:00 UTC,2017-10-04 00:00:00"
|
||||||
|
+ " UTC,theRegistrarCopy,234,,test,RENEW,mydomain2fromanotherclient.test,REPO-ID,3,USD,20.50,"));
|
||||||
|
|
||||||
private static final ImmutableList<String> EXPECTED_INVOICE_OUTPUT =
|
private static final ImmutableList<String> EXPECTED_INVOICE_OUTPUT =
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
"2017-10-01,2020-09-30,234,41.00,USD,10125,1,PURCHASE,theRegistrar,2,"
|
"2017-10-01,2020-09-30,234,61.50,USD,10125,1,PURCHASE,,3,"
|
||||||
+ "RENEW | TLD: test | TERM: 3-year,20.50,USD,",
|
+ "RENEW | TLD: test | TERM: 3-year,20.50,USD,",
|
||||||
"2017-10-01,2022-09-30,234,70.00,JPY,10125,1,PURCHASE,theRegistrar,1,"
|
"2017-10-01,2022-09-30,234,70.00,JPY,10125,1,PURCHASE,,1,"
|
||||||
+ "CREATE | TLD: hello | TERM: 5-year,70.00,JPY,",
|
+ "CREATE | TLD: hello | TERM: 5-year,70.00,JPY,",
|
||||||
"2017-10-01,,234,20.00,USD,10125,1,PURCHASE,theRegistrar,1,"
|
"2017-10-01,,234,20.00,USD,10125,1,PURCHASE,,1,"
|
||||||
+ "SERVER_STATUS | TLD: test | TERM: 0-year,20.00,USD,",
|
+ "SERVER_STATUS | TLD: test | TERM: 0-year,20.00,USD,",
|
||||||
"2017-10-01,2018-09-30,456,20.50,USD,10125,1,PURCHASE,bestdomains,1,"
|
"2017-10-01,2018-09-30,456,20.50,USD,10125,1,PURCHASE,,1,"
|
||||||
+ "RENEW | TLD: test | TERM: 1-year,20.50,USD,116688");
|
+ "RENEW | TLD: test | TERM: 1-year,20.50,USD,116688",
|
||||||
|
"2017-10-01,2022-09-30,234,70.00,JPY,10125,1,PURCHASE,,1,CREATE | TLD: test | TERM:"
|
||||||
|
+ " 5-year,70.00,JPY,");
|
||||||
|
|
||||||
private final InvoicingPipelineOptions options =
|
private final InvoicingPipelineOptions options =
|
||||||
PipelineOptionsFactory.create().as(InvoicingPipelineOptions.class);
|
PipelineOptionsFactory.create().as(InvoicingPipelineOptions.class);
|
||||||
@@ -355,21 +393,21 @@ class InvoicingPipelineTest {
|
|||||||
.isEqualTo(
|
.isEqualTo(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
SELECT b, r FROM BillingEvent b
|
SELECT b, r FROM BillingEvent b
|
||||||
JOIN Registrar r ON b.clientId = r.registrarId
|
JOIN Registrar r ON b.clientId = r.registrarId
|
||||||
JOIN Domain d ON b.domainRepoId = d.repoId
|
JOIN Domain d ON b.domainRepoId = d.repoId
|
||||||
JOIN Tld t ON t.tldStr = d.tld
|
JOIN Tld t ON t.tldStr = d.tld
|
||||||
LEFT JOIN BillingCancellation c ON b.id = c.billingEvent
|
LEFT JOIN BillingCancellation c ON b.id = c.billingEvent
|
||||||
LEFT JOIN BillingCancellation cr ON b.cancellationMatchingBillingEvent = cr.billingRecurrence
|
LEFT JOIN BillingCancellation cr ON b.cancellationMatchingBillingEvent = cr.billingRecurrence
|
||||||
WHERE r.billingAccountMap IS NOT NULL
|
WHERE r.billingAccountMap IS NOT NULL
|
||||||
AND r.type = 'REAL'
|
AND r.type = 'REAL'
|
||||||
AND t.invoicingEnabled IS TRUE
|
AND t.invoicingEnabled IS TRUE
|
||||||
AND CAST(b.billingTime AS timestamp)
|
AND CAST(b.billingTime AS timestamp)
|
||||||
BETWEEN CAST('2017-10-01T00:00:00Z' AS timestamp)
|
BETWEEN CAST('2017-10-01T00:00:00Z' AS timestamp)
|
||||||
AND CAST('2017-11-01T00:00:00Z' AS timestamp)
|
AND CAST('2017-11-01T00:00:00Z' AS timestamp)
|
||||||
AND c.id IS NULL
|
AND c.id IS NULL
|
||||||
AND cr.id IS NULL
|
AND cr.id IS NULL
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the text contents of a file under the beamBucket/results directory. */
|
/** Returns the text contents of a file under the beamBucket/results directory. */
|
||||||
@@ -391,6 +429,13 @@ class InvoicingPipelineTest {
|
|||||||
.setBillingAccountMap(ImmutableMap.of(JPY, "234", USD, "234"))
|
.setBillingAccountMap(ImmutableMap.of(JPY, "234", USD, "234"))
|
||||||
.build();
|
.build();
|
||||||
persistResource(registrar1);
|
persistResource(registrar1);
|
||||||
|
Registrar registrar11 = persistNewRegistrar("theRegistrarCopy");
|
||||||
|
registrar11 =
|
||||||
|
registrar11
|
||||||
|
.asBuilder()
|
||||||
|
.setBillingAccountMap(ImmutableMap.of(JPY, "234", USD, "234"))
|
||||||
|
.build();
|
||||||
|
persistResource(registrar11);
|
||||||
Registrar registrar2 = persistNewRegistrar("bestdomains");
|
Registrar registrar2 = persistNewRegistrar("bestdomains");
|
||||||
registrar2 =
|
registrar2 =
|
||||||
registrar2
|
registrar2
|
||||||
@@ -547,6 +592,21 @@ class InvoicingPipelineTest {
|
|||||||
.setDomainHistory(domainHistoryRecurrence)
|
.setDomainHistory(domainHistoryRecurrence)
|
||||||
.build();
|
.build();
|
||||||
persistResource(cancellationRecurrence);
|
persistResource(cancellationRecurrence);
|
||||||
|
|
||||||
|
// Domains created for registrar with = key but != client id.
|
||||||
|
Domain domain14 = persistActiveDomain("mydomainfromanotherclient.test");
|
||||||
|
Domain domain15 = persistActiveDomain("mydomain2fromanotherclient.test");
|
||||||
|
|
||||||
|
persistBillingEvent(
|
||||||
|
15,
|
||||||
|
domain14,
|
||||||
|
registrar11,
|
||||||
|
Reason.CREATE,
|
||||||
|
5,
|
||||||
|
Money.ofMajor(JPY, 70),
|
||||||
|
DateTime.parse("2017-10-04T00:00:00.0Z"),
|
||||||
|
DateTime.parse("2017-10-02T00:00:00.0Z"));
|
||||||
|
persistBillingEvent(16, domain15, registrar11, Reason.RENEW, 3, Money.of(USD, 20.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DomainHistory persistDomainHistory(Domain domain, Registrar registrar) {
|
private static DomainHistory persistDomainHistory(Domain domain, Registrar registrar) {
|
||||||
|
|||||||
Reference in New Issue
Block a user