'CHECKREC - check cheque or PDQ reconciliations

external   vkeybox() sch scw progress() messbox() vloadif() cpath PrintReport()
external   vunloadif() dpath fentrybox() chkdate() remove() areas greeting
external   base findpopup() messboxwait() $drive Background() popuplist()

public     ptstr choice sum_date br_name psa dsa #banking $mop

global     x ReturnToMenu() Place_Paid() $place i Reconciliation()


MAIN
single-step off
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  file unload all
  while true
    x=Reconciliation()
    if x = -1
      exit while
    end if
  end while

  Background()

  ReturnToMenu()

END MAIN


FUNCTION Reconciliation()
local br_dir repdate cashrep
while true
  x = Place_Paid()
  if x = -1
    return (-1)
  end if

'chq/PDQ
  x = popuplist(8,53,13,"PDQ Cash/cheque","",1,0)
  if x = -1
    continue while
  end if
  if ptstr = "PDQ"
    $mop="P"
  else
    $mop="C"
  end if

  br_name = $place
  sum_date=date2(days(today)-1)
  choice = left(br_name,1)             'message "choice is:"&str(choice)
  vloadif(dpath|"chekrec1.vw")
  order change physical
  if areas ! upper(choice)
    while true
      x = fentrybox(" Reconciliation Date to check ",10,"##\/##\/####",sum_date)
      if x = 0
        sum_date = ptstr
        if chkdate(sum_date,1) = -1
          messbox(" Incorrect date - re-enter ",0,0,1)
          continue while
        end if
        exit while
      elseif x = -1
        return (-1)
      end if
    end while
    progress(15,10," Please wait ... preparing report ",0)
' message "sum_date is:"&str(sum_date)
' message "choice is:"&str(choice)
' message "$mop is:"&str($mop)
    data query execute "chekrec1.dfq" index "chekrec1.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [Date_Of_Receipt]=sum_date and [Branch] = choice
'   and
'   [Method_Of_Payment]=$mop
'   and
'   not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    if cerror
      messboxwait(" No Cash/cheques summarised/paid in ",0,0,1)
      return (1)
    end if
    data browse fields "[PDQtype;Job_Nr;CustOrd_Name;Amount_Received]"
    repaint on
    repaint
    inchar
  end if
  screen clear box 1 1 sch scw 0 0 no-border
end while
' if shop selection is not included in "areas" on oldpurch.vws refuse access
' if "areas" allow 2 areas, then only one report to be done at any one time (DG excepted)
' print report listing all cash rec'd for selected shop(s)
END FUNCTION ' DailyCash()


FUNCTION ReturnToMenu()
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  file unload all
  transfer cpath|"pm_menu.psl" in-memory
END FUNCTION ' ReturnToMenu()


FUNCTION Place_Paid()
local s1 s2 s3 s5 s6 $locn s7
  $locn = "HeadÿOffice"
  s1 = "Fulham"
  s7 = "Putney"
  s2 = "HeadÿOffice"
  s3 = "Sheen"
  while true
    x = findpopup(8,60,15,s1&s7&s2&s3,$locn,"Place",1,0)
    if x = -1
      return (-1)
    end if
    $place = ptstr                     'message "$place is:"&str($place)
    return (0)
  end while
END FUNCTION 'Place_Paid()



