Skip to content

Commit 2d6cef4

Browse files
authored
Merge pull request #1275 from guardian/ph-20251016-1616-row
Set canonical definition of ROW
2 parents 72a6566 + 601fa65 commit 2d6cef4

13 files changed

Lines changed: 1051 additions & 25 deletions

File tree

lambda/src/main/scala/pricemigrationengine/migrations/GuardianWeekly2025Migration.scala

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,29 @@ object GuardianWeekly2025Migration {
153153
} yield date
154154
}
155155

156+
def determineSubscriptionLocalisation(
157+
subscription: ZuoraSubscription,
158+
invoiceList: ZuoraInvoiceList,
159+
account: ZuoraAccount
160+
): Option[SubscriptionLocalisation] = {
161+
for {
162+
ratePlan <- SI2025RateplanFromSubAndInvoices.determineRatePlan(
163+
subscription,
164+
invoiceList
165+
)
166+
currency <- SI2025Extractions.determineCurrency(ratePlan)
167+
} yield {
168+
val country = account.soldToContact.country
169+
val isROWUSD = currency == "USD" && country != "United States"
170+
val isROWGBP = currency == "GBP" && country != "United Kingdom"
171+
if (isROWUSD || isROWGBP) {
172+
RestOfWorld
173+
} else {
174+
Domestic
175+
}
176+
}
177+
}
178+
156179
// ------------------------------------------------
157180
// Primary Functions:
158181
//
@@ -182,8 +205,7 @@ object GuardianWeekly2025Migration {
182205
.determineCurrency(ratePlan)
183206
.map(logValue("currency"))
184207
oldPrice = logValue("oldPrice")(SI2025Extractions.determineOldPrice(ratePlan))
185-
localisation <- SubscriptionLocalisation
186-
.determineSubscriptionLocalisation(subscription, invoiceList, account)
208+
localisation <- determineSubscriptionLocalisation(subscription, invoiceList, account)
187209
.map(logValue("localisation"))
188210
billingPeriod <- SI2025Extractions
189211
.determineBillingPeriod(ratePlan)

lambda/src/main/scala/pricemigrationengine/model/SubscriptionLocalisation.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ object SubscriptionLocalisation {
3333
)
3434
currency <- SI2025Extractions.determineCurrency(ratePlan)
3535
} yield {
36-
val country = account.soldToContact.country
37-
val isROWUSD = currency == "USD" && country != "United States"
38-
val isROWGBP = currency == "GBP" && country != "United Kingdom"
39-
if (isROWUSD || isROWGBP) {
36+
if (currency == "USD" && account.soldToContact.country != "United States") {
4037
RestOfWorld
4138
} else {
4239
Domestic
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"basicInfo" : {
3+
"id" : "ACCOUNT-ID",
4+
"name" : "ACCOUNT-NAME",
5+
"accountNumber" : "ACCOUNT-NUMBER",
6+
"notes" : null,
7+
"status" : "Active",
8+
"crmId" : "ACCOUNT-NAME",
9+
"batch" : "Batch1",
10+
"invoiceTemplateId" : "2c92a0fb49377eae014951ca848e074b",
11+
"communicationProfileId" : null,
12+
"profileNumber" : null,
13+
"purchaseOrderNumber" : null,
14+
"customerServiceRepName" : null,
15+
"ScrubbedOn__c" : null,
16+
"IdentityId__c" : "IdentityId__c",
17+
"sfContactId__c" : "sfContactId__c",
18+
"CCURN__c" : null,
19+
"SpecialDeliveryInstructions__c" : null,
20+
"NonStandardDataReason__c" : null,
21+
"Scrubbed__c" : null,
22+
"ProcessingAdvice__c" : null,
23+
"CreatedRequestId__c" : null,
24+
"RetryStatus__c" : null,
25+
"salesRep" : null,
26+
"creditMemoTemplateId" : null,
27+
"debitMemoTemplateId" : null,
28+
"summaryStatementTemplateId" : null,
29+
"sequenceSetId" : null
30+
},
31+
"billingAndPayment" : null,
32+
"metrics" : {
33+
"balance" : 0.000000000,
34+
"currency" : "USD",
35+
"totalInvoiceBalance" : 0.000000000,
36+
"creditBalance" : 0.000000000,
37+
"totalDebitMemoBalance" : 0.000000000,
38+
"unappliedPaymentAmount" : 0.000000000,
39+
"unappliedCreditMemoAmount" : 0.000000000,
40+
"contractedMrr" : 30.000000000
41+
},
42+
"billToContact" : null,
43+
"soldToContact" : {
44+
"country" : "United States"
45+
},
46+
"taxInfo" : null,
47+
"success" : true
48+
}

lambda/src/test/resources/model/SubscriptionLocalisation/subscription3/invoice-preview.json renamed to lambda/src/test/resources/Migrations/GuardianWeekly2025/SubscriptionLocalisation/subscription1/invoice-preview.json

File renamed without changes.

0 commit comments

Comments
 (0)