package cz.moneta.test.dataprepare.risk.flexicredit;

import cz.moneta.test.dataprepare.risk.DefaultLoan;
import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.pages.loans.expres.OPN008_S001_ExpressSignaturePage;
import cz.moneta.test.dsl.ufo.banka.pages.loans.flexikredit.NFL006_S001_FlexikreditScoringResultPage;
import cz.moneta.test.dsl.util.DateUtils;
import cz.moneta.test.dsl.util.code.lists.HCisAllStavZadosti;
import cz.moneta.test.dsl.util.data.client.OccupationStatus;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.harness.support.auth.Credentials;
import cz.moneta.test.harness.support.auth.Key;

import static cz.moneta.test.dsl.util.credentials.Keys.ufo.banka.banker;
import static cz.moneta.test.dsl.util.credentials.Keys.ufo.banka.secondBanker;

@TestScenario(name = "Test for Risk Retail - Data preparation - client with FlexiCredit")
public class FlexiCreditFixedTermEmployment extends DefaultLoan {

    //17. BU+FLX(žádat o 50tis)+IBS+SBA - Příjem 20tis, Doba určitá; nejvyšší schválený rámec
    @TestCase(name = "FlexiCredit for client with fixed-term employment")
    public void flexiCreditFixedTermEmployment(Harness harness, @Key(banker) Credentials credentials, @Key(secondBanker) Credentials secondCredentials) {

        applicant.withOccupationStatus(OccupationStatus.FULL_TIME_EMPLOYEE_FINITE)
                .withOccupationEmploymentTillRaw(DateUtils.getRawTodayDateIncrementedByDays(365))
                .withNetMonthlyIncome(20000)
                .withHomeIncome(20000);

        OPN008_S001_ExpressSignaturePage firstBankerWindow = bankaTasks.newProduct().createClientWithIb(harness, credentials, applicant)
                .then(bankaTasks.newProduct().createSBA())
                .then(bankaTasks.flexiCreditTasks().createNewFlexiCreditApplicationFixedTerm(applicant, 50000, HCisAllStavZadosti.APPLICATION_CONDITIONALLY_APROVED))
                .then(bankaTasks.flexiCreditTasks().createAccountsForNewFlexiCreditWithExistingBuAndIbUntilSignatureWithoutAmountSelect(secondBankerName));//todo jbr - nejvyssi schvaleny ramec

        bankaTasks.newProduct().openUfoAndVerifyApplicationAsSecondBanker(secondCredentials, harness.get(NFL006_S001_FlexikreditScoringResultPage.APP_ID_STORE));
        firstBankerWindow.then(bankaTasks.flexiCreditTasks().finishAccountCreation(HCisAllStavZadosti.LOAN_ACCOUNT_OPEN));
    }

}