{% set net_refunds = 0 %}
                            {% set total_payments = 0%}
                            {% for invoice in invoices %}
                            {% if invoice.payments|e %}
                            {% set parent_payment = invoice.payments|first %}
                            {% for payment in invoice.payments %}
                            {% set currency_code = payment.currency %}
                            {% for pivot in payment.paymentables %}
                            
                                | {{ pivot.invoice }} | {{ pivot.created_at }} | {%if pivot.is_credit %} | $credit_label {{ pivot.number }}{%else%} | {{ payment.method }}{%endif%} | {{ pivot.amount }} | 
                            {% if pivot.refunded_raw > 0 %}
                            
                                | {{ pivot.invoice }} | {{ pivot.updated_at }} |  | $refund_label | ({{ pivot.refunded }}) | 
                            {% set net_refunds = net_refunds + pivot.refunded_raw %}
                            {% endif %}
                            {% set total_payments = total_payments + pivot.amount_raw %}
                            {% endfor %}
                            {% endfor %}
                            {% endif %}
                            {% endfor %}
                            
                                | {{ currency_code }} |  |  | $payments_label | {{ total_payments|format_currency(currency_code) }} | 
                            {% if net_refunds > 0 %}
                            
                                |  |  |  | $refunded_label | ({{ net_refunds|format_currency(currency_code) }}) | 
                            
                                |  |  |  | $net_label | {{ (total_payments-net_refunds)|format_currency(currency_code) }} | 
                            {% endif %}