Sha256: e60df84d1dc983b4565c0dcb99e40bdc02e7874145d13668a1ee5c087029d336

Contents?: true

Size: 965 Bytes

Versions: 2

Compression:

Stored size: 965 Bytes

Contents

module SpreeAvataxOfficial
  module Transactions
    class AdjustPresenter
      def initialize(order:, adjustment_reason:, adjustment_description:)
        @order                  = order
        @adjustment_reason      = adjustment_reason
        @adjustment_description = adjustment_description
      end

      # Based on: https://developer.avalara.com/api-reference/avatax/rest/v2/models/AdjustTransactionModel/
      def to_json
        {
          adjustmentReason:      adjustment_reason,
          adjustmentDescription: adjustment_description,
          newTransaction:        transaction_payload
        }
      end

      private

      attr_reader :order, :adjustment_reason, :adjustment_description

      def transaction_payload
        SpreeAvataxOfficial::Transactions::CreatePresenter.new(
          order:            order,
          transaction_type: SpreeAvataxOfficial::Transaction::SALES_INVOICE
        ).to_json
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_avatax_official-1.8.0 app/presenters/spree_avatax_official/transactions/adjust_presenter.rb
spree_avatax_official-1.7.1 app/presenters/spree_avatax_official/transactions/adjust_presenter.rb