diff --git a/src/com/apmath/loans/domain/repositories/Repository.kt b/src/com/apmath/loans/domain/repositories/Repository.kt index bc992a2..3c84176 100644 --- a/src/com/apmath/loans/domain/repositories/Repository.kt +++ b/src/com/apmath/loans/domain/repositories/Repository.kt @@ -5,6 +5,8 @@ import com.apmath.loans.domain.exceptions.runtime.RemoveAbsentLoanException import com.apmath.loans.domain.exceptions.runtime.RemoveUnidentifiedLoanException import com.apmath.loans.domain.exceptions.runtime.StoreIdentifiedLoanException import com.apmath.loans.domain.models.loans.LoanInterface +import com.apmath.loans.domain.models.payments.PaymentFromCalculationInterface +import com.apmath.loans.domain.data.Type class Repository : RepositoryInterface { private var identity: Int = 1 @@ -34,4 +36,10 @@ class Repository : RepositoryInterface { this.loans.remove(loan.id) } + override fun getListOfPayments(id: Int, type: Type?): List { + + val loan = get(id) + + return loan.getPayments(type) + } } diff --git a/src/com/apmath/loans/domain/repositories/RepositoryInterface.kt b/src/com/apmath/loans/domain/repositories/RepositoryInterface.kt index faf9804..9f925b5 100644 --- a/src/com/apmath/loans/domain/repositories/RepositoryInterface.kt +++ b/src/com/apmath/loans/domain/repositories/RepositoryInterface.kt @@ -1,6 +1,8 @@ package com.apmath.loans.domain.repositories import com.apmath.loans.domain.models.loans.LoanInterface +import com.apmath.loans.domain.models.payments.PaymentFromCalculationInterface +import com.apmath.loans.domain.data.Type //TODO replace with database interface RepositoryInterface { @@ -8,4 +10,5 @@ interface RepositoryInterface { fun getAll(): List fun store(loan: LoanInterface) fun remove(loan: LoanInterface) + fun getListOfPayments(id: Int, type: Type?): List } diff --git a/src/com/apmath/loans/domain/services/PaymentService.kt b/src/com/apmath/loans/domain/services/PaymentService.kt index bee933a..81940ca 100644 --- a/src/com/apmath/loans/domain/services/PaymentService.kt +++ b/src/com/apmath/loans/domain/services/PaymentService.kt @@ -9,20 +9,12 @@ import com.apmath.loans.domain.repositories.RepositoryInterface import com.apmath.loans.infrastructure.models.payments.PaymentFromCalculation class PaymentService( - private val calculationsFetcher: CalculationsFetcherInterface, private val repository: RepositoryInterface ) : PaymentServiceInterface { - override suspend fun get(loanIdHeader: Int?, loanId: Int?): Array { - // for manual testing - val payment = PaymentFromCalculation( - "date", - 1, - 2, - 3, - Type.REGULAR, - 4, - 5 - ) - return arrayOf(payment) + override suspend fun get(loanIdHeader: Int?, loanId: Int): List { + + val results: List = repository.getListOfPayments(loanId, null) + + return results } } diff --git a/src/com/apmath/loans/domain/services/PaymentServiceInterface.kt b/src/com/apmath/loans/domain/services/PaymentServiceInterface.kt index 67ac89f..846546f 100644 --- a/src/com/apmath/loans/domain/services/PaymentServiceInterface.kt +++ b/src/com/apmath/loans/domain/services/PaymentServiceInterface.kt @@ -3,5 +3,5 @@ package com.apmath.loans.domain.services import com.apmath.loans.domain.models.payments.PaymentFromCalculationInterface interface PaymentServiceInterface { - suspend fun get(loanIdHeader: Int?, loanId: Int?) : Array + suspend fun get(loanIdHeader: Int?, loanId: Int) : List }