JacquesLeRoux commented on code in PR #517: URL: https://github.com/apache/ofbiz-framework/pull/517#discussion_r1147865371
########## applications/accounting/groovyScripts/reports/CostCenters.groovy: ########## @@ -26,50 +25,49 @@ import org.apache.ofbiz.entity.condition.EntityOperator if (!fromDate) { return } -if (!thruDate) { - thruDate = UtilDateTime.nowTimestamp() -} -if (!parameters.glFiscalTypeId) { - parameters.glFiscalTypeId = "ACTUAL" -} +thruDate = thruDate ?: UtilDateTime.nowTimestamp() +parameters.glFiscalTypeId = parameters.glFiscalTypeId ?: 'ACTUAL' // POSTED // Posted transactions totals and grand totals postedTotalDebit = BigDecimal.ZERO postedTotalCredit = BigDecimal.ZERO andExprs = [] -andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds)) -andExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "Y")) -andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, parameters.glFiscalTypeId)) -andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate)) -andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate)) +andExprs.add(EntityCondition.makeCondition('organizationPartyId', EntityOperator.IN, partyIds)) +andExprs.add(EntityCondition.makeCondition('isPosted', EntityOperator.EQUALS, 'Y')) +andExprs.add(EntityCondition.makeCondition('glFiscalTypeId', EntityOperator.EQUALS, parameters.glFiscalTypeId)) +andExprs.add(EntityCondition.makeCondition('transactionDate', EntityOperator.GREATER_THAN_EQUAL_TO, fromDate)) +andExprs.add(EntityCondition.makeCondition('transactionDate', EntityOperator.LESS_THAN_EQUAL_TO, thruDate)) andCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND) -List postedTransactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(andCond).orderBy("glAccountId").queryList() +List postedTransactionTotals = select('glAccountId', 'accountName', 'accountCode', 'debitCreditFlag', 'amount') + .from('AcctgTransEntrySums').where(andCond).orderBy('glAccountId').queryList() if (postedTransactionTotals) { - glAccountCategories = from("GlAccountCategory").where("glAccountCategoryTypeId", "COST_CENTER").orderBy("glAccountCategoryId").queryList() + glAccountCategories = from('GlAccountCategory').where('glAccountCategoryTypeId', 'COST_CENTER').orderBy('glAccountCategoryId').queryList() context.glAccountCategories = glAccountCategories Map postedTransactionTotalsMap = [:] postedTransactionTotals.each { postedTransactionTotal -> Map accountMap = (Map)postedTransactionTotalsMap.get(postedTransactionTotal.glAccountId) if (!accountMap) { accountMap = UtilMisc.makeMapWritable(postedTransactionTotal) - accountMap.put("D", BigDecimal.ZERO) - accountMap.put("C", BigDecimal.ZERO) + accountMap.put('D', BigDecimal.ZERO) + accountMap.put('C', BigDecimal.ZERO) } UtilMisc.addToBigDecimalInMap(accountMap, postedTransactionTotal.debitCreditFlag, postedTransactionTotal.amount) postedTransactionTotalsMap.put(postedTransactionTotal.glAccountId, accountMap) - BigDecimal debitAmount = (BigDecimal)accountMap.get("D") - BigDecimal creditAmount = (BigDecimal)accountMap.get("C") + BigDecimal debitAmount = (BigDecimal)accountMap.get('D') + BigDecimal creditAmount = (BigDecimal)accountMap.get('C') BigDecimal balance = debitAmount.subtract(creditAmount) - accountMap.put("balance", balance) + accountMap.put('balance', balance) glAccountCategories.each { glAccountCategory -> - glAccountCategoryMember = from("GlAccountCategoryMember").where("glAccountCategoryId", glAccountCategory.glAccountCategoryId, "glAccountId", postedTransactionTotal.glAccountId).orderBy("glAccountCategoryId").filterByDate().queryFirst() + glAccountCategoryMember = from('GlAccountCategoryMember') + .where('glAccountCategoryId', glAccountCategory.glAccountCategoryId, 'glAccountId', postedTransactionTotal.glAccountId) + .orderBy('glAccountCategoryId').filterByDate().queryFirst() if (glAccountCategoryMember) { BigDecimal glAccountCategorySharePercentage = glAccountCategoryMember.amountPercentage if (glAccountCategorySharePercentage && glAccountCategorySharePercentage != BigDecimal.ZERO ) { Review Comment: OK -- 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-unsubscr...@ofbiz.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org