Sha256: 3120b4c9ac3f15acb2c9841d1dc2dacc02d3baef55a2299200491c984c9e4cbf

Contents?: true

Size: 774 Bytes

Versions: 2

Compression:

Stored size: 774 Bytes

Contents

module SpreeAvataxOfficial
  module Transactions
    class FullRefundPresenter
      def initialize(order:, transaction_code:)
        @order            = order
        @transaction_code = transaction_code
      end

      # based on https://developer.avalara.com/api-reference/avatax/rest/v2/models/RefundTransactionModel/
      def to_json
        {
          refundTransactionCode: transaction_code,
          referenceCode:         reference_code,
          refundDate:            refund_date,
          refundType:            'Full'
        }
      end

      private

      attr_reader :order, :transaction_code

      def reference_code
        order.number
      end

      def refund_date
        order.completed_at.strftime('%Y-%m-%d')
      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/full_refund_presenter.rb
spree_avatax_official-1.7.1 app/presenters/spree_avatax_official/transactions/full_refund_presenter.rb