Include tax adjustments in serializer and presenter

This commit is contained in:
Matt-Yorkley
2023-05-09 14:16:21 +01:00
committed by Konrad
parent 5bbc63f716
commit 113e1344f2
3 changed files with 9 additions and 2 deletions

View File

@@ -50,6 +50,8 @@ class Invoice
def checkout_adjustments(exclude: [], reject_zero_amount: true)
adjustments = all_eligible_adjustments
adjustments.reject! { |a| a.originator_type == 'Spree::TaxRate' }
if exclude.include? :line_item
adjustments.reject! { |a|
a.adjustable_type == 'Spree::LineItem'
@@ -63,6 +65,10 @@ class Invoice
adjustments
end
def all_tax_adjustments
all_eligible_adjustments.select { |a| a.originator_type == 'Spree::TaxRate' }
end
def invoice_date
date
end

View File

@@ -4,10 +4,11 @@ class Invoice
class DataPresenter
class Adjustment < Invoice::DataPresenter::Base
attributes :additional_tax_total, :adjustable_type, :amount, :currency, :included_tax_total,
:label
:label, :originator_type
invoice_generation_attributes :additional_tax_total, :adjustable_type, :amount,
:included_tax_total
invoice_update_attributes :label
def display_amount
Spree::Money.new(amount, currency: currency)
end

View File

@@ -16,7 +16,7 @@ class Invoice
has_many :all_eligible_adjustments, serializer: Invoice::AdjustmentSerializer
def all_eligible_adjustments
object.all_adjustments.eligible.where.not(originator_type: 'Spree::TaxRate')
object.all_adjustments.eligible
end
def completed_at