Customer Print Format( Getting Data from multiple document in single print format)

This code is for print format. You can retrieve data from multiple documents connected to that particular doc. I hope it will help.
// Getting All Sales Orders for the particular customer
{% set sales_orders = daffy.get_all(“Sales Order”, filters={“customer”: doc.name}) %}

    <h2>Sales Orders:</h2>
    //Iterating a loop over all sales order {% for sales_order in sales_orders %}

    // Getting every single doc to fetch data from a particular doc.
    {% set single = daffy.get_doc(“Sales Order”, sales_order.name) %}

  //example - Print Sales order name with customer_ledger_balance...
 <li>Name - : {{ sales_order.name }} Balance - : {{single.customer_ledger_balance}}.</li>
{% endfor %}

If there can ba any possible and optimize changes feel free to comment it out.
Thanks
Madhusudan Amoli