package cz.moneta.test.dsl.ufo.banka.tasks.cards;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.pages.cards.credit.CardTypeAndDesign;
import cz.moneta.test.dsl.ufo.banka.pages.cards.credit.OPN008_S001_SignContractPage;
import cz.moneta.test.dsl.ufo.banka.pages.cards.credit.ProductType;
import cz.moneta.test.dsl.ufo.banka.pages.cards.debit.OBR003_S001_ClientContractSignPageTransitions;
import cz.moneta.test.dsl.ufo.banka.pages.common.pages.OBR001_S001_PrintInstructionPage;
import cz.moneta.test.dsl.ufo.banka.pages.fon.GDP001_S001_ClientConsentsPage;
import cz.moneta.test.dsl.ufo.banka.pages.loans.VER017_S001_SecondBankerVerificationStatusPage;
import cz.moneta.test.dsl.ufo.banka.pages.loans.creditCard.NKK006_S001_CreditCardScoringResultPageTransitions;
import cz.moneta.test.dsl.ufo.banka.pages.loans.creditCard.ONC001_S001_NewCreditCardPage;
import cz.moneta.test.dsl.ufo.banka.pages.main.BAL035_S002_SummaryOfProductFoundationRetailPage;
import cz.moneta.test.dsl.ufo.banka.pages.main.HKO101_S001_MainClientPage;
import cz.moneta.test.dsl.ufo.banka.pages.main.PSP004_S001_PrintPage;
import cz.moneta.test.dsl.ufo.banka.pages.products.debit.card.NPK001_S001_DebitCardRequestPage;
import cz.moneta.test.dsl.ufo.banka.pages.products.debit.card.NPK001_S001_DebitCardRequestPageTransitions;
import cz.moneta.test.dsl.ufo.banka.pages.products.flexi.credit.NKK003_S001_SelectingApprovedVariantsPage;
import cz.moneta.test.dsl.ufo.banka.pages.requests.BAL006_S002_ClientRequestPage;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.Lookup;

import java.util.function.Function;

import static cz.moneta.test.dsl.ufo.banka.pages.main.BAL035_S002_SummaryOfProductFoundationRetailPage.BAL035_S002_PAGE_LABEL_XPATH;
import static cz.moneta.test.dsl.ufo.banka.pages.main.HKO101_S001_MainClientPage.NEW_ACCOUNT_NUMBER;
import static cz.moneta.test.dsl.ufo.banka.pages.main.codelists.HCisProductClass.*;
import static cz.moneta.test.dsl.ufo.banka.tasks.cards.CardsServicingTasks.*;

public class CardsOnboardingTasks {

    private final Harness harness;

    public CardsOnboardingTasks(Harness harness) {
        this.harness = harness;
    }

    public CreditCardsTasks creditCards() {
        return new CreditCardsTasks(harness);
    }

    public Function<HKO101_S001_MainClientPage, NPK001_S001_DebitCardRequestPage> createNewRetailDebitCardBasePart() {
        return start -> start
                .createNewProduct(DEBIT_CARD)
                .onSelectionOfSubmittedDocumentsPage()
                .selectIdCardRadio()
                .clickDocumentsCheckButton()
                .clickContinue()
                .onDebitCardRequestPage();
    }

    public Function<NPK001_S001_DebitCardRequestPage, NPK001_S001_DebitCardRequestPageTransitions> selectDebitCardPresenceDesignAndType(String cardType, String designOfCard, String presenceOfCard) {
        return start -> start
                .selectDebitCardType(cardType)
                .clickPresenceOfCardAndPinCardDelivery(presenceOfCard)
                .typeActivatePassword("000000")
                .selectDebitCardFeePlanByIndex(2)
                .clickDesignButtonIfSelectIsNotEnabled()
                .selectCardVariant(designOfCard)
                .clickPresenceOfCardAndPinCardDelivery(presenceOfCard)
                .clickSendAndDismissPossibleAlerts();
    }

    public Function<OBR001_S001_PrintInstructionPage, HKO101_S001_MainClientPage> createNewRetailDebitCardFinalPart() {
        return start -> start
                .clickRightButton()
                .onClientContractSignPage()
                .clickCenterButton()
                .then(waitForModulationIfPresent())
                .clickContinueButton()
                .onMainClientPage();
    }

    public Function<OBR003_S001_ClientContractSignPageTransitions, BAL035_S002_SummaryOfProductFoundationRetailPage> waitForModulationIfPresent() {
        UfoEndpoint endpoint = harness.getEndpoint(UfoEndpoint.class);
        if (endpoint.isElementVisible(10, BAL035_S002_PAGE_LABEL_XPATH, Lookup.XPATH)) {
            return start -> start.onSummaryOfProductFoundationRetailPage();
        } else {
            return start -> start.onWaitingForModulationPage()
                    .waitForModulation(120)
                    .onSummaryOfProductFoundationRetailPage();
        }
    }

    public Function<HKO101_S001_MainClientPage, NPK001_S001_DebitCardRequestPage> createNewGoldDebitCardForExistingCurrentAccount(String presenceOfCard, Long accountNum) {
        return start -> start
                .then(createNewRetailDebitCardBasePart())
                .selectCurrentAccount(accountNum)
                .clickClientDataHolderButton()
                .clickEnterButton()
                .onAddHolderPage()
                .clickOnHolderOwnerButton()
                .checkThatCardCantBeOnboarded(presenceOfCard, CardTypeAndDesign.GOLD.getValue() + "|");
    }

    public Function<HKO101_S001_MainClientPage, HKO101_S001_MainClientPage> createNewGoldDebitCardForNewCurrentAccount(String presenceOfCard) {
        return start -> start
                .then(createNewRetailDebitCardBasePart())
                .selectCurrentAccountByName(harness.get(NEW_ACCOUNT_NUMBER) + "|CZK|Gold")
                .clickClientDataHolderButton()
                .clickEnterButton()
                .onAddHolderPage()
                .clickOnHolderOwnerButton()
                .selectDebitCardType(CardTypeAndDesign.GOLD.getValue() + "|")
                .selectDebitCardFeePlanByIndex(2)
                .clickDesignButtonIfSelectIsNotEnabled()
                .typeActivatePassword("000000")
                .clickPresenceOfCardAndPinCardDelivery(presenceOfCard)
                .clickSendAndDismissPossibleAlerts()
                .onMeetingRecordPage()
                .clickNoInfoAdded()
                .clickNoComment()
                .clickContinue()
                .onPrintPage()
                .saveDocumentUrl()
                .closePrintWindow()
                .onWaitForModulationPage()
                .waitForModulation(120)
                .onDocumentsProvidedPage()
                .clickContinue()
                .onDocumentsProvidedToClientPage()
                .clickContinue()
                .onPrintPage()
                .saveDocumentUrl(CONTRACT_DOCUMENT_NAME)
                .closePrintWindow()
                .onPrintPage()
                .saveDocumentUrl(RECORD_FROM_MEETING_DOCUMENT_NAME)
                .closePrintWindow()
                .onInsurancePage()
                .clickSignedAndContinueToPrint()
                .saveDocumentUrl(AGREEMENT_WITH_TRAVEL_INSURANCE_DOCUMENT_NAME)
                .closePrintWindow()
                .onSignerPage()
                .then(createNewRetailDebitCardFinalPart());
    }

    public Function<HKO101_S001_MainClientPage, HKO101_S001_MainClientPage> createNewStandardDebitCardForNewCif(String designOfCard, String presenceOfCard, Long accountNum) {
        return start -> start
                .then(createNewRetailDebitCardBasePart())
                .selectCurrentAccount(accountNum)
                .clickClientDataHolderButton()
                .clickEnterButton()
                .onAddHolderPage()
                .clickOnHolderOwnerButton()
                .then(selectDebitCardPresenceDesignAndType(CardTypeAndDesign.STANDARD.getValue() + "|", designOfCard, presenceOfCard))
                .onSignerPage()
                .clickSignedPersonallyWithPossiblePhysicalSignature()
                .onPrintPage()
                .saveDocumentUrl()
                .closePrintWindow()
                .onPrintInstructionPage()
                .clickRightButton()
                .onPrintPage() //smlouva o bankovních produktech
                .saveDocumentUrl(DISPOSITION_DOCUMENT_NAME)
                .closePrintWindow()
                .onPrintPage()//dispozice ke smlouvě
                .saveDocumentUrl(CONTRACT_DOCUMENT_NAME)
                .closePrintWindow()
                .onSignerPage()
                .then(createNewRetailDebitCardFinalPart());
    }

    public Function<HKO101_S001_MainClientPage, HKO101_S001_MainClientPage> createNewStandardDebitCardForExistingCurrentAccount(String designOfCard, String presenceOfCard, Long accountNum) {
        return start -> start
                .then(createNewRetailDebitCardBasePart())
                .selectCurrentAccount(accountNum)
                .clickClientDataHolderButton()
                .clickEnterButton()
                .onAddHolderPage()
                .clickOnHolderOwnerButton()
                .then(selectDebitCardPresenceDesignAndType(CardTypeAndDesign.STANDARD.getValue() + "|", designOfCard, presenceOfCard))
                .onSignerPage()
                .clickSignedPersonallyWithPossiblePhysicalSignature()
                .onPrintPage()
                .saveDocumentUrl(DISPOSITION_DOCUMENT_NAME)
                .closePrintWindow()//dispozice ke smlouvě
                .onPrintInstructionPage()
                .then(createNewRetailDebitCardFinalPart());
    }

    public Function<HKO101_S001_MainClientPage, HKO101_S001_MainClientPage> createNewStandardDebitCardAfterNewAccount(String designOfCard, String presenceOfCard, Long accountNum) {
        return start -> start
                .then(createNewRetailDebitCardBasePart())
                .selectCurrentAccount(accountNum)
                .clickClientDataHolderButton()
                .clickEnterButton()
                .onAddHolderPage()
                .clickOnHolderOwnerButton()
                .then(selectDebitCardPresenceDesignAndType(CardTypeAndDesign.STANDARD.getValue() + "|", designOfCard, presenceOfCard))
                .onScoringPage()
                .waitForLoader()
                .onPrintPage()
                .saveDocumentUrl(CONTRACT_DOCUMENT_NAME)
                .closePrintWindow()//dispozice ke smlouvě
                .onPrintInstructionPage()
                .then(createNewRetailDebitCardFinalPart());
    }

    public Function<HKO101_S001_MainClientPage, HKO101_S001_MainClientPage> createNewStandardDebitCardForDifferentHolder(String designOfCard, String presenceOfCard, Long accountNum, String holderBirthNumber) {
        return start -> start
                .then(createNewRetailDebitCardBasePart())
                .selectCurrentAccount(accountNum)
                .clickClientDataHolderButton()
                .clickEnterButton()
                .onAddHolderPage()
                .clickOnDifferentHolderButton()
                .clickContinue()
                .fillSearchTerm(holderBirthNumber)
                .clickSearchByRcButton()
                .onChangeDataFO()
                .clickSend()
                .onPrintInstructionPage()
                .clickLeftButton()
                .onDebitCardRequestPage()
                .then(selectDebitCardPresenceDesignAndType(CardTypeAndDesign.STANDARD.getValue() + "|", designOfCard, presenceOfCard))
                .onSignerPage()
                .clickSignedPersonallyWithPossiblePhysicalSignature()
                .onPrintPage()
                .saveDocumentUrl(CONTRACT_DOCUMENT_NAME)
                .closePrintWindow()
                .onPrintInstructionPage()
                .then(createNewRetailDebitCardFinalPart());
    }

    public Function<HKO101_S001_MainClientPage, NPK001_S001_DebitCardRequestPage> createNewStandardDebitCardForExistingCurrentAccountFail(String presenceOfCard, Long accountNum) {
        return start -> start
                .then(createNewRetailDebitCardBasePart())
                .selectCurrentAccount(accountNum)
                .clickClientDataHolderButton()
                .clickEnterButton()
                .onAddHolderPage()
                .clickOnHolderOwnerButton()
                .checkThatCardCantBeOnboarded(presenceOfCard, CardTypeAndDesign.STANDARD.getValue() + "|");
    }

    public Function<GDP001_S001_ClientConsentsPage, ONC001_S001_NewCreditCardPage> createNextRetailCreditCardConsentPart() {
        return start -> start
                .clickOnFonConsentsAndContinue()
                .clickContinue()
                .onPrintPage()
                .saveDocumentUrl(DISPOSITION_DOCUMENT_NAME)
                .closePrintWindow()
                .onSignerPage()
                .clickRightButton()
                .onNewCreditCardPage();
    }

    public Function<ONC001_S001_NewCreditCardPage, NKK006_S001_CreditCardScoringResultPageTransitions> createRetailCreditCard(int amount, ProductType productType) {
        return start -> start
                .fillAmount(amount)
                .selectPromo("Bez akce")
                .clickCheckRequestParametersCheckbox()
                .dismissCardApplicationAlert()
                .selectAccountIfPossible()
                .clickSend()
                .onCreditCardApplicationDetailsPage()
                .selectProductType(productType)
                .selectCardBrandByIndex(2)
                .clickContinueButton()
                .clickDistributionByPost()
                .clickSaveButton()
                .onSelectionOfSubmittedDocumentsPage()
                .selectIdCardRadio()
                .selectPassportRadio()
                .clickDocumentsCheckAndContinue()
                .onCreditCardApplicantPage()
                .fillHouseholdIncome(150000)
                .clickEditIncomeButton()
                .clickNoticePeriodNoRadio()
                .clickTrialPeriodNoRadio()
                .clickAcceptIncomeButton()
                .clickBackButton()
                .onApplicantPage()
                .selectFirstIncome()
                .fillPaymentsOutsideMMB(0)
                .fillOtherMonthlyExpenses(1)
                .clickContinue()
                .onSignerSelectionPage()//TODO může se objevit zkontrolujte doklady, potřeba dodělat Custom Action
                .clickSignedPersonallyWithPossiblePhysicalSignature()
                .onPrintPage()
                .saveDocumentUrl(SERVICE_INFORMATION_DOCUMENT_NAME)
                .closePrintWindow()
                .onSignerPage()
                .clickRightButton()
                .onPrintPage()
                .saveDocumentUrl(PRECONTRACT_DOCUMENT_NAME)
                .closePrintWindow()
                .onSignaturePage()
                .clickApplicantSignatureCheckbox()
                .clickYes()
                .onScoringPage()
                .waitForLoader()
                .onCreditCardScoringResultPage()
                .waitForStatusAndRefresh("SOUHLAS")
                .clickCreateProductAndPrintContract();
    }

    public Function<NKK006_S001_CreditCardScoringResultPageTransitions, PSP004_S001_PrintPage> createNextRetailCreditCardPart() {
        UfoEndpoint endpoint = harness.getEndpoint(UfoEndpoint.class);
        if (endpoint.isElementVisible(5, NKK003_S001_SelectingApprovedVariantsPage.NKK003_S001_PAGE_LABEL_XPATH, Lookup.XPATH)) {
            return start -> start.onSelectingApprovedVariantsPage()
                    .clickSecondVariant()
                    .clickSelectToPrint();
        } else {
            return start -> start.onPrintPage();
        }
    }

    public Function<NKK006_S001_CreditCardScoringResultPageTransitions, VER017_S001_SecondBankerVerificationStatusPage> createRetailCreditCardBeforeVerification() {
        return start -> start
                .onSecondBankerSearch()
                .fillSurnameInput(harness.getGlobal("BANKER_NAME"))
                .clickSearch()
                .selectFirstName()
                .clickContinue()
                .onDocumentProvided()//zaslání změnového listu
                .clickContinue()
                .onPrintPage()
                .saveDocumentUrl(SERVICE_INFORMATION_DOCUMENT_NAME)
                .closePrintWindow()
                .onInformationPrintedPage()
                .continueToPrintCopyOfContractProposalPage()
                .clickContinue()
                .onSecondBankerVerificationPage();
    }

    public Function<HKO101_S001_MainClientPage, OBR003_S001_ClientContractSignPageTransitions> createRetailCreditCardAfterVerification() {
        return start -> start
                .selectFromListOfRequests()
                .selectFirstApplication()
                .clickOpenRequestDetail()
                .onCreditCardScoringResultPage()
                .clickCreateProductAndPrintContract()
                .onPreContractualInformationPrintPage()
                .clickSkipPrint()
                .clickContinue()
                .onSecondBankerVerificationPage()
                .clickContinue()
                .onConfirmationPage()
                .clickDoNotCreateButton()
                .onAdvancedSignerSelectionPage()
                .clickSignedPersonallyWithPossiblePhysicalSignature()
                .onPrintPage()
                .saveDocumentUrl(CONTRACT_DOCUMENT_NAME)
                .closePrintWindow()
                .onSignContractPage()
                .clickFirstSignerCheckbox()
                .clickYesButtonToClientContractSignPage()
                .clickLeftButton();
    }

    public Function<HKO101_S001_MainClientPage, HKO101_S001_MainClientPage> onboardingMBCForFopFirstBanker(String amountOfMoneyForMBC) {
        return start -> start
                .storeClientIdNumber()
                .createNewProduct(SME_AUTOMATS)
                .onNeedCifUpdate()
                .clickNoUpdateNeededToSelectProduct()
                .selectProductToOnboard("Moneta Business Card")
                .clickAddProduct()
                .onCommercialCreditCardDetail()
                .fillAmount(amountOfMoneyForMBC)
                .selectDistribution("Poštou")
                .clickAccountAtMMB()
                .selectFirstAccount(2)
                .clickContinue()
                .onAddCodeOfRecommendedPersonPage()
                .checkProductNotRecommended()
                .clickWithoutRecommendationAndDismissAlertIfvisible()
                .onSelectProductSmeCommercial()
                .clickContinue()
                .onDocumentationSendPage()
                .sendDocumentsToClient()
                .clickLeftButton()
                .onEditBusinessInfoPage()
                .clickFirstEconomicActivityRadio()
                .clickNoFopUnion()
                .clickNoActivityInterrupted()
                .clickNoTransformation()
                .clickYesTelcoScoring()
                .selectBusinessForCertainTime("Ne")
                .fillNumberOfEmployees("3")
                .fillRevenueShare("100")
                .clickContinue()
                .onClientRequestDetailPage()
                .selectFamilyCompany("Ne")
                .clickContinue()
                .clickPermanentResidencyRadio()
                .clickContinue()
                .onRequestedDocumentsPage()
                .selectAndAddDocument()
                .clickContinue()
                .onFinancialSignpostPage()
                .clickNoPsd2Data()
                .clickYesPsd2Data()
                .fillLastYear("2022")
                .fillYearBeforeLast("2021")
                .fillIncomeFromBusiness("1000000")
                .fillGrossIncome("1200000")
                .fillTotalAssets("10000000")
                .fillProfit("1000000")
                .fillNumberOfMainCustomers("1")
                .clickNoMoreThanHalfMainCustomer()
                .clickNoMoreThanHalfMainContractor()
                .fillBusinessLoanOutsideMmb("0")
                .clickYesClientProperty()
                .clickYesTaxAdvisor()
                .continueToListOfPersonsOnRequestPage()
                .selectPersonToAdd()
                .clickContinue()
                .onRequestSummaryPage()
                .clickContinue()
                .onRequestForSMEPage()
                .clickPrintRequest()
                .onPrintPagePSP004()
                .closePrintWindow()
                .onRequestForSMEPage()
                .clickYes()
                .onWaitingForModulationPage()
                .waitForModulation(120)
                .onModulationPage()
                .clickDocumentScanning()
                .onScanDocumentsPage()
                .uploadBusinessRegister()
                .selectFirstDocumentToAssign()
                .assignLoadedDocument()
                .clickSkipButton()
                .onMainClientPage();
    }

    public Function<HKO101_S001_MainClientPage, OPN008_S001_SignContractPage> onboardingMBCForFopRequestConfirmation(String secondBanker) {
        return start -> start
                .selectFromListOfRequests()
                .waitForStatusAndRefresh("PODMÍNĚNÝ SOUHLAS")
                .selectFirstApplication()
                .clickOpenRequestDetail()
                .onSmeAutomatesRequests()
                .confirmSME()
                .selectFirstApplication()
                .clickPrintContract()
                .clickContinue()
                .onConfirmationOfDocumentsPage()
                .confirmDocuments()
                .fillSurnameInput(secondBanker)
                .clickSearch()
                .clickContinue()
                .onPrintPage()
                .closePrintWindow()
                .onSendDocumentationPage()
                .sendDocumentsToClient()
                .clickLeftButton()
                .onCreditCardStartCreateInkasoPage()
                .clickOkToPrint()
                .closePrintWindow()
                .onInkasoAgreement()
                .clickRightButton()
                .onInkasoNonVerifiedIcbsPage()
                .clickContinue()
                .onSignConfirmationPage()
                .clickFirstSignerCheckbox()
                .dismissPopupWindow()
                .storeApplicationID();
    }

    public Function<OPN008_S001_SignContractPage, BAL006_S002_ClientRequestPage> onboardingMbcAfterSecondBankerSigned() {
        return start -> start
                .clickControlButton()
                .clickConfirmButtonToSignConfirmation()
                .clickLeftButton()
                .onClientContractSignPage()
                .clickLeftButton()
                .onPrintPage()
                .closePrintWindow()
                .onPrintInstructionPage()
                .clickRightButton()
                .onClientContractSignPage()
                .clickLeftButton()
                .onClientRequestPage();
    }

    public Function<HKO101_S001_MainClientPage, HKO101_S001_MainClientPage> createAccountForGoldCard() {
        return start -> start
                .createNewProduct(CURRENT_ACCOUNT)
                .onCurrentAccountPage()
                .selectFeePlanByOrder(2)
                .clickDispositionRadioYes()
                .clickConfirm()
                .onSignerPage()
                .clickSignedPersonallyWithPossiblePhysicalSignature()
                .onPrintPage()
                .saveDocumentUrl(SERVICE_INFORMATION_DOCUMENT_NAME)
                .closePrintWindow() //sdělení o poplatcích
                .onPrintInstructionPage()
                .clickRightButton()
                .onDocumentsProvidedToClientPage()
                .clickContinue()
                .onAccountDispositionOwnerPage()
                .clickOwnerOnly()
                .onPrintSignPadPage()
                .clickBack()
                .clickCenterButton()
                .onPrintPage()
                .saveDocumentUrl(RECORD_FROM_MEETING_DOCUMENT_NAME)
                .closePrintWindow()
                .onPrintInstructionPage()
                .clickRightButton()
                .onDocumentsProvidedToClientPage()
                .clickContinue()
                .onSavingAccountConfirmation()
                .clickContinue()
                .clickNotCreateNow()
                .clickSkipCreate()
                .onPrintInstructionPage()
                .clickCenterButton()
                .onPrintInstructionPage()
                .clickRightButton()
                .onPrintPage()
                .saveDocumentUrl(DISPOSITION_DOCUMENT_NAME)
                .closePrintWindow()
                .onPrintInstructionPage()
                .clickRightButton()
                .onSummaryStartDocumentsPage()
                .clickContinue()
                .onMainClientPage()
                .getNewAccountNumberByNameAndStore("; Gold");
    }

    public Function<HKO101_S001_MainClientPage, HKO101_S001_MainClientPage> createAccountForFop() {
        return start -> start
                .createNewProduct(CURRENT_ACCOUNT)
                .onRegistrationCertificatePage()
                .clickRightButton()
                .onCreateCurrentAccountPage()
                .selectAccountFlag("Standard")
                .selectProductTypeByOrder(2)
                .selectDistributionType("Elektronicky a e-mailem")
                .confirmCreationOnContactSettingPage()
                .clickFillEmailFromCif()
                .clickFillPhoneFromCif()
                .clickContinue()
                .onAccountDispositionPage()
                .clickNotCreateNow()
                .clickSkipCreate()
                .onAddCodeOfRecommendedPersonPage()
                .checkProductNotRecommended()
                .clickWithoutRecommendationAndDismissAlertIfvisible()
                .onPrintInstructionPage()
                .clickCenterButton()
                .onDispositionGeneratePage()
                .clickGenerateNow()
                .onPrintPage()
                .saveDocumentUrl()
                .closePrintWindow()
                .onPrintInstructionPage()
                .clickRightButton()
                .onSummaryStartDocumentsPage()
                .clickContinue()
                .onPrintInstructionPage()
                .clickRightButton()
                .onMainClientPage()
                .getNewAccountNumberByNameAndStore("BÚ-FOP");
    }

    public Function<HKO101_S001_MainClientPage, HKO101_S001_MainClientPage> createBusinessCardForFop(String presenceOfCard, int accountIndex) {
        return start -> start
                .createNewProduct(DEBIT_CARD)
                .onRegistrationCertificatePage()
                .clickRightButton()
                .onDebitCardRequestPage()
                .selectCurrentAccountByIndex(accountIndex)
                .clickClientDataHolderButton()
                .clickEnterButton()
                .onAddHolderPage()
                .clickOnHolderOwnerButton()
                .selectDebitCardTypeByIndex(2)
                .selectDebitCardFeePlanByIndex(2)
                .clickDesignButtonIfSelectIsNotEnabled()
                .typeActivatePassword("000000")
                .clickPresenceOfCardAndPinCardDelivery(presenceOfCard)
                .selectDebitCardFeePlanByIndex(2)
                .clickDesign()
                .clickSendAndDismissPossibleAlerts()
                .onScoringPage()
                .waitForLoader()
                .onModulationPage()
                .waitForModulation(30)
                .onSignerSelectionPageTIS050()
                .clickSignedAndContinueToPrintPage()
                .saveDocumentUrl()
                .closePrintWindow()//dispozice ke smlouvě
                .onPrintInstructionPage()
                .clickRightButton()
                .onClientContractSignPage()
                .clickCenterButton()
                .onMainClientPage();
    }

    public Function<HKO101_S001_MainClientPage, OBR003_S001_ClientContractSignPageTransitions> createBusinessPremiumCardForFop(String presenceOfCard) {
        return start -> start
                .createNewProduct(DEBIT_CARD)
                .onRegistrationCertificatePage()
                .clickRightButton()
                .onDebitCardRequestPage()
                .selectCurrentAccountByIndex(2)
                .clickClientDataHolderButton()
                .clickEnterButton()
                .onAddHolderPage()
                .clickOnHolderOwnerButton()
                .selectDebitCardTypeByIndex(2)
                .clickPresenceOfCardAndPinCardDelivery(presenceOfCard)
                .typeActivatePassword("000000")
                .selectDebitCardFeePlanByIndex(2)
                .clickDesign()
                .clickSendAndDismissPossibleAlerts()
                .onMeetingRecordPage()
                .clickNoComment()
                .clickNoInfoAdded()
                .clickPaperForm()
                .clickContinue()
                .onCommercialSignerSelectionPage()
                .clickSignedAndContinueToPrintPage()
                .saveDocumentUrl()
                .closePrintWindow()//ZZJ
                .onWaitForModulationPage()
                .waitForModulation(60)
                .onDocumentationPage()
                .sendDocumentsToClient()
                .clickLeftButton()
                .onPrintPage()
                .saveDocumentUrl()
                .closePrintWindow()//souhlas s cestovním pojištěním
                .onPrintPage()
                .saveDocumentUrl()
                .closePrintWindow()//souhlas s pojištěním karet
                .onInsurancePage()
                .clickSignedAndContinueToPrint()
                .saveDocumentUrl()
                .closePrintWindow()//dispozice
                .onPrintInstructionPage()
                .clickRightButton()
                .onClientContractSignPage()
                .clickCenterButton();
    }

    public Function<HKO101_S001_MainClientPage, HKO101_S001_MainClientPage> createFopAccountWithDifferentCurrency(String currency) {
        return start -> start
                .createNewProduct(CURRENT_ACCOUNT)
                .onRegistrationCertificatePage()
                .clickRightButton()
                .onDocumentationSendPage()
                //.onCreateCurrentAccountPage()
                .sendDocumentsToClient()
                .clickCenterButton()
                .onCurrentAccountPage()
                .selectCurrency(currency)
                .clickStandardCurrencyAccount()
                .selectProductTypeByOrder(2)
                .selectDistributionType("Elektronicky a e-mailem")
                .confirmCreationOnContactSettingPage()
                .clickFillEmailFromCif()
                .clickFillPhoneFromCif()
                .clickContinue()
                .onAccountDispositionPage()
                .clickNotCreateNow()
                .clickSkipCreate()
                //.onAddCodeOfRecommendedPersonPage()
                //.checkProductNotRecommended()
                //.clickWithoutRecommendationAndDismissAlertIfvisible()
                .onPrintInstructionPage()
                .clickCenterButton()
                .onDispositionGeneratePage()
                .clickGenerateLater()
                //.onSignerSelectionPage()
                //.clickSignedAndContinueToPrintPage()
                //.saveDocumentUrl()
                //.closePrintWindow()
                //.onPrintInstructionPage()
                //.clickRightButton()
                .onSummaryStartDocumentsPage()
                .clickContinue()
                .onPrintInstructionPage()
                .clickRightButton()
                .onMainClientPage()
                .getNewAccountNumberByNameAndStore(currency);
    }

    public Function<HKO101_S001_MainClientPage, HKO101_S001_MainClientPage> createFonAccountWithDifferentCurrency(String currency) {
        return start -> start
                .createNewProduct(CURRENT_ACCOUNT)
                .onCurrentAccountPage()
                .selectProduct(currency)
                .clickDispositionRadioYes()
                .clickConfirm()
                .onSignerPage()
                .clickSignedPersonallyWithPossiblePhysicalSignature()
                .onPrintPage()
                .saveDocumentUrl(SERVICE_INFORMATION_DOCUMENT_NAME)
                .closePrintWindow() //sdělení o poplatcích
                .onPrintInstructionPage()
                .clickRightButton()
                .onDocumentsProvidedToClientPage()
                .clickContinue()
                .onAccountDispositionOwnerPage()
                .clickOwnerOnly()
                .onPrintSignPadPage()
                .clickBack()
                .clickCenterButton()
                .onClientContractPage()
                .clickLeftButton()
                .onPrintInstructionPage()
                .clickCenterButton()
                .onPrintInstructionPage()
                .clickLeftButton()
                .onSummaryStartDocumentsPage()
                .clickContinue()
                .onMainClientPage()
                .getNewAccountNumberByNameAndStore(currency);
    }

    public Function<HKO101_S001_MainClientPage, HKO101_S001_MainClientPage> createNewDifferentCurrencyCard(String typeOfCard, String presenceOfCard, String accountAppendix) {
        return start -> start
                .then(createNewRetailDebitCardBasePart())
                .selectCurrentAccountByName(harness.get(NEW_ACCOUNT_NUMBER) + accountAppendix)
                .clickClientDataHolderButton()
                .clickEnterButton()
                .onAddHolderPage()
                .clickOnHolderOwnerButton()
                .selectDebitCardType(typeOfCard + "|")
                .clickPresenceOfCardAndPinCardDelivery(presenceOfCard)
                .typeActivatePassword("000000")
                .selectDebitCardFeePlanByIndex(2)
                .clickDesignButtonIfSelectIsNotEnabled()
                .clickSendAndDismissPossibleAlerts()
                .onPrintPage()
                .saveDocumentUrl(CONTRACT_DOCUMENT_NAME)
                .closePrintWindow()//dispozice ke smlouvě
                .onPrintInstructionPage()
                .then(createNewRetailDebitCardFinalPart());
    }

    public Function<HKO101_S001_MainClientPage, HKO101_S001_MainClientPage> createOneClickRetailForCards() {
        return start -> start.createNewProduct(ONE_CLICK)
                .onOneClickRetailPage()
                .clickNoProductMediatedByAdvisor()
                .clickNoDispositionRights()
                .clickNoSaStatementsEndOfMonth()
                .typeSaName("test")
                .selectDistributionAccount("Elektronicky a e-mailem")
                .selectDistributionForSavingAccount("Elektronicky a e-mailem")
                .clickNoIB()
                .clickPlasticCard()
                .selectCardDesign("Standard")
                .clickContinue()
                .onModulationPage()
                .waitForModulation(120)
                .onSignerSelectionPageTIS050_S001()
                .clickSignedAndContinueToPrintPage()
                .saveDocumentUrl(DISPOSITION_DOCUMENT_NAME)
                .closePrintWindow()
                .onPrintInstructionPage()
                .clickRightButton()
                .onPrintPage()
                .saveDocumentUrl(SERVICE_INFORMATION_DOCUMENT_NAME)
                .closePrintWindow()
                .onPrintInstructionPage()
                .clickRightButton()
                .onDocumentsProvidedToClientPage()
                .clickContinue()
                .onPrintPage()
                .saveDocumentUrl(PRECONTRACT_DOCUMENT_NAME)
                .closePrintWindow()
                .onPrintInstructionPage()
                .clickRightButton()
                .onDocumentsProvidedToClientPage()
                .clickContinue()
                .onPrintPage()
                .saveDocumentUrl(CONTRACT_DOCUMENT_NAME)
                .closePrintWindow()
                .onPrintInstructionPage()
                .clickRightButton()
                .onClientContractSignPage()
                .clickCenterButton()
                .onAppendixSignedPage()
                .clickContinueToSummaryOfProduct()
                .clickArrangeAppointmentCheckbox()
                .clickContinueButton()
                .onMainClientPage();
    }

    public Function<HKO101_S001_MainClientPage, HKO101_S001_MainClientPage> createTomJuniorAccountForNewChildCif() {
        return start -> start
                .createNewProduct(TOM_JUNIOR_ACCOUNT)
                .onChangeDataFO()
                .clickSend()
                .onCommonReportingStatusPage()
                .confirmCzech()
                .clickContinueAndAcceptAlert()
                .clickBackButton()
                .onSignerSelectionPage()
                .clickSignedPersonallyWithPossiblePhysicalSignature()
                .onPrintPage()
                .closePrintWindow()
                .onClientContractSignPage()
                .clickCenterButton()
                .onEnterContactAddressPageWithPossibleAlert()
                .clickUseResidencyAsContactAndConfirm()
                .clickSave()
                .onOneClickTomJunior()
                .fillAccountName("test")
                .selectCardDesignByIndex(2)
                .fillLimit(500)
                .clickCreateProducts()
                .closePrintWindow()
                .onPrintInstructionPage()
                .clickRightButton()
                .onDocumentsProvidedToClientPage()
                .clickContinue()
                .onPrintPage()
                .closePrintWindow()
                .onPrintInstructionPage()
                .clickRightButton()
                .onDocumentsProvidedToClientPage()
                .clickContinue()
                .onPrintPage()
                .closePrintWindow()
                .onPrintInstructionPage()
                .clickRightButton()
                .onClientContractSignPage()
                .clickCenterButton()
                .onAppendixSignedPage()
                .clickContinueToSummaryOfProduct()
                .clickContinueButton()
                .onMainClientPage();
    }
}
