SHARE
TWEET

Untitled

a guest Jan 12th, 2017 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <ListOfAFGFINSApplicationIncomeandExpensesFormFill>
  2.           <AFGFINSApplicationIncomeandExpenses>
  3.               <AFGSubCategory>Rental Expense</AFGSubCategory>
  4.               <Amount>2000</Amount>
  5.               <Frequency>Quarterly</Frequency>
  6.            </AFGFINSApplicationIncomeandExpenses>
  7.  
  8.           <AFGFINSApplicationIncomeandExpenses>
  9.                 <AFGSubCategory>Child Maintenance Paid</AFGSubCategory>
  10.                 <Amount>1000</Amount>
  11.                 <Frequency>4 Weekly</Frequency>                    
  12.           </AFGFINSApplicationIncomeandExpenses>
  13.  
  14.          </ListOfAFGFINSApplicationIncomeandExpensesFormFill>
  15.    
  16. <xsl:template match="ListOfAFGFINSApplicationIncomeandExpensesFormFill/AFGFINSApplicationIncomeandExpenses
  17.     [AFGSubCategory = ('Child Maintenance Paid', 'Rental Expense')]" mode="OtherCommitment">
  18.  
  19.     <OtherCommitment
  20.         UniqueID="{fn:UniqueID(Id)}">
  21.  
  22.         <xsl:attribute name="Amount">
  23.             <xsl:apply-templates select="." mode="Amount"/>
  24.         </xsl:attribute>
  25.  
  26.         <xsl:attribute name="Frequency" select="fn:IncomeFrequency(Frequency)"/>
  27.  
  28.         <xsl:attribute name="Category">
  29.             <xsl:choose>
  30.                 <xsl:when test="AFGSubCategory = 'Child Maintenance Paid'">Child Maintenance</xsl:when>
  31.                 <xsl:when test="AFGSubCategory = 'Rental Expense'">Rent</xsl:when>
  32.             </xsl:choose>
  33.         </xsl:attribute>
  34.  
  35.     </OtherCommitment>
  36.    
  37. <xsl:template match="node()" mode="Amount">
  38.     <xsl:choose>
  39.         <xsl:when test="Frequency = '4 Weekly'">
  40.             <xsl:value-of select="(Amount * 13) div 12"/>
  41.         </xsl:when>
  42.         <xsl:when test="Frequency = 'Quarterly'">
  43.             <xsl:value-of select="Amount * 4"/>
  44.         </xsl:when>
  45.         <xsl:when test="Frequency != ''">
  46.             <xsl:value-of select="Amount"/>
  47.         </xsl:when>
  48.     </xsl:choose>
  49. </xsl:template>
  50.    
  51. <xsl:function name="fn:IncomeFrequency">
  52.     <xsl:param name="Frequency"/>
  53.     <xsl:choose>
  54.         <xsl:when test="$Frequency = '4 Weekly'">Monthly</xsl:when>
  55.         <xsl:when test="$Frequency = 'Annually'">Yearly</xsl:when>
  56.         <xsl:when test="$Frequency = 'Quarterly'">Yearly</xsl:when>
  57.         <xsl:when test="$Frequency != ''">
  58.             <xsl:value-of select="$Frequency"/>
  59.         </xsl:when>
  60.         <xsl:when test="$Frequency/../AFGAnnualAmount != ''">Yearly</xsl:when>
  61.     </xsl:choose>
  62. </xsl:function>
  63.    
  64. <OtherCommitment Amount="8000" Frequency="Yearly"
  65.               Category="Rent">
  66.          </OtherCommitment>
  67.          <OtherCommitment Amount="1083.3333333333333"
  68.                             Frequency="Monthly"
  69.                             Category="Child Maintenance">
  70.          </OtherCommitment>
  71.    
  72. <ListOfAFGFINSApplicationIncomeandExpensesFormFill>
  73.           <AFGFINSApplicationIncomeandExpenses>
  74.               <AFGSubCategory>Rental Expense</AFGSubCategory>
  75.               <Amount>2000</Amount>
  76.               <Frequency>Quarterly</Frequency>
  77.            </AFGFINSApplicationIncomeandExpenses>
  78.  
  79.            <AFGFINSApplicationIncomeandExpenses>
  80.               <AFGSubCategory>Rental Expense</AFGSubCategory>
  81.               <Amount>1000</Amount>
  82.               <Frequency>Mounthly</Frequency>
  83.            </AFGFINSApplicationIncomeandExpenses>
  84.  
  85.           <AFGFINSApplicationIncomeandExpenses>
  86.                 <AFGSubCategory>Child Maintenance Paid</AFGSubCategory>
  87.                 <Amount>1000</Amount>
  88.                 <Frequency>4 Weekly</Frequency>                    
  89.           </AFGFINSApplicationIncomeandExpenses>
  90.  
  91.          </ListOfAFGFINSApplicationIncomeandExpensesFormFill>
  92.    
  93. <OtherCommitment Amount="1666.6666666666667" Frequency="Monthly"
  94.           Category="Rent">
  95.      </OtherCommitment>
  96.     <!-- This will keep the first approach because is only one 'Child Maintenance'-->
  97.     <OtherCommitment Amount="1083.3333333333333"
  98.                         Frequency="Monthly"
  99.                         Category="Child Maintenance">
  100.      </OtherCommitment>
  101.    
  102. <xsl:template match="node()" mode="AmountMonthly">
  103.     <xsl:choose>
  104.         <xsl:when test="Frequency = 'Weekly'">
  105.             <xsl:value-of select="fn:remove-scientific-notation((Amount * 52) div 12)"/>
  106.         </xsl:when>
  107.         <xsl:when test="Frequency = 'Fortnightly'">
  108.             <xsl:value-of select="fn:remove-scientific-notation((Amount * 26) div 12)"/>
  109.         </xsl:when>
  110.         <xsl:when test="Frequency = '4 Weekly'">
  111.             <xsl:value-of select="fn:remove-scientific-notation((Amount * 13) div 12)"/>
  112.         </xsl:when>
  113.         <xsl:when test="Frequency = 'Monthly'">
  114.             <xsl:value-of select="Amount"/>
  115.         </xsl:when>
  116.         <xsl:when test="Frequency = 'Quarterly'">
  117.             <xsl:value-of select="fn:remove-scientific-notation((Amount * 4) div 12)"/>
  118.         </xsl:when>
  119.         <xsl:when test="Frequency = 'Annually'">
  120.             <xsl:value-of select="fn:remove-scientific-notation(Amount div 12)"/>
  121.         </xsl:when>
  122.     </xsl:choose>
  123. </xsl:template>
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top