...
If DocumentLine is a handling cost, meaning DocumentLine.handlingCostCode is set. Accrual Profit/ Loss Account from the related Handling Cost Code account is used.
If DocumentLine has no variousText, portCostCode or handlingCostCode.variousText is null DocumentLine.portCostCode is null and DocumentLine.handlingCostCode is null. Accrual Profit/ Loss Account from the related Account is used.
...