Menu

[4640d3]: / Apeom.prg  Maximize  Restore  History

Download this file

138 lines (127 with data), 3.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/** @package
Apeom.prg
Last change: TG 5 Jan 2011 9:16 pm
*/
Procedure Apeom
#include "bpos.ch"
local mtot,mclear_line:=space(60),mcust,mcode,getlist:={}
field amtcur, amt30, amt60, amt90, tage
Heading( "Age Creditor Accounts" )
Box_Save( 4,02,12,78 )
Center( 05," This option will age the amounts outstanding for each account")
Center( 06," and entries in the transaction file.")
Center( 08, DEVELOPER + " recommends you Backup the Accounts before this Step")
Center( 09,"The Creditors were last aged on " + dtoc( Oddvars( CRE_AGE ) ) )
if Isready(14)
if Ap_file_open( EXCLUSIVE )
if Netuse( 'stkhist', EXCLUSIVE )
SysAudit("CreAge")
select supplier
sum amtcur+amt30+amt60+amt90 to mtot
Accvars( "cop_bal","R",mtot )
Oddvars( CRE_OP_BAL, mtot )
supplier->( dbgotop() )
mclear_line := space(60)
while !supplier->( eof() )
mcust := supplier->name
@ 11,10 say mclear_line
Highlight( 11,10,'Creditor Being Aged ->',trim( mcust ) )
mcode := supplier->code
supplier->amt90 += supplier->amt60 // age balances
supplier->amt60 := amt30
supplier->amt30 := amtcur
supplier->amtcur := 0
supplier->laststat := supplier->amt30 + supplier->amt60 + supplier->amt90
if cretrans->( dbseek( mcode ) )
if !supplier->op_it
while cretrans->code = mcode .and. !cretrans->( eof() )
Aphist_add()
cretrans->( dbdelete() )
skip alias cretrans
enddo
else
while cretrans->code = mcode .and. !cretrans->( eof() )
if Vs(cretrans->amtpaid,10,2) = Vs(cretrans->amt,10,2)
Aphist_add()
cretrans->( dbdelete() ) // erase invoices if paid
else
if cretrans->tage < 4
cretrans->tage += 1
endif
endif
skip alias cretrans
enddo
endif
endif
skip alias supplier
enddo
sele cretrans
pack
select stkhist
@ 11,10 say mclear_line
Center( 11, 'Ageing Stock History Records' )
replace all stkhist->period with min( 99, stkhist->period+1 )
select aphist
@ 11,10 say mclear_line
Center( 11, 'Ageing Transaction History Records' )
replace all tage with min( 4, tage+1 )
Accvars( "l_cre_age", "R", Bvars( B_DATE ) )
Oddvars( CRE_AGE, Bvars( B_DATE ) )
endif
endif
endif
dbcloseall()
return
*
procedure apeoy
if Secure( X_CREDEOM )
Heading( "Zero Year to Date Purchases" )
Box_Save( 4,05,08,75 )
Center( 05,"This option will zero the Suppliers year to date purchases amount.")
Center( 06," Print your supplier listing before this step is performed")
if Isready( 10 )
if Ap_file_open( EXCLUSIVE )
SysAudit( "CreEOY" )
select supplier
replace all supplier->pytdamt with supplier->ytdamt,;
supplier->ytdamt with 0
close databases
endif
endif
endif
return
*
procedure appurge
local mdate := Bvars( B_DATE )-365, getlist:={}
if Secure( X_SYSUTILS )
Heading( "Purge old Transaction Histories" )
@ 14,26 say 'ออออ> Date to purge to' get mdate
read
if lastkey() != K_ESC
Box_Save( 4,05,08,75 )
Center( 05,"You are about to delete all Supplier Transaction Histories")
Center( 06," Older than " + dtoc( mdate ) )
if Isready( 10 )
if Ap_file_open( EXCLUSIVE )
SysAudit( "CreHistPur" )
select aphist
delete for aphist->date <= mdate
close databases
endif
endif
endif
endif
return
*
function Aphist_add
Add_rec( 'aphist' )
aphist->code := cretrans->code
aphist->ttype := cretrans->ttype
aphist->date := cretrans->date
aphist->tnum := cretrans->tnum
aphist->amt := cretrans->amt
aphist->duedate := cretrans->duedate
aphist->amtpaid := cretrans->amtpaid
aphist->tage := cretrans->tage
aphist->desc := cretrans->desc
return nil