svn commit: r803508 - in /ofbiz/trunk/applications/accounting: config/ entitydef/ webapp/ap/WEB-INF/ webapp/ap/WEB-INF/actions/invoices/ webapp/ap/invoices/ webapp/ap/reports/ widget/ap/ widget/ap/forms/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r803508 - in /ofbiz/trunk/applications/accounting: config/ entitydef/ webapp/ap/WEB-INF/ webapp/ap/WEB-INF/actions/invoices/ webapp/ap/invoices/ webapp/ap/reports/ widget/ap/ widget/ap/forms/

apatel-2
Author: apatel
Date: Wed Aug 12 13:48:26 2009
New Revision: 803508

URL: http://svn.apache.org/viewvc?rev=803508&view=rev
Log:
Improvements in the Invoice Generation for commission run functionality. Patch from OFBIZ-2806. Thanks Rishi and Amit for help.
Thanks Eva and Vince for requirements definition.

Added:
    ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/actions/invoices/CommissionReport.groovy
    ofbiz/trunk/applications/accounting/webapp/ap/invoices/CommissionReport.ftl   (with props)
    ofbiz/trunk/applications/accounting/webapp/ap/reports/
    ofbiz/trunk/applications/accounting/webapp/ap/reports/CommissionReport.fo.ftl   (with props)
    ofbiz/trunk/applications/accounting/widget/ap/ApPrintScreens.xml   (with props)
Modified:
    ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml
    ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
    ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/controller.xml
    ofbiz/trunk/applications/accounting/widget/ap/CommonScreens.xml
    ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml
    ofbiz/trunk/applications/accounting/widget/ap/Menus.xml
    ofbiz/trunk/applications/accounting/widget/ap/forms/InvoiceForms.xml

Modified: ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml?rev=803508&r1=803507&r2=803508&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml (original)
+++ ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml Wed Aug 12 13:48:26 2009
@@ -1874,10 +1874,18 @@
         <value xml:lang="th">ความคิดเห็น</value>
         <value xml:lang="zh">评论</value>
     </property>
+    <property key="AccountingCommissionAmount">
+        <value xml:lang="en">Commission Amount</value>
+        <value xml:lang="hi_IN">दलाली राशी</value>
+    </property>
     <property key="AccountingCommissionRun">
         <value xml:lang="en">Commission Run</value>
         <value xml:lang="hi_IN">दलाली भुगतान</value>
     </property>
+    <property key="AccountingCommissionReport">
+        <value xml:lang="en">Commission Report</value>
+        <value xml:lang="hi_IN">दलाली विवरण</value>
+    </property>
     <property key="AccountingCompanies">
         <value xml:lang="ar">شركات</value>
         <value xml:lang="de">Firmen</value>
@@ -5495,6 +5503,10 @@
         <value xml:lang="th">ค้นหาการชำระเงิน</value>
         <value xml:lang="zh">查找支付</value>
     </property>
+    <property key="AccountingLicensedProduct">
+        <value xml:lang="en">Licensed Product</value>
+        <value xml:lang="hi_IN">लाइसेंस उत्पाद</value>
+    </property>
     <property key="AccountingMainMenu">
         <value xml:lang="ar">الرئيسية</value>
         <value xml:lang="de">Haupt</value>
@@ -5706,6 +5718,10 @@
         <value xml:lang="th">รายได้สุทธิ</value>
         <value xml:lang="zh">净收入</value>
     </property>
+    <property key="AccountingNetSale">
+        <value xml:lang="en">Net Sale</value>
+        <value xml:lang="hi_IN">शुद्ध विक्रय</value>
+    </property>
     <property key="AccountingNewAccount">
         <value xml:lang="ar">حساب جديد</value>
         <value xml:lang="de">Neues Konto</value>
@@ -6292,6 +6308,10 @@
         <value xml:lang="th">หมายเลข</value>
         <value xml:lang="zh">数字</value>
     </property>
+    <property key="AccountingNumberOfOrders">
+        <value xml:lang="en">Number of Orders</value>
+        <value xml:lang="hi_IN">आदेशों की संख्या</value>
+    </property>
     <property key="AccountingNumberOfTransaction">
         <value xml:lang="de">Anzahl der Transaktionen</value>
         <value xml:lang="en">Number of Transaction</value>
@@ -8015,6 +8035,14 @@
         <value xml:lang="th">แสดงงานประเภทใบเสร็จการขายถึงรายได้ของหมายเลขบัญชีแยกประเภททั่วไป</value>
         <value xml:lang="zh">从销售发票类型到收入总账账户编号的指定列表</value>
     </property>
+    <property key="AccountingSalesAgents">
+        <value xml:lang="en">Sales Agents</value>
+        <value xml:lang="hi_IN">विक्रय दलाल</value>
+    </property>
+    <property key="AccountingSalesInvoices">
+        <value xml:lang="en">Sales Invoices</value>
+        <value xml:lang="hi_IN">विक्रय चालान </value>
+    </property>
     <property key="AccountingSecurityCodeCard">
         <value xml:lang="en">Card Security Code</value>
         <value xml:lang="es">Código de seguridad de tarjeta</value>
@@ -8439,6 +8467,10 @@
         <value xml:lang="th">รายงานผลรวมภาษี</value>
         <value xml:lang="zh">税务总表</value>
     </property>
+    <property key="AccountingTermAmount">
+        <value xml:lang="en">Term Amount</value>
+        <value xml:lang="hi_IN">शर्त राशी</value>
+    </property>
     <property key="AccountingTermTypeId">
         <value xml:lang="en">Term Type Id</value>
         <value xml:lang="es">Id TipoTérmino</value>
@@ -8455,6 +8487,10 @@
         <value xml:lang="en">Total amountPercentage is greater then 100.</value>
         <value xml:lang="hi_IN">कुल amountPercentage 100 से भी ज्यादा है</value>
     </property>
+    <property key="AccountingTotalCommissionAmount">
+        <value xml:lang="en">Total Commission Amount</value>
+        <value xml:lang="hi_IN">कुल दलाली राशी</value>
+    </property>
     <property key="AccountingTotalOfTheCurrentMonth">
         <value xml:lang="en">Total of the current month</value>
         <value xml:lang="hi_IN">चालू माह के कुल</value>
@@ -8567,6 +8603,14 @@
         <value xml:lang="th">Total excl. tax</value>
         <value xml:lang="zh">未含税合计</value>
     </property>
+    <property key="AccountingTotalNetSales">
+        <value xml:lang="en">Total Net Sales</value>
+        <value xml:lang="hi_IN">कुल शुद्ध विक्रय</value>
+    </property>
+    <property key="AccountingTotalNumberOfOrders">
+        <value xml:lang="en">Total Number of Orders</value>
+        <value xml:lang="hi_IN">कुल आदेशों की संख्या</value>
+    </property>
     <property key="AccountingTotalQuantityOnHand">
         <value xml:lang="en">Total Quantity On Hand</value>
         <value xml:lang="hi_IN">कुल मात्रा हाथ पर</value>

Modified: ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml?rev=803508&r1=803507&r2=803508&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml Wed Aug 12 13:48:26 2009
@@ -1571,6 +1571,17 @@
         </view-link>
     </view-entity>
 
+    <view-entity entity-name="InvoiceItemAndAssoc" package-name="org.ofbiz.accounting.invoice">
+        <member-entity entity-alias="INT" entity-name="InvoiceItem"/>
+        <member-entity entity-alias="IIA" entity-name="InvoiceItemAssoc"/>
+        <alias-all entity-alias="INT"/>
+        <alias-all entity-alias="IIA"/>
+        <alias name="termAmount" field="amount" entity-alias="IIA"/>
+        <view-link entity-alias="INT" rel-entity-alias="IIA" rel-optional="false">
+            <key-map field-name="invoiceId" rel-field-name="invoiceIdFrom"/>
+            <key-map field-name="invoiceItemSeqId" rel-field-name="invoiceItemSeqIdFrom"/>
+        </view-link>
+    </view-entity>
   <!-- ========================================================= -->
   <!-- org.ofbiz.accounting.ledger -->
   <!-- ========================================================= -->

Added: ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/actions/invoices/CommissionReport.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/actions/invoices/CommissionReport.groovy?rev=803508&view=auto
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/actions/invoices/CommissionReport.groovy (added)
+++ ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/actions/invoices/CommissionReport.groovy Wed Aug 12 13:48:26 2009
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.base.util.UtilMisc;
+
+if ("Y".equals(parameters.isSearch)) {
+    fromDate = parameters.fromDate;
+    thruDate = parameters.thruDate;
+    partyId = parameters.partyId;
+    productId = parameters.productId;
+    invoiceItemAndAssocCond = [];
+    if (productId) {
+        invoiceItemAndAssocCond.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId));
+    }
+    if (partyId) {
+        invoiceItemAndAssocCond.add(EntityCondition.makeCondition("partyIdFrom", EntityOperator.EQUALS, partyId));
+    }
+    if (fromDate) {
+        invoiceItemAndAssocCond.add(EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, Timestamp.valueOf(fromDate)));
+    }
+    if (thruDate) {
+        invoiceItemAndAssocCond.add(EntityCondition.makeCondition("thruDate", EntityOperator.LESS_THAN_EQUAL_TO, Timestamp.valueOf(thruDate)));
+    }
+    invoiceItemAndAssocList = [];
+    invoiceItemAndAssocList = delegator.findList("InvoiceItemAndAssoc", EntityCondition.makeCondition(invoiceItemAndAssocCond, EntityOperator.AND), null, null, null, false);
+
+    //filtering invoiceItemAndAssocList for each productId with updating quantity, commission amount and number of order which generated sales invoices.
+    totalQuantity = BigDecimal.ZERO;
+    totalNumberOfOrders = BigDecimal.ZERO;
+    totalCommissionAmount = BigDecimal.ZERO;
+    totalNetSales = BigDecimal.ZERO;
+    commissionReportList = [];
+    if (invoiceItemAndAssocList) {
+        productIds = EntityUtil.getFieldListFromEntityList(invoiceItemAndAssocList, "productId", true);
+        productIds.each { productId ->
+            quantity = BigDecimal.ZERO;
+            commissionAmount = BigDecimal.ZERO;
+            termAmount = BigDecimal.ZERO;
+            invoiceItemProductAmount = BigDecimal.ZERO;
+            assocProductId = null;
+            commissionReportMap = [:];
+            salesAgentAndTermAmtMap = [:];
+            salesInvoiceIds = [];
+            invoiceItemAndAssocList.each { invoiceItemAndAssoc ->
+                if (productId.equals(invoiceItemAndAssoc.productId)) {
+                    partyIdTermAmountMap = [:];
+                    partyIdTermAmountKey = null;
+                    assocProductId = invoiceItemAndAssoc.productId;
+                    quantity = quantity.add(invoiceItemAndAssoc.quantity);
+                    commissionAmount = commissionAmount.add(invoiceItemAndAssoc.termAmount.multiply(invoiceItemAndAssoc.quantity));
+                    termAmount = termAmount.add(invoiceItemAndAssoc.termAmount);
+                    partyIdTermAmountMap.partyId = invoiceItemAndAssoc.partyIdFrom;
+                    partyIdTermAmountMap.termAmount = invoiceItemAndAssoc.termAmount;
+                    partyIdTermAmountKey = invoiceItemAndAssoc.partyIdFrom + invoiceItemAndAssoc.termAmount;
+                    if (!salesAgentAndTermAmtMap.containsKey(partyIdTermAmountKey)) {
+                        salesAgentAndTermAmtMap.put(partyIdTermAmountKey, partyIdTermAmountMap);
+                    }
+                    salesInvoiceIds.add(invoiceItemAndAssoc.invoiceIdFrom);
+                    invoiceItemProductAmount = invoiceItemAndAssoc.amount;
+                }
+            }
+            commissionReportMap.productId = assocProductId;
+            commissionReportMap.quantity = quantity;
+            commissionReportMap.salesAgentAndTermAmtMap = salesAgentAndTermAmtMap;
+            commissionReportMap.commissionAmount = commissionAmount;
+            commissionReportMap.netSale = invoiceItemProductAmount.multiply(quantity);
+            commissionReportMap.salesInvoiceIds = salesInvoiceIds;
+            commissionReportMap.numberOfOrders = salesInvoiceIds.size();
+            commissionReportList.add(commissionReportMap);
+            totalQuantity = totalQuantity.add(quantity);
+            totalNumberOfOrders = totalNumberOfOrders.add(salesInvoiceIds.size());
+            totalCommissionAmount = totalCommissionAmount.add(commissionAmount);
+            totalNetSales = totalNetSales.add(invoiceItemProductAmount.multiply(quantity));
+        }
+    }
+    context.commissionReportList = commissionReportList;
+    context.totalQuantity = totalQuantity;
+    context.totalNumberOfOrders = totalNumberOfOrders;
+    context.totalCommissionAmount = totalCommissionAmount;
+    context.totalNetSales = totalNetSales;
+}

Modified: ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/controller.xml?rev=803508&r1=803507&r2=803508&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/controller.xml Wed Aug 12 13:48:26 2009
@@ -87,6 +87,10 @@
         <response name="success" type="view" value="editPayment"/>
         <response name="error" type="view" value="NewOutgoingPayment"/>
     </request-map>
+    <request-map uri="FindCommissions">
+        <security https="true" auth="true"/>
+        <response name="success" type="view" value="CommissionReport"/>
+    </request-map>
     <request-map uri="newInvoice">
         <security https="true" auth="true"/>
         <response name="success" type="view" value="NewPurchaseInvoice"/>
@@ -114,6 +118,12 @@
         <response name="error" type="view" value="FindVendors"/>
     </request-map>
 
+    <!-- ================ PDF generation requests ================== -->
+    <request-map uri="CommissionReport.pdf">
+        <security https="true" auth="true"/>
+        <response name="success" type="view" value="CommissionReportPdf"/>
+    </request-map>
+
     <!-- end of request mappings -->
 
     <!-- View Mappings -->
@@ -124,6 +134,11 @@
     <view-map name="NewPurchaseInvoice" type="screen" page="component://accounting/widget/ap/InvoiceScreens.xml#NewPurchaseInvoice"/>
     <view-map name="FindApPayments" type="screen" page="component://accounting/widget/ap/ApScreens.xml#FindApPayments"/>
     <view-map name="NewOutgoingPayment" type="screen" page="component://accounting/widget/ap/ApScreens.xml#NewOutgoingPayment"/>
+    <view-map name="CommissionReport" type="screen" page="component://accounting/widget/ap/InvoiceScreens.xml#CommissionReport"/>
+
+    <!-- PDFs  -->
+    <view-map name="CommissionReportPdf" type="screenfop" page="component://accounting/widget/ap/ApPrintScreens.xml#CommissionReportPdf" content-type="application/pdf" encoding="none"/>
+
     <!-- Vendor Mappings -->
     <view-map name="FindVendors" type="screen" page="component://accounting/widget/ap/CommonScreens.xml#FindVendors"/>
     <view-map name="EditVendor" type="screen" page="component://accounting/widget/ap/CommonScreens.xml#EditVendor"/>

Added: ofbiz/trunk/applications/accounting/webapp/ap/invoices/CommissionReport.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/ap/invoices/CommissionReport.ftl?rev=803508&view=auto
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/ap/invoices/CommissionReport.ftl (added)
+++ ofbiz/trunk/applications/accounting/webapp/ap/invoices/CommissionReport.ftl Wed Aug 12 13:48:26 2009
@@ -0,0 +1,78 @@
+<#--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<#if commissionReportList?has_content>
+  <form name="CommissionReport" id="CommissionReport">
+    <div>
+      <a href="<@ofbizUrl>CommissionReport.pdf?isSearch=Y&productId=${parameters.productId!}&partyId=${parameters.partyId!}&fromDate=${parameters.fromDate!}&thruDate=${parameters.thruDate!}</@ofbizUrl>" class="buttontext">${uiLabelMap.AccountingInvoicePDF}</a>
+    </div>
+    <table class="basic-table hover-bar" cellspacing="0">
+      <#-- Header Begins -->
+      <tr class="header-row-2">
+        <th>${uiLabelMap.AccountingLicensedProduct}</th>
+        <th>${uiLabelMap.AccountingQuantity}</th>
+        <th>${uiLabelMap.AccountingNumberOfOrders} / ${uiLabelMap.AccountingSalesInvoices}</th>
+        <th>${uiLabelMap.AccountingCommissionAmount}</th>
+        <th>${uiLabelMap.AccountingNetSale}</th>
+        <th>${uiLabelMap.AccountingSalesAgents} / ${uiLabelMap.AccountingTermAmount}</th>
+      </tr>
+      <#-- Header Ends-->
+      <#assign alt_row = false>
+      <#list commissionReportList as commissionReport>
+        <tr valign="middle"<#if alt_row> class="alternate-row"</#if>>
+          <td><a href="/catalog/control/EditProduct?productId=${commissionReport.productId!}">${commissionReport.productId!}</a></td>
+          <td>${commissionReport.quantity!}</td>
+          <td>
+            ${commissionReport.numberOfOrders!} /
+            <#list commissionReport.salesInvoiceIds as salesInvoiceId>
+              [<a href="/ap/control/invoiceOverview?invoiceId=${salesInvoiceId!}">${salesInvoiceId!}</a>]
+            </#list>
+          </td>
+          <td><@ofbizCurrency amount = commissionReport.commissionAmount!/></td>
+          <td><@ofbizCurrency amount = commissionReport.netSale!/></td>
+          <td>
+            <#if commissionReport.salesAgentAndTermAmtMap?has_content>
+              <#list commissionReport.salesAgentAndTermAmtMap.values() as partyIdAndTermAmountMap>
+                <#assign partyName = (delegator.findOne("PartyNameView", {"partyId" : partyIdAndTermAmountMap.partyId}, true))!>
+                <h6>[${(partyName.firstName)!} ${(partyName.lastName)!} ${(partyName.groupName)!}(<a href="/partymgr/control/viewprofile?partyId=${partyIdAndTermAmountMap.partyId!}">${partyIdAndTermAmountMap.partyId!}</a>)]
+                  / <@ofbizCurrency amount = (partyIdAndTermAmountMap.termAmount)!/>
+                </h6>
+              </#list>
+            </#if>
+          </td>
+        </tr>
+        <#-- toggle the row color -->
+        <#assign alt_row = !alt_row>
+      </#list>
+    </table>
+    <div class="screenlet">
+      <ul>
+        <li class="label"></li>
+        <li class="label"><h3>${uiLabelMap.CommonSummary} :</h3></li>
+        <li class="label"></li>
+        <li class="label">${uiLabelMap.ManufacturingTotalQuantity} : ${totalQuantity!}</li>
+        <li class="label">${uiLabelMap.AccountingTotalCommissionAmount} : <@ofbizCurrency amount = totalCommissionAmount!/></li>
+        <li class="label">${uiLabelMap.AccountingTotalNetSales} : <@ofbizCurrency amount = totalNetSales!/></li>
+        <li class="label">${uiLabelMap.AccountingTotalNumberOfOrders} : ${totalNumberOfOrders!}</li>
+      </ul>
+    </div>
+  </form>
+<#else>
+  <td colspan='4'><h3>${uiLabelMap.AccountingNoRecordFound}</h3></td>
+</#if>

Propchange: ofbiz/trunk/applications/accounting/webapp/ap/invoices/CommissionReport.ftl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/accounting/webapp/ap/invoices/CommissionReport.ftl
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/trunk/applications/accounting/webapp/ap/invoices/CommissionReport.ftl
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/trunk/applications/accounting/webapp/ap/reports/CommissionReport.fo.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/ap/reports/CommissionReport.fo.ftl?rev=803508&view=auto
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/ap/reports/CommissionReport.fo.ftl (added)
+++ ofbiz/trunk/applications/accounting/webapp/ap/reports/CommissionReport.fo.ftl Wed Aug 12 13:48:26 2009
@@ -0,0 +1,110 @@
+<#--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<#escape x as x?xml>
+  <fo:block font-size="14pt" font-weight="bold" text-align="center">${uiLabelMap.AccountingCommissionReport}</fo:block>
+  <fo:block space-after="20pt"/>
+  <fo:table table-layout="fixed" font-size="10pt">
+    <fo:table-column column-width="35mm"/>
+    <fo:table-column column-width="20mm"/>
+    <fo:table-column column-width="35mm"/>
+    <fo:table-column column-width="25mm"/>
+    <fo:table-column column-width="20mm"/>
+    <fo:table-column column-width="60mm"/>
+    <fo:table-header height="14px">
+      <fo:table-row>
+        <fo:table-cell border-bottom-style="solid" border-bottom-width="thin" border-bottom-color="black">
+          <fo:block font-weight="bold">${uiLabelMap.AccountingLicensedProduct}</fo:block>
+        </fo:table-cell>
+        <fo:table-cell border-bottom-style="solid" border-bottom-width="thin" border-bottom-color="black">
+          <fo:block font-weight="bold">${uiLabelMap.AccountingQuantity}</fo:block>
+        </fo:table-cell>
+        <fo:table-cell border-bottom-style="solid" border-bottom-width="thin" border-bottom-color="black">
+          <fo:block font-weight="bold">${uiLabelMap.AccountingNumberOfOrders} / ${uiLabelMap.AccountingSalesInvoices}</fo:block>
+        </fo:table-cell>
+        <fo:table-cell border-bottom-style="solid" border-bottom-width="thin" border-bottom-color="black">
+          <fo:block font-weight="bold">${uiLabelMap.AccountingCommissionAmount}</fo:block>
+        </fo:table-cell>
+        <fo:table-cell border-bottom-style="solid" border-bottom-width="thin" border-bottom-color="black">
+          <fo:block font-weight="bold">${uiLabelMap.AccountingNetSale}</fo:block>
+        </fo:table-cell>
+        <fo:table-cell  border-bottom-style="solid" border-bottom-width="thin" border-bottom-color="black">
+          <fo:block font-weight="bold">${uiLabelMap.AccountingSalesAgents} / ${uiLabelMap.AccountingTermAmount}</fo:block>
+        </fo:table-cell>
+      </fo:table-row>
+    </fo:table-header>
+    <fo:table-body font-size="10pt" height="500px">
+      <#if commissionReportList?has_content>
+        <#list commissionReportList as commissionReport>
+          <fo:table-row height="14px">
+            <fo:table-cell>
+              <fo:block>${commissionReport.productId!}</fo:block>
+            </fo:table-cell>
+            <fo:table-cell>
+              <fo:block>${commissionReport.quantity!}</fo:block>
+            </fo:table-cell>
+            <fo:table-cell>
+              <fo:block>${commissionReport.numberOfOrders!} / ${commissionReport.salesInvoiceIds!}</fo:block>
+            </fo:table-cell>
+            <fo:table-cell>
+              <fo:block><@ofbizCurrency amount = commissionReport.commissionAmount!/></fo:block>
+            </fo:table-cell>
+            <fo:table-cell>
+              <fo:block><@ofbizCurrency amount = commissionReport.netSale!/></fo:block>
+            </fo:table-cell>
+            <fo:table-cell>
+              <#if commissionReport.salesAgentAndTermAmtMap?has_content>
+                <#list commissionReport.salesAgentAndTermAmtMap.values() as partyIdAndTermAmountMap>
+                  <#assign partyName = (delegator.findOne("PartyNameView", {"partyId" : partyIdAndTermAmountMap.partyId}, true))!>
+                  <fo:block>
+                    [${(partyName.firstName)!} ${(partyName.lastName)!} ${(partyName.groupName)!} (${partyIdAndTermAmountMap.partyId!})] / <@ofbizCurrency amount = (partyIdAndTermAmountMap.termAmount)!/>
+                  </fo:block>
+                </#list>
+              </#if>
+            </fo:table-cell>
+          </fo:table-row>
+        </#list>
+      <#else>
+        <fo:table-row height="14px">
+          <fo:table-cell number-columns-spanned="5">
+            <fo:block space-after="10pt"/>
+            <fo:block text-align="center">${uiLabelMap.AccountingNoRecordFound}</fo:block>
+          </fo:table-cell>
+        </fo:table-row>
+      </#if>
+    </fo:table-body>
+ </fo:table>
+ <fo:block space-after="50pt"/>
+ <#if commissionReportList?has_content && totalQuantity?has_content && totalCommissionAmount?has_content && totalNetSales?has_content && totalNumberOfOrders?has_content>
+   <fo:table font-size="14pt">
+     <fo:table-body font-size="10pt">
+       <fo:table-row>
+         <fo:table-cell>
+           <fo:block font-size="14pt" font-weight="bold">${uiLabelMap.CommonSummary} :</fo:block>
+           <fo:block space-after="10pt"/>
+           <fo:block font-weight="bold">${uiLabelMap.ManufacturingTotalQuantity} : ${totalQuantity!}</fo:block>
+           <fo:block font-weight="bold">${uiLabelMap.AccountingTotalCommissionAmount} : <@ofbizCurrency amount = totalCommissionAmount!/></fo:block>
+           <fo:block font-weight="bold">${uiLabelMap.AccountingTotalNetSales} : <@ofbizCurrency amount = totalNetSales!/></fo:block>
+           <fo:block font-weight="bold">${uiLabelMap.AccountingTotalNumberOfOrders} : ${totalNumberOfOrders!}</fo:block>
+         </fo:table-cell>
+       </fo:table-row>
+     </fo:table-body>
+   </fo:table>
+ </#if>
+</#escape>

Propchange: ofbiz/trunk/applications/accounting/webapp/ap/reports/CommissionReport.fo.ftl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/accounting/webapp/ap/reports/CommissionReport.fo.ftl
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/trunk/applications/accounting/webapp/ap/reports/CommissionReport.fo.ftl
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/trunk/applications/accounting/widget/ap/ApPrintScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ap/ApPrintScreens.xml?rev=803508&view=auto
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ap/ApPrintScreens.xml (added)
+++ ofbiz/trunk/applications/accounting/widget/ap/ApPrintScreens.xml Wed Aug 12 13:48:26 2009
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">
+
+    <screen name="CommissionReportPdf">
+        <section>
+            <actions>
+                <property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>
+                <property-map resource="AccountingUiLabels" map-name="uiLabelMap" global="true"/>
+                <property-map resource="ManufacturingUiLabels" map-name="uiLabelMap" global="true"/>
+                <script location="component://accounting/webapp/ap/WEB-INF/actions/invoices/CommissionReport.groovy"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="FoReportDecorator" location="component://common/widget/CommonScreens.xml">
+                    <decorator-section name="topLeft">
+                        <include-screen name="CompanyLogo" location="component://order/widget/ordermgr/OrderPrintScreens.xml"/>
+                    </decorator-section>
+                    <decorator-section name="body">
+                        <platform-specific>
+                            <xsl-fo><html-template location="component://accounting/webapp/ap/reports/CommissionReport.fo.ftl"/></xsl-fo>
+                        </platform-specific>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
+</screens>

Propchange: ofbiz/trunk/applications/accounting/widget/ap/ApPrintScreens.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/accounting/widget/ap/ApPrintScreens.xml
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/trunk/applications/accounting/widget/ap/ApPrintScreens.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: ofbiz/trunk/applications/accounting/widget/ap/CommonScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ap/CommonScreens.xml?rev=803508&r1=803507&r2=803508&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ap/CommonScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ap/CommonScreens.xml Wed Aug 12 13:48:26 2009
@@ -24,6 +24,7 @@
                 <property-map resource="AccountingUiLabels" map-name="uiLabelMap" global="true"/>
                 <property-map resource="PartyUiLabels" map-name="uiLabelMap" global="true"/>
                 <property-map resource="OrderUiLabels" map-name="uiLabelMap" global="true"/>
+                <property-map resource="ManufacturingUiLabels" map-name="uiLabelMap" global="true"/>
                 <set field="layoutSettings.companyName" from-field="uiLabelMap.AccountingApCompanyName" global="true"/>
                 <set field="layoutSettings.companySubtitle" from-field="uiLabelMap.AccountingCompanySubtitle" global="true"/>
                 <set field="applicationMenuName" value="ApAppBar" global="true"/>
@@ -324,4 +325,24 @@
         </section>
     </screen>
 
+    <screen name="CommonApReportDecorator">
+        <section>
+            <actions>
+                <set field="headerItem" value="reports"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="main-decorator" location="${parameter.mainDecoratorLocation}">
+                    <decorator-section name="body">
+                        <section>
+                            <widgets>
+                                <include-menu name="ApReportTabBar" location="component://accounting/widget/ap/Menus.xml"/>
+                                <container style="clear"/>
+                                <decorator-section-include name="body"/>
+                            </widgets>
+                        </section>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
 </screens>
\ No newline at end of file

Modified: ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml?rev=803508&r1=803507&r2=803508&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml Wed Aug 12 13:48:26 2009
@@ -24,17 +24,21 @@
     <screen name="ListReports">
         <section>
             <actions>
-                <set field="headerItem" value="reports"/>
                 <set field="titleProperty" value="AccountingArPageTitleListReports"/>
                 <set field="viewIndex" from-field="parameters.VIEW_INDEX" type="Integer"/>
+                <set field="tabButtonItem" value="viewReports"/>
                 <set field="viewSize" from-field="parameters.VIEW_SIZE" type="Integer" default-value="10"/>
             </actions>
             <widgets>
-                <decorator-screen name="main-decorator" location="component://accounting/widget/ap/CommonScreens.xml">
+                <decorator-screen name="CommonApReportDecorator" location="${parameters.mainDecoratorLocation}">
                     <decorator-section name="body">
-                        <screenlet title="${uiLabelMap.AccountingReports}" navigation-form-name="ListReports">
-                            <include-form name="ListReports" location="component://accounting/widget/ap/forms/InvoiceForms.xml"/>
-                        </screenlet>
+                        <section>
+                            <widgets>
+                                <screenlet title="${uiLabelMap.AccountingReports}" navigation-form-name="ListReports">
+                                    <include-form name="ListReports" location="component://accounting/widget/ap/forms/InvoiceForms.xml"/>
+                                </screenlet>
+                            </widgets>
+                        </section>
                     </decorator-section>
                 </decorator-screen>
             </widgets>
@@ -175,4 +179,34 @@
             </widgets>
         </section>
     </screen>
+
+    <screen name="CommissionReport">
+        <section>
+            <actions>
+                <set field="titleProperty" value="AccountingCommissionReport"/>
+                <set field="tabButtonItem" value="commissionReport"/>
+                <script location="component://accounting/webapp/ap/WEB-INF/actions/invoices/CommissionReport.groovy"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="CommonApReportDecorator" location="${parameters.mainDecoratorLocation}">
+                    <decorator-section name="body">
+                        <section>
+                            <widgets>
+                                <decorator-screen name="FindScreenDecorator" location="component://common/widget/CommonScreens.xml">
+                                    <decorator-section name="search-options">
+                                        <include-form name="CommissionReport" location="component://accounting/widget/ap/forms/InvoiceForms.xml"/>
+                                    </decorator-section>
+                                    <decorator-section name="search-results">
+                                        <platform-specific>
+                                            <html><html-template location="component://accounting/webapp/ap/invoices/CommissionReport.ftl"/></html>
+                                        </platform-specific>
+                                    </decorator-section>
+                                </decorator-screen>
+                            </widgets>
+                        </section>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
 </screens>

Modified: ofbiz/trunk/applications/accounting/widget/ap/Menus.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ap/Menus.xml?rev=803508&r1=803507&r2=803508&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ap/Menus.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ap/Menus.xml Wed Aug 12 13:48:26 2009
@@ -83,4 +83,14 @@
             <link target="CommissionRun"/>
         </menu-item>
     </menu>
+
+    <menu name="ApReportTabBar" extends="CommonTabBarMenu" extends-resource="component://common/widget/CommonMenus.xml"
+            default-menu-item-name="viewInvoices">
+        <menu-item name="viewReports" title="${uiLabelMap.CommonMain}">
+            <link target="listReports"/>
+        </menu-item>
+        <menu-item name="commissionReport" title="${uiLabelMap.AccountingCommissionReport}">
+            <link target="FindCommissions"/>
+        </menu-item>
+    </menu>
 </menus>

Modified: ofbiz/trunk/applications/accounting/widget/ap/forms/InvoiceForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ap/forms/InvoiceForms.xml?rev=803508&r1=803507&r2=803508&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ap/forms/InvoiceForms.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ap/forms/InvoiceForms.xml Wed Aug 12 13:48:26 2009
@@ -119,4 +119,19 @@
         <field name="thruDate" position="2"><date-time/></field>
         <field name="search" widget-style="smallSubmit"><submit button-type="button"/></field>
     </form>
+
+    <form name="CommissionReport" type="single" target="FindCommissions">
+        <field name="isSearch"><hidden value="Y"/><!-- if this isn't there then with all fields empty no query will be done --></field>
+        <field name="productId" position="1"><lookup target-form-name="LookupProduct"/></field>
+        <field name="partyId" position="2" title="${uiLabelMap.PartyPartyId}">
+            <drop-down allow-empty="true">
+                <entity-options entity-name="PartyRoleAndPartyDetail" description="${firstName} ${middleName} ${lastName} ${groupName}(${partyId})">
+                    <entity-constraint name="roleTypeId" operator="equals" value="SALES_REP"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <field name="fromDate" position="1"><date-time/></field>
+        <field name="thruDate" position="2"><date-time/></field>
+        <field name="search" widget-style="smallSubmit" position="1"><submit button-type="button"/></field>
+    </form>
 </forms>