from pos_model import TenderType


class FinalizeActionFunction(object):
    confirm = "0"
    cancel = "1"


class CancelCodes(object):
    credit = 210
    debit = 211
    digital_wallet = 123


class PaymentCodes(object):
    credit = 3
    debit = 2
    digital_wallet = 122
    connection_test = 111


class ResultCodes(object):
    success = 0
    continue_loop = 10000


class CommandCodes(object):

    show_message_operator = 1
    show_message_customer = 2
    show_message_both = 3
    clear_message_operator = 11
    clear_message_customer = 12
    clear_message_both = 13
    idle_command = 23
    idle_field = 30
    set_amount_transaction = 34


class FieldCodes(object):
    empty_information = -1
    receipt_customer = 121
    receipt_merchant = 122
    nsu = 133
    nsu_host = 134
    nsu_origin = 135
    cancel_card_number = 512
    cancel_transaction_date = 515
    cancel_document_number = 516
    transaction_value = 146


class SitefFunctions(object):

    @staticmethod
    def get_cancel_code(
            tender_type  # type: int
    ):
        if int(tender_type) == TenderType.credit:
            return CancelCodes.credit

        if int(tender_type) == TenderType.debit:
            return CancelCodes.debit

        if int(tender_type) == TenderType.digital_wallet:
            return CancelCodes.digital_wallet

        return CancelCodes.credit

    @staticmethod
    def get_payment_code(
        electronic_type,    # type: int
    ):
        # type: (...) -> int

        if int(electronic_type) in (TenderType.credit, TenderType.gift_card):
            return PaymentCodes.credit

        if int(electronic_type) in (TenderType.debit, TenderType.voucher):
            return PaymentCodes.debit

        if int(electronic_type) == TenderType.digital_wallet:
            return PaymentCodes.digital_wallet

        return PaymentCodes.connection_test
