Progress 4GL

{c:\blinick\test_contracts.i}

def stream mout.
output stream mout to c:\blinick\templatePaymentSchedule.csv.

def var vpaid as int.
def var vToPay as int.
def var vAmt as dec.
def var vNextDueDate as date.
def var vSchedNo as int.

i = 1.
do i = 1 to 30:

for each contract fields (ar-entity contract-no cust-no pap-start-date next-invc-dt) no-lock
where contract.ar-entity = ’01’ and
contract.contract-no = vCont[i]:

vPaid = 0.
vToPay = 0.
vAmt = 0.
vSchedNo = 999999999.
vNextDueDate = today + 365.

for each b-pymt fields (pmt contract-no ar-entity invoice-no charge-code bill-date b-pymt) no-lock where
b-pymt.ar-entity = ’01’ and
b-pymt.contract-no = contract.contract-no:

if b-pymt.invoice-no <> 0
then vpaid = vPaid + 1.
else vToPay = vToPay + 1.
if b-pymt.charge-code = ‘pmt’ then vAmt = b-pymt.pmt.
if b-pymt.invoice-no = 0 then vNextDueDate = min(vNextDueDate,b-pymt.bill-date).
vSchedNo = min(vSchedNo,b-pymt.b-pymt).

end.

export stream mout delimiter ‘,’

/* ScheduleNumber*/ vSchedNo
/* AccountId */ contract.cust-no
/* ContractId */ contract.contract-no
/* ScheduleType */ “M”
/* PaymentStreamType*/ “”
/* StartDate */ contract.pap-start-date
/* NextPaymentDueDate*/ vNextDueDate
/* PaymentFrequencyDescription*/ “”
/* PaymentsInvoiced */ vPaid
/* PaymentsRemaining */ vToPay
/* IsAdvance */ “”
/* InvoiceLeadDaysCode*/ “”
/* PaymentAmount */ vAmt
/* TransactionCode */ “”
/* InvoiceCode */ “”
/* DelinquencyCode */ “”
/* IsFollowRentSchedule*/ 0
/* IsCombineWithRent */ 0
/* IsProcessAsEft */ 0
/* IsAssetLevel */ 0
.
end.

end.