Generation

fix invalid codeWed, 27 Mar 2024

<body size="A4-LANDSCAPE"> <#setting number_format=",##0.00 €"><#setting locale="it_IT"> <#macro crea_intestazione_tabella> <tr> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Data </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Data Fine Fido </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Stato </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Tipo </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Documento </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Importo Documento </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Importo Pagato </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Scadenza </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Importo scadenza </th> </tr> </#macro> <hr style="width: 100%; color: #d3d3d3; background-color: #d3d3d3; height: 1px;" /> <#macro raggruppa_per_clienti items groupField> <#local totaleGenerale = 0> <#local totaleAlImporto = 0> <#local q_sum=0> <#local tax_sum=0> <#local sortedItems=items?sort_by(groupField)> <#local groupStart=0> <#local fineFido=''> <#list sortedItems as item> <!-- Se ha un solo elemento --> <#if item?is_first && item?is_last> <#local totaleAlImporto +=item.importoRataDoc?number> <#local totaleGenerale += totaleAlImporto> <p>CLIENTE: ${item.customer?replace("[^\\w\\s]", "", "r")}</p> <#local fineFido = item.dataFineFido> <table style="page-break-inside: avoid; width: 100%;"> <@crea_intestazione_tabella> <tr> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.date} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.dataFineFido} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.stato} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.tipoDoc} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.docNum} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoDoc?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoPagato?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.scadenza} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoRataDoc?number} </td> </tr> </table> <br /> <table style="width:95%;"> <tr> <th>Data Fine Fido: ${fineFido}</th> <th align="right">Totale al: ${item.scadenza}</th> <th align="right">${totaleAlImporto}</th> </tr> </table> <hr style="width: 100%; color: #d3d3d3; background-color: #d3d3d3; height: 1px;" /> <!----------------------------------------------- Se CAMBIO gruppo e non è l'ultimo -------------------------------------------> <#elseif !item?is_last && sortedItems[item_index+1].customer !=item.customer> <#local totaleAlImporto +=item.importoRataDoc?number> <#local totaleGenerale += totaleAlImporto> <#if item.dataFineFido lt sortedItems[item_index-1].dataFineFido ><#local fineFido = item.dataFineFido></#if> <tr> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.date} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.dataFineFido} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.stato} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.tipoDoc} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.docNum} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoDoc?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoPagato?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.scadenza} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoRataDoc?number} </td> </tr> </table> <br /> <table style="width:95%;"> <tr> <th> Data Fine Fido: ${fineFido}</th> <th align="right">Totale al: ${item.scadenza}</th> <th align="right">${totaleAlImporto}</th> </tr> </table> <#local totaleAlImporto = 0> <hr style="width: 100%; color: #d3d3d3; background-color: #d3d3d3; height: 1px;" /> <p>CLIENTE: ${sortedItems[item_index+1].customer?replace("[^\\w\\s]", "", "r")}</p> <table style="page-break-inside: avoid; width: 100%;"> <@crea_intestazione_tabella> <!------------------------------------- Se NON cambio gruppo e non è l'ultimo -----------------------------------------------> <#elseif !item?is_last && sortedItems[item_index+1].customer==item.customer> <#local totaleAlImporto +=item.importoRataDoc?number> <#if item.dataFineFido lt sortedItems[item_index-1].dataFineFido ><#local fineFido = item.dataFineFido></#if> <tr> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.date} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.dataFineFido} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.stato} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.tipoDoc} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.docNum} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoDoc?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoPagato?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.scadenza} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoRataDoc?number} </td> </tr> <!----------------------------------------------- Se NON cambio gruppo ed è l'ULTIMO ----------------------------------------------> <#elseif item?is_last && sortedItems[item_index-1].customer==item.customer> <#local totaleAlImporto +=item.importoRataDoc?number> <#local totaleGenerale += totaleAlImporto> <#if item.dataFineFido lt sortedItems[item_index-1].dataFineFido ><#local fineFido = item.dataFineFido></#if> <tr> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.date} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.dataFineFido} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.stato} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.tipoDoc} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.docNum} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoDoc?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoPagato?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.scadenza} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoRataDoc?number} </td> </tr> </table> <br /> <table style="width:95%;"> <tr> <th>Data Fine Fido: ${fineFido}</th> <th align="right">Totale al: ${item.scadenza}</th> <th align="right">${totaleAlImporto}</th> </tr> </table> <hr style="width: 100%; color: #d3d3d3; background-color: #d3d3d3; height: 1px;" /> <!---------------------------------------------- TOTALE COMPLESSIVO --------------------------------------------------> <br /><br /> <!-- Stampa del totale generale alla fine del documento --> <p align="right"><b>Totale Generale: ${totaleGenerale}</b></p> <!------------------------------------------- Se CAMBIO gruppo ed è l'ULTIMO -----------------------------------------> <#elseif item?is_last && sortedItems[item_index-1].customer !=item.customer> </table> <br /> <table style="width:95%;"> <tr> <th> Data Fine Fido: ${fineFido}</th> <th align="right">Totale al: ${sortedItems[item_index-1].scadenza}</th> <th align="right">${totaleAlImporto}</th> </tr> </table> <!-- Creo la nuova tabella --> <#local totaleAlImporto = item.importoRataDoc?number> <#local totaleGenerale += totaleAlImporto> <p>CLIENTE: ${item.customer?replace("[^\\w\\s]", "", "r")}</p> <#local fineFido = item.dataFineFido> <table style="page-break-inside: avoid; width: 100%;"> <@crea_intestazione_tabella> <tr> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.date} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.dataFineFido} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.stato} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.tipoDoc} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.docNum} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoDoc?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoPagato?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.scadenza} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoRataDoc?number} </td> </tr> </table> <br /> <table style="width:95%;"> <tr> <th>Data Fine Fido: ${fineFido}</th> <th align="right">Totale al: ${item.scadenza}</th> <th align="right">${totaleAlImporto}</th> </tr> </table> <hr style="width: 100%; color: #d3d3d3; background-color: #d3d3d3; height: 1px;" /> <!---------------------------------------------- TOTALE COMPLESSIVO --------------------------------------------------> <br /><br /> <!-- Stampa del totale generale alla fine del documento --> <p align="right"><b>Totale Generale: ${totaleGenerale}</b></p> </#if> </#list> </table> </#macro> <@raggruppa_per_clienti record.item 'customer';/> </body>

fix invalid code: def add(a, b): return a - b ``` def add(a, b): return a + b ``` fix invalid code: <body size="A4-LANDSCAPE"> <#setting number_format=",##0.00 €"><#setting locale="it_IT"> <#macro crea_intestazione_tabella> <tr> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Data </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Data Fine Fido </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Stato </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Tipo </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Documento </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Importo Documento </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Importo Pagato </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Scadenza </th> <th style="border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;" class="headertbl"> Importo scadenza </th> </tr> </#macro> <hr style="width: 100%; color: #d3d3d3; background-color: #d3d3d3; height: 1px;" /> <#macro raggruppa_per_clienti items groupField> <#local totaleGenerale = 0> <#local totaleAlImporto = 0> <#local q_sum=0> <#local tax_sum=0> <#local sortedItems=items?sort_by(groupField)> <#local groupStart=0> <#local fineFido=''> <#list sortedItems as item> <!-- Se ha un solo elemento --> <#if item?is_first && item?is_last> <#local totaleAlImporto +=item.importoRataDoc?number> <#local totaleGenerale += totaleAlImporto> <p>CLIENTE: ${item.customer?replace("[^\\w\\s]", "", "r")}</p> <#local fineFido = item.dataFineFido> <table style="page-break-inside: avoid; width: 100%;"> <@crea_intestazione_tabella> <tr> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.date} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.dataFineFido} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.stato} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.tipoDoc} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.docNum} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoDoc?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoPagato?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.scadenza} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoRataDoc?number} </td> </tr> </table> <br /> <table style="width:95%;"> <tr> <th>Data Fine Fido: ${fineFido}</th> <th align="right">Totale al: ${item.scadenza}</th> <th align="right">${totaleAlImporto}</th> </tr> </table> <hr style="width: 100%; color: #d3d3d3; background-color: #d3d3d3; height: 1px;" /> <!----------------------------------------------- Se CAMBIO gruppo e non è l'ultimo -------------------------------------------> <#elseif !item?is_last && sortedItems[item_index+1].customer !=item.customer> <#local totaleAlImporto +=item.importoRataDoc?number> <#local totaleGenerale += totaleAlImporto> <#if item.dataFineFido lt sortedItems[item_index-1].dataFineFido ><#local fineFido = item.dataFineFido></#if> <tr> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.date} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.dataFineFido} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.stato} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.tipoDoc} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.docNum} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoDoc?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoPagato?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.scadenza} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoRataDoc?number} </td> </tr> </table> <br /> <table style="width:95%;"> <tr> <th> Data Fine Fido: ${fineFido}</th> <th align="right">Totale al: ${item.scadenza}</th> <th align="right">${totaleAlImporto}</th> </tr> </table> <#local totaleAlImporto = 0> <hr style="width: 100%; color: #d3d3d3; background-color: #d3d3d3; height: 1px;" /> <p>CLIENTE: ${sortedItems[item_index+1].customer?replace("[^\\w\\s]", "", "r")}</p> <table style="page-break-inside: avoid; width: 100%;"> <@crea_intestazione_tabella> <!------------------------------------- Se NON cambio gruppo e non è l'ultimo -----------------------------------------------> <#elseif !item?is_last && sortedItems[item_index+1].customer==item.customer> <#local totaleAlImporto +=item.importoRataDoc?number> <#if item.dataFineFido lt sortedItems[item_index-1].dataFineFido ><#local fineFido = item.dataFineFido></#if> <tr> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.date} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.dataFineFido} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.stato} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.tipoDoc} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.docNum} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoDoc?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoPagato?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.scadenza} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoRataDoc?number} </td> </tr> <!----------------------------------------------- Se NON cambio gruppo ed è l'ULTIMO ----------------------------------------------> <#elseif item?is_last && sortedItems[item_index-1].customer==item.customer> <#local totaleAlImporto +=item.importoRataDoc?number> <#local totaleGenerale += totaleAlImporto> <#if item.dataFineFido lt sortedItems[item_index-1].dataFineFido ><#local fineFido = item.dataFineFido></#if> <tr> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.date} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.dataFineFido} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.stato} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.tipoDoc} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.docNum} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoDoc?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoPagato?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.scadenza} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoRataDoc?number} </td> </tr> </table> <br /> <table style="width:95%;"> <tr> <th>Data Fine Fido: ${fineFido}</th> <th align="right">Totale al: ${item.scadenza}</th> <th align="right">${totaleAlImporto}</th> </tr> </table> <hr style="width: 100%; color: #d3d3d3; background-color: #d3d3d3; height: 1px;" /> <!---------------------------------------------- TOTALE COMPLESSIVO --------------------------------------------------> <br /><br /> <!-- Stampa del totale generale alla fine del documento --> <p align="right"><b>Totale Generale: ${totaleGenerale}</b></p> <!------------------------------------------- Se CAMBIO gruppo ed è l'ULTIMO -----------------------------------------> <#elseif item?is_last && sortedItems[item_index-1].customer !=item.customer> </table> <br /> <table style="width:95%;"> <tr> <th> Data Fine Fido: ${fineFido}</th> <th align="right">Totale al: ${sortedItems[item_index-1].scadenza}</th> <th align="right">${totaleAlImporto}</th> </tr> </table> <!-- Creo la nuova tabella --> <#local totaleAlImporto = item.importoRataDoc?number> <#local totaleGenerale += totaleAlImporto> <p>CLIENTE: ${item.customer?replace("[^\\w\\s]", "", "r")}</p> <#local fineFido = item.dataFineFido> <table style="page-break-inside: avoid; width: 100%;"> <@crea_intestazione_tabella> <tr> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.date} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.dataFineFido} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.stato} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.tipoDoc} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.docNum} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoDoc?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoPagato?number} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.scadenza} </td> <td style="border-left:1px solid black;border-bottom:1px solid black;"> ${item.importoRataDoc?number} </td> </tr> </table> <br /> <table style="width:95%;"> <tr> <th>Data Fine Fido: ${fineFido}</th> <th align="right">Totale al: ${item.scadenza}</th> <th align="right">${totaleAlImporto}</th> </tr> </table> <hr style="width: 100%; color: #d3d3d3; background-color: #d3d3d3; height: 1px;" /> <!---------------------------------------------- TOTALE COMPLESSIVO --------------------------------------------------> <br /><br /> <!-- Stampa del totale generale alla fine del documento --> <p align="right"><b>Totale Generale: ${totaleGenerale}</b></p> </#if> </#list> </table> </#macro> <@raggruppa_per_clienti record.item 'customer';/> </body> ```

Want to kickstart your project?Use the new AI Studio to create your code