Stock Status for materials that have reached retest and expiration date

How can we configure the system Sage X3 to automatically assign a Q (Quarantine) status to materials when they reach their retest date and an R (Rejected) status when they reach their expiry date?