Sha256: cdd735b19eb8657c1a90ad5d25d74755e7ca92a686bd63f04d3f7acd8a8f4b00
Contents?: true
Size: 841 Bytes
Versions: 18
Compression:
Stored size: 841 Bytes
Contents
module Unidom::Order::Concerns::AsAdjusted extend ActiveSupport::Concern included do |includer| has_many :adjustments, class_name: 'Unidom::Order::OrderAdjustment', as: :adjusted def is_adjusted!(amount, due_to: 'FRGT', at: Time.now) query = adjustments.adjustment_factor_coded_as(due_to).valid_at(now: at).alive adjustment = query.first if adjustment.present? if 0==amount adjustment.soft_destroy else adjustment.amount = amount adjustment.save! end else adjustment = query.create! amount: amount, opened_at: at end adjustment end def is_adjusted?(due_to: 'FRGT', at: Time.now) adjustments.adjustment_factor_coded_as(due_to).valid_at(now: at).alive.exists? end end module ClassMethods end end
Version data entries
18 entries across 18 versions & 1 rubygems