Use VoucherAdjustmentsService to retrieve tax part of the voucher

This commit is contained in:
Gaetan Craig-Riou
2023-09-18 14:45:13 +02:00
parent 7c34145ed7
commit bec5ad55dd
2 changed files with 2 additions and 5 deletions

View File

@@ -70,7 +70,6 @@ module Spree
scope :credit, -> { where('amount < 0') }
scope :return_authorization, -> { where(originator_type: "Spree::ReturnAuthorization") }
scope :voucher, -> { where(originator_type: "Voucher") }
scope :voucher_tax, -> { where(originator_type: "Voucher").where("label LIKE 'Tax%'") }
scope :non_voucher, -> { where.not(originator_type: "Voucher") }
scope :inclusive, -> { where(included: true) }
scope :additional, -> { where(included: false) }

View File

@@ -159,10 +159,8 @@ module Reporting
end
def voucher_tax_adjustment(order)
included_tax_voucher_adjustment = order.voucher_adjustments.first&.included_tax || 0
excluded_tax_voucher_adjustment = order.all_adjustments.voucher_tax.first&.amount || 0
included_tax_voucher_adjustment + excluded_tax_voucher_adjustment
VoucherAdjustmentsService.new(order).voucher_included_tax +
VoucherAdjustmentsService.new(order).voucher_excluded_tax
end
def first_name(query_result_row)