diff --git a/src/main/resources/templates/modules/fooddistribution/fooddistributiondetailedreport.html b/src/main/resources/templates/modules/fooddistribution/fooddistributiondetailedreport.html index 5e31070..f4d95a1 100644 --- a/src/main/resources/templates/modules/fooddistribution/fooddistributiondetailedreport.html +++ b/src/main/resources/templates/modules/fooddistribution/fooddistributiondetailedreport.html @@ -381,6 +381,8 @@ doc.content[1].table.dontBreakRows = true; var rowCount = doc.content[1].table.body.length; + var totalPenalty = 0; + for (var i = 1; i < rowCount; i++) { var evidenceCell = doc.content[1].table.body[i][4]; var urlText = typeof evidenceCell === 'object' ? evidenceCell.text : evidenceCell; @@ -394,7 +396,22 @@ decoration: 'underline' }; } + + var penaltyCell = doc.content[1].table.body[i][5]; + var penaltyText = typeof penaltyCell === 'object' ? penaltyCell.text : penaltyCell; + if (penaltyText && penaltyText !== '-' && penaltyText !== 'Pending') { + var amount = parseInt(penaltyText.replace(/[^0-9]/g, '')); + if (!isNaN(amount)) { + totalPenalty += amount; + } + } } + + doc.content[1].table.body.push([ + { text: 'Total Penalty Amount', colSpan: 5, alignment: 'right', bold: true }, + {}, {}, {}, {}, + { text: 'Rs. ' + totalPenalty, bold: true } + ]); } }, {