Your source didn't have a root element so I just chose:
Edit: Updated root element as mentioned in comment
<?xml version="1.0" encoding="UTF-8"?>
<Report_Data>
<Plan Id="01">
<Ledger>1</Ledger>
<Product>PRD-AAA</Product>
<Order_Amount>2480</Order_Amount>
<Invoice_Amount>496</Invoice_Amount>
</Plan>
<Plan Id="02">
<Ledger>2</Ledger>
<Product>PRD-BBB</Product>
<Order_Amount>9000</Order_Amount>
<Invoice_Amount>3000</Invoice_Amount>
</Plan>
<Plan Id="03">
<Product Id="PRD-X">
<Ledger>1</Ledger>
<Order_Amount>4500</Order_Amount>
<Invoice_Amount>1650</Invoice_Amount>
</Product>
<Product Id="PRD-Y">
<Ledger>1</Ledger>
<Order_Amount>550</Order_Amount>
<Invoice_Amount>866</Invoice_Amount>
</Product>
<Product Id="PRD-Z">
<Ledger>2</Ledger>
<Order_Amount>5000</Order_Amount>
<Invoice_Amount>1000</Invoice_Amount>
</Product>
<Product Id="PRD-A">
<Ledger>3</Ledger>
<Order_Amount>2500</Order_Amount>
<Invoice_Amount>1000</Invoice_Amount>
</Product>
</Plan>
</Report_Data>
With this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:output method="text"/>
<xsl:template match="Report_Data">
<xsl:apply-templates select="Plan"/>
</xsl:template>
<xsl:template match="Plan">
<xsl:choose>
<!-- Plan type 1, Id 1 and 2 -->
<xsl:when test="not(Product/@Id)">
<xsl:value-of select="@Id,Ledger,Product,Order_Amount,Invoice_Amount" separator=","/>
<xsl:text>
</xsl:text>
</xsl:when>
<!-- Plan type 2, Id 3-->
<xsl:otherwise>
<xsl:for-each-group select="Product" group-by="Ledger">
<xsl:value-of
select="for $i in current-group() return ($i/../@Id,$i/Ledger,$i/@Id,$i/Order_Amount,$i/Invoice_Amount)"
separator=","/>
<xsl:text>
</xsl:text>
</xsl:for-each-group>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
I get:
01,1,PRD-AAA,2480,496
02,2,PRD-BBB,9000,3000
03,1,PRD-X,4500,1650,03,1,PRD-Y,550,866
03,2,PRD-Z,5000,1000
03,3,PRD-A,2500,1000
Basically the value-of's
select the sequence of elements in the order you want to display them depending which plan type you have. With xslt-2.0 you can save yourself the delimeter and use the value-of's seprartor attribute instead.