1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Method-Library
4 /*--------------------------------------------------------------------------
6 Purpose
: Deal with getting things associated with accounting entities
15 ------------------------------------------------------------------------*/
17 /* _UIB-CODE-BLOCK-END
*/
21 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
23 /* ******************** Preprocessor Definitions
******************** */
27 /* _UIB-PREPROCESSOR-BLOCK-END
*/
31 /* ************************ Function Prototypes
********************** */
33 &IF DEFINED(EXCLUDE-get-entity-account) = 0 &THEN
35 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-entity-account Method-Library
36 FUNCTION get-entity-account
RETURNS CHARACTER
37 ( INPUT et
AS CHAR, INPUT ec
AS INT, INPUT ac
AS DEC ) FORWARD.
39 /* _UIB-CODE-BLOCK-END
*/
44 &IF DEFINED(EXCLUDE-get-entity-client) = 0 &THEN
46 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-entity-client Method-Library
47 FUNCTION get-entity-client
RETURNS CHARACTER
48 ( INPUT et
AS CHAR, INPUT ec
AS INT ) FORWARD.
50 /* _UIB-CODE-BLOCK-END
*/
55 &IF DEFINED(EXCLUDE-get-entity-ledger) = 0 &THEN
57 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-entity-ledger Method-Library
58 FUNCTION get-entity-ledger
RETURNS INTEGER
59 ( INPUT et
AS CHAR, INPUT ec
AS INT ) FORWARD.
61 /* _UIB-CODE-BLOCK-END
*/
66 &IF DEFINED(EXCLUDE-get-entity-name) = 0 &THEN
68 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-entity-name Method-Library
69 FUNCTION get-entity-name
RETURNS CHARACTER
70 ( INPUT et
AS CHAR, INPUT ec
AS INT ) FORWARD.
72 /* _UIB-CODE-BLOCK-END
*/
77 &IF DEFINED(EXCLUDE-get-entity-type-name) = 0 &THEN
79 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-entity-type-name Method-Library
80 FUNCTION get-entity-type-name
RETURNS CHARACTER
81 ( INPUT et
AS CHAR ) FORWARD.
83 /* _UIB-CODE-BLOCK-END
*/
88 &IF DEFINED(EXCLUDE-get-parent-entity) = 0 &THEN
90 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-parent-entity Method-Library
91 FUNCTION get-parent-entity
RETURNS CHARACTER
92 ( INPUT et
AS CHAR, INPUT ec
AS INT ) FORWARD.
94 /* _UIB-CODE-BLOCK-END
*/
100 /* *********************** Procedure Settings
************************ */
102 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
103 /* Settings for
THIS-PROCEDURE
107 Add Fields to
: Neither
108 Other Settings
: INCLUDE-ONLY
110 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
112 /* ************************* Create Window
************************** */
114 &ANALYZE-SUSPEND _CREATE-WINDOW
115 /* DESIGN Window definition
(used by the UIB
)
116 CREATE WINDOW Method-Library
ASSIGN
119 /* END WINDOW DEFINITION
*/
123 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Method-Library
124 /* ************************* Included-Libraries
*********************** */
126 /* _UIB-CODE-BLOCK-END
*/
133 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Method-Library
136 /* *************************** Main Block
*************************** */
138 /* _UIB-CODE-BLOCK-END
*/
142 /* ************************ Function Implementations
***************** */
144 &IF DEFINED(EXCLUDE-get-entity-account) = 0 &THEN
146 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-entity-account Method-Library
147 FUNCTION get-entity-account
RETURNS CHARACTER
148 ( INPUT et
AS CHAR, INPUT ec
AS INT, INPUT ac
AS DEC ) :
149 /*------------------------------------------------------------------------------
152 ------------------------------------------------------------------------------*/
153 DEF VAR name
AS CHAR NO-UNDO INITIAL "* * * Unknown * * *".
155 DEF BUFFER tmp_COA
FOR ChartOfAccount.
156 DEF BUFFER tmp_ProjectBudget
FOR ProjectBudget.
159 FIND tmp_ProjectBudget
WHERE tmp_ProjectBudget.ProjectCode
= ec
AND tmp_ProjectBudget.AccountCode
= ac
NO-LOCK NO-ERROR.
160 IF AVAILABLE(tmp_ProjectBudget
) THEN RETURN tmp_ProjectBudget.Description.
163 FIND tmp_COA
WHERE tmp_COA.AccountCode
= ac
NO-LOCK NO-ERROR.
164 IF AVAILABLE(tmp_COA
) THEN name
= tmp_COA.Name.
170 /* _UIB-CODE-BLOCK-END
*/
175 &IF DEFINED(EXCLUDE-get-entity-client) = 0 &THEN
177 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-entity-client Method-Library
178 FUNCTION get-entity-client
RETURNS CHARACTER
179 ( INPUT et
AS CHAR, INPUT ec
AS INT ) :
180 /*------------------------------------------------------------------------------
181 Purpose
: Find the client for this entity type
/ entity code.
182 ------------------------------------------------------------------------------*/
183 DEF VAR entity-code
AS CHAR NO-UNDO.
185 DEF BUFFER tmp_Company
FOR Company.
187 entity-code
= get-parent-entity
( et
, ec
).
188 et
= SUBSTRING( entity-code
, 1, 1).
189 ec
= INT( SUBSTRING( entity-code
, 2) ).
192 FIND tmp_Company
WHERE tmp_Company.CompanyCode
= ec
NO-LOCK NO-ERROR.
193 RETURN tmp_Company.ClientCode.
197 /* _UIB-CODE-BLOCK-END
*/
202 &IF DEFINED(EXCLUDE-get-entity-ledger) = 0 &THEN
204 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-entity-ledger Method-Library
205 FUNCTION get-entity-ledger
RETURNS INTEGER
206 ( INPUT et
AS CHAR, INPUT ec
AS INT ) :
207 /*------------------------------------------------------------------------------
208 Purpose
: Find the ultimate ledger parent for this entity type
/ entity code.
209 ------------------------------------------------------------------------------*/
210 DEF VAR entity-code
AS CHAR NO-UNDO.
213 entity-code
= get-parent-entity
( et
, ec
).
214 et
= SUBSTRING( entity-code
, 1, 1).
215 ec
= INT( SUBSTRING( entity-code
, 2) ).
222 /* _UIB-CODE-BLOCK-END
*/
227 &IF DEFINED(EXCLUDE-get-entity-name) = 0 &THEN
229 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-entity-name Method-Library
230 FUNCTION get-entity-name
RETURNS CHARACTER
231 ( INPUT et
AS CHAR, INPUT ec
AS INT ) :
232 /*------------------------------------------------------------------------------
235 ------------------------------------------------------------------------------*/
236 DEF VAR name
AS CHAR NO-UNDO.
240 DEF BUFFER tmp_Tenant
FOR Tenant.
241 FIND tmp_Tenant
WHERE tmp_Tenant.TenantCode
= ec
NO-LOCK NO-ERROR.
242 name
= IF AVAILABLE(tmp_Tenant
) THEN tmp_Tenant.Name
ELSE "* * * Unknown * * *".
245 DEF BUFFER tmp_Creditor
FOR Creditor.
246 FIND tmp_Creditor
WHERE tmp_Creditor.CreditorCode
= ec
NO-LOCK NO-ERROR.
247 name
= IF AVAILABLE(tmp_Creditor
) THEN tmp_Creditor.Name
ELSE "* * * Unknown * * *".
250 DEF BUFFER tmp_Property
FOR Property.
251 FIND tmp_Property
WHERE tmp_Property.PropertyCode
= ec
NO-LOCK NO-ERROR.
252 name
= IF AVAILABLE(tmp_Property
) THEN tmp_Property.Name
ELSE "* * * Unknown * * *".
255 DEF BUFFER tmp_Company
FOR Company.
256 FIND tmp_Company
WHERE tmp_Company.CompanyCode
= ec
NO-LOCK NO-ERROR.
257 name
= IF AVAILABLE(tmp_Company
) THEN tmp_Company.LegalName
ELSE "* * * Unknown * * *".
260 DEF BUFFER tmp_Project
FOR Project.
261 FIND tmp_Project
WHERE tmp_Project.ProjectCode
= ec
NO-LOCK NO-ERROR.
262 name
= IF AVAILABLE(tmp_Project
) THEN tmp_Project.Name
ELSE "* * * Unknown * * *".
265 DEF BUFFER tmp_FixedAsset
FOR FixedAsset.
266 FIND tmp_FixedAsset
WHERE tmp_FixedAsset.AssetCode
= ec
NO-LOCK NO-ERROR.
267 name
= IF AVAILABLE(tmp_FixedAsset
) THEN tmp_FixedAsset.Description
ELSE "* * * Unknown * * *".
275 /* _UIB-CODE-BLOCK-END
*/
280 &IF DEFINED(EXCLUDE-get-entity-type-name) = 0 &THEN
282 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-entity-type-name Method-Library
283 FUNCTION get-entity-type-name
RETURNS CHARACTER
284 ( INPUT et
AS CHAR ) :
285 /*------------------------------------------------------------------------------
288 ------------------------------------------------------------------------------*/
290 WHEN 'P'
THEN RETURN "Property".
291 WHEN "J" THEN RETURN "Project".
292 WHEN "C" THEN RETURN "Creditor".
293 WHEN "L" THEN RETURN "Company".
294 WHEN "T" THEN RETURN "Tenant".
295 WHEN "F" THEN RETURN "Fixed Asset".
298 RETURN ?.
/* Function return value.
*/
302 /* _UIB-CODE-BLOCK-END
*/
307 &IF DEFINED(EXCLUDE-get-parent-entity) = 0 &THEN
309 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-parent-entity Method-Library
310 FUNCTION get-parent-entity
RETURNS CHARACTER
311 ( INPUT et
AS CHAR, INPUT ec
AS INT ) :
312 /*------------------------------------------------------------------------------
315 ------------------------------------------------------------------------------*/
316 DEF VAR parent-entity
AS CHAR NO-UNDO.
320 DEF BUFFER tmp_Project
FOR Project.
321 FIND tmp_Project
WHERE tmp_Project.ProjectCode
= ec
NO-LOCK NO-ERROR.
322 parent-entity
= tmp_Project.EntityType
+ STRING( tmp_Project.EntityCode
, "99999").
325 DEF BUFFER tmp_Property
FOR Property.
326 FIND tmp_Property
WHERE tmp_Property.PropertyCode
= ec
NO-LOCK NO-ERROR.
327 parent-entity
= "L" + STRING( tmp_Property.CompanyCode
, "99999").
330 DEF BUFFER tmp_Tenant
FOR Tenant.
331 FIND tmp_Tenant
WHERE tmp_Tenant.TenantCode
= ec
NO-LOCK NO-ERROR.
332 parent-entity
= tmp_Tenant.EntityType
+ STRING( tmp_Tenant.EntityCode
, "99999").
335 DEF BUFFER tmp_Creditor
FOR Creditor.
336 FIND tmp_Creditor
WHERE tmp_Creditor.CreditorCode
= ec
NO-LOCK NO-ERROR.
337 parent-entity
= "L" + STRING( tmp_Creditor.CompanyCode
, "99999").
340 parent-entity
= "L00001".
344 RETURN parent-entity.
348 /* _UIB-CODE-BLOCK-END
*/