From 1070d05a3c897cdd199320f878adb4ff3c3c62dc Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Tue, 2 Jun 2009 12:07:13 +1200 Subject: [PATCH] Rewrite FM section to group by first part of accountname for PROPEX. --- process/report/schdtgg2.p | 213 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 201 insertions(+), 12 deletions(-) diff --git a/process/report/schdtgg2.p b/process/report/schdtgg2.p index 27a42d2..f94080d 100644 --- a/process/report/schdtgg2.p +++ b/process/report/schdtgg2.p @@ -208,6 +208,21 @@ FUNCTION do-5-facilities-management RETURNS CHARACTER &ENDIF +&IF DEFINED(EXCLUDE-do-5a-building-account) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD do-5a-building-account Procedure +FUNCTION do-5a-building-account RETURNS CHARACTER + ( INPUT month-from AS INT, INPUT month-to AS INT, + OUTPUT mth-actual AS DECIMAL, OUTPUT mth-budget AS DECIMAL, + OUTPUT ytd-actual AS DECIMAL, OUTPUT ytd-budget AS DECIMAL, + OUTPUT fyr-budget AS DECIMAL, OUTPUT fyr-frcast AS DECIMAL + ) FORWARD. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + &IF DEFINED(EXCLUDE-do-6-building-income) = 0 &THEN &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD do-6-building-income Procedure @@ -1293,22 +1308,145 @@ FUNCTION do-5-facilities-management RETURNS CHARACTER /*------------------------------------------------------------------------------ Purpose: Get the current arrears for the tenants of this property. ------------------------------------------------------------------------------*/ -DEF VAR report AS CHAR NO-UNDO. -DEF VAR rrows AS CHAR NO-UNDO. -DEF VAR i AS INT NO-UNDO. +DEF VAR report AS CHAR NO-UNDO INITIAL ''. -DEF VAR fm-areas AS CHAR NO-UNDO - INITIAL "Building & Structural,Mechanical Services,Electrical Services,Lift Services,Fire Services,Access Control,Cleaning,Security,Fitouts & Makegoods,OH&S Management,Capital Works". + DEF VAR month-from AS INT NO-UNDO. + DEF VAR month-to AS INT NO-UNDO. + DEF VAR fin-year AS INT NO-UNDO. + DEF VAR totals AS DECIMAL EXTENT 6 NO-UNDO INITIAL 0.0 . -rrows = tr( empty(16), 'class="groupbreak"'). -rrows = rrows + tr( td("Facilities Management Report", 'colspan="3" class="subhead"') + empty(13), ''). + DEF VAR mth-actual AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR mth-budget AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR ytd-actual AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR ytd-budget AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR fyr-budget AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR fyr-frcast AS DECIMAL NO-UNDO INITIAL 0.0 . + + DEF VAR mth-actual-t AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR mth-budget-t AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR ytd-actual-t AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR ytd-budget-t AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR fyr-budget-t AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR fyr-frcast-t AS DECIMAL NO-UNDO INITIAL 0.0 . + + DEF VAR mth-actual-g AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR mth-budget-g AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR ytd-actual-g AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR ytd-budget-g AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR fyr-budget-g AS DECIMAL NO-UNDO INITIAL 0.0 . + DEF VAR fyr-frcast-g AS DECIMAL NO-UNDO INITIAL 0.0 . + + FIND LAST Month WHERE Month.StartDate < as-at-date NO-LOCK. + month-to = Month.MonthCode. + fin-year = Month.FinancialYearCode. + FIND FIRST Month WHERE Month.FinancialYearCode = fin-year NO-LOCK. + month-from = Month.MonthCode. + FIND LAST Month WHERE Month.FinancialYearCode = fin-year NO-LOCK. -DO i = 1 TO NUM-ENTRIES(fm-areas): - rrows = rrows + tr( td( ENTRY(i,fm-areas), 'colspan="2" class="subhead2"') + empty(14), ''). - rrows = rrows + tr( empty(16), ''). -END. + DEF VAR last-section AS CHAR INITIAL ?. + DEF VAR this-section AS CHAR INITIAL ?. + FOR EACH ChartOfAccount NO-LOCK WHERE ChartOfAccount.AccountGroupCode = 'PROPEX' BY NAME: + IF INDEX( ChartOfAccount.NAME, '-' ) = 0 THEN NEXT. + this-section = TRIM( ENTRY( 1, ChartOfAccount.NAME, '-') ). + IF this-section <> last-section THEN DO: + IF last-section <> ? THEN DO: + report = report + tr( + td(last-section, 'colspan="2"') + + td(TRIM(STRING(mth-actual-t,money-format)), 'class="money"') + + td(TRIM(STRING(mth-budget-t,money-format)), 'class="money"') + + td(TRIM(STRING(ytd-actual-t,money-format)), 'class="money"') + + td(TRIM(STRING(ytd-budget-t,money-format)), 'class="money"') + + td(TRIM(STRING(fyr-budget-t,money-format)), 'class="money"') + + td(TRIM(STRING(fyr-frcast-t,money-format)), 'class="money"') + + td(TRIM(STRING( (fyr-frcast-t / total-area), money-format)), 'class="money"') + + td(TRIM(STRING(((fyr-frcast-t - fyr-budget-t) / fyr-budget-t) * 100,pcnt-format)), 'class="decimal"') + + empty(6) + , ''). + + mth-actual-g = mth-actual-g + mth-actual-t. + mth-budget-g = mth-budget-g + mth-budget-t. + ytd-actual-g = ytd-actual-g + ytd-actual-t. + ytd-budget-g = ytd-budget-g + ytd-budget-t. + fyr-budget-g = fyr-budget-g + fyr-budget-t. + fyr-frcast-g = fyr-frcast-g + fyr-frcast-t. + + END. + ELSE DO: + report = + tr( empty(15), 'class="groupbreak"') + + tbody( tr( + td("Account", 'colspan="2"') + + td("Mth Actual", '') + + td("Mth Budget", '') + + td("YTD Actual", '') + + td("YTD Budget", '') + + td("FY Budget", '') + + td("FY Forecast", '') + + td("$PSM", '') + + td("Variance", '') + + td("Notes", 'colspan="6"') + , ''), 'class="colhead"'). + END. + mth-actual-t = 0.0 . + mth-budget-t = 0.0 . + ytd-actual-t = 0.0 . + ytd-budget-t = 0.0 . + fyr-budget-t = 0.0 . + fyr-frcast-t = 0.0 . + last-section = this-section. + END. + do-5a-building-account( month-from, month-to, mth-actual, mth-budget, + ytd-actual, ytd-budget, fyr-budget, fyr-frcast ). + + IF mth-actual <> 0.0 OR mth-budget <> 0.0 + OR ytd-actual <> 0.0 OR ytd-budget <> 0.0 + OR fyr-frcast <> 0.0 OR ytd-budget <> 0.0 + THEN DO: + + mth-actual-t = mth-actual-t + mth-actual. + mth-budget-t = mth-budget-t + mth-budget. + ytd-actual-t = ytd-actual-t + ytd-actual. + ytd-budget-t = ytd-budget-t + ytd-budget. + fyr-budget-t = fyr-budget-t + fyr-budget. + fyr-frcast-t = fyr-frcast-t + fyr-frcast. + END. - report = tbody(rrows,'class="facilities"'). + END. + + IF last-section = ? THEN RETURN ''. + + report = report + tr( + td(last-section, 'colspan="2"') + + td(TRIM(STRING(mth-actual-t,money-format)), 'class="money"') + + td(TRIM(STRING(mth-budget-t,money-format)), 'class="money"') + + td(TRIM(STRING(ytd-actual-t,money-format)), 'class="money"') + + td(TRIM(STRING(ytd-budget-t,money-format)), 'class="money"') + + td(TRIM(STRING(fyr-budget-t,money-format)), 'class="money"') + + td(TRIM(STRING(fyr-frcast-t,money-format)), 'class="money"') + + td(TRIM(STRING( (fyr-frcast-t / total-area), money-format)), 'class="money"') + + td(TRIM(STRING(((fyr-frcast-t - fyr-budget-t) / fyr-budget-t) * 100,pcnt-format)), 'class="decimal"') + + empty(6) + , ''). + + mth-actual-g = mth-actual-g + mth-actual-t. + mth-budget-g = mth-budget-g + mth-budget-t. + ytd-actual-g = ytd-actual-g + ytd-actual-t. + ytd-budget-g = ytd-budget-g + ytd-budget-t. + fyr-budget-g = fyr-budget-g + fyr-budget-t. + fyr-frcast-g = fyr-frcast-g + fyr-frcast-t. + + report = report + tbody( tr( + td("Property Expense Totals", 'colspan="2"') + + td(TRIM(STRING(mth-actual-g,money-format)), 'class="money"') + + td(TRIM(STRING(mth-budget-g,money-format)), 'class="money"') + + td(TRIM(STRING(ytd-actual-g,money-format)), 'class="money"') + + td(TRIM(STRING(ytd-budget-g,money-format)), 'class="money"') + + td(TRIM(STRING(fyr-budget-g,money-format)), 'class="money"') + + td(TRIM(STRING(fyr-frcast-g,money-format)), 'class="money"') + + td(TRIM(STRING( (fyr-frcast-g / total-area), money-format)), 'class="money"') + + td(TRIM(STRING(((fyr-frcast-g - fyr-budget-g) / fyr-budget-g) * 100,pcnt-format)), 'class="decimal"') + + empty(6) + , ''), 'class="totals"'). RETURN report. @@ -1319,6 +1457,57 @@ END FUNCTION. &ENDIF +&IF DEFINED(EXCLUDE-do-5a-building-account) = 0 &THEN + +&ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION do-5a-building-account Procedure +FUNCTION do-5a-building-account RETURNS CHARACTER + ( INPUT month-from AS INT, INPUT month-to AS INT, + OUTPUT mth-actual AS DECIMAL, OUTPUT mth-budget AS DECIMAL, + OUTPUT ytd-actual AS DECIMAL, OUTPUT ytd-budget AS DECIMAL, + OUTPUT fyr-budget AS DECIMAL, OUTPUT fyr-frcast AS DECIMAL + ) : +/*------------------------------------------------------------------------------ + Purpose: + Notes: +------------------------------------------------------------------------------*/ +DEF VAR rrow AS CHAR NO-UNDO INITIAL ''. +DEF VAR acctgroup AS CHAR NO-UNDO. + + mth-actual = 0.0 . mth-budget = 0.0 . + ytd-actual = 0.0 . ytd-budget = 0.0 . + fyr-budget = 0.0 . fyr-frcast = 0.0 . + FOR EACH AccountBalance NO-LOCK WHERE + AccountBalance.EntityType = 'P' AND + AccountBalance.EntityCode = Property.PropertyCode AND + AccountBalance.AccountCode = ChartOfAccount.AccountCode AND + AccountBalance.MonthCode >= month-from AND + AccountBalance.MonthCode <= Month.MonthCode: + + IF AccountBalance.MonthCode = month-to THEN DO: + mth-actual = AccountBalance.Balance. + mth-budget = AccountBalance.Budget. + END. + + IF AccountBalance.MonthCode <= month-to THEN DO: + ytd-actual = ytd-actual + AccountBalance.Balance. + ytd-budget = ytd-budget + AccountBalance.Budget. + fyr-frcast = fyr-frcast + AccountBalance.Balance. + END. + ELSE DO: + fyr-frcast = fyr-frcast + AccountBalance.Budget. + END. + + fyr-budget = fyr-budget + AccountBalance.Budget. + + END. + +END FUNCTION. + +/* _UIB-CODE-BLOCK-END */ +&ANALYZE-RESUME + +&ENDIF + &IF DEFINED(EXCLUDE-do-6-building-income) = 0 &THEN &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION do-6-building-income Procedure -- 2.11.4.GIT