Sobes.tech
Middle

Is the discount type (percentage or fixed amount) a separate attribute or not?

sobes.tech AI

Answer from AI

It is better to highlight the discount type (percentage or fixed amount) as a separate attribute rather than mixing it with the discount value itself. This clearly indicates how to interpret the discount value and simplifies processing logic.

For example, you can have a structure:

Discount {
  type: "percent" | "fixed"
  value: number
}

This approach facilitates validation, final price calculation, and expansion of functionality (such as adding new discount types).