You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2007/03/28 04:29:50 UTC
svn commit: r523146 - in /ofbiz/trunk/applications:
accounting/entitydef/entitymodel.xml
order/src/org/ofbiz/order/finaccount/FinAccountHelper.java
Author: jonesde
Date: Tue Mar 27 19:29:49 2007
New Revision: 523146
URL: http://svn.apache.org/viewvc?view=rev&rev=523146
Log:
Updated TransSum view-entity to use FinAccountTrans.amount field, small change to helper method as well
Modified:
ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
ofbiz/trunk/applications/order/src/org/ofbiz/order/finaccount/FinAccountHelper.java
Modified: ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml?view=diff&rev=523146&r1=523145&r2=523146
==============================================================================
--- ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml Tue Mar 27 19:29:49 2007
@@ -550,15 +550,10 @@
<description>View entity to help calculate total of financial account transactions by doing a query for the sum of all amounts
on a range of transactionDates for a given finAccountId, finAccountTransTypeId</description>
<member-entity entity-alias="FAT" entity-name="FinAccountTrans"/>
- <member-entity entity-alias="P" entity-name="Payment"/>
<alias entity-alias="FAT" name="finAccountId" group-by="true"/>
<alias entity-alias="FAT" name="finAccountTransTypeId" group-by="false"/> <!-- must not group-by this, or aggregating DEPOSIT and ADJUSTMENT won't work -->
<alias entity-alias="FAT" name="transactionDate" group-by="false"/>
- <alias entity-alias="P" name="amount" function="sum"/>
- <alias entity-alias="P" name="currencyUomId" group-by="true"/>
- <view-link entity-alias="FAT" rel-entity-alias="P">
- <key-map field-name="paymentId"/>
- </view-link>
+ <alias entity-alias="FAT" name="amount" function="sum"/>
</view-entity>
<view-entity entity-name="FinAccountAuthSum" package-name="org.ofbiz.accounting.finaccount" title="Financial Account Authorization Sum">
<description>View entity to help calculate total of financial account authorizations by doing a query for the sum of all amounts
Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/finaccount/FinAccountHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/finaccount/FinAccountHelper.java?view=diff&rev=523146&r1=523145&r2=523146
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/finaccount/FinAccountHelper.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/finaccount/FinAccountHelper.java Tue Mar 27 19:29:49 2007
@@ -175,40 +175,39 @@
* @throws GenericEntityException
*/
public static BigDecimal getBalance(String finAccountId, Timestamp asOfDateTime, GenericDelegator delegator) throws GenericEntityException {
- if (asOfDateTime == null) asOfDateTime = UtilDateTime.nowTimestamp();
+ if (asOfDateTime == null) asOfDateTime = UtilDateTime.nowTimestamp();
- BigDecimal incrementTotal = ZERO; // total amount of transactions which increase balance
- BigDecimal decrementTotal = ZERO; // decrease balance
+ BigDecimal incrementTotal = ZERO; // total amount of transactions which increase balance
+ BigDecimal decrementTotal = ZERO; // decrease balance
- GenericValue finAccount = delegator.findByPrimaryKeyCache("FinAccount", UtilMisc.toMap("finAccountId", finAccountId));
- String currencyUomId = finAccount.getString("currencyUomId");
+ GenericValue finAccount = delegator.findByPrimaryKeyCache("FinAccount", UtilMisc.toMap("finAccountId", finAccountId));
+ String currencyUomId = finAccount.getString("currencyUomId");
- // find the sum of all transactions which increase the value
- EntityConditionList incrementConditions = new EntityConditionList(UtilMisc.toList(
- new EntityExpr("finAccountId", EntityOperator.EQUALS, finAccountId),
- new EntityExpr("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, asOfDateTime),
- new EntityExpr("currencyUomId", EntityOperator.EQUALS, currencyUomId),
- new EntityConditionList(UtilMisc.toList(
- new EntityExpr("finAccountTransTypeId", EntityOperator.EQUALS, "DEPOSIT"),
- new EntityExpr("finAccountTransTypeId", EntityOperator.EQUALS, "ADJUSTMENT")),
- EntityOperator.OR)),
- EntityOperator.AND);
- List transSums = delegator.findByCondition("FinAccountTransSum", incrementConditions, UtilMisc.toList("amount"), null);
- incrementTotal = addFirstEntryAmount(incrementTotal, transSums, "amount", (decimals+1), rounding);
+ // find the sum of all transactions which increase the value
+ EntityConditionList incrementConditions = new EntityConditionList(UtilMisc.toList(
+ new EntityExpr("finAccountId", EntityOperator.EQUALS, finAccountId),
+ new EntityExpr("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, asOfDateTime),
+ new EntityConditionList(UtilMisc.toList(
+ new EntityExpr("finAccountTransTypeId", EntityOperator.EQUALS, "DEPOSIT"),
+ new EntityExpr("finAccountTransTypeId", EntityOperator.EQUALS, "ADJUSTMENT")),
+ EntityOperator.OR)),
+ EntityOperator.AND);
+ List transSums = delegator.findByCondition("FinAccountTransSum", incrementConditions, UtilMisc.toList("amount"), null);
+ incrementTotal = addFirstEntryAmount(incrementTotal, transSums, "amount", (decimals+1), rounding);
- // now find sum of all transactions with decrease the value
- EntityConditionList decrementConditions = new EntityConditionList(UtilMisc.toList(
- new EntityExpr("finAccountId", EntityOperator.EQUALS, finAccountId),
- new EntityExpr("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, asOfDateTime),
- new EntityExpr("currencyUomId", EntityOperator.EQUALS, currencyUomId),
- new EntityExpr("finAccountTransTypeId", EntityOperator.EQUALS, "WITHDRAWAL")),
- EntityOperator.AND);
- transSums = delegator.findByCondition("FinAccountTransSum", decrementConditions, UtilMisc.toList("amount"), null);
- decrementTotal = addFirstEntryAmount(decrementTotal, transSums, "amount", (decimals+1), rounding);
-
- // the net balance is just the incrementTotal minus the decrementTotal
- return incrementTotal.subtract(decrementTotal).setScale(decimals, rounding);
- }
+ // now find sum of all transactions with decrease the value
+ EntityConditionList decrementConditions = new EntityConditionList(UtilMisc.toList(
+ new EntityExpr("finAccountId", EntityOperator.EQUALS, finAccountId),
+ new EntityExpr("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, asOfDateTime),
+ new EntityExpr("currencyUomId", EntityOperator.EQUALS, currencyUomId),
+ new EntityExpr("finAccountTransTypeId", EntityOperator.EQUALS, "WITHDRAWAL")),
+ EntityOperator.AND);
+ transSums = delegator.findByCondition("FinAccountTransSum", decrementConditions, UtilMisc.toList("amount"), null);
+ decrementTotal = addFirstEntryAmount(decrementTotal, transSums, "amount", (decimals+1), rounding);
+
+ // the net balance is just the incrementTotal minus the decrementTotal
+ return incrementTotal.subtract(decrementTotal).setScale(decimals, rounding);
+ }
/**
* Returns the net balance (see above) minus the sum of all authorization amounts which are not expired and were authorized by the as of date
@@ -218,25 +217,25 @@
* @return
* @throws GenericEntityException
*/
- public static BigDecimal getAvailableBalance(String finAccountId, Timestamp asOfDateTime, GenericDelegator delegator) throws GenericEntityException {
- if (asOfDateTime == null) asOfDateTime = UtilDateTime.nowTimestamp();
+ public static BigDecimal getAvailableBalance(String finAccountId, Timestamp asOfDateTime, GenericDelegator delegator) throws GenericEntityException {
+ if (asOfDateTime == null) asOfDateTime = UtilDateTime.nowTimestamp();
- BigDecimal netBalance = getBalance(finAccountId, asOfDateTime, delegator);
+ BigDecimal netBalance = getBalance(finAccountId, asOfDateTime, delegator);
- // find sum of all authorizations which are not expired and which were authorized before as of time
- EntityConditionList authorizationConditions = new EntityConditionList(UtilMisc.toList(
- new EntityExpr("finAccountId", EntityOperator.EQUALS, finAccountId),
- new EntityExpr("authorizationDate", EntityOperator.LESS_THAN_EQUAL_TO, asOfDateTime),
- EntityUtil.getFilterByDateExpr(asOfDateTime)),
- EntityOperator.AND);
-
- List authSums = delegator.findByCondition("FinAccountAuthSum", authorizationConditions, UtilMisc.toList("amount"), null);
-
- BigDecimal authorizationsTotal = addFirstEntryAmount(ZERO, authSums, "amount", (decimals+1), rounding);
-
- // the total available balance is transactions total minus authorizations total
- return netBalance.subtract(authorizationsTotal).setScale(decimals, rounding);
- }
+ // find sum of all authorizations which are not expired and which were authorized before as of time
+ EntityConditionList authorizationConditions = new EntityConditionList(UtilMisc.toList(
+ new EntityExpr("finAccountId", EntityOperator.EQUALS, finAccountId),
+ new EntityExpr("authorizationDate", EntityOperator.LESS_THAN_EQUAL_TO, asOfDateTime),
+ EntityUtil.getFilterByDateExpr(asOfDateTime)),
+ EntityOperator.AND);
+
+ List authSums = delegator.findByCondition("FinAccountAuthSum", authorizationConditions, UtilMisc.toList("amount"), null);
+
+ BigDecimal authorizationsTotal = addFirstEntryAmount(ZERO, authSums, "amount", (decimals+1), rounding);
+
+ // the total available balance is transactions total minus authorizations total
+ return netBalance.subtract(authorizationsTotal).setScale(decimals, rounding);
+ }
public static boolean validateFinAccount(GenericValue finAccount) {
return false;