For all customer debit and credit items, maximum cash discount is always considered.
The reason for this, is that the customer should not be penalized for carrying out the automatic payment after the due date. Thus max cash discount should be granted.
SAP Note 31345 explains this behavior.
Credit memos are always paid with the maximum cash discount if they do not have reference to the corresponding invoice in REBZG field.
If you post a credit memo with reference to a certain invoice (or set this reference via FB02) the credit memo will be paid with the same payment conditions as the invoice.
Or if you want the net due date to be calculated according to the payment term you have entered in the document, you need to enter a 'V' in the 'Invoice reference' field (BSEG-REBZG).
Regarding to Vendors, please check customizing of the payment program in your system:
transaction FBZP -> All Company Codes -> your Company Code -> the checkbox 'Max. cash discount'
According to F1-help to this field:
"Vendor Payments Always with Maximum Cash Discount" Means that the maximum cash discount is always to be deducted when automatically paying vendor invoices.