svn commit: r1730890 - in /ofbiz/branches/release15.12: ./ applications/accounting/webapp/accounting/payment/PrintChecks.fo.ftl

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1730890 - in /ofbiz/branches/release15.12: ./ applications/accounting/webapp/accounting/payment/PrintChecks.fo.ftl

jleroux@apache.org
Author: jleroux
Date: Wed Feb 17 17:50:39 2016
New Revision: 1730890

URL: http://svn.apache.org/viewvc?rev=1730890&view=rev
Log:
"Applied fix from trunk for revision: 1730889  "
------------------------------------------------------------------------
r1730889 | jleroux | 2016-02-17 18:47:47 +0100 (mer. 17 févr. 2016) | 5 lignes

A patch from Pierre Smits for "printCheck action generates an error" https://issues.apache.org/jira/browse/OFBIZ-6898

When generating a check (/accounting/control/printChecks.pdf?paymentId=demo10000) following error is generated:
Unable to transform FO file: org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: null:32:31: "fo:table-cell" is missing child elements. Required content model: marker* (%block;)+ (See position 32:31)
     [java] javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: null:32:31: "fo:table-cell" is missing child elements. Required content model: marker* (%block;)+ (See position 32:31); Screen XSL:FO text was:
------------------------------------------------------------------------


Modified:
    ofbiz/branches/release15.12/   (props changed)
    ofbiz/branches/release15.12/applications/accounting/webapp/accounting/payment/PrintChecks.fo.ftl

Propchange: ofbiz/branches/release15.12/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb 17 17:50:39 2016
@@ -9,4 +9,4 @@
 /ofbiz/branches/json-integration-refactoring:1634077-1635900
 /ofbiz/branches/multitenant20100310:921280-927264
 /ofbiz/branches/release13.07:1547657
-/ofbiz/trunk:1722712,1723007,1723248,1724402,1724411,1724566,1724689,1724763,1724916,1724918,1724925,1724930,1724940,1724943,1724946,1724951,1724957,1724975,1724978,1725006,1725217,1725257,1725561,1725574,1726388,1726486,1726493,1726828,1728398,1728411,1729005,1729078,1729609,1729809,1730035,1730456,1730735-1730736,1730882
+/ofbiz/trunk:1722712,1723007,1723248,1724402,1724411,1724566,1724689,1724763,1724916,1724918,1724925,1724930,1724940,1724943,1724946,1724951,1724957,1724975,1724978,1725006,1725217,1725257,1725561,1725574,1726388,1726486,1726493,1726828,1728398,1728411,1729005,1729078,1729609,1729809,1730035,1730456,1730735-1730736,1730882,1730889

Modified: ofbiz/branches/release15.12/applications/accounting/webapp/accounting/payment/PrintChecks.fo.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release15.12/applications/accounting/webapp/accounting/payment/PrintChecks.fo.ftl?rev=1730890&r1=1730889&r2=1730890&view=diff
==============================================================================
--- ofbiz/branches/release15.12/applications/accounting/webapp/accounting/payment/PrintChecks.fo.ftl (original)
+++ ofbiz/branches/release15.12/applications/accounting/webapp/accounting/payment/PrintChecks.fo.ftl Wed Feb 17 17:50:39 2016
@@ -25,472 +25,443 @@ by hand from a real template using a rul
 <#escape x as x?xml>
 
 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
-
-  <fo:layout-master-set>
-
+    <fo:layout-master-set>
     <#-- define the margins of the check layout here -->
-    <fo:simple-page-master master-name="checks"
-      page-height="27.9cm" page-width="21.6cm">
-      <fo:region-body/>
-    </fo:simple-page-master>
-
-  </fo:layout-master-set>
-
-  <fo:page-sequence master-reference="checks">
-    <fo:flow flow-name="xsl-region-body">
-      <#if !security.hasEntityPermission("ACCOUNTING", "_PRINT_CHECKS", session)>
-      <fo:block padding="20pt">${uiLabelMap.AccountingPrintChecksPermissionError}</fo:block>
-      <#else>
-      <#if payments.size() == 0>
-        <fo:block padding="20pt">${uiLabelMap.AccountingPaymentCheckMessage1}</fo:block>
-      </#if>
-
-      <#list payments as payment>
-      <#assign paymentApplications = payment.getRelated("PaymentApplication", null, null, false)>
-      <fo:block font-size="10pt" break-before="page"> <#-- this produces a page break if this block cannot fit on the current page -->
-
-        <#-- the check: note that the format is fairly precise -->
-
-        <#-- this seems to be the only way to force a fixed height in fop -->
-        <fo:table table-layout="fixed" width="100%">
-          <fo:table-column column-width="100%"/>
-          <fo:table-body>
-          <fo:table-row height="8.85cm">
-          <fo:table-cell>
-
-        <fo:table table-layout="fixed" width="100%">
-          <fo:table-column column-width="17.7cm"/>
-          <fo:table-column column-width="3cm"/>
-          <fo:table-body>
-            <fo:table-row>
-              <fo:table-cell/>
-              <fo:table-cell>
-                <fo:block padding-before="2.2cm">${payment.effectiveDate?date?string.short}</fo:block>
-              </fo:table-cell>
-            </fo:table-row>
-            <fo:table-row>
-              <fo:table-cell padding-before="0.8cm">
-                <fo:block margin-left="3.0cm">
-                  <#assign toPartyNameResult = dispatcher.runSync("getPartyNameForDate", Static["org.ofbiz.base.util.UtilMisc"].toMap("partyId", payment.partyIdTo, "compareDate", payment.effectiveDate, "userLogin", userLogin))/>
-                  ${toPartyNameResult.fullName?default("Name Not Found")}
-                </fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding-before="0.8cm">
-                <fo:block>**${payment.getBigDecimal("amount").setScale(decimals, rounding).toString()}</fo:block>
-              </fo:table-cell>
-            </fo:table-row>
-            <fo:table-row>
-              <fo:table-cell number-columns-spanned="2">
-                <#assign amount = Static["org.ofbiz.base.util.UtilNumber"].formatRuleBasedAmount(payment.getDouble("amount"), "%dollars-and-hundredths", locale).toUpperCase()>
-                <fo:block padding-before="0.4cm" margin-left="1.3cm">${amount}<#list 1..(100-amount.length()) as x>*</#list></fo:block>
-              </fo:table-cell>
-            </fo:table-row>
-          </fo:table-body>
-        </fo:table>
-
-        </fo:table-cell>
-        </fo:table-row>
-        </fo:table-body>
-        </fo:table>
-
-        <#-- payment applications (twice: both blocks are exactly the same) -->
-
-        <#-- this seems to be the only way to force a fixed height in fop -->
-        <fo:table table-layout="fixed" width="100%">
-          <fo:table-column column-width="100%"/>
-          <fo:table-body>
-          <fo:table-row height="9.3cm">
-          <fo:table-cell>
-
-        <fo:table table-layout="fixed" margin-left="5pt" margin-right="5pt" width="100%">
-          <fo:table-column column-width="3cm"/>
-          <fo:table-column column-width="3cm"/>
-          <fo:table-column column-width="3cm"/>
-          <fo:table-column column-width="3cm"/>
-          <fo:table-column column-width="3cm"/>
-          <fo:table-column column-width="3cm"/>
-          <fo:table-column column-width="3cm"/>
-          <fo:table-header>
-            <fo:table-row>
-              <fo:table-cell padding="3pt" number-columns-spanned="3" text-align="center">
-                <fo:block text-align="center">
-                  <#assign toPartyNameResult = dispatcher.runSync("getPartyNameForDate", Static["org.ofbiz.base.util.UtilMisc"].toMap("partyId", payment.partyIdTo, "compareDate", payment.effectiveDate, "userLogin", userLogin))/>
-                  ${toPartyNameResult.fullName?default("Name Not Found")}
-                </fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt" number-columns-spanned="4" text-align="center">
-                <fo:block text-align="center">${payment.effectiveDate?date?string.short}</fo:block>
-              </fo:table-cell>
-            </fo:table-row>
-
-            <fo:table-row>
-              <fo:table-cell padding="3pt">
-                <fo:block font-weight="bold">${uiLabelMap.CommonDate}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block font-weight="bold">${uiLabelMap.CommonType}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block font-weight="bold">${uiLabelMap.AccountingReferenceNumber}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block font-weight="bold" text-align="right">${uiLabelMap.AccountingPaymentOriginalAmount}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block font-weight="bold" text-align="right">${uiLabelMap.AccountingBalanceDue}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block font-weight="bold" text-align="right">${uiLabelMap.AccountingPayment}</fo:block>
-              </fo:table-cell>
-            </fo:table-row>
-
-          </fo:table-header>
-          <fo:table-body>
-
-            <#list paymentApplications as paymentApplication>
-            <#assign invoice = paymentApplication.getRelatedOne("Invoice", false)!>
-            <fo:table-row>
-              <fo:table-cell padding="3pt">
-                <fo:block>${payment.effectiveDate?date?string.short}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block><#if invoice??>${uiLabelMap.AccountingInvoice} : ${invoice.invoiceId}</#if></fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block>
-                  <#if invoice??>${invoice.referenceNumber!}</#if>
-                  ${paymentApplication.taxAuthGeoId!}
-                </fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block text-align="end">${paymentApplication.getBigDecimal("amountApplied").setScale(decimals, rounding).toString()}</fo:block>
-              </fo:table-cell>
-            </fo:table-row>
-            <#if invoice.invoiceTypeId! == "PAYROL_INVOICE">
-              <#assign InvoiceItems = invoice.getRelated("InvoiceItem", null, null, false)!>
-              <#assign PayrolGroups = PayrolGroup!>
-              <#list PayrolGroups as payrolGroup>
-                  <#assign fontSize = "75%">
-                  <#assign lineStyle = "dashed">
-
-                  <#assign sumQuantity = 0>
-                  <#assign sumAmount = 0>
-                  <#assign sumSubTotal = 0>
-                  <#list InvoiceItems as invoiceItem>
-                      <#assign invoiceItemType = invoiceItem.getRelatedOne("InvoiceItemType", false)!>
-                      <#assign quantity = 0>
-                      <#assign amount = 0>
-                      <#assign subTotal = 0>
-                      <#if invoiceItemType.parentTypeId == payrolGroup.invoiceItemTypeId>
-                      <#if invoiceItem.quantity?has_content><#assign quantity = invoiceItem.quantity!><#else><#assign quantity = 0></#if>
-                      <#if invoiceItem.amount?has_content><#assign amount = invoiceItem.amount!><#else><#assign amount = 0></#if>
-                      <#if amount != 0 && quantity == 0 ><#assign quantity = 1></#if>
-                          <#assign subTotal = quantity * amount>
-                          <#assign sumQuantity = sumQuantity + quantity>
-                          <#assign sumAmount = sumAmount + amount>
-                          <#assign sumSubTotal = sumSubTotal + subTotal>
-                      </#if>
-                  </#list>
-                  <#if sumSubTotal != 0>
-              <fo:table-row font-size="${fontSize}">
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt" number-columns-spanned="3" border-bottom-style="${lineStyle}">
-              <fo:block font-weight="bold">${payrolGroup.description!}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt" border-bottom-style="${lineStyle}" >
-              <fo:block font-weight="bold" text-align="center">Quantity</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt" border-bottom-style="${lineStyle}" >
-              <fo:block font-weight="bold" text-align="center">Amount</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt" border-bottom-style="${lineStyle}" >
-              <fo:block font-weight="bold" text-align="center">Sum</fo:block>
-              </fo:table-cell>
-              </fo:table-row>
-                </#if>
-
-                <#assign sumQuantity = 0>
-                <#assign sumAmount = 0>
-                  <#assign sumSubTotal = 0>
-                  <#list InvoiceItems as invoiceItem>
-                      <#assign invoiceItemType = invoiceItem.getRelatedOne("InvoiceItemType", false)!>
-                      <#assign subTotal = 0>
-                      <#if invoiceItemType.parentTypeId == payrolGroup.invoiceItemTypeId>
-                      <#if invoiceItem.quantity?has_content><#assign quantity = invoiceItem.quantity!><#else><#assign quantity = 0></#if>
-                      <#if invoiceItem.amount?has_content><#assign amount = invoiceItem.amount!><#else><#assign amount = 0></#if>
-                      <#if amount != 0 && quantity == 0 ><#assign quantity = 1></#if>
-                      <#assign subTotal = quantity * amount>
-                      <#assign sumQuantity = sumQuantity + quantity>
-                      <#assign sumAmount = sumAmount + amount>
-                      <#assign sumSubTotal = sumSubTotal + subTotal>
-              <fo:table-row font-size="${fontSize}">
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt" number-columns-spanned="3"><fo:block>${invoiceItemType.description!}</fo:block></fo:table-cell>
-              <fo:table-cell padding="3pt"><fo:block text-align="center">${quantity!}</fo:block></fo:table-cell>
-              <fo:table-cell padding="3pt"><fo:block text-align="center">${amount!}</fo:block></fo:table-cell>
-              <fo:table-cell padding="3pt"><fo:block text-align="center">${subTotal!}</fo:block></fo:table-cell>
-              </fo:table-row>
-                      </#if>
-                  </#list>
-
-                  <#assign sumQuantity = 0>
-                <#assign sumAmount = 0>
-                  <#assign sumSubTotal = 0>
-                  <#list InvoiceItems as invoiceItem>
-                      <#assign invoiceItemType = invoiceItem.getRelatedOne("InvoiceItemType", false)!>
-                      <#assign subTotal = 0>
-                      <#if invoiceItemType.parentTypeId == payrolGroup.invoiceItemTypeId>
-                      <#if invoiceItem.quantity?has_content><#assign quantity = invoiceItem.quantity!><#else><#assign quantity = 0></#if>
-                      <#if invoiceItem.amount?has_content><#assign amount = invoiceItem.amount!><#else><#assign amount = 0></#if>
-                      <#if amount != 0 && quantity == 0><#assign quantity = 1></#if>
-                          <#assign subTotal = quantity * amount>
-                          <#assign sumQuantity = sumQuantity + quantity>
-                          <#assign sumAmount = sumAmount + amount>
-                          <#assign sumSubTotal = sumSubTotal + subTotal>
-                      </#if>
-                  </#list>
-                  <#if sumSubTotal != 0>
-              <fo:table-row font-size="${fontSize}">
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt" number-columns-spanned="3" border-top-style="${lineStyle}"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt" border-top-style="${lineStyle}"><fo:block text-align="center">${sumQuantity!}</fo:block></fo:table-cell>
-              <fo:table-cell padding="3pt" border-top-style="${lineStyle}"><fo:block text-align="center">${sumAmount!}</fo:block></fo:table-cell>
-              <fo:table-cell padding="3pt" border-top-style="solid" border-bottom-style="${lineStyle}"><fo:block text-align="right">${sumSubTotal!}</fo:block></fo:table-cell>
-              </fo:table-row>
-              <fo:table-row font-size="${fontSize}">
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              </fo:table-row>
-                  </#if>
-
-              </#list>
-              <fo:table-row font-size="${fontSize}">
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt" number-columns-spanned="6" border-top-style="solid"><fo:block/></fo:table-cell>
-              </fo:table-row>
-              </#if>
-
-            </#list>
-
-            <fo:table-row>
-              <fo:table-cell padding="3pt" number-columns-spanned="6">
-                <fo:block text-align="end">${uiLabelMap.AccountingCheckAmount}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block text-align="end">${payment.getBigDecimal("amount").setScale(decimals, rounding).toString()}</fo:block>
-              </fo:table-cell>
-            </fo:table-row>
-          </fo:table-body>
-        </fo:table>
-
-        </fo:table-cell>
-        </fo:table-row>
-        </fo:table-body>
-        </fo:table>
-
-
-        <#-- copy of above -->
-
-        <#-- this seems to be the only way to force a fixed height in fop -->
-        <fo:table table-layout="fixed" width="100%">
-          <fo:table-column column-width="100%"/>
-          <fo:table-body>
-          <fo:table-row height="9.3cm">
-          <fo:table-cell>
-
-        <fo:table table-layout="fixed" margin-left="5pt" margin-right="5pt" width="100%">
-          <fo:table-column column-width="3cm"/>
-          <fo:table-column column-width="3cm"/>
-          <fo:table-column column-width="3cm"/>
-          <fo:table-column column-width="3cm"/>
-          <fo:table-column column-width="3cm"/>
-          <fo:table-column column-width="3cm"/>
-          <fo:table-column column-width="3cm"/>
-          <fo:table-header>
-            <fo:table-row>
-              <fo:table-cell padding="3pt" number-columns-spanned="3" text-align="center">
-                <fo:block text-align="center">
-                  ${Static["org.ofbiz.party.party.PartyHelper"].getPartyName(delegator, payment.partyIdTo, false)}
-                </fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt" number-columns-spanned="4" text-align="center">
-                <fo:block text-align="center">${payment.effectiveDate?date?string.short}</fo:block>
-              </fo:table-cell>
-            </fo:table-row>
-            <fo:table-row>
-              <fo:table-cell padding="3pt">
-                <fo:block font-weight="bold">${uiLabelMap.CommonDate}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block font-weight="bold">${uiLabelMap.CommonType}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block font-weight="bold">${uiLabelMap.AccountingReferenceNumber}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block font-weight="bold" text-align="right">${uiLabelMap.AccountingPaymentOriginalAmount}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block font-weight="bold" text-align="right">${uiLabelMap.AccountingBalanceDue}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block font-weight="bold" text-align="right">${uiLabelMap.AccountingPayment}</fo:block>
-              </fo:table-cell>
-            </fo:table-row>
-          </fo:table-header>
-          <fo:table-body>
-
-            <#list paymentApplications as paymentApplication>
-            <#assign invoice = paymentApplication.getRelatedOne("Invoice", false)!>
-            <fo:table-row>
-              <fo:table-cell padding="3pt">
-                <fo:block>${payment.effectiveDate?date?string.short}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block><#if invoice??>${uiLabelMap.AccountingInvoice} : ${invoice.invoiceId}</#if></fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block>
-                  <#if invoice??>${invoice.referenceNumber!}</#if>
-                  ${paymentApplication.taxAuthGeoId!}
-                </fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block text-align="end">${paymentApplication.getBigDecimal("amountApplied").setScale(decimals, rounding).toString()}</fo:block>
-              </fo:table-cell>
-            </fo:table-row>
-            <#if invoice.invoiceTypeId! == "PAYROL_INVOICE">
-              <#assign InvoiceItems = invoice.getRelated("InvoiceItem", null, null, false)!>
-              <#assign PayrolGroups = PayrolGroup!>
-              <#list PayrolGroups as payrolGroup>
-                  <#assign fontSize = "75%">
-                  <#assign lineStyle = "dashed">
-
-                  <#assign sumQuantity = 0>
-                  <#assign sumAmount = 0>
-                  <#assign sumSubTotal = 0>
-                  <#list InvoiceItems as invoiceItem>
-                      <#assign invoiceItemType = invoiceItem.getRelatedOne("InvoiceItemType", false)!>
-                      <#assign quantity = 0>
-                      <#assign amount = 0>
-                      <#assign subTotal = 0>
-                      <#if invoiceItemType.parentTypeId == payrolGroup.invoiceItemTypeId>
-                      <#if invoiceItem.quantity?has_content><#assign quantity = invoiceItem.quantity!><#else><#assign quantity = 0></#if>
-                      <#if invoiceItem.amount?has_content><#assign amount = invoiceItem.amount!><#else><#assign amount = 0></#if>
-                      <#if amount != 0 && quantity == 0 ><#assign quantity = 1></#if>
-                          <#assign subTotal = quantity * amount>
-                          <#assign sumQuantity = sumQuantity + quantity>
-                          <#assign sumAmount = sumAmount + amount>
-                          <#assign sumSubTotal = sumSubTotal + subTotal>
-                      </#if>
-                  </#list>
-                  <#if sumSubTotal != 0>
-              <fo:table-row font-size="${fontSize}">
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt" number-columns-spanned="3" border-bottom-style="${lineStyle}">
-              <fo:block font-weight="bold">${payrolGroup.description!}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt" border-bottom-style="${lineStyle}" >
-              <fo:block font-weight="bold" text-align="center">Quantity</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt" border-bottom-style="${lineStyle}" >
-              <fo:block font-weight="bold" text-align="center">Amount</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt" border-bottom-style="${lineStyle}" >
-              <fo:block font-weight="bold" text-align="center">Sum</fo:block>
-              </fo:table-cell>
-              </fo:table-row>
+        <fo:simple-page-master master-name="checks" page-height="27.9cm" page-width="21.6cm">
+            <fo:region-body/>
+        </fo:simple-page-master>
+
+    </fo:layout-master-set>
+
+    <fo:page-sequence master-reference="checks">
+        <fo:flow flow-name="xsl-region-body">
+            <#if !security.hasEntityPermission("ACCOUNTING", "_PRINT_CHECKS", session)>
+                <fo:block padding="20pt">${uiLabelMap.AccountingPrintChecksPermissionError}</fo:block>
+            <#else>
+                <#if payments.size() == 0>
+                    <fo:block padding="20pt">${uiLabelMap.AccountingPaymentCheckMessage1}</fo:block>
                 </#if>
-
-                <#assign sumQuantity = 0>
-                <#assign sumAmount = 0>
-                  <#assign sumSubTotal = 0>
-                  <#list InvoiceItems as invoiceItem>
-                      <#assign invoiceItemType = invoiceItem.getRelatedOne("InvoiceItemType", false)!>
-                      <#assign subTotal = 0>
-                      <#if invoiceItemType.parentTypeId == payrolGroup.invoiceItemTypeId>
-                      <#if invoiceItem.quantity?has_content><#assign quantity = invoiceItem.quantity!><#else><#assign quantity = 0></#if>
-                      <#if invoiceItem.amount?has_content><#assign amount = invoiceItem.amount!><#else><#assign amount = 0></#if>
-                      <#if amount != 0 && quantity == 0 ><#assign quantity = 1></#if>
-                      <#assign subTotal = quantity * amount>
-                      <#assign sumQuantity = sumQuantity + quantity>
-                      <#assign sumAmount = sumAmount + amount>
-                      <#assign sumSubTotal = sumSubTotal + subTotal>
-              <fo:table-row font-size="${fontSize}">
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt" number-columns-spanned="3"><fo:block>${invoiceItemType.description!}</fo:block></fo:table-cell>
-              <fo:table-cell padding="3pt"><fo:block text-align="center">${quantity!}</fo:block></fo:table-cell>
-              <fo:table-cell padding="3pt"><fo:block text-align="center">${amount!}</fo:block></fo:table-cell>
-              <fo:table-cell padding="3pt"><fo:block text-align="center">${subTotal!}</fo:block></fo:table-cell>
-              </fo:table-row>
-                      </#if>
-                  </#list>
-
-                  <#assign sumQuantity = 0>
-                <#assign sumAmount = 0>
-                  <#assign sumSubTotal = 0>
-                  <#list InvoiceItems as invoiceItem>
-                      <#assign invoiceItemType = invoiceItem.getRelatedOne("InvoiceItemType", false)!>
-                      <#assign subTotal = 0>
-                      <#if invoiceItemType.parentTypeId == payrolGroup.invoiceItemTypeId>
-                      <#if invoiceItem.quantity?has_content><#assign quantity = invoiceItem.quantity!><#else><#assign quantity = 0></#if>
-                      <#if invoiceItem.amount?has_content><#assign amount = invoiceItem.amount!><#else><#assign amount = 0></#if>
-                      <#if amount != 0 && quantity == 0><#assign quantity = 1></#if>
-                          <#assign subTotal = quantity * amount>
-                          <#assign sumQuantity = sumQuantity + quantity>
-                          <#assign sumAmount = sumAmount + amount>
-                          <#assign sumSubTotal = sumSubTotal + subTotal>
-                      </#if>
-                  </#list>
-                  <#if sumSubTotal != 0>
-              <fo:table-row font-size="${fontSize}">
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt" number-columns-spanned="3" border-top-style="${lineStyle}"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt" border-top-style="${lineStyle}"><fo:block text-align="center">${sumQuantity!}</fo:block></fo:table-cell>
-              <fo:table-cell padding="3pt" border-top-style="${lineStyle}"><fo:block text-align="center">${sumAmount!}</fo:block></fo:table-cell>
-              <fo:table-cell padding="3pt" border-top-style="solid" border-bottom-style="${lineStyle}"><fo:block text-align="right">${sumSubTotal!}</fo:block></fo:table-cell>
-              </fo:table-row>
-              <fo:table-row font-size="${fontSize}">
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              </fo:table-row>
-                  </#if>
-
-              </#list>
-              <fo:table-row font-size="${fontSize}">
-              <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
-              <fo:table-cell padding="3pt" number-columns-spanned="6" border-top-style="solid"><fo:block/></fo:table-cell>
-              </fo:table-row>
-              </#if>
-
-            </#list>
-
-            <fo:table-row>
-              <fo:table-cell padding="3pt" number-columns-spanned="6">
-                <fo:block text-align="end">${uiLabelMap.AccountingCheckAmount}</fo:block>
-              </fo:table-cell>
-              <fo:table-cell padding="3pt">
-                <fo:block text-align="end">${payment.getBigDecimal("amount").setScale(decimals, rounding).toString()}</fo:block>
-              </fo:table-cell>
-            </fo:table-row>
-          </fo:table-body>
-        </fo:table>
-
-        </fo:table-cell>
-        </fo:table-row>
-        </fo:table-body>
-        </fo:table>
-
-      </fo:block>
-      </#list>
-      </#if> <#-- security if -->
-    </fo:flow>
-  </fo:page-sequence>
+                <#list payments as payment>
+                    <#assign paymentApplications = payment.getRelated("PaymentApplication", null, null, false)>
+                    <fo:block font-size="10pt" break-before="page"> <#-- this produces a page break if this block cannot fit on the current page -->
+                        
+                        <#-- the check: note that the format is fairly precise -->
+                        
+                        <#-- this seems to be the only way to force a fixed height in fop -->
+                        <fo:table table-layout="fixed" width="100%">
+                            <fo:table-column column-width="100%"/>
+                            <fo:table-body>
+                                <fo:table-row height="8.85cm">
+                                    <fo:table-cell>
+                                        <fo:table table-layout="fixed" width="100%">
+                                            <fo:table-column column-width="17.7cm"/>
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-body>
+                                                <fo:table-row>
+                                                    <fo:table-cell><fo:block/></fo:table-cell>
+                                                    <fo:table-cell>
+                                                        <fo:block padding-before="2.2cm">${payment.effectiveDate?date?string.short}</fo:block>
+                                                    </fo:table-cell>
+                                                </fo:table-row>
+                                                <fo:table-row>
+                                                    <fo:table-cell padding-before="0.8cm">
+                                                        <fo:block margin-left="3.0cm">
+                                                            <#assign toPartyNameResult = dispatcher.runSync("getPartyNameForDate", Static["org.ofbiz.base.util.UtilMisc"].toMap("partyId", payment.partyIdTo, "compareDate", payment.effectiveDate, "userLogin", userLogin))/>
+                                                            ${toPartyNameResult.fullName?default("Name Not Found")}
+                                                        </fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding-before="0.8cm">
+                                                        <fo:block>**${payment.getBigDecimal("amount").setScale(decimals, rounding).toString()}</fo:block>
+                                                    </fo:table-cell>
+                                                </fo:table-row>
+                                                <fo:table-row>
+                                                    <fo:table-cell number-columns-spanned="2">
+                                                        <#assign amount = Static["org.ofbiz.base.util.UtilNumber"].formatRuleBasedAmount(payment.getDouble("amount"), "%dollars-and-hundredths", locale).toUpperCase()>
+                                                        <fo:block padding-before="0.4cm" margin-left="1.3cm">${amount}<#list 1..(100-amount.length()) as x>*</#list></fo:block>
+                                                    </fo:table-cell>
+                                                </fo:table-row>
+                                            </fo:table-body>
+                                        </fo:table>
+                                    </fo:table-cell>
+                                </fo:table-row>
+                            </fo:table-body>
+                        </fo:table>
+                        <#-- payment applications (twice: both blocks are exactly the same) -->
+                    
+                        <#-- this seems to be the only way to force a fixed height in fop -->
+                        <fo:table table-layout="fixed" width="100%">
+                            <fo:table-column column-width="100%"/>
+                            <fo:table-body>
+                                <fo:table-row height="9.3cm">
+                                    <fo:table-cell>
+                                        <fo:table table-layout="fixed" margin-left="5pt" margin-right="5pt" width="100%">
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-header>
+                                                <fo:table-row>
+                                                    <fo:table-cell padding="3pt" number-columns-spanned="3" text-align="center">
+                                                        <fo:block text-align="center">
+                                                            <#assign toPartyNameResult = dispatcher.runSync("getPartyNameForDate", Static["org.ofbiz.base.util.UtilMisc"].toMap("partyId", payment.partyIdTo, "compareDate", payment.effectiveDate, "userLogin", userLogin))/>
+                                                            ${toPartyNameResult.fullName?default("Name Not Found")}
+                                                        </fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding="3pt" number-columns-spanned="4" text-align="center">
+                                                        <fo:block text-align="center">${payment.effectiveDate?date?string.short}</fo:block>
+                                                    </fo:table-cell>
+                                                </fo:table-row>
+                                                <fo:table-row>
+                                                    <fo:table-cell padding="3pt">
+                                                        <fo:block font-weight="bold">${uiLabelMap.CommonDate}</fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding="3pt">
+                                                        <fo:block font-weight="bold">${uiLabelMap.CommonType}</fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding="3pt">
+                                                        <fo:block font-weight="bold">${uiLabelMap.AccountingReferenceNumber}</fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                    <fo:table-cell padding="3pt">
+                                                        <fo:block font-weight="bold" text-align="right">${uiLabelMap.AccountingPaymentOriginalAmount}</fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding="3pt">
+                                                        <fo:block font-weight="bold" text-align="right">${uiLabelMap.AccountingBalanceDue}</fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding="3pt">
+                                                        <fo:block font-weight="bold" text-align="right">${uiLabelMap.AccountingPayment}</fo:block>
+                                                    </fo:table-cell>
+                                                </fo:table-row>
+                                            </fo:table-header>
+                                            <fo:table-body>
+                                                <#list paymentApplications as paymentApplication>
+                                                    <#assign invoice = paymentApplication.getRelatedOne("Invoice", false)!>
+                                                    <fo:table-row>
+                                                        <fo:table-cell padding="3pt">
+                                                            <fo:block>${payment.effectiveDate?date?string.short}</fo:block>
+                                                        </fo:table-cell>
+                                                        <fo:table-cell padding="3pt">
+                                                            <fo:block><#if invoice??>${uiLabelMap.AccountingInvoice} : ${invoice.invoiceId}</#if></fo:block>
+                                                        </fo:table-cell>
+                                                        <fo:table-cell padding="3pt">
+                                                            <fo:block>
+                                                                <#if invoice??>${invoice.referenceNumber!}</#if>
+                                                                ${paymentApplication.taxAuthGeoId!}
+                                                            </fo:block>
+                                                        </fo:table-cell>
+                                                        <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                        <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                        <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                        <fo:table-cell padding="3pt">
+                                                            <fo:block text-align="end">${paymentApplication.getBigDecimal("amountApplied").setScale(decimals, rounding).toString()}</fo:block>
+                                                        </fo:table-cell>
+                                                    </fo:table-row>
+                                                        <#if invoice.invoiceTypeId! == "PAYROL_INVOICE">
+                                                            <#assign InvoiceItems = invoice.getRelated("InvoiceItem", null, null, false)!>
+                                                            <#assign PayrolGroups = PayrolGroup!>
+                                                            <#list PayrolGroups as payrolGroup>
+                                                                <#assign fontSize = "75%">
+                                                                <#assign lineStyle = "dashed">
+                                                                <#assign sumQuantity = 0>
+                                                                <#assign sumAmount = 0>
+                                                                <#assign sumSubTotal = 0>
+                                                                <#list InvoiceItems as invoiceItem>
+                                                                    <#assign invoiceItemType = invoiceItem.getRelatedOne("InvoiceItemType", false)!>
+                                                                    <#assign quantity = 0>
+                                                                    <#assign amount = 0>
+                                                                    <#assign subTotal = 0>
+                                                                    <#if invoiceItemType.parentTypeId == payrolGroup.invoiceItemTypeId>
+                                                                        <#if invoiceItem.quantity?has_content><#assign quantity = invoiceItem.quantity!><#else><#assign quantity = 0></#if>
+                                                                        <#if invoiceItem.amount?has_content><#assign amount = invoiceItem.amount!><#else><#assign amount = 0></#if>
+                                                                        <#if amount != 0 && quantity == 0 ><#assign quantity = 1></#if>
+                                                                        <#assign subTotal = quantity * amount>
+                                                                        <#assign sumQuantity = sumQuantity + quantity>
+                                                                        <#assign sumAmount = sumAmount + amount>
+                                                                        <#assign sumSubTotal = sumSubTotal + subTotal>
+                                                                    </#if>
+                                                                </#list>
+                                                                <#if sumSubTotal != 0>
+                                                                    <fo:table-row font-size="${fontSize}">
+                                                                        <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                                        <fo:table-cell padding="3pt" number-columns-spanned="3" border-bottom-style="${lineStyle}">
+                                                                            <fo:block font-weight="bold">${payrolGroup.description!}</fo:block>
+                                                                        </fo:table-cell>
+                                                                        <fo:table-cell padding="3pt" border-bottom-style="${lineStyle}" >
+                                                                            <fo:block font-weight="bold" text-align="center">Quantity</fo:block>
+                                                                        </fo:table-cell>
+                                                                        <fo:table-cell padding="3pt" border-bottom-style="${lineStyle}" >
+                                                                            <fo:block font-weight="bold" text-align="center">Amount</fo:block>
+                                                                        </fo:table-cell>
+                                                                        <fo:table-cell padding="3pt" border-bottom-style="${lineStyle}" >
+                                                                            <fo:block font-weight="bold" text-align="center">Sum</fo:block>
+                                                                        </fo:table-cell>
+                                                                    </fo:table-row>
+                                                                </#if>
+                                                                <#assign sumQuantity = 0>
+                                                                <#assign sumAmount = 0>
+                                                                <#assign sumSubTotal = 0>
+                                                                <#list InvoiceItems as invoiceItem>
+                                                                    <#assign invoiceItemType = invoiceItem.getRelatedOne("InvoiceItemType", false)!>
+                                                                    <#assign subTotal = 0>
+                                                                    <#if invoiceItemType.parentTypeId == payrolGroup.invoiceItemTypeId>
+                                                                        <#if invoiceItem.quantity?has_content><#assign quantity = invoiceItem.quantity!><#else><#assign quantity = 0></#if>
+                                                                        <#if invoiceItem.amount?has_content><#assign amount = invoiceItem.amount!><#else><#assign amount = 0></#if>
+                                                                        <#if amount != 0 && quantity == 0 ><#assign quantity = 1></#if>
+                                                                        <#assign subTotal = quantity * amount>
+                                                                        <#assign sumQuantity = sumQuantity + quantity>
+                                                                        <#assign sumAmount = sumAmount + amount>
+                                                                        <#assign sumSubTotal = sumSubTotal + subTotal>
+                                                                        <fo:table-row font-size="${fontSize}">
+                                                                            <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                                            <fo:table-cell padding="3pt" number-columns-spanned="3"><fo:block>${invoiceItemType.description!}</fo:block></fo:table-cell>
+                                                                            <fo:table-cell padding="3pt"><fo:block text-align="center">${quantity!}</fo:block></fo:table-cell>
+                                                                            <fo:table-cell padding="3pt"><fo:block text-align="center">${amount!}</fo:block></fo:table-cell>
+                                                                            <fo:table-cell padding="3pt"><fo:block text-align="center">${subTotal!}</fo:block></fo:table-cell>
+                                                                        </fo:table-row>
+                                                                    </#if>
+                                                            </#list>
+                                                            <#assign sumQuantity = 0>
+                                                            <#assign sumAmount = 0>
+                                                            <#assign sumSubTotal = 0>
+                                                            <#list InvoiceItems as invoiceItem>
+                                                                <#assign invoiceItemType = invoiceItem.getRelatedOne("InvoiceItemType", false)!>
+                                                                <#assign subTotal = 0>
+                                                                <#if invoiceItemType.parentTypeId == payrolGroup.invoiceItemTypeId>
+                                                                    <#if invoiceItem.quantity?has_content><#assign quantity = invoiceItem.quantity!><#else><#assign quantity = 0></#if>
+                                                                    <#if invoiceItem.amount?has_content><#assign amount = invoiceItem.amount!><#else><#assign amount = 0></#if>
+                                                                    <#if amount != 0 && quantity == 0><#assign quantity = 1></#if>
+                                                                    <#assign subTotal = quantity * amount>
+                                                                    <#assign sumQuantity = sumQuantity + quantity>
+                                                                    <#assign sumAmount = sumAmount + amount>
+                                                                    <#assign sumSubTotal = sumSubTotal + subTotal>
+                                                                </#if>
+                                                            </#list>
+                                                            <#if sumSubTotal != 0>
+                                                                <fo:table-row font-size="${fontSize}">
+                                                                    <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                                    <fo:table-cell padding="3pt" number-columns-spanned="3" border-top-style="${lineStyle}"><fo:block/></fo:table-cell>
+                                                                    <fo:table-cell padding="3pt" border-top-style="${lineStyle}"><fo:block text-align="center">${sumQuantity!}</fo:block></fo:table-cell>
+                                                                    <fo:table-cell padding="3pt" border-top-style="${lineStyle}"><fo:block text-align="center">${sumAmount!}</fo:block></fo:table-cell>
+                                                                    <fo:table-cell padding="3pt" border-top-style="solid" border-bottom-style="${lineStyle}"><fo:block text-align="right">${sumSubTotal!}</fo:block></fo:table-cell>
+                                                                </fo:table-row>
+                                                                <fo:table-row font-size="${fontSize}">
+                                                                    <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                                </fo:table-row>
+                                                            </#if>
+                                                        </#list>
+                                                        <fo:table-row font-size="${fontSize}">
+                                                            <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                            <fo:table-cell padding="3pt" number-columns-spanned="6" border-top-style="solid"><fo:block/></fo:table-cell>
+                                                        </fo:table-row>
+                                                    </#if>
+                                                </#list>
+                                                <fo:table-row>
+                                                    <fo:table-cell padding="3pt" number-columns-spanned="6">
+                                                        <fo:block text-align="end">${uiLabelMap.AccountingCheckAmount}</fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding="3pt">
+                                                        <fo:block text-align="end">${payment.getBigDecimal("amount").setScale(decimals, rounding).toString()}</fo:block>
+                                                    </fo:table-cell>
+                                                </fo:table-row>
+                                            </fo:table-body>
+                                        </fo:table>
+                                    </fo:table-cell>
+                                </fo:table-row>
+                            </fo:table-body>
+                        </fo:table>
+
+                        <#-- copy of above -->
+                        <#-- this seems to be the only way to force a fixed height in fop -->
+                        <fo:table table-layout="fixed" width="100%">
+                            <fo:table-column column-width="100%"/>
+                            <fo:table-body>
+                                <fo:table-row height="9.3cm">
+                                    <fo:table-cell>
+                                        <fo:table table-layout="fixed" margin-left="5pt" margin-right="5pt" width="100%">
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-column column-width="3cm"/>
+                                            <fo:table-header>
+                                                <fo:table-row>
+                                                    <fo:table-cell padding="3pt" number-columns-spanned="3" text-align="center">
+                                                        <fo:block text-align="center">
+                                                            ${Static["org.ofbiz.party.party.PartyHelper"].getPartyName(delegator, payment.partyIdTo, false)}
+                                                        </fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding="3pt" number-columns-spanned="4" text-align="center">
+                                                        <fo:block text-align="center">${payment.effectiveDate?date?string.short}</fo:block>
+                                                    </fo:table-cell>
+                                                </fo:table-row>
+                                                <fo:table-row>
+                                                    <fo:table-cell padding="3pt">
+                                                        <fo:block font-weight="bold">${uiLabelMap.CommonDate}</fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding="3pt">
+                                                        <fo:block font-weight="bold">${uiLabelMap.CommonType}</fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding="3pt">
+                                                        <fo:block font-weight="bold">${uiLabelMap.AccountingReferenceNumber}</fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                    <fo:table-cell padding="3pt">
+                                                        <fo:block font-weight="bold" text-align="right">${uiLabelMap.AccountingPaymentOriginalAmount}</fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding="3pt">
+                                                        <fo:block font-weight="bold" text-align="right">${uiLabelMap.AccountingBalanceDue}</fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding="3pt">
+                                                        <fo:block font-weight="bold" text-align="right">${uiLabelMap.AccountingPayment}</fo:block>
+                                                    </fo:table-cell>
+                                                </fo:table-row>
+                                            </fo:table-header>
+                                            <fo:table-body>
+                                                <#list paymentApplications as paymentApplication>
+                                                    <#assign invoice = paymentApplication.getRelatedOne("Invoice", false)!>
+                                                    <fo:table-row>
+                                                        <fo:table-cell padding="3pt">
+                                                            <fo:block>${payment.effectiveDate?date?string.short}</fo:block>
+                                                        </fo:table-cell>
+                                                        <fo:table-cell padding="3pt">
+                                                            <fo:block><#if invoice??>${uiLabelMap.AccountingInvoice} : ${invoice.invoiceId}</#if></fo:block>
+                                                        </fo:table-cell>
+                                                        <fo:table-cell padding="3pt">
+                                                            <fo:block>
+                                                                <#if invoice??>${invoice.referenceNumber!}</#if>
+                                                                ${paymentApplication.taxAuthGeoId!}
+                                                            </fo:block>
+                                                        </fo:table-cell>
+                                                        <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                        <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                        <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                        <fo:table-cell padding="3pt">
+                                                            <fo:block text-align="end">${paymentApplication.getBigDecimal("amountApplied").setScale(decimals, rounding).toString()}</fo:block>
+                                                        </fo:table-cell>
+                                                    </fo:table-row>
+                                                    
+                                                    <#if invoice.invoiceTypeId! == "PAYROL_INVOICE">
+                                                        <#assign InvoiceItems = invoice.getRelated("InvoiceItem", null, null, false)!>
+                                                        <#assign PayrolGroups = PayrolGroup!>
+                                                        <#list PayrolGroups as payrolGroup>
+                                                            <#assign fontSize = "75%">
+                                                            <#assign lineStyle = "dashed">
+                                                            <#assign sumQuantity = 0>
+                                                            <#assign sumAmount = 0>
+                                                            <#assign sumSubTotal = 0>
+                                                            <#list InvoiceItems as invoiceItem>
+                                                                <#assign invoiceItemType = invoiceItem.getRelatedOne("InvoiceItemType", false)!>
+                                                                <#assign quantity = 0>
+                                                                <#assign amount = 0>
+                                                                <#assign subTotal = 0>
+                                                                <#if invoiceItemType.parentTypeId == payrolGroup.invoiceItemTypeId>
+                                                                    <#if invoiceItem.quantity?has_content><#assign quantity = invoiceItem.quantity!><#else><#assign quantity = 0></#if>
+                                                                    <#if invoiceItem.amount?has_content><#assign amount = invoiceItem.amount!><#else><#assign amount = 0></#if>
+                                                                    <#if amount != 0 && quantity == 0 ><#assign quantity = 1></#if>
+                                                                    <#assign subTotal = quantity * amount>
+                                                                    <#assign sumQuantity = sumQuantity + quantity>
+                                                                    <#assign sumAmount = sumAmount + amount>
+                                                                    <#assign sumSubTotal = sumSubTotal + subTotal>
+                                                                </#if>
+                                                            </#list>
+                                                            <#if sumSubTotal != 0>
+                                                                <fo:table-row font-size="${fontSize}">
+                                                                    <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                                    <fo:table-cell padding="3pt" number-columns-spanned="3" border-bottom-style="${lineStyle}">
+                                                                        <fo:block font-weight="bold">${payrolGroup.description!}</fo:block>
+                                                                    </fo:table-cell>
+                                                                    <fo:table-cell padding="3pt" border-bottom-style="${lineStyle}" >
+                                                                        <fo:block font-weight="bold" text-align="center">Quantity</fo:block>
+                                                                    </fo:table-cell>
+                                                                    <fo:table-cell padding="3pt" border-bottom-style="${lineStyle}" >
+                                                                        <fo:block font-weight="bold" text-align="center">Amount</fo:block>
+                                                                    </fo:table-cell>
+                                                                    <fo:table-cell padding="3pt" border-bottom-style="${lineStyle}" >
+                                                                        <fo:block font-weight="bold" text-align="center">Sum</fo:block>
+                                                                    </fo:table-cell>
+                                                                </fo:table-row>
+                                                            </#if>
+                                                            <#assign sumQuantity = 0>
+                                                            <#assign sumAmount = 0>
+                                                            <#assign sumSubTotal = 0>
+                                                            <#list InvoiceItems as invoiceItem>
+                                                                <#assign invoiceItemType = invoiceItem.getRelatedOne("InvoiceItemType", false)!>
+                                                                <#assign subTotal = 0>
+                                                                <#if invoiceItemType.parentTypeId == payrolGroup.invoiceItemTypeId>
+                                                                    <#if invoiceItem.quantity?has_content><#assign quantity = invoiceItem.quantity!><#else><#assign quantity = 0></#if>
+                                                                    <#if invoiceItem.amount?has_content><#assign amount = invoiceItem.amount!><#else><#assign amount = 0></#if>
+                                                                    <#if amount != 0 && quantity == 0 ><#assign quantity = 1></#if>
+                                                                    <#assign subTotal = quantity * amount>
+                                                                    <#assign sumQuantity = sumQuantity + quantity>
+                                                                    <#assign sumAmount = sumAmount + amount>
+                                                                    <#assign sumSubTotal = sumSubTotal + subTotal>
+                                                                    <fo:table-row font-size="${fontSize}">
+                                                                        <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                                        <fo:table-cell padding="3pt" number-columns-spanned="3"><fo:block>${invoiceItemType.description!}</fo:block></fo:table-cell>
+                                                                        <fo:table-cell padding="3pt"><fo:block text-align="center">${quantity!}</fo:block></fo:table-cell>
+                                                                        <fo:table-cell padding="3pt"><fo:block text-align="center">${amount!}</fo:block></fo:table-cell>
+                                                                        <fo:table-cell padding="3pt"><fo:block text-align="center">${subTotal!}</fo:block></fo:table-cell>
+                                                                    </fo:table-row>
+                                                                </#if>
+                                                            </#list>
+                                                            <#assign sumQuantity = 0>
+                                                            <#assign sumAmount = 0>
+                                                            <#assign sumSubTotal = 0>
+                                                            <#list InvoiceItems as invoiceItem>
+                                                                <#assign invoiceItemType = invoiceItem.getRelatedOne("InvoiceItemType", false)!>
+                                                                <#assign subTotal = 0>
+                                                                <#if invoiceItemType.parentTypeId == payrolGroup.invoiceItemTypeId>
+                                                                    <#if invoiceItem.quantity?has_content><#assign quantity = invoiceItem.quantity!><#else><#assign quantity = 0></#if>
+                                                                    <#if invoiceItem.amount?has_content><#assign amount = invoiceItem.amount!><#else><#assign amount = 0></#if>
+                                                                    <#if amount != 0 && quantity == 0><#assign quantity = 1></#if>
+                                                                    <#assign subTotal = quantity * amount>
+                                                                    <#assign sumQuantity = sumQuantity + quantity>
+                                                                    <#assign sumAmount = sumAmount + amount>
+                                                                    <#assign sumSubTotal = sumSubTotal + subTotal>
+                                                                </#if>
+                                                            </#list>
+                                                            <#if sumSubTotal != 0>
+                                                                <fo:table-row font-size="${fontSize}">
+                                                                    <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                                    <fo:table-cell padding="3pt" number-columns-spanned="3" border-top-style="${lineStyle}"><fo:block/></fo:table-cell>
+                                                                    <fo:table-cell padding="3pt" border-top-style="${lineStyle}"><fo:block text-align="center">${sumQuantity!}</fo:block></fo:table-cell>
+                                                                    <fo:table-cell padding="3pt" border-top-style="${lineStyle}"><fo:block text-align="center">${sumAmount!}</fo:block></fo:table-cell>
+                                                                    <fo:table-cell padding="3pt" border-top-style="solid" border-bottom-style="${lineStyle}"><fo:block text-align="right">${sumSubTotal!}</fo:block></fo:table-cell>
+                                                                </fo:table-row>
+                                                                <fo:table-row font-size="${fontSize}">
+                                                                    <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                                </fo:table-row>
+                                                            </#if>
+                                                        </#list>
+                                                        <fo:table-row font-size="${fontSize}">
+                                                            <fo:table-cell padding="3pt"><fo:block/></fo:table-cell>
+                                                            <fo:table-cell padding="3pt" number-columns-spanned="6" border-top-style="solid"><fo:block/></fo:table-cell>
+                                                        </fo:table-row>
+                                                    </#if>
+                                                </#list>
+                                                <fo:table-row>
+                                                    <fo:table-cell padding="3pt" number-columns-spanned="6">
+                                                        <fo:block text-align="end">${uiLabelMap.AccountingCheckAmount}</fo:block>
+                                                    </fo:table-cell>
+                                                    <fo:table-cell padding="3pt">
+                                                        <fo:block text-align="end">${payment.getBigDecimal("amount").setScale(decimals, rounding).toString()}</fo:block>
+                                                    </fo:table-cell>
+                                                </fo:table-row>
+                                            </fo:table-body>
+                                        </fo:table>
+                                    </fo:table-cell>
+                                </fo:table-row>
+                            </fo:table-body>
+                        </fo:table>
+                    </fo:block>
+                </#list>
+            </#if> <#-- security if -->
+        </fo:flow>
+    </fo:page-sequence>
 </fo:root>
 </#escape>