Sha256: 59f76b3db8f41f9667cbfd03c85b63f4021a54b635886230e9ae627c54d9c89a

Contents?: true

Size: 1.97 KB

Versions: 82

Compression:

Stored size: 1.97 KB

Contents

json.data do
  json.array! @sale_plans do |d|
    json.id d.id
    json.staff d.staff.user.real_name
    json.staff_id d.staff_id
    json.clazz EducodeSales::SalePlan::CLAZZ_NAME.invert[d.clazz]
    json.year d.year
    json.clazz_id d.clazz
    json.target_money d['annual'] || 0
    # json.plan_money  d['budget_amounts']&.round(2) || 0
    json.minimum_money d['annual'].present? ?  (d['annual'].to_f * 0.8).round(2) : 0
    
    # if d.clazz == 1
    #   # 签单计划的预算额
    #   json.finish_money d.business_infos.where.not(plan_sign_on: nil).sum(:budget_amount)
    # elsif d.clazz == 18
    #   # 中标目标
    #   json.finish_money d.business_infos.where.not(plan_bid_on: nil).sum(:budget_amount)
    # elsif d.clazz == 2
    #   # 回款目标
    #   json.finish_money d.business_infos.where.not(plan_bid_on: nil).sum(:budget_amount)
    # elsif d.clazz == 7
    #   # 商机目标
    #   json.finish_money d.business_infos.sum(:budget_amount)
    # end
    if d.clazz == 1
      # 签单计划的预算额
      json.plan_money d['clazz_1'] || 0
      json.finish_money d['finish_sign']
      json.finish_rate (d['finish_sign']  * 100 / (d['clazz_1'] || 0).to_f).round(2)
    elsif d.clazz == 18
      # 中标目标
      json.plan_money d['clazz_18'] || 0
      json.finish_money d['finish_bid']
      json.finish_rate (d['finish_bid']  * 100 / (d['clazz_18'] || 0).to_f).round(2)
    elsif d.clazz == 2
      # 回款目标
      json.plan_money d['clazz_2'] || 0
      json.finish_money d['finish_return_money']
      json.finish_rate (d['finish_return_money']  * 100 / (d['clazz_2'] || 0).to_f).round(2)
    elsif d.clazz == 7
      # 商机目标
      json.plan_money d['clazz_7'] || 0
      json.finish_money d['clazz_7'] || 0
      json.finish_rate 100
    end
    
    json.updated_at d.updated_at.to_s
    json.clazz_1 d['clazz_1']
    json.clazz_2 d['clazz_2']
    json.clazz_7 d['clazz_7']
    json.clazz_18 d['clazz_18']
  end
end

json.code 0
json.count @sale_plans.total_count

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
educode_sales-1.10.74 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.73 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.72 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.71 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.70 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.59 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.58 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.49 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.48 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.46 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.41 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.37 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.36 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.35 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.34 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.33 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.31 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.30 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.29 app/views/educode_sales/plans/years_plan.json.jbuilder
educode_sales-1.10.28 app/views/educode_sales/plans/years_plan.json.jbuilder