'DAYSRCPT - cash receipts since last DLY_PSTG

external   dpath PrintReport() sch scw vloadif() progress() progtag() fgi bgi
external   vatrate remove() makeidx() fentrybox() chkdate() messbox() cpath
external   nr8 messboxwait() dly_pstgpath vunloadif()

public     ptstr rel_date from_date chk_cb
public     #sd
public     cr                          ' cash rec'd - calc'd from data
public     tot_con                     ' total contras
public     tot_cash                    ' total cash/chq's
public     tot_pdq                     ' total pdq's
public     csh_F                       ' Fulham receipts cash/chqs - calc'd
public     csh_H                       ' H/O receipts cash/chqs - calc'd
public     csh_P                       ' Putney receipts cash/chqs - calc'd
public     csh_R                       ' Raynes receipts cash/chqs - calc'd
public     csh_S                       ' Sheen receipts cash/chqs - calc'd
public     pdq_F                       ' Fulham receipts PDQ   - calc'd
public     pdq_H                       ' H/O receipts PDQ   - calc'd
public     pdq_P                       ' Putney receiipts PDQ   - calc'd
public     pdq_R                       ' Raynes receipts PDQ   - calc'd
public     pdq_S                       ' Sheen receipts PDQ   - calc'd
public     con_F                       ' Fulham contras - calc'd
public     con_H                       ' H/O contras - calc'd
public     con_P                       ' Putney contras - calc'd
public     con_R                       ' Raynes contras - calc'd
public     con_S                       ' Sheen contras - calc'd
public     rcv_F                       ' Fulham receipts
public     rcv_R                       ' Raynes receipts
public     rcv_P                       ' Putney receipts
public     rcv_S                       ' Sheen receipts
public     rcv_T                       ' Trade receipts
public     rcv_W                       ' W'hse receipts
public     rcv_Y                       ' Sundry receipts

global     x Receipts()
global     ReturnToMenu()
global     #chk #chk1 p1 p2 p3 p4 p5 p6 cm


MAIN
single-step off
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  file unload all
  remove("sal_pstg.idx")
  remove("salpstg1.idx")
  remove("dly_cash.idx")
  remove("dlypstg3.idx")
  remove("dlypstg4.idx")
  remove("csh_pstg.idx")
  remove("contras.idx")

  p2 = ""               ' p2 = title at top of choice popup ("LABEL")
  p3 = 1                ' p3 = printer to be used (1=HPIII_QC; 2=GEN_EPSN etc)
  p4 = 1                ' p4 = printer port to use (1,2 etc - network set to use 2=LASER; 3=LABEL)
  p5 = 1                ' choose VIEW/PRINT 1=PRINT; 2=VIEW; 3=CHOOSE
  p6 = 1                ' p6 = nr of copies

  rel_date = date2(today)
  progress(15,10," Collecting data for unposted Cash Receipts ",0)
  x = Receipts()
  if x = -1
    ReturnToMenu()
  end if

  messbox(" Unposted cash is"&currency(cr)&"- print full report? (y/n) ",1,1,1)
' yn - 1 allow Yes/No;o=disallow
' col- 1 for pleasing; 0 for error
' esc- 1 do NOT allow Esc;0=allow Esc
  if ptstr == "y"
    screen clear box 1 1 sch scw 0 0 no-border
    repaint off
    remove("printme.idx")
    vloadif(dpath|"cust_ord.vws")
    x=makeidx("cust_ord","printme.idx",precord,3)  'message "x is:"&str(x)
    order change index "printme"
    p1 = "daysrcpt.dfr"
    p2 = "Summary"
    PrintReport(p1,p2,p3,p4,p5,p6)
  end if

  ReturnToMenu()

END MAIN


FUNCTION Receipts()
local postcash
  vloadif(dpath|"dly_cash.vw")
  order change key "[Posted]"
  data query execute "daysrcp2.dfq" index "csh1.idx"
'   data query execute "daysrcp2.dfq" index "csh_pstg.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [Posted] = blank
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    csh_F = 0
    csh_H = 0
    csh_P = 0
    csh_R = 0
    csh_S = 0
    pdq_F = 0
    pdq_H = 0
    pdq_P = 0
    pdq_R = 0
    pdq_S = 0
    con_F = 0
    con_H = 0
    con_P = 0
    con_R = 0
    con_S = 0
    return(0)
  end if
  data query execute "daysrcp1.dfq" index "csh_pstg.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [SalesAnalysis]<>"X"
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    csh_F = 0
    csh_H = 0
    csh_P = 0
    csh_R = 0
    csh_S = 0
    pdq_F = 0
    pdq_H = 0
    pdq_P = 0
    pdq_R = 0
    pdq_S = 0
    con_F = 0
    con_H = 0
    con_P = 0
    con_R = 0
    con_S = 0
    return(0)
  end if

  csh_F = round(filesum([Amount_Received],[Branch]="F" and [Abbrv_M]="C"),2)+round(filesum([Amount_Received],[Branch]="F" and [Abbrv_M]="D"),2)  ' message "csh_F is:"&str(csh_F)
  csh_H = round(filesum([Amount_Received],[Branch]="H" and [Abbrv_M]="C"),2)+round(filesum([Amount_Received],[Branch]="H" and [Abbrv_M]="D"),2)  'message "csh_H is:"&str(csh_H)
  csh_P = round(filesum([Amount_Received],[Branch]="P" and [Abbrv_M]="C"),2)+round(filesum([Amount_Received],[Branch]="P" and [Abbrv_M]="D"),2)  'message "csh_H is:"&str(csh_H)
  csh_R = round(filesum([Amount_Received],[Branch]="R" and [Abbrv_M]="C"),2)+round(filesum([Amount_Received],[Branch]="R" and [Abbrv_M]="D"),2)  ' message "csh_F is:"&str(csh_F)
  csh_S = round(filesum([Amount_Received],[Branch]="S" and [Abbrv_M]="C"),2)+round(filesum([Amount_Received],[Branch]="S" and [Abbrv_M]="D"),2)  ' message "csh_F is:"&str(csh_F)

  pdq_F = round(filesum([Amount_Received],[Branch]="F" and [Abbrv_M]="P"),2)  ' message "pdq_F is:"&str(pdq_F)
  pdq_H = round(filesum([Amount_Received],[Branch]="H" and [Abbrv_M]="P"),2)  ' message "pdq_F is:"&str(pdq_F)
  pdq_P = round(filesum([Amount_Received],[Branch]="P" and [Abbrv_M]="P"),2)  ' message "pdq_F is:"&str(pdq_F)
  pdq_R = round(filesum([Amount_Received],[Branch]="R" and [Abbrv_M]="P"),2)  ' message "pdq_F is:"&str(pdq_F)
  pdq_S = round(filesum([Amount_Received],[Branch]="S" and [Abbrv_M]="P"),2)  ' message "pdq_F is:"&str(pdq_F)

  con_F = round(filesum([Amount_Received],[Branch]="F" and [Abbrv_M]="O"),2)  ' message "pdq_F is:"&str(pdq_F)
  con_H = round(filesum([Amount_Received],[Branch]="H" and [Abbrv_M]="O"),2)  ' message "pdq_F is:"&str(pdq_F)
  con_P = round(filesum([Amount_Received],[Branch]="P" and [Abbrv_M]="O"),2)  ' message "pdq_F is:"&str(pdq_F)
  con_R = round(filesum([Amount_Received],[Branch]="R" and [Abbrv_M]="O"),2)  ' message "pdq_F is:"&str(pdq_F)
  con_S = round(filesum([Amount_Received],[Branch]="S" and [Abbrv_M]="O"),2)  ' message "pdq_F is:"&str(pdq_F)

  rcv_F = round(filesum([Amount_Received],[SalesAnalysis]="F"),2)  ' message "csh_F is:"&str(csh_F)
  rcv_P = round(filesum([Amount_Received],[SalesAnalysis]="P"),2)  ' message "csh_R is:"&str(csh_R)
  rcv_R = round(filesum([Amount_Received],[SalesAnalysis]="R"),2)  ' message "csh_R is:"&str(csh_R)
  rcv_S = round(filesum([Amount_Received],[SalesAnalysis]="S"),2)  ' message "csh_S is:"&str(csh_S)
  rcv_T = round(filesum([Amount_Received],[SalesAnalysis]="T"),2)  ' message "csh_W is:"&str(csh_T)
  rcv_W = round(filesum([Amount_Received],[SalesAnalysis]="W"),2)  ' message "csh_W is:"&str(csh_W)
  rcv_Y = round(filesum([Amount_Received],[SalesAnalysis]="Y"),2)  ' message "csh_Y is:"&str(csh_Y)

  #chk = filesum([Amount_Received])    'message "Cash rec'd from filesum is:"&str(#chk)
  tot_cash = csh_F+csh_S+csh_H+csh_R+csh_P
  tot_pdq  = pdq_F+pdq_S+pdq_H+pdq_R+pdq_P
  tot_con  = con_F+con_S+con_H+con_R+con_P
   'message "tot_con is:"&str(tot_con)
  cr = tot_cash + tot_pdq + tot_con    'message "Cash,cheque,PDQ rec'd is:"&str(cr)

  postcash = rcv_F+rcv_S+rcv_W+rcv_R+rcv_P+rcv_Y+rcv_T 'message "Total cash to post is:"&str(postcash)
  if abs(#chk-cr)>.01
' message " More than 1p diff"
' message "#chk is:"&str(#chk)
' message "#chk1 is:"&str(#chk1)
  end if
END FUNCTION ' Receipts()


FUNCTION ReturnToMenu()
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  clear public
  file unload all
'   transfer cpath|"pm_menu.psl" in-memory
END FUNCTION ' ReturnToMenu()
