<commit_before>
<% if invoice.activity_results %>
  <% invoice.activity_results.flatten.group_by(&:package).map do |package, results| %>
  <a name="<%= (package.name+"-"+invoice.date.strftime('%Y-%m')).underscore%>"></a>
  <h2><%= package.name %> at <%=invoice.date.strftime('%Y-%m')%>  </h2>

  <%= package.linked_org_units(@org_unit, @pyramid).map(&:name).join(" and ") %>

  <table class="table invoice num-span-table table-striped">
    <thead>
      <tr>

      <%package.invoice_details.each do |detail| %>

         <th><%=detail.humanize %> </th>
      <%end%>
    </tr>
    </thead>

    <tbody>
    <% states = State.all.index_by(&:code) %>
    <%results.sort_by{|r| r.activity.id }.each do |result|%>
      <tr>
       <% package.invoice_details.each do |detail|%>
       <% classes = [] %>
       <% classes.push "formula-input" if states[detail] %>
       <% classes.push "formula-output" if result.package.activity_rule.formula(detail)&.formula_mapping(result.activity) %>

       <% hint = states[detail] ? [result.activity.activity_state(states[detail])&.external_reference,result.activity.activity_state(states[detail])&.name] : [
         result.package.activity_rule.formula(detail)&.expression,
         result.package.activity_rule.formula(detail)&.formula_mapping(result.activity)&.external_reference,
         @datacompound.data_element(result.package.activity_rule.formula(detail)&.formula_mapping(result.activity)&.external_reference)&.name
         ] %>
       <td title="<%= hint.join("- \t") %> - <%=result.solution.to_json%> ">
         <span class="<%= 'num-span' if result.solution[detail].is_a? Numeric %> <%= classes.join(" ") %>"><%= d_to_s(result.solution[detail]) %></span>
      </td>


       <% end%>
     </tr>
    <%end%>
   </tbody>
  </table>

<button data-toggle="collapse" data-target="#activity-descriptors-<%= package.id %>">Show activity descriptors</button>
  <div id="activity-descriptors-<%= package.id %>" class="collapse">
  <pre>
    activityDescriptors = [
    <% package.activities.each do |activity| %>
    {
          name: "<%=activity.name %>",
       <% package.states.each do |state|%>
        <%if activity.activity_state(state)&.external_reference.present? %>
          <%= state.code %>: "<%= activity.activity_state(state)&.external_reference%>",
        <%end%>
       <% end%>
       <% package.activity_rule.formulas.each do |formula| %>
        <% if formula.formula_mapping(activity) %>
          <%= formula.code %>: "<%= formula.formula_mapping(activity)&.external_reference%>",
        <%end%>
       <% end%>
    },
    <% end %>
    ]
  </pre>
  </div>
    <% if invoice.package_results %>

    <div class="container">
    <% package.package_rule.formulas.map(&:code).map do |item| %>
      <%package_result = invoice.package_results.find { |pr| pr.package == package }%>
      <%next unless package_result.solution[item]%>
        <div class="row">
           <div class="col-md-3">
             <%=item.humanize %> :
          </div>
             <% classes = [] %>
             <% external_reference = package_result.package.package_rule.formula(item)&.formula_mapping&.external_reference %>
             <% classes.push "formula-output" if external_reference %>
          <div class="col-md-4 <%= classes.join(" ") %>" title="<%= package_result.package.package_rule.formula(item)&.expression %> - <%= external_reference %> - <%= @datacompound.data_element(external_reference)&.name %> - <%=package_result.solution.to_json%>">
            <b><%= d_to_s(package_result.solution[item])%></b>
          </div>
        </div>
    <%end%>
    </div>
    <%end%>
  <%end%>
  <%if invoice.payment_result %>
  <h2>Payments</h2>

    <div class="container">
      <%invoice.payment_result.payment_rule.rule.formulas.map do |formula|%>
        <div class="row">
           <div class="col-md-3">
             <%=formula.code.humanize %> :
          </div>
          <% classes = [] %>
          <% external_reference = formula.formula_mapping&.external_reference %>
          <% classes.push "formula-output" if external_reference %>
          <div class="col-md-4 <%= classes.join(" ") %>" title="<%= formula.expression %> - <%= external_reference %> - <%= @datacompound.data_element(external_reference)&.name %>">
            <b><%= d_to_s( invoice.payment_result.solution[formula.code])%></b>
          </div>
        </div>
      <%end%>
  <%end%>

<%end%>
<commit_msg>packageDescriptors<commit_after>
<% if invoice.activity_results %>
  <% invoice.activity_results.flatten.group_by(&:package).map do |package, results| %>
  <a name="<%= (package.name+"-"+invoice.date.strftime('%Y-%m')).underscore%>"></a>
  <h2><%= package.name %> at <%=invoice.date.strftime('%Y-%m')%>  </h2>

  <%= package.linked_org_units(@org_unit, @pyramid).map(&:name).join(" and ") %>

  <table class="table invoice num-span-table table-striped">
    <thead>
      <tr>

      <%package.invoice_details.each do |detail| %>

         <th><%=detail.humanize %> </th>
      <%end%>
    </tr>
    </thead>

    <tbody>
    <% states = State.all.index_by(&:code) %>
    <%results.sort_by{|r| r.activity.id }.each do |result|%>
      <tr>
       <% package.invoice_details.each do |detail|%>
       <% classes = [] %>
       <% classes.push "formula-input" if states[detail] %>
       <% classes.push "formula-output" if result.package.activity_rule.formula(detail)&.formula_mapping(result.activity) %>

       <% hint = states[detail] ? [result.activity.activity_state(states[detail])&.external_reference,result.activity.activity_state(states[detail])&.name] : [
         result.package.activity_rule.formula(detail)&.expression,
         result.package.activity_rule.formula(detail)&.formula_mapping(result.activity)&.external_reference,
         @datacompound.data_element(result.package.activity_rule.formula(detail)&.formula_mapping(result.activity)&.external_reference)&.name
         ] %>
       <td title="<%= hint.join("- \t") %> - <%=result.solution.to_json%> ">
         <span class="<%= 'num-span' if result.solution[detail].is_a? Numeric %> <%= classes.join(" ") %>"><%= d_to_s(result.solution[detail]) %></span>
      </td>


       <% end%>
     </tr>
    <%end%>
   </tbody>
  </table>

<button class="pull-right btn btn-default" data-toggle="collapse" data-target="#activity-descriptors-<%= package.id %>">Show activity descriptors</button>
  <div id="activity-descriptors-<%= package.id %>" class="collapse">
  <pre>
    activityDescriptors = [
    <% package.activities.each do |activity| %>
    {
          name: "<%=activity.name %>",
       <% package.states.each do |state|%>
        <%if activity.activity_state(state)&.external_reference.present? %>
          <%= state.code %>: "<%= activity.activity_state(state)&.external_reference%>",
        <%end%>
       <% end%>
       <% package.activity_rule.formulas.each do |formula| %>
        <% if formula.formula_mapping(activity) %>
          <%= formula.code %>: "<%= formula.formula_mapping(activity)&.external_reference%>",
        <%end%>
       <% end%>
    },
    <% end %>
    ]

    packageDescriptors = [
    <% package.package_rule.formulas.each do |formula| %>
      <% if formula.formula_mapping %>
        <%= formula.code %>: "<%= formula.formula_mapping&.external_reference%>",
      <%end%>
    <% end %>
    ]

  </pre>
  </div>
    <% if invoice.package_results %>

    <div class="container">
    <% package.package_rule.formulas.map(&:code).map do |item| %>
      <%package_result = invoice.package_results.find { |pr| pr.package == package }%>
      <%next unless package_result.solution[item]%>
        <div class="row">
           <div class="col-md-3">
             <%=item.humanize %> :
          </div>
             <% classes = [] %>
             <% external_reference = package_result.package.package_rule.formula(item)&.formula_mapping&.external_reference %>
             <% classes.push "formula-output" if external_reference %>
          <div class="col-md-4 <%= classes.join(" ") %>" title="<%= package_result.package.package_rule.formula(item)&.expression %> - <%= external_reference %> - <%= @datacompound.data_element(external_reference)&.name %> - <%=package_result.solution.to_json%>">
            <b><%= d_to_s(package_result.solution[item])%></b>
          </div>
        </div>
    <%end%>
    </div>
    <%end%>
  <%end%>
  <%if invoice.payment_result %>
  <h2>Payments</h2>

    <div class="container">
      <%invoice.payment_result.payment_rule.rule.formulas.map do |formula|%>
        <div class="row">
           <div class="col-md-3">
             <%=formula.code.humanize %> :
          </div>
          <% classes = [] %>
          <% external_reference = formula.formula_mapping&.external_reference %>
          <% classes.push "formula-output" if external_reference %>
          <div class="col-md-4 <%= classes.join(" ") %>" title="<%= formula.expression %> - <%= external_reference %> - <%= @datacompound.data_element(external_reference)&.name %>">
            <b><%= d_to_s( invoice.payment_result.solution[formula.code])%></b>
          </div>
        </div>
      <%end%>
  <%end%>

<%end%>

{'fraction_non_alphanumeric': 0.19594152301985598, 'fraction_numerical': 0.0017455814968361336, 'mean_word_length': 3.011816192560175, 'pattern_counts': {'":': 0, '<': 245, '<?xml version=': 0, '>': 245, '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': '5096269', 'n_tokens_mistral': 3235, 'n_tokens_neox': 2890, 'n_words': 411}