Class: Spree::ClaimLineItem

Inherits:
Object
  • Object
show all
Extended by:
DisplayMoney
Includes:
PostSale::TaxedLine
Defined in:
app/models/spree/claim_line_item.rb

Overview

One problem item on a Claim, and how it is being made right: money back, a replacement, or both.

Instance Method Summary collapse

Methods included from DisplayMoney

money_methods

Methods included from PostSale::TaxedLine

#credited_tax_total, #settles_tax?

Instance Method Details

#credited_quantity ⇒ Integer

Nothing is given back on a claim that was denied or withdrawn.

Returns:

  • (Integer)


51
52
53
# File 'app/models/spree/claim_line_item.rb', line 51

def credited_quantity
  claim.denied? || claim.canceled? ? 0 : quantity.to_i
end

#credited_worth ⇒ BigDecimal

Returns:

  • (BigDecimal)


56
57
58
# File 'app/models/spree/claim_line_item.rb', line 56

def credited_worth
  paid_amount
end

#fold_tax_lines! ⇒ void

This method returns an undefined value.



61
62
63
64
# File 'app/models/spree/claim_line_item.rb', line 61

def fold_tax_lines!
  included, additional = tax_totals_from(tax_lines.credits.reload)
  update_columns(included_tax_total: included, additional_tax_total: additional)
end

What the customer paid for the affected units, after discounts and with the tax charged on top of the price — the ceiling for a refund on this line, which is entered tax included. A claim opened before claims carried tax has none, so its ceiling is unchanged.

Returns:

  • (BigDecimal)


35
36
37
# File 'app/models/spree/claim_line_item.rb', line 35

def paid_amount
  discounted_amount + additional_tax_total
end

#pre_tax_amount ⇒ BigDecimal

Returns the affected units before tax.

Returns:

  • (BigDecimal) —

    the affected units before tax



40
41
42
# File 'app/models/spree/claim_line_item.rb', line 40

def pre_tax_amount
  discounted_amount - included_tax_total
end

#tax_total ⇒ Object



44
45
46
# File 'app/models/spree/claim_line_item.rb', line 44

def tax_total
  included_tax_total + additional_tax_total
end

#variant_to_send ⇒ Object

What actually ships when the claim is resolved with a replacement.



67
68
69
# File 'app/models/spree/claim_line_item.rb', line 67

def variant_to_send
  replacement_variant || variant
end