$$IsDr will tell you if the argument passed is debit or credit, use it in the formula, calculate accordingly for example, $$IsDr:$VchAmt will return true if VchAmt is debit, if it is credit, the function returns false.