1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v9r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*------------------------------------------------------------------------
5 Purpose
: Convert ledger codes from one set of numbers to another
7 Author
(s
) : Andrew McMillan
8 Created
: 27th September
2005
10 ----------------------------------------------------------------------*/
12 /* *************************** Definitions
************************** */
14 DEFINE TEMP-TABLE conversion
15 FIELD old-code
LIKE ChartOfAccount.AccountCode
16 FIELD new-code
LIKE ChartOfAccount.AccountCode
17 FIELD new-name
LIKE ChartOfAccount.Name
18 FIELD converted
AS LOGICAL
19 FIELD in-line-no
AS INT
20 INDEX xpk-old old-code
ASCENDING
21 INDEX xak-new new-code
ASCENDING.
23 DEF VAR pass-no
AS INT INITIAL 0.
24 DEF BUFFER other-conv
FOR conversion.
26 /* _UIB-CODE-BLOCK-END
*/
30 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
32 /* ******************** Preprocessor Definitions
******************** */
34 &Scoped-define PROCEDURE-TYPE Procedure
35 &Scoped-define DB-AWARE no
39 /* _UIB-PREPROCESSOR-BLOCK-END
*/
44 /* *********************** Procedure Settings
************************ */
46 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
47 /* Settings for
THIS-PROCEDURE
51 Add Fields to
: Neither
52 Other Settings
: CODE-ONLY
COMPILE
54 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
56 /* ************************* Create Window
************************** */
58 &ANALYZE-SUSPEND _CREATE-WINDOW
59 /* DESIGN Window definition
(used by the UIB
)
60 CREATE WINDOW Procedure
ASSIGN
63 /* END WINDOW DEFINITION
*/
70 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
73 /* *************************** Main Block
*************************** */
74 OUTPUT TO TERMINAL UNBUFFERED NO-CONVERT.
76 PUT UNFORMATTED "Temp Table Loaded" SKIP.
77 RUN clean-chartofaccount.
79 REPEAT WHILE CAN-FIND( FIRST conversion
WHERE NOT(converted
) ) AND pass-no
< 20:
80 pass-no
= pass-no
+ 1.
81 FOR EACH conversion
WHERE NOT(converted
)
82 AND NOT CAN-FIND( FIRST other-conv
WHERE other-conv.old-code
= conversion.new-code
)
84 RUN do-conversion
( conversion.old-code
, conversion.new-code
, conversion.new-name
).
88 RUN clean-chartofaccount.
90 FOR EACH conversion
WHERE NOT(conversion.converted
):
91 PUT UNFORMATTED "Could not convert " + STRING( conversion.old-code
, "9999.99" ) SKIP.
94 PUT UNFORMATTED "Completed processing in " + TRIM(STRING(pass-no
)) + " passes" SKIP.
98 /* _UIB-CODE-BLOCK-END
*/
102 /* ********************** Internal Procedures
*********************** */
104 &IF DEFINED(EXCLUDE-clean-chartofaccount) = 0 &THEN
106 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE clean-chartofaccount Procedure
107 PROCEDURE clean-chartofaccount
:
108 /*------------------------------------------------------------------------------
110 ------------------------------------------------------------------------------*/
112 FOR EACH ChartOfAccount
WHERE NOT CAN-FIND( FIRST Accttran
OF ChartOfAccount
):
113 DELETE ChartOfAccount.
118 /* _UIB-CODE-BLOCK-END
*/
123 &IF DEFINED(EXCLUDE-do-conversion) = 0 &THEN
125 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE do-conversion Procedure
126 PROCEDURE do-conversion
:
127 /*------------------------------------------------------------------------------
128 Purpose
: Convert all instances of one accountcode to another
129 Notes
: We also try and rename the account on the way through...
130 ------------------------------------------------------------------------------*/
131 DEF INPUT PARAMETER what-is
AS DECIMAL NO-UNDO.
132 DEF INPUT PARAMETER what-shall-be
AS DECIMAL NO-UNDO.
133 DEF INPUT PARAMETER new-account-name
AS CHAR NO-UNDO.
135 IF NOT CAN-FIND( FIRST ChartOfAccount
WHERE AccountCode
= what-shall-be
) THEN DO:
136 FOR EACH ChartOfAccount
WHERE ChartOfAccount.AccountCode
= what-is
:
137 ChartOfAccount.AccountCode
= what-shall-be.
140 FIND FIRST ChartOfAccount
WHERE AccountCode
= what-shall-be
NO-ERROR.
141 IF NOT AVAILABLE(ChartOfAccount
) THEN DO:
142 CREATE ChartOfAccount.
143 ChartOfAccount.AccountCode
= what-shall-be.
144 ChartOfAccount.AccountGroupCode
= "TEMP".
145 ChartOfAccount.UpdateTo
= "L".
147 ChartOfAccount.Name
= new-account-name.
149 FOR EACH AcctTran
WHERE AcctTran.AccountCode
= what-is
: AcctTran.AccountCode
= what-shall-be.
END.
150 FOR EACH VoucherLine
WHERE VoucherLine.AccountCode
= what-is
: VoucherLine.AccountCode
= what-shall-be.
END.
151 FOR EACH Voucher
WHERE Voucher.AccountCode
= what-is
: Voucher.AccountCode
= what-shall-be.
END.
152 FOR EACH InvoiceLine
WHERE InvoiceLine.AccountCode
= what-is
: InvoiceLine.AccountCode
= what-shall-be.
END.
153 FOR EACH AreaType
WHERE AreaType.AccountCode
= what-is
: AreaType.AccountCode
= what-shall-be.
END.
154 FOR EACH AssetType
WHERE AssetType.AccountCode
= what-is
: AssetType.AccountCode
= what-shall-be.
END.
155 FOR EACH BankAccount
WHERE BankAccount.AccountCode
= what-is
: BankAccount.AccountCode
= what-shall-be.
END.
156 FOR EACH BankImportException
WHERE BankImportException.AccountCode
= what-is
: BankImportException.AccountCode
= what-shall-be.
END.
157 FOR EACH CashFlow
WHERE CashFlow.AccountCode
= what-is
: CashFlow.AccountCode
= what-shall-be.
END.
158 FOR EACH ClosingGroup
WHERE ClosingGroup.AccountCode
= what-is
: ClosingGroup.AccountCode
= what-shall-be.
END.
159 FOR EACH EntityListMember
WHERE EntityListMember.AccountCode
= what-is
: EntityListMember.AccountCode
= what-shall-be.
END.
160 FOR EACH NewAcctTrans
WHERE NewAcctTrans.AccountCode
= what-is
: NewAcctTrans.AccountCode
= what-shall-be.
END.
161 FOR EACH OfficeControlAccount
WHERE OfficeControlAccount.AccountCode
= what-is
: OfficeControlAccount.AccountCode
= what-shall-be.
END.
162 FOR EACH Order
WHERE Order.AccountCode
= what-is
: Order.AccountCode
= what-shall-be.
END.
163 FOR EACH Project
WHERE Project.EntityAccount
= what-is
: Project.EntityAccount
= what-shall-be.
END.
164 FOR EACH ProjectBudget
WHERE ProjectBudget.AccountCode
= what-is
: ProjectBudget.AccountCode
= what-shall-be.
END.
165 FOR EACH ProjectBudget
WHERE ProjectBudget.EntityAccount
= what-is
: ProjectBudget.EntityAccount
= what-shall-be.
END.
166 FOR EACH PropertyOutgoing
WHERE PropertyOutgoing.AccountCode
= what-is
: PropertyOutgoing.AccountCode
= what-shall-be.
END.
167 FOR EACH PropForecast
WHERE PropForecast.AccountCode
= what-is
: PropForecast.AccountCode
= what-shall-be.
END.
168 FOR EACH RentCharge
WHERE RentCharge.AccountCode
= what-is
: RentCharge.AccountCode
= what-shall-be.
END.
169 FOR EACH RentChargeType
WHERE RentChargeType.AccountCode
= what-is
: RentChargeType.AccountCode
= what-shall-be.
END.
170 FOR EACH ServiceType
WHERE ServiceType.AccountCode
= what-is
: ServiceType.AccountCode
= what-shall-be.
END.
171 FOR EACH SupplyMeter
WHERE SupplyMeter.AccountCode
= what-is
: SupplyMeter.AccountCode
= what-shall-be.
END.
172 FOR EACH TenancyOutgoing
WHERE TenancyOutgoing.AccountCode
= what-is
: TenancyOutgoing.AccountCode
= what-shall-be.
END.
173 FOR EACH VariationFlow
WHERE VariationFlow.AccountCode
= what-is
: VariationFlow.AccountCode
= what-shall-be.
END.
175 conversion.converted
= true.
177 PUT UNFORMATTED conversion.old-code
" => " conversion.new-code
" " conversion.new-name
SKIP.
181 /* _UIB-CODE-BLOCK-END
*/
186 &IF DEFINED(EXCLUDE-load-temp-table) = 0 &THEN
188 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE load-temp-table Procedure
189 PROCEDURE load-temp-table
:
190 /*------------------------------------------------------------------------------
191 Purpose
: Load the temp table from a file
192 ------------------------------------------------------------------------------*/
193 DEF VAR line-no
AS INT NO-UNDO INITIAL 0.
195 INPUT FROM new-codes.csv.
197 REPEAT ON ENDKEY UNDO, LEAVE:
198 line-no
= line-no
+ 1.
205 IF old-code
= ?
OR new-code
= ?
THEN NEXT.
213 FOR EACH conversion
WHERE old-code
EQ ?
OR new-code
EQ ?
214 OR old-code
EQ 0 OR new-code
EQ 0
215 OR old-code
EQ new-code
:
221 /* _UIB-CODE-BLOCK-END
*/