<?xml version="1.0"?>
<document filename="test.pdf">
  <template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
    <pageTemplate id="first">
      <frame id="first" x1="35.0" y1="57.0" width="525" height="728"/>
    </pageTemplate>
  </template>
  <stylesheet>
    <blockTableStyle id="Standard_Outline">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
    </blockTableStyle>
    <blockTableStyle id="Table5">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
      <blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
      <blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
    </blockTableStyle>
    <blockTableStyle id="Table8">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="GRID" colorName="black"/>
      <blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
      <blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
      <blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
      <blockBackground colorName="#e6e6e6" start="3,0" stop="3,0"/>
      <blockBackground colorName="#e6e6e6" start="4,0" stop="4,0"/>
      <blockBackground colorName="#e6e6e6" start="5,0" stop="5,0"/>
      <blockBackground colorName="#e6e6e6" start="6,0" stop="6,0"/>
    </blockTableStyle>
    <blockTableStyle id="Table4">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
    </blockTableStyle>
    <blockTableStyle id="Table1">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
    </blockTableStyle>
    <blockTableStyle id="Table6">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
    </blockTableStyle>
    <blockTableStyle id="Table7">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
    </blockTableStyle>
    <initialize>
      <paraStyle name="all" alignment="justify"/>
    </initialize>
    <paraStyle name="P1" fontName="Times-Roman" alignment="LEFT"/>
    <paraStyle name="P2" fontName="Times-Bold" fontSize="20.0" leading="25" alignment="CENTER"/>
    <paraStyle name="P3" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="RIGHT"/>
    <paraStyle name="P4" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT"/>
    <paraStyle name="P5" fontName="Times-Roman" alignment="LEFT"/>
    <paraStyle name="P6" fontName="Times-Roman" alignment="LEFT"/>
    <paraStyle name="P7" fontName="Times-Roman" alignment="RIGHT"/>
    <paraStyle name="P8" fontName="Times-Roman" fontSize="6.0" leading="8"/>
    <paraStyle name="P9" fontName="Helvetica-Bold" fontSize="16.0" leading="20"/>
    <paraStyle name="P10" fontName="Times-Roman" alignment="RIGHT"/>
    <paraStyle name="Standard" fontName="Times-Roman"/>
    <paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
    <paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
    <paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
    <paraStyle name="Table Contents" fontName="Times-Roman"/>
    <paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER"/>
    <paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
    <paraStyle name="Index" fontName="Times-Roman"/>
    <paraStyle name="Preformatted Text" fontName="Courier" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="0.0"/>
    <paraStyle name="Untitled1" fontName="Times-Roman"/>
  </stylesheet>
  <story>
    <blockTable colWidths="175.0,175.0,175.0" repeatRows="1" style="Table5">
      <tr>
        <td>
          <para style="P1">[[ company.name ]]</para>
        </td>
        <td>
          <para style="P2">Invoice rate</para>
          <para style="P2">by user</para>
        </td>
        <td>
          <para style="P3">Period from [[ data['form']['date_from'] ]]</para>
          <para style="P3">to [[ data['form']['date_to'] ]]</para>
          <para style="P4">Currency: [[ company.currency_id.name ]]</para>
        </td>
      </tr>
    </blockTable>
    <para style="P5">
      <font color="white"> </font>
    </para>
    <blockTable colWidths="118.0,59.0,77.0,70.0,65.0,59.0,68.0" style="Table8">
      <tr>
        <td>
          <para style="P6">Employee</para>
        </td>
        <td>
          <para style="P6">
            <font color="white"> </font>
          </para>
        </td>
        <td>
          <para style="P7">Units</para>
        </td>
        <td>
          <para style="P7">Income</para>
        </td>
        <td>
          <para style="P7">Cost</para>
        </td>
        <td>
          <para style="P7">Profit</para>
        </td>
        <td>
          <para style="P7">Eff.</para>
        </td>
      </tr>
    </blockTable>
    <para style="P5">
      <font color="white"> </font>
    </para>
    <section>
      <para style="P8">[[ repeatIn(user_ids(lines(data['form'])), 'e') ]]</para>
      <blockTable colWidths="104.0,421.0" style="Table4">
        <tr>
          <td>
            <para style="P9">[[ e.name ]]</para>
          </td>
        </tr>
        <tr>
          <td>
            <para style="Table Contents">[[ repeatIn(journal_ids(data['form'], e.id), 'j') ]]</para>
            <para style="Untitled1">[[ j.name ]]</para>
          </td>
          <td>
            <blockTable colWidths="71.0,77.0,71.0,64.0,64.0,64.0" style="Table1">
              <tr>
                <td>
                  <para style="P10">
                    <font color="white"> </font>
                  </para>
                </td>
                <td>
                  <para style="P7">[[ reduce(lambda x, y: x+y['unit_amount'], line(data['form'], [j.id], [e.id]), 0)]]</para>
                </td>
                <td>
                  <para style="P7">[[ reduce(lambda x, y: x+y['amount'], line(data['form'], [j.id], [e.id]), 0) ]]</para>
                </td>
                <td>
                  <para style="P7">[[ reduce(lambda x, y: x+y['cost'], line(data['form'], [j.id], [e.id]), 0) ]]</para>
                </td>
                <td>
                  <para style="P7">[[ reduce(lambda x, y: x+y['profit'], line(data['form'], [j.id], [e.id]), 0)]]</para>
                </td>
                <td>
                  <para style="P7">[[ round( reduce(lambda x, y: x+y['eff'], line(data['form'], [j.id], [e.id]), 0)/len(line(data['form'], [j.id], [e.id])) , 2)]] %</para>
                </td>
              </tr>
              <tr>
                <td>
                  <para style="P7">[[ repeatIn(line(data['form'], [j.id], [e.id]), 'l') ]]</para>
                  <para style="P7">[[ l['name'] ]]</para>
                </td>
                <td>
                  <para style="P7">[[ l['unit_amount'] ]]</para>
                </td>
                <td>
                  <para style="P7">[[ l['amount'] ]]</para>
                </td>
                <td>
                  <para style="P7">[[ l['cost'] ]]</para>
                </td>
                <td>
                  <para style="P7">[[ l['profit'] ]]</para>
                </td>
                <td>
                  <para style="P7">[[ l['eff'] ]] %</para>
                </td>
              </tr>
            </blockTable>
          </td>
        </tr>
      </blockTable>
    </section>
        <blockTable colWidths="103.0,422.0" style="Table6">
          <tr>
            <td>
              <para style="P9">Totals</para>
            </td>
            <td>
              <blockTable colWidths="74.0,73.0,72.0,65.0,63.0,64.0" style="Table7">
                <tr>
                  <td>
                    <para style="P7">
                      <font color="white"> </font>
                    </para>
                  </td>
                  <td>
                    <para style="P7">[[ reduce(lambda x, y: x+y['unit_amount'], line(data['form'], data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]]</para>
                  </td>
                  <td>
                    <para style="P7">[[ reduce(lambda x, y: x+y['amount'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]]</para>
                  </td>
                  <td>
                    <para style="P7">[[ reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]]</para>
                  </td>
                  <td>
                    <para style="P7">[[ reduce(lambda x, y: x+y['profit'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]]</para>
                  </td>
                  <td>
                    <para style="P7">[[ round(reduce(lambda x, y: x+y['amount'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0)/reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0)* -100, 2)]] %</para>
                  </td>
                </tr>
              </blockTable>
              <para style="Table Contents">
                <font color="white"> </font>
              </para>
            </td>
          </tr>
        </blockTable>
        <para style="Standard">
          <font color="white"> </font>
        </para>
  </story>
</document>

