Cashflows from coupons and principal are discounted using the YTM to get PV of the bond in dirty price.
as shown here in this question Misunderstanding of 'day counts' and accrued interest
When backing out the clean price, the accrual is calculated as $coupon/freq*day/daycount$. But why do we linearly prorate the accrual?
Technically, shouldn't the accrued interest be the PV that is discounted by YTM of $coupon/freq*day/daycount$? The actual coupon amount will only be paid at the coupon date, so shouldn't the accrued interest take into account the time value between settlement date and coupon date?