View Categories

Category wise sales report with parent category and profit

4 min read

This template can be used to printer category wise sales report with it’s parent category and profit.

Maintenance > Resources
Use this template in Printer.CloseCash/Printer.PartialCash/Printer.CloseCashMail

<!-- CATEGORY SALE REPORT WITH PARENT CATEGORY START -->
        <line>
            <text bold="true">Category Sales Report</text>
        </line>
        <line>
            <text align ="left" length="23">Name</text>
            <text align ="left" length="10">Units</text>
            <text align ="right" length="15">Total</text>
        </line>
        <line>
            <text>------------------------------------------------</text>
        </line>

#set($cat = "@")
#set($parcat = "@")
#set($catTotal = 0)
#set($parcatTotal = 0)
#set($catUnits = 0)
#set($parcatUnits = 0)

#set($catcost = 0.00)
#set($parcatcost = 0.00)
#set($netcatcost = 0.00)

#set($catNetTotal = 0)
#set($catNetUnits = 0)
#set($flag = 0)

#foreach ($line in $payments.getProductSalesLines())

#if($cat.equals("@"))
#set($cat=$line.printCategoryName())
#set($parcat=$line.printParentCategoryName())
#end

#if (!$cat.equals($line.printCategoryName()))
#set($profit=$catTotal - $catcost)
#set($pct= $profit * 100 / $catcost)
        <line>
            <text align ="left" length="23">${cat}</text>
            <text align ="left" length="10">${catUnits}</text>
            <text align ="right" length="15">$payments.formatCurrency(${catTotal})</text>
        </line>
        <line>
            <text align ="left" length="20">Cost: $payments.formatCurrency(${catcost})</text>
            <text align ="left" length="28">Profit: $payments.formatCurrency(${profit}) ($payments.roundDouble($pct,2)%)</text>
        </line>

#set($parcatTotal = $catTotal + $parcatTotal)
#set($parcatUnits = $catUnits + $parcatUnits)
#set($parcatcost = $catcost + $parcatcost)
    
 #set($cat=$line.printCategoryName())
 #set($catTotal = $line.getProductPrice())
 #set($catUnits = $line.getProductUnits())
 #set($catcost = $line.getCost())

#if (!$parcat.equals($line.printParentCategoryName()))
#set($parprofit=$parcatTotal - $parcatcost)
#set($parpct= $profit * 100 / $parcatcost)
        <line>
            <text>------------------------------------------------</text>
        </line>
        <line>
            <text align ="left" bold="true" length="23">${parcat}</text>
            <text align ="left" bold="true" length="10">${parcatUnits}</text>
            <text align ="right" bold="true" length="15">$payments.formatCurrency(${parcatTotal})</text>
        </line>
        <line>
            <text align ="left" length="20" bold="true">Cost: $payments.formatCurrency(${parcatcost})</text>
            <text align ="left" length="28" bold="true">Profit: $payments.formatCurrency(${parprofit}) ($payments.roundDouble($parpct,2)%)</text>
        </line>
<line></line>

#set($parcat=$line.printParentCategoryName())
#set($parcatTotal = 0.00)
#set($parcatUnits = 0.00)
#set($parcatcost = 0.00)

#end

#else
 $flag=1
        #set($catTotal = $catTotal + $line.getProductPrice())
        #set($catUnits = $catUnits + $line.getProductUnits())
        #set($catcost = $catcost + $line.getCost())

#end
 #set($catNetTotal = $catNetTotal + $line.getProductPrice())
 #set($catNetUnits = $catNetUnits + $line.getProductUnits())
 #set($netcatcost = $netcatcost + $line.getCost())
#end

#set($profit=$catTotal - $catcost)
#set($pct= $profit * 100 / $catcost)
 <line>
            <text align ="left" length="23">${cat}</text>
            <text align ="left" length="10">${catUnits}</text>
            <text align ="right" length="15">$payments.formatCurrency(${catTotal})</text>
        </line>
        <line>
            <text align ="left" length="20">Cost: $payments.formatCurrency(${catcost})</text>
            <text align ="left" length="28">Profit: $payments.formatCurrency(${profit}) ($payments.roundDouble($pct,2)%)</text>
        </line>
        
#set($parcatTotal = $catTotal + $parcatTotal)
#set($parcatUnits = $catUnits + $parcatUnits)
#set($parprofit=$parcatTotal - $parcatcost)
#set($parpct= $profit * 100 / $parcatcost)

        <line>
            <text>------------------------------------------------</text>
        </line>
        <line>
            <text align ="left" bold="true" length="23">${parcat}</text>
            <text align ="left" bold="true" length="10">${parcatUnits}</text>
            <text align ="right" bold="true" length="15">$payments.formatCurrency(${parcatTotal})</text>
        </line>
        <line>
            <text align ="left" length="20" bold="true">Cost: $payments.formatCurrency(${parcatcost})</text>
            <text align ="left" length="28" bold="true">Profit: $payments.formatCurrency(${parprofit}) ($payments.roundDouble($parpct,2)%)</text>
        </line>
<line></line>

        <line>
            <text>------------------------------------------------</text>
        </line>
        <line>
            <text>------------------------------------------------</text>
        </line>

#set($netprofit=$catNetTotal - $netcatcost)
#set($netpct= $netprofit * 100 / $netcatcost)

        <line size="1">
            <text align ="left" length="23" bold="true">Total</text>
            <text align ="left" length="10" bold="true">${catNetUnits}</text>
            <text align ="right" length="15" bold="true">$payments.formatCurrency(${catNetTotal})</text>
        </line>
        <line size="1">
            <text align ="left" length="20" bold="true">Cost: $payments.formatCurrency(${netcatcost})</text>
            <text align ="left" length="28" bold="true">Profit: $payments.formatCurrency(${netprofit}) ($payments.roundDouble($netpct,2)%)</text>
        </line>
<!-- CATEGORY SALE REPORT WITH PARET CATEGORY END -->

Save & restart

0 Comments

Leave a Reply

Arrow-up