<commit_before>- if @production and @production.budgets.any?
  :ruby
        balance = 0
        equipment_balance = 0
        worker_balance = 0
        preparation_balance = 0
        other_balance = 0
        divider = 1.0
        currency = Preference[:currency]
        title_legend_complement = ''
        # get working indicator and unit (ex: net_surface_area and hectare)
        production_working_indicator = @production.working_indicator
        production_working_unit = @production.working_unit
        production_working_unit_nomen = Nomen::Units[production_working_unit.to_sym] if production_working_unit

        if production_working_unit
          title_legend_complement = " (#{currency}/#{production_working_unit_nomen.human_name})"
        end

        if production_working_indicator and production_working_indicator.to_sym == :net_surface_area
          divider = @production.net_surface_area.to_d(@production.working_unit.to_sym)
        end


        data_series = []
        data_worker = []
        data_equipment = []
        data_preparation = []
        data_indirect_charges = []
        series = []
        if @production.revenues
          for revenue in @production.revenues
            value = revenue.items.sum(:global_amount)
            data_series << { name: revenue.variant.name, y: (value/divider).to_s.to_f, color: "#000077"}
            balance += value
          end
        end

        if @production.expenses
          for expense in @production.expenses
            value = expense.items.sum(:global_amount)
            variant_variety = Nomen::Varieties.find(expense.variant.variety)
            if variant_variety <= :worker
              worker_balance += value
            elsif variant_variety <= :equipment
              equipment_balance += value
            elsif variant_variety <= :preparation
              preparation_balance += value
            else
              other_balance += value
            end
            balance += value
          end
          # add balance
          data_worker << worker_balance.to_f
          data_equipment << equipment_balance.to_f
          data_preparation << preparation_balance.to_f
          data_indirect_charges << (-1 * @production.indirect_budget_items_value.to_f)
          # add balance per working_unit if exist
          if divider and divider != 0
            data_worker << (worker_balance.to_f/ divider.to_f).round(2).to_s.to_f
            data_equipment << (equipment_balance.to_f / divider.to_f).round(2).to_s.to_f
            data_preparation << (preparation_balance.to_f / divider.to_f).round(2).to_s.to_f
            data_indirect_charges << (-1 * (@production.indirect_budget_items_value.to_f / divider.to_f)).round(2).to_s.to_f
          end
        end

        series << { name: :worker.tl, data: data_worker}
        series << { name: :equipment.tl, data: data_equipment}
        series << { name: :preparation.tl, data: data_preparation}
        series << { name: :indirect_charges.tl, data: data_indirect_charges}
        #
        direct_charges_by_working_unit = (balance.to_f/ divider.to_f).round(2).to_s.to_f rescue 0.0
        indirect_charges_by_working_unit = (-1 * (@production.indirect_budget_items_value.to_f / divider.to_f)).round(2).to_s.to_f rescue 0.0
        global_charges_by_working_unit = direct_charges_by_working_unit + indirect_charges_by_working_unit

  -#= column_chart(series, y_axis: {title: {text: :duration.tl}, stack_labels: {enabled: true, format: "{total}"}, labels: { format: "{value}" }}, x_axis: { categories: ['a','b']}, legend: true, plot_options: { column: {stacking: 'normal'}})
  .med-info.important
    %span.title= :direct_charges.tl + title_legend_complement
    %span.value= link_to(direct_charges_by_working_unit.to_s, {controller: "/backend/productions" ,action: :show, id: @production.id})
    %span.title= :indirect_charges.tl + title_legend_complement
    %span.value= indirect_charges_by_working_unit

- else
  = no_data<commit_msg>Work in progress on commercialization cell<commit_after>- if @production and @production.budgets.any?
  :ruby
        balance = 0
        equipment_balance = 0
        worker_balance = 0
        preparation_balance = 0
        other_balance = 0
        divider = 1.0
        currency = Preference[:currency]
        title_legend_complement = ''
        # get working indicator and unit (ex: net_surface_area and hectare)
        production_working_indicator = @production.working_indicator
        production_working_unit = @production.working_unit
        production_working_unit_nomen = Nomen::Units[production_working_unit.to_sym] if production_working_unit

        if production_working_unit
          title_legend_complement = " (#{currency}/#{production_working_unit_nomen.human_name})"
        end

        if production_working_indicator and production_working_indicator.to_sym == :net_surface_area
          divider = @production.net_surface_area.to_d(@production.working_unit.to_sym)
        end


        data_series = []
        data_worker = []
        data_equipment = []
        data_preparation = []
        data_indirect_charges = []
        series = []
        if @production.revenues
          for revenue in @production.revenues
            value = revenue.items.sum(:global_amount)
            data_series << { name: revenue.variant.name, y: (value/divider).to_s.to_f, color: "#000077"}
            balance += value
          end
        end

        if @production.expenses
          for expense in @production.expenses
            value = expense.items.sum(:global_amount)
            variant_variety = Nomen::Varieties.find(expense.variant.variety)
            if variant_variety <= :worker
              worker_balance += value
            elsif variant_variety <= :equipment
              equipment_balance += value
            elsif variant_variety <= :preparation
              preparation_balance += value
            else
              other_balance += value
            end
            balance += value
          end
          # add balance
          data_worker << worker_balance.to_f
          data_equipment << equipment_balance.to_f
          data_preparation << preparation_balance.to_f
          data_indirect_charges << (-1 * @production.indirect_budget_items_value.to_f)
          # add balance per working_unit if exist
          if divider and divider != 0
            data_worker << (worker_balance.to_f/ divider.to_f).round(2).to_s.to_f
            data_equipment << (equipment_balance.to_f / divider.to_f).round(2).to_s.to_f
            data_preparation << (preparation_balance.to_f / divider.to_f).round(2).to_s.to_f
            data_indirect_charges << (-1 * (@production.indirect_budget_items_value.to_f / divider.to_f)).round(2).to_s.to_f
          end
        end

        series << { name: :worker.tl, data: data_worker}
        series << { name: :equipment.tl, data: data_equipment}
        series << { name: :preparation.tl, data: data_preparation}
        series << { name: :indirect_charges.tl, data: data_indirect_charges}
        # 
        direct_charges_by_working_unit = (balance.to_f/ divider.to_f).round(2).to_s.to_f rescue 0.0
        indirect_charges_by_working_unit = (-1 * (@production.indirect_budget_items_value.to_f / divider.to_f)).round(2).to_s.to_f rescue 0.0
        global_charges_by_working_unit = direct_charges_by_working_unit + indirect_charges_by_working_unit
        # équation
        # y : prix d'objectif en [€/ton]
        # a : quantité de budget_item du salaire de l'exploitant [mois]
        a = 12
        # x : salaire mensuel de l'exploitant [€] proratisé à l'unité d'oeuvre et distribué entre activités
        # TODO
        x = 0
        # b : pourcentage de variation du rendement [%]
        b = 1.0
        # z : rendement de la prodution (budget_item, sens: revenus et varieties: grain)
        variants = ProductNatureVariant.derivative_of(@production.variant.variety)
        z = @production.revenues.where(variant_id: variants.pluck(:id)).items.average(:quantity)
        # c : charges globales [global_charges_by_working_unit]
        c = global_charges_by_working_unit
        # y [€/ton] = (ax + c [€/Ha]) / bz[qt/Ha] * 10
        y = ((a * x + c) / (b * z)) * 10

  -#= column_chart(series, y_axis: {title: {text: :duration.tl}, stack_labels: {enabled: true, format: "{total}"}, labels: { format: "{value}" }}, x_axis: { categories: ['a','b']}, legend: true, plot_options: { column: {stacking: 'normal'}})
  .med-info.important
    %span.title= :direct_charges.tl + title_legend_complement
    %span.value= link_to(direct_charges_by_working_unit.to_s, {controller: "/backend/productions" ,action: :show, id: @production.id})
    %span.title= :indirect_charges.tl + title_legend_complement
    %span.value= indirect_charges_by_working_unit

- else
  = no_data
{'fraction_non_alphanumeric': 0.10038348748026167, 'fraction_numerical': 0.007105797428378074, 'mean_word_length': 2.6640495867768594, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3440711', 'n_tokens_mistral': 2799, 'n_tokens_neox': 2716, 'n_words': 522}