@@ -84,6 +84,49 @@ class OutstandingPaymentsControllerSpec extends SpecBase {
8484 }
8585 }
8686
87+ " return Ok and display correct view for a GET with outstanding payments that existed before company registration date" in {
88+ val subscriptionData = SubscriptionData (
89+ formBundleNumber = " form bundle" ,
90+ upeDetails = UpeDetails (None , None , None , " orgName" , LocalDate .of(2024 , 1 , 1 ), domesticOnly = false , filingMember = false ),
91+ upeCorrespAddressDetails = UpeCorrespAddressDetails (" middle" , None , Some (" lane" ), None , None , " obv" ),
92+ primaryContactDetails = ContactDetailsType (" shadow" , Some (" dota2" ), " shadow@fiend.com" ),
93+ secondaryContactDetails = None ,
94+ filingMemberDetails = None ,
95+ accountingPeriod = AccountingPeriod (LocalDate .of(2024 , 1 , 1 ), LocalDate .of(2024 , 12 , 31 )),
96+ accountStatus = Some (AccountStatus .ActiveAccount )
97+ )
98+
99+ val application = applicationBuilder(enrolments = enrolments, additionalData = Map (" features.useAccountActivityApi" -> false ))
100+ .overrides(
101+ bind[SessionRepository ].toInstance(mockSessionRepository),
102+ bind[FinancialDataService ].toInstance(mockFinancialDataService),
103+ bind[SubscriptionService ].toInstance(mockSubscriptionService)
104+ )
105+ .build()
106+
107+ running(application) {
108+ when(mockFinancialDataService.retrieveFinancialData(any(), any(), any())(using any[HeaderCarrier ]))
109+ .thenReturn(Future .successful(samplePreRegistrationChargeTransaction))
110+ when(mockSubscriptionService.readSubscription(any())(using any[HeaderCarrier ]))
111+ .thenReturn(Future .successful(subscriptionData))
112+ when(mockSessionRepository.get(any())).thenReturn(Future .successful(Some (emptyUserAnswers)))
113+
114+ val request = FakeRequest (GET , controllers.payments.routes.OutstandingPaymentsController .onPageLoad.url)
115+ val result = route(application, request).value
116+
117+ val view = application.injector.instanceOf[OutstandingPaymentsView ]
118+
119+ status(result) mustEqual OK
120+ contentAsString(result) mustEqual
121+ view(preRegistrationOverdueTables, pillar2Id, BigDecimal (1000.00 ), hasOverdueReturnPayment = true )(
122+ request,
123+ applicationConfig,
124+ messages(application),
125+ isAgent = false
126+ ).toString
127+ }
128+ }
129+
87130 " redirect to Journey Recovery when service call fails" in {
88131 val subscriptionData = SubscriptionData (
89132 formBundleNumber = " form bundle" ,
@@ -327,6 +370,21 @@ object OutstandingPaymentsControllerSpec {
327370 )
328371 )
329372
373+ val samplePreRegistrationChargeTransaction : FinancialData =
374+ FinancialData (
375+ Seq (
376+ FinancialTransaction .OutstandingCharge .UktrMainOutstandingCharge (
377+ accountingPeriod = AccountingPeriod (LocalDate .of(2020 , 1 , 1 ), LocalDate .of(2020 , 12 , 31 )),
378+ subTransactionRef = EtmpSubtransactionRef .Dtt ,
379+ outstandingAmount = BigDecimal (1000.00 ),
380+ chargeItems = OutstandingCharge .FinancialItems (
381+ earliestDueDate = LocalDate .of(2020 , 12 , 31 ),
382+ Seq (FinancialItem (dueDate = Some (LocalDate .of(2020 , 12 , 31 )), clearingDate = None ))
383+ )
384+ )
385+ )
386+ )
387+
330388 val overdueFinancialSummary : Seq [FinancialSummary ] = Seq (
331389 FinancialSummary (
332390 AccountingPeriod (LocalDate .of(2024 , 1 , 1 ), LocalDate .of(2024 , 12 , 31 )),
@@ -345,5 +403,14 @@ object OutstandingPaymentsControllerSpec {
345403 )
346404 )
347405
406+ val preRegistrationOverdueTables : Seq [OutstandingPaymentsTable ] = Seq (
407+ OutstandingPaymentsTable (
408+ accountingPeriod = AccountingPeriod (LocalDate .of(2020 , 1 , 1 ), LocalDate .of(2020 , 12 , 31 )),
409+ rows = Seq (
410+ OutstandingPaymentsRow (description = " UKTR - DTT" , outstandingAmount = BigDecimal (1000.00 ), dueDate = LocalDate .of(2020 , 12 , 31 ))
411+ )
412+ )
413+ )
414+
348415 val amountDue : BigDecimal = samplePaymentsData.flatMap(_.transactions.map(_.outstandingAmount)).sum.max(0 )
349416}
0 commit comments