You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2009/06/17 12:17:57 UTC
svn commit: r785537 - in /ofbiz/trunk/applications/accounting:
webapp/accounting/WEB-INF/actions/reports/TransactionTotals.groovy
widget/ReportFinancialSummaryForms.xml
widget/ReportFinancialSummaryScreens.xml
Author: jacopoc
Date: Wed Jun 17 10:17:57 2009
New Revision: 785537
URL: http://svn.apache.org/viewvc?rev=785537&view=rev
Log:
Misc enhancements to the "Transaction Totals" report; thanks to Sumit for the patch. OFBIZ-2611
Modified:
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/TransactionTotals.groovy
ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml
ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml
Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/TransactionTotals.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/TransactionTotals.groovy?rev=785537&r1=785536&r2=785537&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/TransactionTotals.groovy (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/TransactionTotals.groovy Wed Jun 17 10:17:57 2009
@@ -17,67 +17,129 @@
* under the License.
*/
-import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilDateTime;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityConditionList;
-import org.ofbiz.entity.condition.EntityExpr;
import org.ofbiz.entity.condition.EntityOperator;
import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.util.EntityUtil;
import javolution.util.FastList;
import javolution.util.FastMap;
+debitTotal = BigDecimal.ZERO;
+creditTotal = BigDecimal.ZERO;
+
exprs = [EntityCondition.makeCondition("organizationPartyId", EntityOperator.EQUALS, organizationPartyId)];
if (fromDate) {
exprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate));
+} else return;
+
+if (!thruDate) {
+ thruDate = UtilDateTime.nowTimestamp();
}
-if (thruDate) {
- exprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate));
-}
+exprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate));
-postedExprs = FastList.newInstance();
-postedExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "Y"));
-postedExprs.addAll(exprs);
-fieldsToSelect = ["glAccountId", "debitCreditFlag", "totalAmount"] as Set;
+exprList = FastList.newInstance();
+orExprs = new ArrayList();
+orExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "Y"));
+orExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "N"));
+orCond = EntityCondition.makeCondition(orExprs, EntityOperator.OR);
+
+exprList.add(orCond);
+exprList.addAll(exprs);
+
+fieldsToSelect = ["glAccountId", "debitCreditFlag", "totalAmount", "isPosted"] as Set;
orderBy = ["glAccountId"];
postedTransTotalList = FastList.newInstance();
-postedTrans = delegator.findList("GlAccOrgAndAcctgTransAndEntry", EntityCondition.makeCondition(postedExprs, EntityOperator.AND), fieldsToSelect, orderBy, null, false);
-if (postedTrans) {
- postedTrans.each { value ->
- postedMap = FastMap.newInstance();
- postedMap.glAccountId = value.glAccountId;
- if ("C".equals(value.debitCreditFlag)) {
- postedMap.credit = value.getBigDecimal("totalAmount");
- postedMap.debit = BigDecimal.ZERO;
- } else {
- postedMap.credit = BigDecimal.ZERO;
- postedMap.debit = value.getBigDecimal("totalAmount");
- }
- postedTransTotalList.add(postedMap);
+unpostedTransTotalList = FastList.newInstance();
+postedAndUnpostedTransTotalList = FastList.newInstance();
+tempValueMap = [:];
+tempValueMap.isPosted = "";
+tempValueMap.glAccountId = "000";
+tempValueMap.debitCreditFlag = "X";
+tempValueMap.totalAmount = 0.00;
+
+allTrans = delegator.findList("GlAccOrgAndAcctgTransAndEntry", EntityCondition.makeCondition(exprList, EntityOperator.AND), fieldsToSelect, orderBy, null, false);
+if (allTrans) {
+ //PostedTransaction Section
+ allPostedTrans = EntityUtil.filterByCondition(allTrans, EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "Y"));
+ getPostedTrans(0, (allPostedTrans.get(0)).glAccountId);
+
+ //UnPostedTransaction Section
+ allUnPostedTrans = EntityUtil.filterByCondition(allTrans, EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "N"));
+ getUnpostedTrans(0, (allUnPostedTrans.get(0)).glAccountId);
+
+ //PostedAndUnPostedTransaction Section
+ getPostedAndUnpostedTrans(0, (allTrans.get(0)).glAccountId);
+}
+
+private void addTransToList(List transectionList, String prevGlAccountId, Map value) {
+ if (!prevGlAccountId.equals(value.glAccountId)) {
+ postedAndUnpostedMap = FastMap.newInstance();
+ postedAndUnpostedMap.glAccountId = prevGlAccountId;
+ postedAndUnpostedMap.credit = creditTotal;
+ postedAndUnpostedMap.debit = debitTotal;
+ transectionList.add(postedAndUnpostedMap);
+ debitTotal = BigDecimal.ZERO;
+ creditTotal = BigDecimal.ZERO;
}
+ if ("C".equals(value.debitCreditFlag))
+ creditTotal += value.getBigDecimal("totalAmount");
+ if ("D".equals(value.debitCreditFlag))
+ debitTotal += value.getBigDecimal("totalAmount");
+}
+
+private void getPostedTrans(int index, String prevGlAccountId) {
+ if (index < allPostedTrans.size())
+ value = allPostedTrans.get(index);
+ else {
+ tempValueMap.isPosted = "Y";
+ value = tempValueMap;
+ }
+ if("Y".equals(value.isPosted)) {
+ addTransToList(postedTransTotalList, prevGlAccountId, value);
+ }
+ if (index < allPostedTrans.size()) {
+ index++;
+ getPostedTrans(index, value.glAccountId);
+ }
+ else return;
}
-context.postedTransTotalList = postedTransTotalList;
-unpostedExprs = FastList.newInstance();
-unpostedExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "N"));
-unpostedExprs.addAll(exprs);
+private void getUnpostedTrans(int index, String prevGlAccountId) {
+ if (index != allUnPostedTrans.size())
+ value = allUnPostedTrans.get(index);
+ else {
+ tempValueMap.isPosted = "N";
+ value = tempValueMap;
+ }
+
+ if("N".equals(value.isPosted)) {
+ addTransToList(unpostedTransTotalList, prevGlAccountId, value);
+ }
+ if (index < allUnPostedTrans.size()) {
+ index++;
+ getUnpostedTrans(index, value.glAccountId);
+ }
+ else return;
+}
-unpostedTransTotalList = FastList.newInstance();
-unpostedTrans = delegator.findList("GlAccOrgAndAcctgTransAndEntry", EntityCondition.makeCondition(unpostedExprs, EntityOperator.AND), fieldsToSelect, orderBy, null, false);
-if (unpostedTrans) {
- unpostedTrans.each { value ->
- Map unpostedMap = FastMap.newInstance();
- unpostedMap.glAccountId = value.glAccountId;
- if ("C".equals(value.debitCreditFlag)) {
- unpostedMap.credit = value.getBigDecimal("totalAmount");
- unpostedMap.debit = BigDecimal.ZERO;
- } else {
- unpostedMap.credit = BigDecimal.ZERO;
- unpostedMap.debit = value.getBigDecimal("totalAmount");
- }
- unpostedTransTotalList.add(unpostedMap);
+private void getPostedAndUnpostedTrans(int index, String prevGlAccountId) {
+ if (index != allTrans.size())
+ value = allTrans.get(index);
+ else {
+ tempValueMap.isPosted = "X";
+ value = tempValueMap;
}
+ addTransToList(postedAndUnpostedTransTotalList, prevGlAccountId, value);
+ if (index < allTrans.size()) {
+ index++;
+ getPostedAndUnpostedTrans(index, value.glAccountId);
+ }
+ else return;
}
-context.put("unpostedTransTotalList", unpostedTransTotalList);
\ No newline at end of file
+context.postedTransTotalList = postedTransTotalList;
+context.unpostedTransTotalList = unpostedTransTotalList;
+context.postedAndUnpostedTransTotalList = postedAndUnpostedTransTotalList;
\ No newline at end of file
Modified: ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml?rev=785537&r1=785536&r2=785537&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml Wed Jun 17 10:17:57 2009
@@ -231,6 +231,7 @@
<form name="PostedTransactionTotalList" type="list" list-name="postedTransTotalList"
odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
<field name="glAccountId"><display/></field>
+ <field name="accountName" entry-name="glAccountId"><display-entity entity-name="GlAccount" key-field-name="glAccountId" description="${accountName}"/></field>
<field name="debit"><display/></field>
<field name="credit"><display/></field>
</form>
@@ -238,6 +239,14 @@
<form name="UnpostedTransactionTotalList" type="list" list-name="unpostedTransTotalList"
odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
<field name="glAccountId"><display/></field>
+ <field name="accountName" entry-name="glAccountId"><display-entity entity-name="GlAccount" key-field-name="glAccountId" description="${accountName}"/></field>
+ <field name="debit"><display/></field>
+ <field name="credit"><display/></field>
+ </form>
+ <form name="PostedAndUnpostedTransactionTotalList" type="list" list-name="postedAndUnpostedTransTotalList"
+ odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
+ <field name="glAccountId"><display/></field>
+ <field name="accountName" entry-name="glAccountId"><display-entity entity-name="GlAccount" key-field-name="glAccountId" description="${accountName}"/></field>
<field name="debit"><display/></field>
<field name="credit"><display/></field>
</form>
Modified: ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml?rev=785537&r1=785536&r2=785537&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml Wed Jun 17 10:17:57 2009
@@ -568,6 +568,16 @@
</container>
</container>
</container>
+ <container style="screenlet">
+ <container style="screenlet-title-bar">
+ <container style="h3">
+ <label text="${uiLabelMap.AccountingPostedAndUnpostedTransactionTotals}"/>
+ </container>
+ <container style="screenlet-body">
+ <include-form name="PostedAndUnpostedTransactionTotalList" location="component://accounting/widget/ReportFinancialSummaryForms.xml"/>
+ </container>
+ </container>
+ </container>
</decorator-section>
</decorator-screen>
</widgets>