I am calling Amount, PaidtoDate, PropDist and sum of Amount in Ms Word template(.dot) using following code
*--------------------- Start Code - This code calling from Class
CREATE CURSOR AdminCur (CaseID I NULL, ClaimNo C(10) NULL, Payee M NULL, ClaimType C(50) NULL, ;
Filed Y NULL, PaidToDate Y NULL, Balance Y NULL, PropDist Y NULL, RunTotal Y NULL)
lcsql = "Sql Query ....."
IF THIS.SPT(lcSQL,'SQLCurs',.T.)
IF RECCOUNT('SQLCurs') > 0
SELECT SQLCurs
SCAN
m.ClaimNo = ALLTRIM(SQLCurs.ClaimNo)
m.Payee = IIF(EMPTY(SQLCurs.last) OR ISNULL(SQLCurs.last),ALLTRIM(SQLCurs.company),ALLTRIM(SQLCurs.Last) + ', ' + ALLTRIM(SQLCurs.First))
IF llIncNotes
IF !EMPTY(SQLCurs.ClaimNote) AND !ISNULL(SQLCurs.ClaimNote)
m.Payee = ALLTRIM(m.Payee) + CHR(13) + 'Note: ' + ALLTRIM(SQLCurs.ClaimNote)
ENDIF
ENDIF
m.ClaimType = 'Admin' + chr(13) + 'Percent Paid'
m.Filed = NVL(SQLCurs.Amount,0)
m.PaidToDate = NVL(SQLCurs.PaidToDate,0)
m.Balance = m.Filed - m.PaidToDate
IF SQLCurs.PaidAsDD = 1 AND SQLCurs.PropDist < 5.00
llPaidAsDD = .T.
m.PropDist = 0
ELSE
llPaidAsDD = .F.
m.PropDist = NVL(SQLCurs.PropDist,0)
ENDIF
INSERT INTO AdminCur FROM MEMVAR
ENDIF
ENDSCAN
ENDIF
EndIF
* Now build the running totals
SELECT AdminCur
SCAN
m.RunTotal = m.RunTotal - AdminCur.PropDist
REPLACE AdminCur.RunTotal WITH m.RunTotal
ENDSCAN
SELECT AdminCur
LOCAL lnATotal1 AS CURRENCY
LOCAL lnATotal2 AS CURRENCY
LOCAL lnATotal3 AS CURRENCY
LOCAL lnATotal4 AS CURRENCY
lnATotal1 = 0
lnATotal2 = 0
lnATotal3 = 0
lnATotal4 = 0
IF RECCOUNT() > 0
THIS.WordFillTable('
','AdminCur')
SELECT SUM(Filed) AS ATotal1, ;
SUM(PaidToDate) AS ATotal2, ;
SUM(Balance) AS ATotal3, ;
SUM(PropDist) AS ATotal4 ;
FROM AdminCur INTO CURSOR SumCurs
lnATotal1 = SumCurs.ATotal1
lnATotal2 = SumCurs.ATotal2
lnATotal3 = SumCurs.ATotal3
lnATotal4 = SumCurs.ATotal4
THIS.WordReplaceToken('', lnATotal1)
THIS.WordReplaceToken('', lnATotal2)
THIS.WordReplaceToken('', lnATotal3)
THIS.WordReplaceToken('', lnATotal4)
ELSE
THIS.WordDeleteRow('')
THIS.WordDeleteRow('')
ENDIF
*------------------End Code
WordFillTable, WordReplaceTOken, WOrdDeleteRow are function defined in Class.
In MS Word DOT file format, I want to enhance it and please read my queries and give me your suggestion.
This is working fine, Now I want to calculate Percentage for Individual Item and for Total also. For calculating Percentage I am using following formula
Perpaid = (Paidtodate+Proposed Payment)/Clain Amount
APerpaid = (Atotal2+Atotal4)/ATotal1
I tried various things, but did not handle it. Please let me know, How do I make it work. I am stuck.
Regards