Sha256: 66549bca565f61ade25fdba55b808283d4e70c65f5f0d41c18bef08a81a5846d
Contents?: true
Size: 850 Bytes
Versions: 1
Compression:
Stored size: 850 Bytes
Contents
# see RailsBooking::PlanAttender module Trade module Model::PlanAttender extend ActiveSupport::Concern included do has_many :card_payments has_many :card_returns, as: :consumable after_save_commit :sync_card_expense, if: -> { saved_change_to_attended? && attended? } after_commit :sync_card_return, if: -> { saved_change_to_attended? && !attended? } end def sync_card_expense return unless self.attender.cards.present? card_id = self.attender.card_ids.first log = self.card_expenses.build(card_id: card_id) log.amount = plan_item.planned.price log.save log end def sync_card_return self.card_expenses.map do |card_expense| log = self.card_returns.build(card_expense_id: card_expense.id) log.save log end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_trade-0.0.3 | app/models/trade/model/plan_attender.rb |