Hi,
Create a "user entry variable" for "posting date".
Convert "Document type", "Invoice No", "Posting date" and "Net due date" into Kfs by using formula variables by replacement path. Otherwise you cannot calculate the differences.
So you will be creating two Posting date variables. One by user entry and another by replacement path. http://scn.sap.com/docs/DOC-12182
Case 1:
Write If ..else formula like below
(Document type KF == (CQ, CS,CC) + Invoice No KF NE (#, V) ) * ( (Posting Date(selection) KF) - (Net Due Date KF) ) +( ( Posting date(selection) Kf) - (Posting Date KF) )
Try to achieve your other requirements in the above fashion.
Regards,
Suman