<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:dateFN="date-function">
	<msxsl:script language="javascript" implements-prefix="dateFN"><![CDATA[

			function today() {
				var dt = Date.parse(Date());
				return (25567 + 693596) + (Math.floor(dt / (1000 * 60 * 60 * 24)));
				//return dt;
			}

			function julDate(s) {
				var ms = Date.parse(s);
				return (25567 + 693596) + (Math.floor(ms / (1000 * 60 * 60 * 24)));
				//return s;
			}

		]]></msxsl:script>
	<xsl:template match="/">
		<arinpchg>
			<xsl:apply-templates select="cvlink_response/cv_generic_invoice_custom_export_response/invoice_custom/invoice"/>
		</arinpchg>
	</xsl:template>
	<xsl:template match="invoice">
		<trx_ctrl_num>
			<xsl:text>SV</xsl:text>
			<xsl:value-of select="invoice_no"/>
		</trx_ctrl_num>
		<doc_ctrl_num>
			<xsl:text>SV</xsl:text>
			<xsl:value-of select="invoice_no"/>
		</doc_ctrl_num>
		<doc_desc>
			<xsl:value-of select="doc_type"/>
		</doc_desc>
		<apply_to_num>
			<xsl:text>SV</xsl:text>
			<xsl:value-of select="invoice_no"/>
		</apply_to_num>
		<apply_trx_type>2021</apply_trx_type>
		<order_ctrl_num>
			<xsl:value-of select="doc_no"/>
		</order_ctrl_num>
		<batch_code>
			<xsl:value-of select="batch_no"/>
		</batch_code>
		<date_entered>
			<xsl:value-of select="dateFN:today()"/>
		</date_entered>
		<date_applied>
			<xsl:value-of select="dateFN:julDate(string(invoice_date))"/>
		</date_applied>
		<date_doc>
			<xsl:value-of select="dateFN:julDate(string(invoice_date))"/>
		</date_doc>
		<date_shipped>
			<xsl:value-of select="dateFN:julDate(string(invoice_date))"/>
		</date_shipped>
		<date_due>
			<xsl:value-of select="dateFN:julDate(string(due_date))"/>
		</date_due>
		<date_required>
			<xsl:value-of select="dateFN:julDate(string(due_date))"/>
		</date_required>
		<date_aging>
			<xsl:value-of select="dateFN:julDate(string(invoice_date))"/>
		</date_aging>
		<trx_type>2021</trx_type>
		<customer_code>
			<xsl:value-of select="bus_code"/>
		</customer_code>
		<ship_to_code>
			<xsl:text>&#x20;</xsl:text>
		</ship_to_code>
		<salesperson_code>
			<xsl:value-of select="salesrep_code"/>
		</salesperson_code>
		<territory_code>
			<xsl:value-of select="branch_code"/>
		</territory_code>
		<terms_code>
			<xsl:value-of select="terms_code"/>
		</terms_code>
		<dest_zone_code>zzz</dest_zone_code>
		<posting_code>
			<xsl:value-of select="branch_code"/>
		</posting_code>
		<recurring_flag>0</recurring_flag>
		<tax_code>
			<xsl:value-of select="tax_code"/>
		</tax_code>
		<cust_po_num>
			<xsl:value-of select="customer_po"/>
		</cust_po_num>
		<amt_gross>
			<xsl:value-of select="sub_amt"/>
		</amt_gross>
		<amt_tax>
			<xsl:value-of select="tax_total_amt"/>
		</amt_tax>
		<amt_net>
			<xsl:value-of select="total_amt"/>
		</amt_net>
		<amt_due>
			<xsl:value-of select="total_amt"/>
		</amt_due>
		<printed_flag>0</printed_flag>
		<posted_flag>0</posted_flag>
		<hold_flag>0</hold_flag>
		<user_id>1</user_id>
		<customer_addr1>
			<xsl:value-of select="cust_name"/>
		</customer_addr1>
		<customer_addr2>
			<xsl:value-of select="addr1"/>
		</customer_addr2>
		<customer_addr3>
			<xsl:value-of select="addr2"/>
		</customer_addr3>
		<customer_addr4>
			<xsl:value-of select="addr3"/>
		</customer_addr4>
		<customer_addr5>
			<xsl:value-of select="city"/>
			<xsl:text>,</xsl:text>
			<xsl:text/>
			<xsl:value-of select="state_code"/>
			<xsl:text/>
			<xsl:value-of select="postal_code"/>
		</customer_addr5>
		<ship_to_addr1>
			<xsl:value-of select="sell_to_cust_name"/>
		</ship_to_addr1>
		<ship_to_addr2>
			<xsl:value-of select="sell_to_addr1"/>
		</ship_to_addr2>
		<ship_to_addr3>
			<xsl:value-of select="sell_to_addr2"/>
		</ship_to_addr3>
		<ship_to_addr4>
			<xsl:value-of select="sell_to_addr3"/>
		</ship_to_addr4>
		<ship_to_addr5>
			<xsl:value-of select="sell_to_city"/>
			<xsl:text>,</xsl:text>
			<xsl:text/>
			<xsl:value-of select="sell_to_state_code"/>
			<xsl:text/>
			<xsl:value-of select="sell_to_postal_code"/>
		</ship_to_addr5>
		<attention_name>
			<xsl:value-of select="sell_to_contact_first_name"/>
			<xsl:text/>
			<xsl:value-of select="sell_to_contact_last_name"/>
		</attention_name>
		<attention_phone>
			<xsl:choose>
				<xsl:when test="string-length(sell_to_contact_phone) = 10">
					<xsl:text>(</xsl:text>
					<xsl:value-of select="substring(sell_to_contact_phone,1,3)"/>
					<xsl:text>)</xsl:text>
					<xsl:value-of select="substring(sell_to_contact_phone,4,3)"/>
					<xsl:text>-</xsl:text>
					<xsl:value-of select="substring(sell_to_contact_phone,7,4)"/>
				</xsl:when>
				<xsl:when test="string-length(sell_to_contact_phone) = 20">
					<xsl:text>(</xsl:text>
					<xsl:value-of select="substring(sell_to_contact_phone,1,3)"/>
					<xsl:text>)</xsl:text>
					<xsl:value-of select="substring(sell_to_contact_phone,4,3)"/>
					<xsl:text>-</xsl:text>
					<xsl:value-of select="substring(sell_to_contact_phone,7,4)"/>
				</xsl:when>
				<xsl:otherwise/>
			</xsl:choose>
			<xsl:text>x:</xsl:text>
			<xsl:value-of select="sell_to_contact_phone_ext"/>
		</attention_phone>
		<nat_cur_code>USD</nat_cur_code>
		<rate_type_home>BUY</rate_type_home>
		<rate_type_oper>BUY</rate_type_oper>
		<rate_home>1</rate_home>
		<rate_oper>1</rate_oper>
	</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2005. Progress Software Corporation. All rights reserved.
<metaInformation>
<scenarios ><scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="CV Invoice 235539.xml" htmlbaseurl="" outputurl="" processortype="internal" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="ATF.xsd" destSchemaRoot="arinpchg" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no" ><SourceSchema srcSchemaPath="CV Invoice 235539.xml" srcSchemaRoot="invoice" AssociatedInstance="" loaderFunction="document" loaderFunctionUsesURI="no"/></MapperInfo><MapperBlockPosition><template match="/"><block path="arinpchg/xsl:apply&#x2D;templates" x="439" y="18"/></template><template match="/cvlink_response/cv_generic_invoice_custom_export_response/invoice_custom/invoice"><block path="arinpchg/trx_ctrl_num/xsl:value&#x2D;of" x="439" y="36"/><block path="arinpchg/doc_desc/xsl:value&#x2D;of" x="439" y="72"/><block path="arinpchg/apply_to_num/xsl:value&#x2D;of" x="479" y="90"/><block path="arinpchg/order_ctrl_num/xsl:value&#x2D;of" x="439" y="126"/><block path="arinpchg/batch_code/xsl:value&#x2D;of" x="479" y="144"/><block path="arinpchg/date_entered/xsl:value&#x2D;of" x="439" y="180"/><block path="arinpchg/date_applied/xsl:value&#x2D;of" x="439" y="270"/><block path="arinpchg/date_doc/xsl:value&#x2D;of" x="479" y="288"/><block path="arinpchg/date_shipped/xsl:value&#x2D;of" x="439" y="306"/><block path="arinpchg/date_due/xsl:value&#x2D;of" x="359" y="165"/><block path="arinpchg/date_required/xsl:value&#x2D;of" x="399" y="165"/><block path="arinpchg/date_aging/xsl:value&#x2D;of" x="319" y="165"/><block path="arinpchg/customer_code/xsl:value&#x2D;of" x="279" y="165"/><block path="arinpchg/salesperson_code/xsl:value&#x2D;of" x="239" y="165"/><block path="arinpchg/territory_code/xsl:value&#x2D;of" x="199" y="165"/><block path="arinpchg/terms_code/xsl:value&#x2D;of" x="159" y="165"/><block path="arinpchg/posting_code/xsl:value&#x2D;of" x="119" y="165"/><block path="arinpchg/tax_code/xsl:value&#x2D;of" x="79" y="165"/><block path="arinpchg/cust_po_num/xsl:value&#x2D;of" x="39" y="165"/><block path="arinpchg/amt_gross/xsl:value&#x2D;of" x="399" y="125"/><block path="arinpchg/amt_tax/xsl:value&#x2D;of" x="359" y="125"/><block path="arinpchg/amt_net/xsl:value&#x2D;of" x="319" y="125"/><block path="arinpchg/amt_due/xsl:value&#x2D;of" x="279" y="125"/><block path="arinpchg/customer_addr1/xsl:value&#x2D;of" x="239" y="125"/><block path="arinpchg/customer_addr2/xsl:value&#x2D;of" x="199" y="125"/><block path="arinpchg/customer_addr3/xsl:value&#x2D;of" x="159" y="125"/><block path="arinpchg/customer_addr4/xsl:value&#x2D;of" x="119" y="125"/><block path="arinpchg/customer_addr5/xsl:value&#x2D;of" x="79" y="125"/><block path="arinpchg/customer_addr5/xsl:value&#x2D;of[1]" x="39" y="125"/><block path="arinpchg/customer_addr5/xsl:value&#x2D;of[2]" x="399" y="85"/><block path="arinpchg/ship_to_addr1/xsl:value&#x2D;of" x="359" y="85"/><block path="arinpchg/ship_to_addr2/xsl:value&#x2D;of" x="319" y="85"/><block path="arinpchg/ship_to_addr3/xsl:value&#x2D;of" x="279" y="85"/><block path="arinpchg/ship_to_addr4/xsl:value&#x2D;of" x="239" y="85"/><block path="arinpchg/ship_to_addr5/xsl:value&#x2D;of" x="199" y="85"/><block path="arinpchg/ship_to_addr5/xsl:value&#x2D;of[1]" x="159" y="85"/><block path="arinpchg/ship_to_addr5/xsl:value&#x2D;of[2]" x="119" y="85"/><block path="arinpchg/attention_name/xsl:value&#x2D;of" x="79" y="85"/><block path="arinpchg/attention_name/xsl:value&#x2D;of[1]" x="39" y="85"/><block path="arinpchg/attention_phone/xsl:choose" x="409" y="15"/><block path="arinpchg/attention_phone/xsl:choose/=[0]" x="363" y="9"/><block path="arinpchg/attention_phone/xsl:choose/=[0]/string&#x2D;length[0]" x="317" y="3"/><block path="arinpchg/attention_phone/xsl:choose/xsl:when/xsl:value&#x2D;of" x="479" y="45"/><block path="arinpchg/attention_phone/xsl:choose/xsl:when/xsl:value&#x2D;of[1]" x="359" y="45"/><block path="arinpchg/attention_phone/xsl:choose/xsl:when/xsl:value&#x2D;of[2]" x="319" y="45"/><block path="arinpchg/attention_phone/xsl:choose/=[1]" x="363" y="17"/><block path="arinpchg/attention_phone/xsl:choose/=[1]/string&#x2D;length[0]" x="317" y="11"/><block path="arinpchg/attention_phone/xsl:choose/xsl:when[1]/xsl:value&#x2D;of" x="279" y="45"/><block path="arinpchg/attention_phone/xsl:choose/xsl:when[1]/xsl:value&#x2D;of[1]" x="239" y="45"/><block path="arinpchg/attention_phone/xsl:choose/xsl:when[1]/xsl:value&#x2D;of[2]" x="199" y="45"/><block path="arinpchg/attention_phone/xsl:choose/xsl:otherwise/xsl:value&#x2D;of" x="159" y="45"/><block path="arinpchg/attention_phone/xsl:value&#x2D;of" x="119" y="45"/></template><template match="invoice"><block path="date_entered/xsl:value&#x2D;of" x="318" y="58"/><block path="date_applied/xsl:value&#x2D;of" x="332" y="83"/><block path="date_doc/xsl:value&#x2D;of" x="346" y="110"/><block path="date_shipped/xsl:value&#x2D;of" x="360" y="136"/><block path="date_due/xsl:value&#x2D;of" x="388" y="188"/><block path="date_required/xsl:value&#x2D;of" x="374" y="162"/><block path="date_aging/xsl:value&#x2D;of" x="401" y="214"/><block path="attention_phone/xsl:choose" x="137" y="134"/><block path="attention_phone/xsl:choose/=[0]" x="80" y="115"/><block path="attention_phone/xsl:choose/=[0]/string&#x2D;length[0]" x="30" y="111"/><block path="attention_phone/xsl:choose/xsl:when/xsl:value&#x2D;of" x="401" y="341"/><block path="attention_phone/xsl:choose/xsl:when/xsl:value&#x2D;of[1]" x="367" y="311"/><block path="attention_phone/xsl:choose/xsl:when/xsl:value&#x2D;of[2]" x="332" y="277"/><block path="attention_phone/xsl:choose/=[1]" x="80" y="151"/><block path="attention_phone/xsl:choose/=[1]/string&#x2D;length[0]" x="32" y="147"/><block path="attention_phone/xsl:choose/xsl:when[1]/xsl:value&#x2D;of" x="294" y="239"/><block path="attention_phone/xsl:choose/xsl:when[1]/xsl:value&#x2D;of[1]" x="261" y="205"/><block path="attention_phone/xsl:choose/xsl:when[1]/xsl:value&#x2D;of[2]" x="228" y="171"/></template></MapperBlockPosition></MapperMetaTag>
</metaInformation>
-->