# Test terminal lookup Application.put_env(:da_product_app, DaProductApp.Repo, adapter: Ecto.Adapters.MyXQL, username: "root", password: "dataaegis123", hostname: "localhost", database: "lic_project", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", pool_size: 1 ) Application.put_env(:da_product_app, :ecto_repos, [DaProductApp.Repo]) # Load the application Mix.install([:ecto, :ecto_sql, :myxql]) defmodule DaProductApp.Repo do use Ecto.Repo, otp_app: :da_product_app, adapter: Ecto.Adapters.MyXQL end defmodule DaProductApp.Acquirer.Schemas.AcquirerTerminal do use Ecto.Schema import Ecto.Query, warn: false @primary_key {:id, :id, autogenerate: true} schema "acquirer_terminal" do field :tid, :string field :mid, :string field :acquirer_id, :integer field :terminal_name, :string field :nii, :string field :status, :string timestamps() end def find_by_switch_ids(switch_tid, switch_mid) do from(t in __MODULE__, where: t.tid == ^switch_tid and t.mid == ^switch_mid and t.status == "ACTIVE" ) |> DaProductApp.Repo.one() end end # Start the repo {:ok, _} = DaProductApp.Repo.start_link() IO.puts("🔍 Testing terminal lookup...") # Test the lookup that was failing alias DaProductApp.Acquirer.Schemas.AcquirerTerminal switch_tid = "12345673" switch_mid = "123456789012345" IO.puts("Looking for terminal: TID=#{switch_tid}, MID=#{switch_mid}") case AcquirerTerminal.find_by_switch_ids(switch_tid, switch_mid) do nil -> IO.puts("❌ Terminal not found!") terminal -> IO.puts("✅ Terminal found!") IO.puts(" Terminal ID: #{terminal.tid}") IO.puts(" Merchant ID: #{terminal.mid}") IO.puts(" Terminal Name: #{terminal.terminal_name}") IO.puts(" NII: #{terminal.nii}") IO.puts(" Status: #{terminal.status}") IO.puts(" Acquirer ID: #{terminal.acquirer_id}") end IO.puts("🎯 Terminal lookup test completed!")