<#-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <#macro maskSensitiveNumber cardNumber> <#assign cardNumberDisplay = ""> <#if cardNumber?has_content> <#assign size = cardNumber?length - 4> <#if (size > 0)> <#list 0 .. size-1 as foo> <#assign cardNumberDisplay = cardNumberDisplay + "*"> <#assign cardNumberDisplay = cardNumberDisplay + cardNumber[size .. size + 3]> <#else> <#-- but if the card number has less than four digits (ie, it was entered incorrectly), display it in full --> <#assign cardNumberDisplay = cardNumber> ${cardNumberDisplay!}

<#assign orderTypeId = orderReadHelper.getOrderTypeId()> <#if orderTypeId == "PURCHASE_ORDER"> <#list orderPaymentPreferences as orderPaymentPreference> <#assign payments = orderPaymentPreference.getRelated("Payment", null, null, false)> <#list payments as payment> <#assign statusItem = payment.getRelatedOne("StatusItem", false)> <#assign partyName = delegator.findOne("PartyNameView", {"partyId" : payment.partyIdTo}, true)> <#if security.hasEntityPermission("PAY_INFO", "_VIEW", session) || security.hasEntityPermission("ACCOUNTING", "_VIEW", session)> <#else> <#-- invoices --> <#if invoices?has_content> <#else> <#-- order payment status --> <#if orderPaymentPreferences?has_content || billingAccount?has_content || invoices?has_content> <#list orderPaymentPreferences as orderPaymentPreference> <#assign paymentList = orderPaymentPreference.getRelated("Payment", null, null, false)> <#assign pmBillingAddress = {}> <#assign oppStatusItem = orderPaymentPreference.getRelatedOne("StatusItem", false)> <#if outputted?default("false") == "true"> <#assign outputted = "true"> <#-- try the paymentMethod first; if paymentMethodId is specified it overrides paymentMethodTypeId --> <#assign paymentMethod = orderPaymentPreference.getRelatedOne("PaymentMethod", false)!> <#if !paymentMethod?has_content> <#assign paymentMethodType = orderPaymentPreference.getRelatedOne("PaymentMethodType", false)> <#if paymentMethodType.paymentMethodTypeId == "EXT_BILLACT"> <#assign outputted = "false"> <#-- billing account --> <#if billingAccount??> <#if outputted?default("false") == "true"> <#elseif paymentMethodType.paymentMethodTypeId == "FIN_ACCOUNT"> <#assign finAccount = orderPaymentPreference.getRelatedOne("FinAccount", false)!/> <#if (finAccount?has_content)> <#assign gatewayResponses = orderPaymentPreference.getRelated("PaymentGatewayResponse", null, null, false)> <#assign finAccountType = finAccount.getRelatedOne("FinAccountType", false)!/> <#if paymentList?has_content> <#else> <#if paymentMethodType.paymentMethodTypeId != "EXT_OFFLINE" && paymentMethodType.paymentMethodTypeId != "EXT_PAYPAL" && paymentMethodType.paymentMethodTypeId != "EXT_COD"> <#else> <#if paymentList?has_content> <#else> <#if paymentMethod.paymentMethodTypeId! == "CREDIT_CARD"> <#assign gatewayResponses = orderPaymentPreference.getRelated("PaymentGatewayResponse", null, null, false)> <#assign creditCard = paymentMethod.getRelatedOne("CreditCard", false)!> <#if creditCard?has_content> <#assign pmBillingAddress = creditCard.getRelatedOne("PostalAddress", false)!> <#elseif paymentMethod.paymentMethodTypeId! == "EFT_ACCOUNT"> <#assign eftAccount = paymentMethod.getRelatedOne("EftAccount", false)> <#if eftAccount?has_content> <#assign pmBillingAddress = eftAccount.getRelatedOne("PostalAddress", false)!> <#if paymentList?has_content> <#elseif paymentMethod.paymentMethodTypeId! == "GIFT_CARD"> <#assign giftCard = paymentMethod.getRelatedOne("GiftCard", false)> <#if giftCard??> <#assign pmBillingAddress = giftCard.getRelatedOne("PostalAddress", false)!> <#if paymentList?has_content> <#if pmBillingAddress?has_content> <#if paymentList?has_content> <#if customerPoNumber?has_content> <#-- invoices --> <#if invoices?has_content> <#else> <#if (!orderHeader.statusId.equals("ORDER_COMPLETED")) && !(orderHeader.statusId.equals("ORDER_REJECTED")) && !(orderHeader.statusId.equals("ORDER_CANCELLED")) && (paymentMethodValueMaps?has_content)>
${uiLabelMap.AccountingPaymentID} ${uiLabelMap.CommonTo} ${uiLabelMap.CommonAmount} ${uiLabelMap.CommonStatus}
${payment.paymentId}${payment.paymentId} ${partyName.groupName!}${partyName.lastName!} ${partyName.firstName!} ${partyName.middleName!} <#if security.hasPermission("PARTYMGR_VIEW", session) || security.hasPermission("PARTYMGR_ADMIN", session)> [${partyId}] <#else> [${partyId}] <@ofbizCurrency amount=payment.amount!/> ${statusItem.description}

 ${uiLabelMap.OrderInvoices}   <#list invoices as invoice>
${uiLabelMap.CommonNbr}${invoice} (PDF)
 
 ${uiLabelMap.OrderStatusHistory}   <#assign orderPaymentStatuses = orderReadHelper.getOrderPaymentStatuses()> <#if orderPaymentStatuses?has_content> <#list orderPaymentStatuses as orderPaymentStatus> <#assign statusItem = orderPaymentStatus.getRelatedOne("StatusItem", false)!> <#if statusItem?has_content>
${statusItem.get("description",locale)} <#if orderPaymentStatus.statusDatetime?has_content>- ${Static["org.apache.ofbiz.base.util.UtilFormatOut"].formatDateTime(orderPaymentStatus.statusDatetime, "", locale, timeZone)!}   ${uiLabelMap.CommonBy} - [${orderPaymentStatus.statusUserLogin!}]
 



<#-- billing accounts require a special OrderPaymentPreference because it is skipped from above section of OPPs -->
 ${uiLabelMap.AccountingBillingAccount}  <#if billingAccountMaxAmount?has_content>
${uiLabelMap.OrderPaymentMaximumAmount}: <@ofbizCurrency amount=billingAccountMaxAmount?default(0.00) isoCode=currencyUomId/>
 
${uiLabelMap.CommonNbr}${billingAccount.billingAccountId} - ${billingAccount.description!} <#if orderPaymentPreference.statusId != "PAYMENT_SETTLED" && orderPaymentPreference.statusId != "PAYMENT_RECEIVED"> ${uiLabelMap.AccountingReceivePayment}
<#if (!orderHeader.statusId.equals("ORDER_COMPLETED")) && !(orderHeader.statusId.equals("ORDER_REJECTED")) && !(orderHeader.statusId.equals("ORDER_CANCELLED"))> <#if orderPaymentPreference.statusId != "PAYMENT_SETTLED">
 ${uiLabelMap.AccountingFinAccount} <#if orderPaymentPreference.maxAmount?has_content>
${uiLabelMap.OrderPaymentMaximumAmount}: <@ofbizCurrency amount=orderPaymentPreference.maxAmount?default(0.00) isoCode=currencyUomId/>
 
<#if (finAccountType?has_content)> ${finAccountType.description?default(finAccountType.finAccountTypeId)}  #${finAccount.finAccountCode?default(finAccount.finAccountId)} (${finAccount.finAccountId})
${finAccount.finAccountName!}
<#-- Authorize and Capture transactions -->
<#if orderPaymentPreference.statusId != "PAYMENT_SETTLED"> ${uiLabelMap.AccountingAuthorize} <#if orderPaymentPreference.statusId == "PAYMENT_AUTHORIZED"> ${uiLabelMap.AccountingCapture}
<#if gatewayResponses?has_content>

<#list gatewayResponses as gatewayResponse> <#assign transactionCode = gatewayResponse.getRelatedOne("TranCodeEnumeration", false)> ${(transactionCode.get("description",locale))?default("Unknown")}: <#if gatewayResponse.transactionDate?has_content>${Static["org.apache.ofbiz.base.util.UtilFormatOut"].formatDateTime(gatewayResponse.transactionDate, "", locale, timeZone)!} <@ofbizCurrency amount=gatewayResponse.amount isoCode=currencyUomId/>
(${uiLabelMap.OrderReference} ${gatewayResponse.referenceNum!} ${uiLabelMap.OrderAvs} ${gatewayResponse.gatewayAvsResult?default("N/A")} ${uiLabelMap.OrderScore} ${gatewayResponse.gatewayScoreResult?default("N/A")}) ${uiLabelMap.CommonDetails} <#if gatewayResponse_has_next>
<#if (!orderHeader.statusId.equals("ORDER_COMPLETED")) && !(orderHeader.statusId.equals("ORDER_REJECTED")) && !(orderHeader.statusId.equals("ORDER_CANCELLED"))> <#if orderPaymentPreference.statusId != "PAYMENT_SETTLED">
 ${uiLabelMap.AccountingInvoicePayments}
 
<#list paymentList as paymentMap> ${paymentMap.paymentId}<#if paymentMap_has_next>
 ${paymentMethodType.get("description",locale)!}  <#if orderPaymentPreference.maxAmount?has_content>
${uiLabelMap.OrderPaymentMaximumAmount}: <@ofbizCurrency amount=orderPaymentPreference.maxAmount?default(0.00) isoCode=currencyUomId/>
 
<#if orderPaymentPreference.maxAmount?has_content>
${uiLabelMap.OrderPaymentMaximumAmount}: <@ofbizCurrency amount=orderPaymentPreference.maxAmount?default(0.00) isoCode=currencyUomId/>
 [<#if oppStatusItem??>${oppStatusItem.get("description",locale)}<#else>${orderPaymentPreference.statusId}]
${uiLabelMap.AccountingReceivePayment} <#if (!orderHeader.statusId.equals("ORDER_COMPLETED")) && !(orderHeader.statusId.equals("ORDER_REJECTED")) && !(orderHeader.statusId.equals("ORDER_CANCELLED"))> <#if orderPaymentPreference.statusId != "PAYMENT_SETTLED">
 ${uiLabelMap.AccountingInvoicePayments}
 
<#list paymentList as paymentMap> ${paymentMap.paymentId}<#if paymentMap_has_next>
 ${uiLabelMap.AccountingCreditCard} <#if orderPaymentPreference.maxAmount?has_content>
${uiLabelMap.OrderPaymentMaximumAmount}: <@ofbizCurrency amount=orderPaymentPreference.maxAmount?default(0.00) isoCode=currencyUomId/>
 
<#if creditCard?has_content> <#if creditCard.companyNameOnCard??>${creditCard.companyNameOnCard}
<#if creditCard.titleOnCard?has_content>${creditCard.titleOnCard}  ${creditCard.firstNameOnCard?default("N/A")}  <#if creditCard.middleNameOnCard?has_content>${creditCard.middleNameOnCard}  ${creditCard.lastNameOnCard?default("N/A")} <#if creditCard.suffixOnCard?has_content> ${creditCard.suffixOnCard}
<#if security.hasEntityPermission("PAY_INFO", "_VIEW", session) || security.hasEntityPermission("ACCOUNTING", "_VIEW", session)> ${creditCard.cardType} <@maskSensitiveNumber cardNumber=creditCard.cardNumber!/> ${creditCard.expireDate}  [<#if oppStatusItem??>${oppStatusItem.get("description",locale)}<#else>${orderPaymentPreference.statusId}] <#else> ${Static["org.apache.ofbiz.party.contact.ContactHelper"].formatCreditCard(creditCard)}  [<#if oppStatusItem??>${oppStatusItem.get("description",locale)}<#else>${orderPaymentPreference.statusId}]
<#-- Authorize and Capture transactions -->
<#if orderPaymentPreference.statusId != "PAYMENT_SETTLED"> ${uiLabelMap.AccountingAuthorize} <#if orderPaymentPreference.statusId == "PAYMENT_AUTHORIZED"> ${uiLabelMap.AccountingCapture}
<#else> ${uiLabelMap.CommonInformation} ${uiLabelMap.CommonNot} ${uiLabelMap.CommonAvailable}
<#if gatewayResponses?has_content>

<#list gatewayResponses as gatewayResponse> <#assign transactionCode = gatewayResponse.getRelatedOne("TranCodeEnumeration", false)> ${(transactionCode.get("description",locale))?default("Unknown")}: <#if gatewayResponse.transactionDate?has_content>${Static["org.apache.ofbiz.base.util.UtilFormatOut"].formatDateTime(gatewayResponse.transactionDate, "", locale, timeZone)!} <@ofbizCurrency amount=gatewayResponse.amount isoCode=currencyUomId/>
(${uiLabelMap.OrderReference} ${gatewayResponse.referenceNum!} ${uiLabelMap.OrderAvs} ${gatewayResponse.gatewayAvsResult?default("N/A")} ${uiLabelMap.OrderScore} ${gatewayResponse.gatewayScoreResult?default("N/A")}) ${uiLabelMap.CommonDetails} <#if gatewayResponse_has_next>
<#if (!orderHeader.statusId.equals("ORDER_COMPLETED")) && !(orderHeader.statusId.equals("ORDER_REJECTED")) && !(orderHeader.statusId.equals("ORDER_CANCELLED"))> <#if orderPaymentPreference.statusId != "PAYMENT_SETTLED"> ${uiLabelMap.CommonCancel}
 ${uiLabelMap.AccountingEFTAccount} <#if orderPaymentPreference.maxAmount?has_content>
${uiLabelMap.OrderPaymentMaximumAmount}: <@ofbizCurrency amount=orderPaymentPreference.maxAmount?default(0.00) isoCode=currencyUomId/>
 
<#if eftAccount?has_content> ${eftAccount.nameOnAccount!}
<#if eftAccount.companyNameOnAccount??>${eftAccount.companyNameOnAccount}
${uiLabelMap.AccountingBankName}: ${eftAccount.bankName}, ${eftAccount.routingNumber}
${uiLabelMap.AccountingAccount}#: ${eftAccount.accountNumber} <#else> ${uiLabelMap.CommonInformation} ${uiLabelMap.CommonNot} ${uiLabelMap.CommonAvailable}
<#if (!orderHeader.statusId.equals("ORDER_COMPLETED")) && !(orderHeader.statusId.equals("ORDER_REJECTED")) && !(orderHeader.statusId.equals("ORDER_CANCELLED"))> <#if orderPaymentPreference.statusId != "PAYMENT_SETTLED"> ${uiLabelMap.CommonCancel}
 ${uiLabelMap.AccountingInvoicePayments}
 
<#list paymentList as paymentMap> ${paymentMap.paymentId}<#if paymentMap_has_next>
 ${uiLabelMap.OrderGiftCard} <#if orderPaymentPreference.maxAmount?has_content>
${uiLabelMap.OrderPaymentMaximumAmount}: <@ofbizCurrency amount=orderPaymentPreference.maxAmount?default(0.00) isoCode=currencyUomId/>
 
<#if giftCard?has_content> <#if security.hasEntityPermission("PAY_INFO", "_VIEW", session) || security.hasEntityPermission("ACCOUNTING", "_VIEW", session)> ${giftCard.cardNumber?default("N/A")} [${giftCard.pinNumber?default("N/A")}]  [<#if oppStatusItem??>${oppStatusItem.get("description",locale)}<#else>${orderPaymentPreference.statusId}] <#else> <@maskSensitiveNumber cardNumber=giftCard.cardNumber!/> <#if !cardNumberDisplay?has_content>N/A  [<#if oppStatusItem??>${oppStatusItem.get("description",locale)}<#else>${orderPaymentPreference.statusId}] <#else> ${uiLabelMap.CommonInformation} ${uiLabelMap.CommonNot} ${uiLabelMap.CommonAvailable}
<#if (!orderHeader.statusId.equals("ORDER_COMPLETED")) && !(orderHeader.statusId.equals("ORDER_REJECTED")) && !(orderHeader.statusId.equals("ORDER_CANCELLED"))> <#if orderPaymentPreference.statusId != "PAYMENT_SETTLED"> ${uiLabelMap.CommonCancel}
 ${uiLabelMap.AccountingInvoicePayments}
 
<#list paymentList as paymentMap> ${paymentMap.paymentId}<#if paymentMap_has_next>
  
   
<#if pmBillingAddress.toName?has_content>${uiLabelMap.CommonTo} ${pmBillingAddress.toName}
<#if pmBillingAddress.attnName?has_content>${uiLabelMap.CommonAttn} ${pmBillingAddress.attnName}
${pmBillingAddress.address1}
<#if pmBillingAddress.address2?has_content>${pmBillingAddress.address2}
${pmBillingAddress.city}<#if pmBillingAddress.stateProvinceGeoId?has_content>, ${pmBillingAddress.stateProvinceGeoId} ${pmBillingAddress.postalCode!}
${pmBillingAddress.countryGeoId!}
 
 ${uiLabelMap.AccountingInvoicePayments}
 
<#list paymentList as paymentMap> ${paymentMap.paymentId}<#if paymentMap_has_next>

${uiLabelMap.OrderPONumber}   ${customerPoNumber!}  

 ${uiLabelMap.OrderInvoices}   <#list invoices as invoice>
${uiLabelMap.CommonNbr}${invoice} (PDF)
 
${uiLabelMap.OrderNoOrderPaymentPreferences}

<#assign openAmount = orderReadHelper.getOrderOpenAmount()>
${uiLabelMap.AccountingPaymentMethod}    
${uiLabelMap.AccountingAmount}