package cz.moneta.test.dsl.payment_engine.parts_of_menu.menu_transaction;

import cz.moneta.test.harness.support.web.*;

public interface PaymentEngineCreateDomesticPayment extends WebFlow<PaymentEngineCreateDomesticPayment> {
    String INVALID_ICON = "//ancestor::div[@class='x-form-field-wrap']//following-sibling::div";
    String INVALID_ICON_PICKER = "//ancestor::div[@class='x-form-field-wrap x-form-picker']//following-sibling::div";
    String AMOUNT = "//input[@name = 'amount']";
    String TRANSACTION_TYPE = "//input[@name='mciTrnTypeId']//following-sibling::input";
    String INVALID_TRANSACTION_TYPE = TRANSACTION_TYPE + INVALID_ICON;
    String CHANNEL_ID = "//input[@name = 'channelIdent']//following-sibling::input";
    String INVALID_CHANNEL_ID = CHANNEL_ID + INVALID_ICON;
    String DEBTOR_ACC = "//input[@name = 'orAccIdent']";
    String INVALID_DEBTOR_ACC = DEBTOR_ACC + INVALID_ICON_PICKER;
    String DEBTOR_NAME = "//input[@name = 'orName']";
    String CREDITOR_ACC = "//input[@name = 'cpAccIdent']";
    String INVALID_CREDITOR_ACC = CREDITOR_ACC + INVALID_ICON_PICKER;
    String MESSAGE1 = "//textarea[@name = 'rmtInfUnstr']";
    String MESSAGE2 = "//textarea[@name = 'cpAgentInstr']";
    String BANK_CODE_CR = "//input[@name = 'cpBankCode']//following-sibling::input";
    String INVALID_BANK_CODE_CR = BANK_CODE_CR + INVALID_ICON;
    String ICBS_PROFILE = "//input[@name = 'icbsProfile']//following-sibling::input";
    String OK_BUTTON = "//*[@type  = 'submit']";
    String TRANSACTION_ID_KEY = "TRANSACTION_ID_KEY";
    String TRANSACTION_ID_XPATH = "//div[@class = 'ext-mb-content']/span[@class = 'ext-mb-text']";
    String NO_BUTTON = "//button[text() = 'Ne']";
    String VARIABLE_SYMBOL = "//input[@name = 'ceeSymbolVs']";
    String SPECIFIC_SYMBOL = "//input[@name = 'ceeSymbolSs']";
    String CONSTANT_SYMBOL = "//input[@name = 'ceeSymbolKs']";
    String SUBMISSION_DATE = "//input[@name = 'receiptDatetime']//following-sibling::input";
    String DOCUMENT_DATE = "//input[@name = 'documentDate']//following-sibling::input";
    String EXECUTION_DATE_BUTTON = "//label[text() = 'Datum vykonání']//following-sibling::div[@class=\"x-form-element\"]//img";
    String EXECUTION_DATE_VALUE = "//td[@title='Dnes']%s";
    String DOCUMENT_ID = "//label[text() = 'Identifikace dokladu']//following-sibling::div/input";
    String IDENTIFICATION1 = "//textArea[@name = 'czOrIdent']";
    String IDENTIFICATION2 = "//textArea[@name = 'czCpIdent']";
    String DEBTOR_ACCOUNT_PANEL = "//input[@name = 'orAccIdent']/following-sibling::img";
    String ACCOUNT_INPUT = "//input[@name = 'accIdent']";
    String SEARCH = "//div[@class = 'x-panel-footer']//button[text() = 'Hledat']";
    String SELECT = "//div[@class = 'x-grid3-row-checker']";
    String ACCEPT_BUTTON = "//div[@class='x-panel-bwrap ']//button[text() = 'OK']";

    @TypeIntos({@TypeInto(value = TRANSACTION_TYPE, andWait = @Wait(value = INVALID_TRANSACTION_TYPE, until = Until.GONE)), @TypeInto(AMOUNT),
            @TypeInto(CHANNEL_ID), @TypeInto(value = DEBTOR_ACC, andWait = @Wait(value = INVALID_DEBTOR_ACC, until = Until.GONE)),
            @TypeInto(DEBTOR_NAME), @TypeInto(value = CREDITOR_ACC, andWait = @Wait(value = INVALID_CREDITOR_ACC, until = Until.GONE)),
            @TypeInto(value = BANK_CODE_CR, andWait = @Wait(value = INVALID_BANK_CODE_CR, until = Until.GONE)),
            @TypeInto(MESSAGE1), @TypeInto(MESSAGE2), @TypeInto(ICBS_PROFILE)})
    PaymentEngineCreateDomesticPayment fillManualData(String transactionType, String amount, String message1, String debtorAcc,
                                                      String creditorAcc, String bankCodeCr, String channelId, String message2,
                                                      String debtorName, String icbsProfile);

    @TypeIntos({@TypeInto(value = TRANSACTION_TYPE, andWait = @Wait(value = INVALID_TRANSACTION_TYPE, until = Until.GONE)), @TypeInto(AMOUNT),
            @TypeInto(CHANNEL_ID), @TypeInto(VARIABLE_SYMBOL), @TypeInto(SPECIFIC_SYMBOL), @TypeInto(CONSTANT_SYMBOL),
            @TypeInto(value = DEBTOR_ACC, andWait = @Wait(value = INVALID_DEBTOR_ACC, until = Until.GONE)), @TypeInto(DEBTOR_NAME),
            @TypeInto(value = CREDITOR_ACC, andWait = @Wait(value = INVALID_CREDITOR_ACC, until = Until.GONE)),
            @TypeInto(value = BANK_CODE_CR, andWait = @Wait(value = INVALID_BANK_CODE_CR, until = Until.GONE)),
            @TypeInto(MESSAGE1), @TypeInto(MESSAGE2), @TypeInto(IDENTIFICATION1), @TypeInto(IDENTIFICATION2), @TypeInto(ICBS_PROFILE)})
    PaymentEngineCreateDomesticPayment fillManualMaxData(String transactionType, String amount, String channelId, String variableSymbol,
                                                         String specificSymbol, String constantSymbol, String debtorAcc, String debtorName,
                                                         String creditorAcc, String bankCodeCr, String message1, String message2,
                                                         String identification1, String identification2, String icbsProfile);

    @TypeIntos({@TypeInto(value = TRANSACTION_TYPE, andWait = @Wait(value = INVALID_TRANSACTION_TYPE, until = Until.GONE)), @TypeInto(AMOUNT),
            @TypeInto(DEBTOR_NAME), @TypeInto(value = CREDITOR_ACC, andWait = @Wait(value = INVALID_CREDITOR_ACC, until = Until.GONE)),
            @TypeInto(value = BANK_CODE_CR, andWait = @Wait(value = INVALID_BANK_CODE_CR, until = Until.GONE)),
            @TypeInto(MESSAGE1), @TypeInto(MESSAGE2), @TypeInto(ICBS_PROFILE)})
    PaymentEngineCreateDomesticPayment fillManualDataWithoutDebtor(String transactionType, String amount, String message1, String creditorAcc,
                                                                   String bankCodeCr, String message2, String debtorName, String icbsProfile);

    @Click(value = EXECUTION_DATE_BUTTON, andWait = @Wait(explicitWaitSeconds = 2))
    PaymentEngineCreateDomesticPayment clickOnExecutionDate();

    @Click(value = EXECUTION_DATE_VALUE, isStringDynamicXpath = true)
    PaymentEngineCreateDomesticPayment chooseExecutionDate(String dateXpath);

    @TypeIntos({@TypeInto(SUBMISSION_DATE), @TypeInto(DOCUMENT_DATE), @TypeInto(DOCUMENT_ID),
            @TypeInto(value = CHANNEL_ID, andWait = @Wait(value = INVALID_CHANNEL_ID, until = Until.GONE))})
    PaymentEngineCreateDomesticPayment fillDates(String submissionDate, String documentDate,
                                                 String documentId, String channelId);

    @Click(value = OK_BUTTON, andWait = @Wait(value = TRANSACTION_ID_XPATH, until = Until.VISIBLE))
    PaymentEngineCreateDomesticPayment clickOk();

    @StoreElementContent(storeKey = TRANSACTION_ID_KEY, value = TRANSACTION_ID_XPATH, by = Lookup.XPATH)
    PaymentEngineCreateDomesticPayment storeTransactionId();

    @Click(value = NO_BUTTON, andWait = @Wait(value = NO_BUTTON, until = Until.GONE))
    PaymentEngineCreateDomesticPayment clickNo();

    @Click(value = DEBTOR_ACCOUNT_PANEL, andWait = @Wait(value = ACCOUNT_INPUT, until = Until.VISIBLE))
    PaymentEngineCreateDomesticPayment clickOnDebtorPanel();

    @TypeInto(ACCOUNT_INPUT)
    @Click(value = SEARCH, andWait = @Wait(value = SELECT, until = Until.VISIBLE))
    PaymentEngineCreateDomesticPayment searchDebtorAccount(String debtorAcc);

    @Click(value = SELECT, andWait = @Wait(value = ACCEPT_BUTTON, until = Until.CLICKABLE))
    PaymentEngineCreateDomesticPayment selectDebtorAccount();

    @Click(value = ACCEPT_BUTTON, andWait = @Wait(value = ACCEPT_BUTTON, until = Until.GONE))
    PaymentEngineCreateDomesticPayment acceptDebtorAccount();
}