Adjustments help to track adjustments made to entities such as an
line item. Adjustments can be due to various reasons such as adding a
promotion, or adding taxes etc.
The adjustments table has a polymorphic relationship with the actions leading to it. e.g. Promotion Adjustments
The adjustment model has the following attributes:
adjustable_type: The type of adjustable for which adjustment is created it can be an
adjustable_id: The id of the adjustable for which the adjustment was created.
amount: The amount for the adjustment it can be positive or negative depending on whether the amount has to be added or substracted from the adjustable total. e.g. it is negative in case of promotions and positive in case of taxes.
eligible: This is used to check if the created adjustment should be considered while calculating totals for the adjustable. Adjustment which have
eligibleas true are only considered during the adjustable total calculations. This field is especially important while handling promotions. A promotion is considered applied if adjustments created due to it are eligible.
included: This is used to assert whether, amount adjusted is already present in the adjustable total. In case it is false the amount should be considered during total computation.
Adjustment Polymorphic Associations
Adjustments play a very important role while applying promotions. They help
in tracking the entity for which the adjustment was created using
adjustable_id and the
amount which was added.
eligible field is used to verify which adjustments are going to affect
the computations for an
line item. Only those adjustments which
eligible as true affect the calculation.