Forum
Keyword

CHARGE.ROUTINE for FT.COMMISSION.TYPE

  • Posts: 1
  • Thank you received: 0

emy created the topic: CHARGE.ROUTINE for FT.COMMISSION.TYPE

I need sample CHARGE.ROUTINE for FT.COMMISSION.TYPE, need to setup charge for MORTGAGE which is a fucntion of Outstanding balance of the loan
#17415

Please Log in or Create an account to join the conversation.

  • armin
  • armin's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • “So long - and thanks for all the fish!”
  • Posts: 300
  • Karma: 13
  • Thank you received: 57

armin replied the topic: CHARGE.ROUTINE for FT.COMMISSION.TYPE

As per helptext the routine has the same parameters as the core CALCULATE.CHARGE routine, in the user guides you may find some hints about the 10 parameters that are passed, but no concret mapping.

Some years back I received a sample routine that is also somewhere mentioned in the user guides, important are only 2 parameters.
You will be able to change this for your needs . . .
*-----------------------------------------------------------------------------
    SUBROUTINE IC.CALC.NO.OF.TXNS(PASS.CUSTOMER, PASS.DEAL.AMOUNT, PASS.DEAL.CCY, PASS.CCY.MKT,PASS.CROSS.RATE, PASS.CROSS.CCY, PASS.DWN.CCY, PASS.DATA, CUST.CDN, CHARGE.AMOUNT)

* Routine TO calculate no of transactions AND apply charge FOR the transactions.
* Account Number, FROM Period, TO Period AND calculation period will be passed FROM Accrual PROGRAM
*-----------------------------------------------------------------------
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.DATES
$INSERT I_F.ACCOUNT
$INSERT I_F.ACCT.ACTIVITY
$INSERT I_F.TRANSACTION
$INSERT I_F.NUMBER.OF.TXNS
$INSERT I_F.STMT.GEN.CHG
$INSERT I_DAS.COMMON
$INSERT I_DAS.ACCT.ACTIVITY

    GOSUB INITIALISE
    GOSUB PROCESS
    RETURN

INITIALISE:
***********
    IC.CHARGE.PARM.START = 37 ;* Specify the posn. of parm. in T.DATA
    IC.CHARGE.PARM.END = 47

    AC.NO = PASS.DATA<IC.CHARGE.PARM.START>       ;* Passed from Calculate Charge.
    FROM.YEARMTH = PASS.DATA<IC.CHARGE.PARM.START + 1>[1,6] ;*Year-month.
    TO.YEARMTH = PASS.DATA<IC.CHARGE.PARM.START + 2>[1,6]
    Y.CAL.PERIOD = PASS.DATA<IC.CHARGE.PARM.START + 3>
    Y.DATE = PASS.DATA<IC.CHARGE.PARM.START + 1>
    IF Y.CAL.PERIOD = '' THEN
        Y.CAL.PERIOD = 'P'
    END

    VALUE1 = AC.NO:"-":FROM.YEARMTH
    VALUE2 = AC.NO:"-":TO.YEARMTH
    TOTAL.TXNS = 0
    NO.TXN.ARRAY = '' ; TOT.CHG.AMT = ''

    FN.NUMBER.OF.TXNS = 'F.NUMBER.OF.TXNS'
    F.NUMBER.OF.TXNS = ''
    CALL OPF(FN.NUMBER.OF.TXNS,F.NUMBER.OF.TXNS)

    FN.TRANSACTION = 'F.TRANSACTION'
    F.TRANSACTION = ''
    CALL OPF(FN.TRANSACTION,F.TRANSACTION)

    FN.STMT.GEN.CHG = 'F.STMT.GEN.CHG' ; F.STMT.GEN.CHG = ''
    CALL OPF(FN.STMT.GEN.CHG,F.STMT.GEN.CHG)

    NARRATIVE = ''

    RETURN

PROCESS:
*******
    ID.LIST      = DAS.ACCT.ACTIVITY$ID.RANGE
    THE.ARGS     = VALUE1 : FM : VALUE2
    TABLE.SUFFIX = ''
    CALL DAS('ACCT.ACTIVITY',ID.LIST,THE.ARGS,TABLE.SUFFIX)

    IF Y.CAL.PERIOD = 'P' THEN
        LOOP
            REMOVE ACCT.ID FROM ID.LIST SETTING ACCT.POS
        WHILE ACCT.ID:ACCT.POS
            CALL EB.READ.ACCT.ACTIVITY.RECORD(ACCT.ID, R.ACCT.ACTIVITY, "", ERRMSG)
            IF NOT(ERRMSG) THEN
                TOTAL.TXNS = SUMMATION(R.ACCT.ACTIVITY<IC.ACT.NO.OF.TRANSACT>)  ;* CI_10022665 S/E
                NO.TXN.ARRAY<-1> = TOTAL.TXNS
            END
        REPEAT
        TOTAL.TXNS = SUMMATION(NO.TXN.ARRAY)                                    ;* CI_10022665 S/E
        NARRATIVE = "CALC.TYPE   = PERIODIC"      ;* GB0101820 S/E
        NARRATIVE<-1> = "NO.OF.TXNS  = ":TOTAL.TXNS         ;* GB0101704 S/E
        GOSUB TXN.AMOUNT
        GOSUB INTERIM.CAP.CHG.AMT
        *--- Update the Narrative.
        NARRATIVE<-1> = "FROM.PERIOD = ":FROM.YEARMTH
        NARRATIVE<-1> = "TO.PERIOD   = ":TO.YEARMTH
    END ELSE
        TOT.CHG.AMT = ''
        NARRATIVE = "CALC.TYPE      = MONTHLY"
        LOOP
            REMOVE ACCT.ID FROM ID.LIST SETTING ACCT.POS
        WHILE ACCT.ID:ACCT.POS
            CALL EB.READ.ACCT.ACTIVITY.RECORD(ACCT.ID, R.ACCT.ACTIVITY, "", ERRMSG1)
            IF NOT(ERRMSG1) THEN
                TOTAL.TXNS = SUMMATION(R.ACCT.ACTIVITY<IC.ACT.NO.OF.TRANSACT>)   ;* CI_10022665 S/E
            END
            NARRATIVE<-1> = "NO.OF.TXNS     = ":TOTAL.TXNS  ;* GB0101704 S/E
            GOSUB TXN.AMOUNT
            TOT.CHG.AMT = TOT.CHG.AMT + CHARGE.AMOUNT
            CURRYRMTH = FIELD(ACCT.ID,'-',2,1)
            CURRMTH = CURRYRMTH[5,2]
            NARRATIVE<-1> = "CHARGE MONTH    =":CURRMTH
            NARRATIVE<-1> = "CHARGE.AMOUNT = ":CHARGE.AMOUNT
        REPEAT
        CHARGE.AMOUNT = TOT.CHG.AMT
        GOSUB INTERIM.CAP.CHG.AMT
    END
    PASS.DATA<IC.CHARGE.PARM.START> = LOWER(NARRATIVE)
    RETURN

TXN.AMOUNT:
**********
* Charge calculation based ON total no of transactions
    ERRMSG = ''
*
    Y.NO.OF.TXNS.ID = ''
    CALL EB.READ.PARAMETER(FN.NUMBER.OF.TXNS,'N','',R.NO.OF.TXNS,Y.NO.OF.TXNS.ID,F.NUMBER.OF.TXNS,ERRMSG)
* EN_10002090 /E
    TXN.POS = ''
* IF total txns is zero, RETURN TO main program.
    IF TOTAL.TXNS = 0 THEN
        CHARGE.AMOUNT = 0
        RETURN
    END
* IF total txns is NOT found IN UPTO.TXN multivalue set THEN take the last value.
    LOCATE TOTAL.TXNS IN R.NO.OF.TXNS<NO.TXN.UPTO.TXN,1> BY 'AR' SETTING TXN.POS THEN
        GOSUB CALC.CHRG.AMT
    END ELSE
        IF R.NO.OF.TXNS<NO.TXN.UPTO.TXN><1,TXN.POS> EQ '' THEN
            TXN.POS = TXN.POS - 1
        END
        GOSUB CALC.CHRG.AMT
    END
    RETURN

CALC.CHRG.AMT:
*************
    CALL DBR("ACCOUNT":FM:AC.CURRENCY,AC.NO,Y.CCY)
* IF calculation type is set TO BAND OR LEVEL
    BEGIN CASE
        CASE R.NO.OF.TXNS<NO.TXN.CALCULATION.TYPE> = 'LEVEL'
            CCY.POS = ''
            * IF account currency is found THEN take flat charge ELSE take default charge IN that level.
            LOCATE Y.CCY IN R.NO.OF.TXNS<NO.TXN.CURRENCY,TXN.POS,1> SETTING CCY.POS THEN
                CHARGE.AMOUNT = R.NO.OF.TXNS<NO.TXN.FLAT.CHARGE,TXN.POS,CCY.POS>
            END ELSE
                CHARGE.AMOUNT = R.NO.OF.TXNS<NO.TXN.DEFAULT.CHG,TXN.POS>
            END
        CASE R.NO.OF.TXNS<NO.TXN.CALCULATION.TYPE> = 'BAND'
            CHRG.AMT = 0
            UPTO.TXN.ARRAY = ''
            Y.TOTAL.TXNS = TOTAL.TXNS
            UPTO.TXN.ARRAY = R.NO.OF.TXNS<NO.TXN.UPTO.TXN>
            * LOOP through each UPTO.TXN value, IF upto.txn is less than OR equal TO total txns THEN
            * calculate total charge amount. substract the upto.txn value FROM total txns.
            LOOP
                REMOVE UPTO.TXN FROM UPTO.TXN.ARRAY SETTING POS
            WHILE UPTO.TXN:POS
                LOCATE UPTO.TXN IN R.NO.OF.TXNS<NO.TXN.UPTO.TXN,1> BY 'AR' SETTING T.POS THEN
                    IF UPTO.TXN LE TOTAL.TXNS THEN
                        GOSUB CALC.TOT.CHRG.AMT
                        TOTAL.TXNS = TOTAL.TXNS - UPTO.TXN
                        IF TOTAL.TXNS LE 0 THEN
                            EXIT
                        END
                    END ELSE
                        GOSUB CALC.TOT.CHRG.AMT
                        EXIT
                    END
                END
            REPEAT
            * IF UPTO.TXN is null, increase the value of T.POS BY 1 because T.POS will hold the previous value.
            IF UPTO.TXN EQ '' THEN
                T.POS = T.POS + 1
                GOSUB CALC.TOT.CHRG.AMT
            END
            CHARGE.AMOUNT = CHRG.AMT
    END CASE
    RETURN

CALC.TOT.CHRG.AMT:
*****************
* This para returns the FLAT.CHARGE IF curreny is located ELSE
* returns DEFAULT.CHG amount.
    CCY.POS = ''
    LOCATE Y.CCY IN R.NO.OF.TXNS<NO.TXN.CURRENCY,T.POS,1> SETTING CCY.POS THEN
        CHRG.AMT = CHRG.AMT + R.NO.OF.TXNS<NO.TXN.FLAT.CHARGE,T.POS,CCY.POS>
    END ELSE
        CHRG.AMT = CHRG.AMT + R.NO.OF.TXNS<NO.TXN.DEFAULT.CHG,T.POS>
    END
    RETURN

INTERIM.CAP.CHG.AMT:
******************
* This para returns charge amount FOR interim capitalisation.
* IF current month AND the FROM period month are same AND
* the day is NOT the first day of the month THEN READ
* STMT.GEN.CHG record GET the charge amount, subtract it
* FROM the charge amount calculated BY the routine.
    Y.MTH = PASS.DATA<IC.CHARGE.PARM.START + 1>[5,2]
    CUR.MTH = TODAY[5,2]
    IF Y.MTH = CUR.MTH THEN
        TEMP.DATE = TODAY[1,6]:"01"
        CALL CDT("",TEMP.DATE,'-1C')
        FIRST.WRK.DAY = TEMP.DATE
        CALL CDT("",FIRST.WRK.DAY,"+1W")
        * If it is first working day of the month
        IF Y.DATE[7,2] EQ FIRST.WRK.DAY[7,2] ELSE
            CALL CDT("",Y.DATE,"-01W")
            FT.COMMISSION.ID = PASS.DATA<1>
            STMT.GEN.CHG.ID = AC.NO:".":FT.COMMISSION.ID:".":Y.DATE
            CALL F.READ(FN.STMT.GEN.CHG,STMT.GEN.CHG.ID,R.STMT.GEN.CHG,F.STMT.GEN.CHG,ERRMSG)
            IF ERRMSG = '' THEN
                CHARGE.AMOUNT = CHARGE.AMOUNT - R.STMT.GEN.CHG<STMT.GEN.CHARGE.AMOUNT>
            END
        END
    END
    RETURN
    END

using R11 on Unix
#17417

Please Log in or Create an account to join the conversation.

  • Posts: 12
  • Thank you received: 0

rizkiisroi replied the topic: CHARGE.ROUTINE for FT.COMMISSION.TYPE

Thanks, it's very helpful to begin with this example
#21509

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 1

dungtruong8x replied the topic: CHARGE.ROUTINE for FT.COMMISSION.TYPE

dear Armin
Can you explain more about CAL.PERIOD field, difference between P and M value?
thanks all!
#21695

Please Log in or Create an account to join the conversation.

Time to create page: 0.129 seconds