@startuml
'diagram parameters'
autonumber
'skinparam dpi 300
skinparam LegendBackgroundColor #white

'diagram title'
title UC17 - Get installment Lime

'a brief description of the diagram'
legend top
**Abstract:**

end legend

'a list of the actors and participants'
actor "Next Customer" as UI

box "Credit Service"
participant "Credit" as CS
database "Credit Database" as DB
end box

box "Lime Plataform" #lime
participant "Lime" as Lime
database "Lime Database" as LB
end box

participant "Core Bradesco" as BR

ref over UI, CS, BR
See the **UC16 - Get credit Lime** to have the contractNo
end ref


UI -> CS: GET/installmentsListLime(credit_UID)
  activate CS
      note right UI #coral
      ** Clarification **
      Temos que fazer essa validação na database do
      microserviço? para os antigos contratos Lime
      como vamos fazer essa validação?
      end note

      CS->DB: Get CREDIT_CORE_ID
      activate DB
      DB->DB: **SQL** \n SELECT CREDIT_CORE_ID FROM CUSTOMER_CREDIT WHERE CREDIT_UID, CUSTOMER_UID
      DB-->CS: Return CREDIT_CORE_ID
      deactivate DB

      CS -> BR: GET /limeListaParcelas(CREDIT_CORE_ID)
        activate BR
        BR --> CS: Get details about installment credit
        note left BR #plum
        CoreBank will return:
          - requested value
          - IOF Value
          - value of installment credit
          - quantity of installments
          - value of installments
          - due date of the first installment
          - due date of the last installment
          - interest rate
          - IOF tax
          - total payments to be authorized tax
          - CET tax

        end note
        deactivate BR

      alt Credit found in core banking
      CS -> Lime: Get Credit description
      Lime -> LB: Get credit description
      activate LB
      LB --> Lime: Return CREDIT_DESCRIPTION
      deactivate LB
      Lime --> CS: Return description

      CS -> CS: Merge credit details + credit description


      CS --> UI: return list of details
      note left of CS #coral
        **Assumption:**
        Credit customer will receive:
        - requested value
        - IOF Value
        - value of installment credit
        - quantity of installments
        - value of installments
        - due date of the first installment
        - due date of the last installment
        - interest rate
        - IOF tax
        - total payments to be authorized tax
        - CET tax
        - description of installment credit
        end note

    else Credit_UID not found for the logged customer
      CS-->UI: Error message: CREDIT_UID not found for the logged customer

    end alt
  deactivate CS

@enduml
