[DEV-6370] Pass in the $line_code rather than using it from the contract

The LOB being passed into the function was being ignored and instead it
was pulling it from the contract object. With Package, this caused all 3
LOB to be "COMMPKGE" rather than the correct LOB being processed at the
time.

Going forward, one cannot `map` or `pass` to "line_code" as it will be
considered a reserved word.

Co-Authored-By: Jim Grundner <james.grundner@rtspecialty.com>
master
Joseph Frazer 2019-10-21 13:07:05 -04:00
parent ad7d585d37
commit cbe32aff72
2 changed files with 22 additions and 10 deletions

View File

@ -331,6 +331,10 @@
</lvmp:var>
</xsl:template>
<xsl:template match="lvm:pass[@name='line_code'] | lvm:map[@to='line_code']" priority="9">
<xsl:message terminate="yes">error: "line_code" is a reserved word</xsl:message>
</xsl:template>
<xsl:template match="lvm:external" priority="4">
<lvmp:var name="{@name}" from="{@name}" src="external">
<xsl:call-template name="lvmp:map-common" />

View File

@ -55,7 +55,7 @@
<xsl:text> {</xsl:text>
<xsl:value-of select="$lvmp:nl" />
<xsl:text>public function compose( $contract ) {</xsl:text>
<xsl:text>public function compose( $contract, $line_code ) {</xsl:text>
<xsl:value-of select="$lvmp:nl" />
<xsl:text> return array(</xsl:text>
<xsl:value-of select="$lvmp:nl" />
@ -201,7 +201,16 @@
<xsl:value-of select="$from" />
<xsl:text>', $contract->getValueIndex( '</xsl:text>
<xsl:value-of select="$index-name" />
<xsl:text>' ) )</xsl:text>
<xsl:text>' )</xsl:text>
<xsl:if test="$default">
<xsl:text>, </xsl:text>
<xsl:apply-templates select="$default" mode="lvmp:render" />
</xsl:if>
<xsl:text> ) )</xsl:text>
</xsl:when>
<xsl:when test="$from='line_code'">
<xsl:text>$</xsl:text>
<xsl:value-of select="$from" />
</xsl:when>
<xsl:otherwise>
<xsl:text>$contract-&gt;getValue( '</xsl:text>
@ -209,15 +218,14 @@
<xsl:text>', $contract->getValueIndex( '</xsl:text>
<xsl:value-of select="$index-name" />
<xsl:text>' )</xsl:text>
<xsl:if test="$default">
<xsl:text>, </xsl:text>
<xsl:apply-templates select="$default" mode="lvmp:render" />
</xsl:if>
<xsl:text> )</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$default">
<xsl:text>, </xsl:text>
<xsl:apply-templates select="$default" mode="lvmp:render" />
</xsl:if>
<xsl:text> )</xsl:text>
</xsl:template>
@ -315,7 +323,7 @@
<xsl:text>$contract->iterateValues( '</xsl:text>
<xsl:value-of select="$from" />
<xsl:text>', </xsl:text>
<xsl:text>function( $contract ) {</xsl:text>
<xsl:text>function( $contract ) use( $line_code ) {</xsl:text>
<xsl:text> return array(</xsl:text>
<xsl:apply-templates mode="lvmp:render" />
<xsl:text>);</xsl:text>
@ -334,7 +342,7 @@
<xsl:text>$contract->iterateValues( '</xsl:text>
<xsl:value-of select="$from" />
<xsl:text>', </xsl:text>
<xsl:text>function( $contract ) {</xsl:text>
<xsl:text>function( $contract ) use( $line_code ) {</xsl:text>
<xsl:text> return </xsl:text>
<xsl:apply-templates mode="lvmp:render" select="lvmp:condition" />
<xsl:text>;</xsl:text>