 
     if debit === "" do
       # Credit Entry
-      r =
-        Enum.find(program, :not_found, fn {_id, m} ->
+      temp =
+        Enum.filter(program, fn {_id, m} ->
           m.drcr === "C" and Decimal.compare(m.amount, credit) === :eq
         end)
+
+      r =
+        if length(temp) > 1 do
+          Enum.sort_by(temp, fn {_id, m} -> m.date end, Date)
+          |> hd
+
+          # Enum.min_by(temp, fn {_id, m} -> Date.diff(date, m.date) end)
+        else
+          case temp do
+            [] -> :not_found
+            _ -> hd(temp)
+          end
+        end
 
       if r !== :not_found do
         {id, _} = r


          [
            bank_date(date),
            String.slice(desc, 0, 40),
            zero_to_empty(debit),
            zero_to_empty(credit)
          ]

  alias Mgp.Sync.DbaseParser
  alias Mgp.Utils

  def run(code, year, month) do
    short_code = Calendar.strftime(Date.new!(year, month, 1), "%y%m")

    folder =
      case code do
        "MB" -> "UMB"
