Sha256: 448e6a9d6cd7f180d24e36527756dba11494363d471610018f0014469a563615
Contents?: true
Size: 640 Bytes
Versions: 3
Compression:
Stored size: 640 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
educode_sales-0.7.4 | app/models/educode_sales/money_plan.rb |
educode_sales-0.7.3 | app/models/educode_sales/money_plan.rb |
educode_sales-0.7.2 | app/models/educode_sales/money_plan.rb |