[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Calculate balance

Subject: Calculate balance
From: Shabbir Rahman <nitol_shabbir@xxxxxxxxx>
Date: Mon, 11 Mar 2002 05:35:14 -0800 (PST)
how to calculate opening balance
my xml file is

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"
href="ledgerbook.xsl"?>
<report>
    <date>
        <currentdate>11-Mar-2002</currentdate>
        <startdate>12-dec-02</startdate>
        <enddate>12-dec-02</enddate>
    </date>
    <ledgerbook>
        <openingbalance>-2000.0</openingbalance>
        <table>
            <row>
                <ledgerdate>12-DEC-2002</ledgerdate>
                <voucher>V1.1.3</voucher>
                <costcenter>Head Office</costcenter>
                <lccode />
                <description />
                <amount type="C">1000</amount>
            </row>
            <row>
                <ledgerdate>12-DEC-2002</ledgerdate>
                <voucher>V1.1.2</voucher>
                <costcenter>Head Office</costcenter>
                <lccode />
                <description />
                <amount type="C">1000</amount>
            </row>
            <row>
                <ledgerdate>12-DEC-2002</ledgerdate>
                <voucher>V1.2.1</voucher>
                <costcenter />
                <lccode />
                <description />
                <amount type="D">2000</amount>
            </row>
            <row>
                <ledgerdate>12-DEC-2002</ledgerdate>
                <voucher>V1.2.2</voucher>
                <costcenter />
                <lccode />
                <description />
                <amount type="D">2000</amount>
            </row>
        </table>
    </ledgerbook>
</report>

and my xsl file is

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:variable name="bal"
select="report/ledgerbook/openingbalance"/>

<xsl:template match="/">
	<html>
	<title>Ledger Book</title>
	<body>

		<xsl:apply-templates select="report/date"/>
		<xsl:apply-templates
select="report/ledgerbook/openingbalance"/>

		<table border="0" width="100%" align="center"
cellspacing="4">
			<tr>
				<th><u>Date</u></th>
				<th><u>Voucher No</u></th>
				<th><u>Cost Center</u></th>
				<th><u>L/C Code</u></th>
				<th>Description</th>
				<th><u>Dr.</u></th>
				<th><u>Cr.</u></th>
				<th><u>Balance</u></th>
			</tr>
			<xsl:for-each select="report/ledgerbook/table/row">
			<tr>
				<td><xsl:value-of select="ledgerdate"/></td>
				<td><xsl:value-of select="voucher"/></td>
				<td><xsl:value-of select="costcenter"/></td>
				<td><xsl:value-of select="lccode"/></td>
				<td><xsl:value-of select="description"/></td>
				<xsl:call-template name="amountplace"/>
			</tr>
			</xsl:for-each>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td colspan="2"><b>Closing Balance</b></td>
		</tr>
		</table> 
	</body>
	</html>	
</xsl:template>



<xsl:template match="report/date">
	<p align="right"><xsl:value-of
select="currentdate"/></p>
	<h1>Ledger Book</h1>
	<h3>From <xsl:value-of select="startdate"/> To
<xsl:value-of select="enddate"/></h3>
</xsl:template>


<xsl:template
match="report/ledgerbook/openingbalance">
	<p align="right"><b><xsl:text>Opening Balance :
</xsl:text>   </b>   <xsl:value-of select="$bal"/></p>
</xsl:template>

<xsl:template name="amountplace">
	<xsl:choose>
	<xsl:when test="amount[@type='D']">
		<td align="right"><xsl:value-of
select="amount"/></td>
		<td align="right"><xsl:text>-</xsl:text></td>
	</xsl:when>
	<xsl:otherwise>
		<td align="right"><xsl:text>-</xsl:text></td>
		<td align="right"><xsl:value-of
select="amount"/></td>
	</xsl:otherwise>
	</xsl:choose>
</xsl:template>

</xsl:stylesheet>


I want to put calculated value in the Blance column

of the table. I am expalining it in the natural
laguage 

x=openingbalance
balance[1]=x-debit[1]+credit[1]
balance[2=balance[1]-debit[2]+credit[2]
balance[3]=balance[2]-debit[3]+credit[3]
...
...

can any one give me the solve.



__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.