Sha256: bf1f739c9ab7e87e34b0370310cce1a90f139a2da39809a2a511c837c382def9
Contents?: true
Size: 628 Bytes
Versions: 57
Compression:
Stored size: 628 Bytes
Contents
module EducodeSales class MoneyPlan < ApplicationRecord belongs_to :staff belongs_to :follow_up, counter_cache: true enum clazz: ['未完成', '已完成'] after_save :update_return_money after_destroy :update_return_money private def update_return_money if follow_up.business.last_follow_up_id == self.follow_up_id follow_up.business.update(return_money: MoneyPlan.where(clazz: '已完成', follow_up_id: self.follow_up_id).sum(:amount)) else follow_up.update(return_money: follow_up.money_plans.where(clazz: '已完成').sum(:amount)) end end end end
Version data entries
57 entries across 57 versions & 1 rubygems