Skip to content

Instantly share code, notes, and snippets.

@terrywbrady
Last active April 24, 2018 21:27
Show Gist options
  • Save terrywbrady/bfca696348cd6b5ae9e561e49854dc96 to your computer and use it in GitHub Desktop.
Save terrywbrady/bfca696348cd6b5ae9e561e49854dc96 to your computer and use it in GitHub Desktop.
Alma to GMS Vendor Stylesheet
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:vend="http://com/exlibris/repository/acq/invoice/xmlbeans" version="1.0">
<xsl:output method="text"/>
<xsl:template match="/vend:payment_data">
<xsl:apply-templates select="vend:invoice_list/vend:invoice"/>
</xsl:template>
<!-- Question: Special handling of Credit Card Stuff -->
<xsl:template match="vend:invoice">
<!--01,SUP-0002213,02032015,Lauinger | 111874,1127.94,69866-->
<xsl:text>01</xsl:text>
<xsl:text>,</xsl:text>
<!-- Vendor: SUP-0002213 -->
<xsl:if test="not(vend:vendor_FinancialSys_Code)">
<xsl:message>
<xsl:text>No supplier code found for Inoivice Record </xsl:text>
<xsl:number/>
<xsl:value-of select="concat(' (',vend:invoice_number,')')"/>
</xsl:message>
</xsl:if>
<xsl:value-of select="vend:vendor_FinancialSys_Code/text()"/>
<xsl:text>,</xsl:text>
<!-- Date: 02032015 -->
<xsl:value-of select="translate(vend:invoice_date/text(),'/','')"/>
<xsl:text>,</xsl:text>
<!-- Memo | Voucher No: Lauinger | 111874 -->
<xsl:text>Lauinger | </xsl:text>
<xsl:text>TBD-VoucherNo</xsl:text>
<xsl:text>,</xsl:text>
<!-- Amount: 1127.94 -->
<xsl:value-of select="vend:invoice_amount/vend:sum/text()"/>
<xsl:text>,</xsl:text>
<!-- InvoiceNo: 69866 -->
<xsl:value-of select="vend:invoice_number/text()"/>
<xsl:text>&#10;</xsl:text>
<xsl:apply-templates select="vend:invoice_line_list/vend:invoice_line[vend:fund_info_list/vend:fund_info/vend:amount/vend:sum]"/>
<xsl:variable name="sum" select="sum(vend:invoice_line_list/vend:invoice_line/vend:fund_info_list/vend:fund_info/vend:amount/vend:sum)"/>
<xsl:variable name="tsum" select="sum(vend:invoice_amount/vend:sum)"/>
<xsl:if test="$sum != $tsum">
<xsl:message>
<xsl:text>Sum Mismatch: Inoivice Record </xsl:text>
<xsl:number/>
<xsl:value-of select="concat(' (',vend:invoice_number,') ', $sum, ':', $tsum)"/>
</xsl:message>
</xsl:if>
</xsl:template>
<xsl:template match="vend:invoice_line">
<!-- 02,S0152,24.65,,1703,CC2276,PP3002,PG004345,,,BG201123, -->
<xsl:text>02</xsl:text>
<xsl:text>,</xsl:text>
<!-- GMS Spend: S0152 -->
<xsl:text>TBD-Spend</xsl:text>
<xsl:text>,</xsl:text>
<!-- Amount: 24.65 -->
<xsl:value-of select="vend:fund_info_list/vend:fund_info/vend:amount/vend:sum/text()"/>
<xsl:text>,</xsl:text>
<!-- Line memo (previously blank) -->
<xsl:value-of select="vend:po_line_info/vend:po_line_title/text()"/>
<xsl:text>,</xsl:text>
<!-- GMS Fund - 1703 -->
<xsl:text>TBD-Fund</xsl:text>
<xsl:text>,</xsl:text>
<!-- Cost Center - CC2276 -->
<xsl:text>TBD-CostCenter</xsl:text>
<xsl:text>,</xsl:text>
<!-- Purpose - PP30002 -->
<xsl:text>TBD-Purpose</xsl:text>
<xsl:text>,</xsl:text>
<!-- Program - PG004345 -->
<xsl:text>TBD-Program</xsl:text>
<xsl:text>,</xsl:text>
<!-- Grant -->
<xsl:text>TBD-Grant</xsl:text>
<xsl:text>,</xsl:text>
<!-- Assignee -->
<xsl:text>TBD-Assignee</xsl:text>
<xsl:text>,</xsl:text>
<!-- Gift: BG201123 -->
<xsl:text>TBD-Gift</xsl:text>
<xsl:text>,</xsl:text>
<!-- Project -->
<xsl:text>TBD-Project</xsl:text>
<xsl:text>&#10;</xsl:text>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment