Vous êtes sur la page 1sur 7

*Program name St_sales.

prg
*For printing sales report
if !used("allusers")
use cDataPath+"systemf2" alias allusers in 0 SHARED
endif
Select allusers
set Order to username
seek musername
if !found()
messageb("User Name No Longer Exists !",55,"Integra")
return
endif
if !allusers.ST_SALE
messageb("Access Denied !",25,"Integra")
return
endif

if !used("company")
use cDataPath+"companyfile" alias company in 0 shared
endif
select company
set order to code
seek mcompcode
mname = NAME

if !used('stockfile')
use &mstockf alias stockfile in 0 shared
endif
Select stockfile
set filter to
set order to stloc

if !used('st_loc')
use &mlocf alias st_loc in 0 shared
endif
select st_loc
set order to code

if !used('st_cat')
use &mcatf alias st_cat in 0 shared
endif
select st_cat
set order to code

if !used('st_trans')
use &mtransf alias st_trans in 0 shared
endif
select st_trans
set order to locst_date

if !used('ptr_tmp')
use &mpos_ptrtmp alias ptr_tmp in 0 shared &&SELECT 1
endif

*Create TMP
**********************
SELECT ptr_tmp &&1
temp = 'tmp\' + subst(sys(2015),3,8)
copy stru to &temp
if used('temp')
select temp
zap
use
endif
use &temp alias temp in 0 excl
select temp

if !used('psummary')
use &mpsummary alias psummary in 0 shared
endif
sele psummary
set order to typeref
go top

if !used('cashpoints')
use &mpoints Order code alias cashpoints in 0 shared
endif
Select cashpoints
set order to Code

if !used('accounts')
use &mglf Order accno alias accounts in 0 shared
endif
Select accounts
set order to accno

mcopy = .t.
mprint = " " && Reprint on NORMAL A4 Paper

store ' ' to m.location,m.proceedcancel,m.locname


mdate = date()
m.prnscr = 'Screen'

do form stocks\forms\salesreport
return

****************************
Procedure unload_salesreport
****************************
*Reset Filters

Select stockfile
set filt to
select st_trans
Set filter to
return

************************
Procedure valid_location
************************
if left(m.location,1)='?'
do location_search in stocks\progs\reportsearch with m.location
endif
Select st_loc
if !empty(m.location)
seek m.location
if !eof()
m.locname = NAME
else
messageb("Location Code Not found ",64,"Integra")
return 0
endif
endif
salesreport.refresh
Return

*****************
Procedure seleopt
*****************
parameter m.proceedcancel
if m.proceedcancel = 'Proceed'
if empty(m.location)
messageb("Empty Location Disallowed",64,"Integra")
return 0
endif
if empty(mdate)
messageb("Date Is Mandatory ",64,"Integra")
return 0
endif
do sales_report
endif
salesreport.release

**********************
PROCEDURE SALES_REPORT
**********************
*Does Actual Printing

wait wind "Please Wait..." nowait


Select st_trans
set filter to TYPE = "ISP" and LOCATION = m.location and DATE = mdate
go top

if eof()
wait wind "Please Wait..." time 0.01
messageb("No Transactions in the given range !",64,"Integra")
return
endif

*Create tmp's
**************
*1) Summarised grid
Select st_trans
if !used("Tmp_st_trans")
mtmp_sttrans = "tmp\" + substr(sys(2015),3,8) + '.dbf'
copy stru to &mtmp_sttrans fiel DOC_NO,TYPE,CONSM_NAME,UNIT_PRICE,INPUTBY
use &mtmp_sttrans in 0 alias tmp_st_trans excl
sele tmp_st_trans
index on TYPE + DOC_NO tag typedoc
set order to typedoc
endif

Sele tmp_st_trans
do while .t.
if flock()
zap
unlock
exit
endif
enddo

*2) Detailed grid


Select st_trans
if !used("Tmp_detailed")
mtmp_detailed = "tmp\" + substr(sys(2015),3,8) + '.dbf'
copy stru to &mtmp_detailed fiel TYPE,DOC_NO,DATE,QTY,UNIT_PRICE
use &mtmp_detailed in 0 alias Tmp_detailed excl
sele Tmp_detailed
Alter table &mtmp_detailed add column DESC1 c(30)
Alter table &mtmp_detailed add column TOTAL N(13,2)
index on TYPE + DOC_NO tag typedoc
set order to typedoc
endif

Sele Tmp_detailed
append blank
do while .t.
if flock()
zap
unlock
exit
endif
enddo

Select st_trans
set order to typedoc
go top
do while !eof()
scatter memvar
mdoc = DOC_NO
mtype = TYPE
mtotal_price = 0
do while !eof() and DOC_NO = mdoc
if PACKAGE
mtotal_price = mtotal_price + (UNIT_PRICE * QTY)
endif
if !PACKAGE and !INGREDIENT && Independent item
mtotal_price = mtotal_price + (UNIT_PRICE * QTY)
endif
skip
enddo
Sele tmp_st_trans
seek mtype + mdoc
if eof()
insert into tmp_st_trans from memvar
endif
repl UNIT_PRICE with mtotal_price
Select st_trans
enddo
sele st_trans
set order to stloc
Sele tmp_st_trans
sum UNIT_PRICE to m_totalunitprice
go top
m.display_opt ="Package in summary"

do form stocks\forms\salesreport2
return

*****************************
Procedure unload_salesreport2
*****************************
*Clear tmp's
if used('tmp_detailed')
sele tmp_detailed
use
Erase &mtmp_detailed.dbf
Erase &mtmp_detailed.cdx
Erase &mtmp_detailed.bak
Erase &mtmp_detailed.*
endif

if used('tmp_st_trans')
sele tmp_st_trans
use
Erase &mtmp_sttrans.dbf
Erase &mtmp_sttrans.cdx
Erase &mtmp_sttrans.bak
Erase &mtmp_sttrans.*
endif
if used("temp")
select temp
use
Erase &temp.dbf
Erase &temp.cdx
Erase &temp.*
endif

Select st_trans
Set filter to
Return

***********************
Procedure detailed_info
***********************
*Fill the Second Grid Based on Current Record in summarised Grid
Select tmp_detailed
do while .t.
if flock()
zap
unlock
exit
endif
enddo

Select tmp_st_trans
mdoc = DOC_NO
mtype = TYPE
m_total = UNIT_PRICE
Select st_trans
set order to typedoc
seek mtype + mdoc
do while !eof()
if TYPE = mtype and DOC_NO = mdoc and ;
iif (m.display_opt ="Package in summary" ,(PACKAGE or (!PACKAGE and !INGREDIENT)),;
!PACKAGE or !PACKAGE and !INGREDIENT)

scatter memvar
Select stockfile
seek m.location + m.st_code
m.desc1 = " "
if !eof()
m.desc1 = DESC1
else
m.desc1 = m.st_code
endif
insert into tmp_detailed from memvar
Select tmp_detailed
repla TOTAL with QTY * UNIT_PRICE
endif
Select st_trans
if !eof()
skip
endif
enddo

Select tmp_detailed
go top
salesreport2.refresh
Return

**********************
Procedure print_report
**********************
*Print to text file -- Deactivated
mtxt_salesrpt = "tmp\" + substr(sys(2015),3,8) + ".txt"
set device to file &mtxt_salesrpt
ln = 99
pg = 0
mgr_cost = 0
heading1 = "DAILY SALES REPORT "
heading2 = "STORE "+ trim(m.location) + + " DATE :" + dtoc(mdate)

do stocks\progs\prn_head
@ ln, 0 say repl("-",80)
ln = ln + 1
@ ln, 0 say "Trans "
ln = ln + 1
@ ln, 0 say "No. Desc Price Qty Total Customer "
ln = ln + 1
@ ln, 0 say repl("-",80)
ln = ln + 1
store 0 to mgr_gds
Do while !eof()
m_ref = DOC_NO
mprintname = .t.
Do while !eof() .and. DOC_NO = m_ref
if (out_opt = 2 .and. ln >= 57)
do stocks\progs\prn_hd9
@ ln, 0 say repl("-",80)
ln = ln + 1
@ ln, 0 say "Trans "
ln = ln + 1
@ ln, 0 say "No. Desc Price Qty Total Customer "
ln = ln + 1
@ ln, 0 say repl("-",80)
ln = ln + 1
endif
if PACKAGE .or. (!PACKAGE and !INGREDIENT)
if mprintname
@ ln, 0 say DOC_NO
@ ln, 7 say TRANS_DESC
mprintname = .f.
endif
@ ln,38 say UNIT_PRICE pict "9999999999"
@ ln,48 say QTY pict "99999"
@ ln,55 say UNIT_PRICE * QTY PICT "9999999999"
mgr_gds = mgr_gds + (UNIT_PRICE * QTY)
@ ln,66 say left(CONSM_NAME,15)
ln = ln + 1
endif
skip
Enddo
Enddo
@ ln, 45 say "-----------------------------------"
ln = ln + 1
@ ln, 45 say "Total "
@ ln, 55 say mgr_gds pict "99999999999"
ln = ln + 1
@ ln, 0 say repl("=",80)
wait wind "Please Wait..." time 0.01
if m.prnscr = "Screen"
set device to screen
modi comm &mtxt_salesrpt nomodify
else
@ 59, 130 say chr(18) + " "
set device to screen
!type &mtxt_salesrpt > prn
eject
endif
return

Procedure clk_display_opt
*************************
do detailed_info
return

Procedure printsale
********************
m.proceedcancel = 'Proceed'
m.rcptno = tmp_st_trans.DOC_NO

do seleopt in pos\progs\reprintsale with m.proceedcancel

Vous aimerez peut-être aussi