
{{~#*inline "format-money"~}}
{{money-amount money}} {{money.currency}}
{{~/inline~}}

{{~#*inline "format-date"~}}
{{date date format="MMM d, YYYY"}}
{{~/inline~}}

<html>
  <body>
    {{#with transaction}}
    <h1>You have been paid {{> format-money money=payout-total}}</h1>

    <p>We have sent you {{> format-money money=payout-total}} for the booking of {{listing.title}} from {{> format-date date=booking.start}} to {{> format-date date=booking.end}} by {{customer.display-name}}. It might take up to 7 days for the money to reach your bank account.</p>

    <p>Here's the breakdown.</p>

    <table>
      <thead>
        <tr>
          <th style="text-align: left;">Payment</th>
        </tr>
      </thead>
      <tbody>
      {{#each line-items}}
        {{#contains include-for "provider"}}
          <tr>
            {{#eq "day" code}}
            <td>{{> format-money money=unit-price}} &times; {{number quantity}} {{inflect quantity "day" "days"}}</td>
            <td style="text-align: right; padding-left: 20px">{{> format-money money=line-total}}</td>
            {{/eq}}

            {{#eq "night" code}}
            <td>{{> format-money money=unit-price}} &times; {{number quantity}} {{inflect quantity "night" "nights"}}</td>
            <td style="text-align: right; padding-left: 20px">{{> format-money money=line-total}}</td>
            {{/eq}}

            {{#eq "provider-commission" code}}
            <td>{{marketplace.name}} fee:</td>
            <td style="text-align: right; padding-left: 20px;">{{> format-money money=line-total}}</td>
            {{/eq}}
          </tr>
        {{/contains}}
      {{/each}}
      </tbody>
      <tfoot>
        <tr>
          <th style="text-align: left;">You earn</th>
          <th style="text-align: right; padding-left: 20px;">{{> format-money money=payout-total}}</th>
        </tr>
      </tfoot>
    </table>

    {{/with}}
  </body>
</html>