Friday, 23 November 2018

Positive pay file in Dynamics 365 F&O



This post demonstrate how to create positive pay file and difference/changes between Dynamics 365 application 7.3 and 8.0. 


      Most of the banks prefer format of the positive pay file in “.txt”. In Dynamics 365 for Finance and Operations, the default format of the Positive Pay file output is XML. Microsoft has provided steps for the setup of Positive pay file as well as a sample XSLT file used to transform the output (7.3 version please see below for 8.0 version XSLT file)

      In 7.3 output file generates as “.xml” and we cannot the change the file extension in the code.
o   If we need the file in “.txt” or other format then we need to save manually “.xml” as “.txt”.
o   Method BankPositivePayExport > getFileExtensionFromURL()  is a private method so we cannot create extensions for private methods.
      Where as in 8.0 and later we can change the file extension to other extensions like “.txt”.
o   Microsoft changed Method BankPositivePayExport > getFileExtensionFromURL()  to protected so we can create extensions and change the file extension.

      In 7.3 the XSLT file accepts the data entity name in whatever way we mention like small letter or capital letter (BankPositivePayExportEntity) and capital letter field names.



      In 8.0 and later version accepts only capital letter data entity name and field names. (BANKPOSITIVEPAYEXPORTENTITY)










Sample XSLT File



<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

  xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl xslthelper"

  xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.02"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xslthelper="http://schemas.microsoft.com/BizTalk/2003/xslthelper"
  xmlns:Message="schemas.microsoft.com/.../Message"
  xmlns:BankPositivePay="schemas.microsoft.com/.../BankPositivePay">
  <xsl:output method="text" omit-xml-declaration="no" version="1.0" encoding="utf-8"/>
  <xsl:template name="last-day-of-month">
    <xsl:param name="date"/>
    <xsl:param name="y" select="substring($date, 1, 4)"/>
    <xsl:param name="m" select="substring($date, 6, 2)"/>
    <xsl:param name="cal" select="'312831303130313130313031'"/>
    <xsl:param name="leap" select="not($y mod 4) and $y mod 100 or not($y mod 400)"/>
    <xsl:param name="month-length" select="substring($cal, 2*($m - 1) + 1, 2) + ($m=2 and $leap)" />
    <xsl:value-of select="concat($y, $m, $month-length)" />
  </xsl:template>
  
  <xsl:template match="/">
    <Document>
      <xsl:for-each select="Document/BANKPOSITIVEPAYEXPORTENTITY">      <!--Cheque Detail begin-->
        <div>
          <xsl:value-of select='"#"'/>          <!--Placeholder-->
          <xsl:value-of select='"SDR"'/>          <!--Payment Method-->
          <xsl:value-of select='"#"'/>
          <xsl:value-of select='"IS"'/>          <!--Service Request Type-->
          <xsl:value-of select='"#"'/>
          <xsl:value-of select="substring(ACCOUNTNUM/text(), 1, 10)"/>          <!--Account Number-->
          <xsl:value-of select='"#"'/>
          <xsl:value-of select='"S"'/>          <!--Single / Range-->
          <xsl:value-of select='"#"'/>
          <xsl:value-of select='"#"'/>          <!--Account Currency-->
          <xsl:value-of select='"#"'/>          <!--Account Name-->
          <xsl:variable name="year" select="substring(TRANSDATE/text(),1,4)" />
          <xsl:variable name="month" select="substring(TRANSDATE/text(),6,2)" />
          <xsl:variable name="day" select="substring(TRANSDATE/text(),9,2)" />
          <xsl:value-of select="concat($year,$month,$day)" />          <!--Issue Date-->
          <xsl:value-of select='"#"'/>
          <xsl:variable name="amount" select="AMOUNTCUR" />
          <xsl:value-of select="format-number($amount, '#.00')" />          <!--Cheque Amount-->
          <xsl:value-of select='"#"'/>
          <xsl:value-of select='normalize-space(CHEQUENUM/text())'/>          <!--Cheque Number-->
          <xsl:value-of select='"#"'/>
          <xsl:value-of select='"#"'/>          <!--Plan Number-->
          <xsl:value-of select='"#"'/>          <!--Additional Data-->
          <xsl:value-of select='BANKNEGINSTRECIPIENTNAME/text()'/>          <!--Issued Payee Name 1-->
          <xsl:value-of select='"#"'/>
            <div>
              <xsl:value-of select='normalize-space(HSRECIPIENTADDRESS/text())'/>
            </div>          <!--Issued Payee Name 2-->
          <xsl:value-of select='"#"'/>
          <xsl:value-of select='"#"'/>          <!--FSI-->
          <xsl:call-template name="last-day-of-month">
            <xsl:with-param name="date" select= 'TRANSDATE'/>            <!--Rule-off Date-->
          </xsl:call-template>
          <xsl:value-of select='"#"'/>
          <xsl:value-of select='"#"'/>          <!--Placeholder-->
          <xsl:value-of select='"#"'/>          <!--Placeholder-->
          <xsl:value-of select='"#"'/>          <!--Duplicate Sequence Number-->
          <xsl:value-of select='"#"'/>          <!--Stop-->
          <xsl:value-of select='"#"'/>          <!--Voided Date-->
          <xsl:value-of select='"#"'/>          <!--Placeholder-->
          <xsl:value-of select='"#"'/>          <!--Placeholder-->
          <xsl:value-of select='"#"'/>          <!--Cents Compare-->
          <xsl:value-of select='"#"'/>          <!--Void-->
          <xsl:value-of select='"#"'/>          <!--Placeholder-->
          <xsl:value-of select='"#"'/>          <!--Comments-->
          <xsl:value-of select='"#"'/>          <!--Payee-->
          <xsl:text>&#xa;</xsl:text>
        </div>
      </xsl:for-each>
    </Document>
  </xsl:template>
</xsl:stylesheet>



No comments:

Post a Comment