This question evaluates numerical reasoning for monetary calculations, handling of multiple promotion types, precision and rounding considerations, and edge-case handling such as empty carts and clamping totals within the Coding & Algorithms domain.

Assume you are implementing a checkout price calculator for an online shopping cart.
You are given:
price
: a non-negative decimal number representing the item's price.
shipping_fee
: a non-negative decimal number representing the shipping cost for the entire order.
p
(e.g., 10 for 10%). This discount applies
only to the sum of item prices
,
not
to the shipping fee.
d
. This discount is subtracted from the
total amount including shipping
.
Rules and assumptions:
items_sum
be the sum of all item prices.
items_sum + shipping_fee
.
p
(e.g., 10 for 10%), the discounted total is:
discounted_items = items_sum * (1 - p/100)
total = discounted_items + shipping_fee
.
d
, the discounted total is:
total = max(0, items_sum + shipping_fee - d)
.
Task
Given the list of item prices, the shipping fee, and a list of promotions of the two types above, write a function that:
Handle relevant edge cases, such as:
Specify the input and output formats for your function, including how you represent promotions and their types, and then implement the function.