You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "gilPts (via GitHub)" <gi...@apache.org> on 2023/02/08 13:24:04 UTC

[GitHub] [ofbiz-framework] gilPts commented on a diff in pull request #586: Fixed: Display contra accounts on balance sheet as negative values (OFBIZ-12754)

gilPts commented on code in PR #586:
URL: https://github.com/apache/ofbiz-framework/pull/586#discussion_r1100136979


##########
applications/accounting/groovyScripts/reports/BalanceSheet.groovy:
##########
@@ -101,7 +101,12 @@ if (lastClosedTimePeriod) {
     timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId))
     lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList()
     lastTimePeriodHistories.each { lastTimePeriodHistory ->
-        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"))
+        // Contra accounts are CREDIT accounts and act to offset the value of any asset DEBIT accounts they correspond
+        // to. These contra accounts shall be listed in the asset section of the balance sheet with the intention of
+        // reducing overall asset values. We therefore negate the opening credit balance of the contra account, treating
+        // it as if it was an asset account with a negative value.
+        def endingBalance = lastTimePeriodHistory.getBigDecimal("endingBalance").negate()

Review Comment:
   It is better to declare the good type when known
   ```suggestion
           BigDecimal endingBalance = lastTimePeriodHistory.getBigDecimal("endingBalance").negate()
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org