Skip to content

Error in Order Calculations #191

@jakepenn

Description

@jakepenn

The PayPal Order Breakdown is Incorrect:

    def breakdown
      {
        item_total: price(@order.item_total),
        shipping: price(@order.shipment_total),
        tax_total: price(@order.additional_tax_total),
        discount: price(@order.all_adjustments.promotion.sum(&:amount).abs)
      }
    end

Solidus Version:
3.1.8

To Reproduce

Step 1 - create an order.
Step 2 - add promotions on the order, ensure that one of the promotions is: eligible: false -- ours looks like:

#<Spree::Adjustment:0x00007fa4d8190f58
 id: 213210,
 source_type: "Spree::PromotionAction",
 source_id: 115,
 adjustable_type: "Spree::LineItem",
 adjustable_id: 242932,
 amount: -0.5337e3,
 label: "Promotion (Bundle Upgrade)",
 eligible: false,
 created_at: Wed, 01 Mar 2023 09:38:51.503385000 CST -06:00,
 updated_at: Wed, 01 Mar 2023 18:09:07.143385000 CST -06:00,
 order_id: 208491,
 included: false,
 promotion_code_id: nil,
 adjustment_reason_id: nil,
 finalized: false>

Current behavior
The order totals will be incorrect and PayPal will reject and not process the order. This is because all non eligible promotions will also be included inside of: discount: price(@order.all_adjustments.promotion.sum(&:amount).abs)

Expected behavior
The order totals should always be perfect

Screenshots

Screenshot 2023-03-01 at 4 30 24 PM

Desktop (please complete the following information):
NA

Smartphone (please complete the following information):
NA

Additional context
NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions