xsl-list
[Top] [All Lists]

Sum a group of transactions, and determne debit or credit

2003-12-16 19:09:41
I've looked countless places for this answer, so I thought I'd throw it
out to the experts.  I truly appreciate any advice.  I basically have a
listing of transaction that are unsorted.  I need to sort by an account
code, then give a total of debits and credits on each account code, then
a final total of debits in credits.  Right now, I am able to break
between each account code, but I'm having trouble summating the totals.


Sample XML:

<ArrayOfAccountLineItem xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
  <AccountLineItem>
        <Name>Base Price</Name>
       <Amount>90</Amount>
       <GLAccountNumber>P3-325-23114-5223-33181</GLAccountNumber>
  </AccountLineItem>
  <AccountLineItem>
       <Name>Base Price</Name>
       <Amount>20</Amount>
       <GLAccountNumber>P3-325-23114-5246-33181</GLAccountNumber>
  </AccountLineItem>
  <AccountLineItem>
       <Name>Equipment Rental Price if Age &lt; 18</Name>
       <Amount>9</Amount>
       <GLAccountNumber>P3-325-23114-5408-33181</GLAccountNumber>
  </AccountLineItem>
  <AccountLineItem>
       <Name>Resident Discount</Name>
       <Amount>-5</Amount>
       <GLAccountNumber>P3-325-23114-5500-33181</GLAccountNumber>
  </AccountLineItem>
</ ArrayOfAccountLineItem>


Sample XSL:

<xsl:template match="ArrayOfAccountLineItem">
  <xsl:for-each select="AccountLineItem">
   <xsl:sort select="GLAccountNumber"/>
   <xsl:if test="position() &gt; 1">
    <xsl:choose>
        <xsl:when test="not(./GLAccountNumber =
preceding::GLAccountNumber) ">
--->IN THIS CASE, I NEED TO BREAK, AND PRINT THE SUM OF CREDITS(Amount >
0)
AND THE SUM OF DEBITS(Amount < 0) for all AccountLineItems/Amounts that
have the GLAccountNumber = preceding::GLAccountNumber

<close tags...>


Any help is greatly, greatly appreciated.



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>