mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
Include tax adjustments in serializer and presenter
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user