Custom Crystal Report gives incorrect entries for Invoice Credits

Hi,

I'm using SAGE 300 Premium (Version 2018) and SAP Crystal Reports 2013. I'm working on a Crystal report and using the following table linkings:

 OEAUDH linking to OEINVH (Linking field- ORDNUMBER, Join- Inner Join)

 OEAUDH linking to OECRDH (Linking field- ORDNUMBER, Join- Inner Join)

OEINVH linking to OEINVD (Linking field- INVUNIQ, Join- Inner Join)

OECRDH linking to OECRDD (Linking field- CRDUNIQ, Join- Inner Join)

The objective of the report is to extract line description (OEINVD.DESC) along with the number of cases on each line description (OEINVD.SHIPTRACK) and equivalent credit lines issued on the invoice number. A formula (if {OEAUDH.TRANSTYPE = 1 THEN VAL({OEINVD.SHIPTRACK}) ELSE -VAL({OEINVD.SHIPTRACK}) has been added to represent the credit as a negative number of cases, which gets deducted from the total cases on the invoice. The details are then grouped by the OEAUDH.ORDNUMBER, which shows the final number of cases on each invoice (after deducting any credit on the invoice).

 Here is the snapshot of the problem with details (suppressed and not suppressed) and the Design screen:

  

For a particular line item with 6 cases (highlighted in yellow) on invoice # 0775988, there is an equivalent credit for 6 cases (highlighted in green). However, the report shows credits with each line item on the invoice (highlighted in red), which makes the final sum in the group footer zero. The correct representation for invoice # 0775988 should be 128 cases (134-6) and not zero.

Please suggest any changes which can fix this. Thanks!