Description
SetStatutoryCurrencyBasedOnTCAPMGetGL: Submethod of SetStatutoryCurrencyBasedOnTCAPM that will return the GL to be used for the VarExchRate-postingline of the matching
Parameters
ilGetGainAccount | input | logical | |
oiGLID | output | integer | |
oiDivisionID | output | integer | |
oiCostCentreID | output | integer | |
ocErrorMessage | output | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/tsetstatutorycurrency.p)
/* ========================================================================================================= */
/* SetStatutoryCurrencyBasedOnTCAPMGetGL: Submethod of SetStatutoryCurrencyBasedOnTCAPM that will return */
/* the GL and other analysis details to be used for the VarExchRate-postingline of the matching */
/* The logic in this method is copy of what's in BAPMatching:AdditionalUpdatesAllLinesPLVarExchRateAccount() */
/* ========================================================================================================= */
/* ================================================================================================================== */
/* Note: the logic here accesses operational tables so this has to be done via data-objects that use dynamic querying */
/* ================================================================================================================== */
/* ==================================================================================== */
/* Find out the correct GL, Division and CostCentre that are used for this posting-line */
/* in case of rate-variances (project will always be empty) */
/* Case 1: Get the info from the DefAccountMstr-acdf (Gain + incl:prod-line) */
/* Case 2: Get the info from the DefAccountMstr-acdf (Gain + excl:prod-line) */
/* Case 3: Get the info from the system G/L-Account for 'Exchange - Unrealised Profit' */
/* Case 4: Get the info from the DefAccountMstr-acdf (Loss + incl:prod-line) */
/* Case 5: Get the info from the DefAccountMstr-acdf (Loss + excl:prod-line) */
/* Case 6: Get the info from the system G/L-Account for 'Exchange - Unrealised Loss' */
/* ==================================================================================== */
/* ======================== */
/* Define dataobjects */
/* Set default ReturnStatus */
/* ======================== */
define variable DOProductMaster as com.qad.eefin.tsetstatutorycurrency.ProductMaster.
define variable DOAccountDefaultMaster as com.qad.eefin.tsetstatutorycurrency.AccountDefaultMaster.
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
/* =========================== */
/* Major block for this method */
/* =========================== */
FINDACCOUNTBLOCK: DO :
/* First get the item/product definition as we need the pruduct-line to get the correct account */
DOProductMaster = new com.qad.eefin.tsetstatutorycurrency.ProductMaster (APMatchingLn.PvoDomain,
APMatchingLn.APMatchingLnPvodItem).
assign vcProductLine = DOProductMaster:ProductLine
no-error.
if valid-object(DOProductMaster)
then delete object DOProductMaster no-error. /* Needed to free up memory */
/* Get the account */
if ilGetGainAccount = true /* CreditLC > 0 /* meaning a Gain */ */
then do :
/* Find acdf (account defaults): currency and prod-line */
DOAccountDefaultMaster = new com.qad.eefin.tsetstatutorycurrency.AccountDefaultMaster (APMatchingLn.PvoDomain,
"PO":U,
"PUR_GAIN_ACCT":U,
APMatchingLn.APMatchingLnPvodCurrency,
vcProductLine,
"":U,
"":U,
"":U,
"":U).
/* === Case 1 === */
if valid-object(DOAccountDefaultMaster)
then do :
if DOAccountDefaultMaster:Available
then assign vcGLCode = DOAccountDefaultMaster:GLCode
vcDivisionCode = DOAccountDefaultMaster:DivisionCode
vcCostCentreCode = DOAccountDefaultMaster:CostCentreCode
no-error.
delete object DOAccountDefaultMaster no-error. /* Needed to free up memory */
end. /* if valid-object(DOAccountDefaultMaster) */
if vcGLCode = "":U or
vcGLCode = ?
then do :
DOAccountDefaultMaster = new com.qad.eefin.tsetstatutorycurrency.AccountDefaultMaster (APMatchingLn.PvoDomain,
"PO":U,
"PUR_GAIN_ACCT":U,
APMatchingLn.APMatchingLnPvodCurrency,
"":U,
"":U,
"":U,
"":U,
"":U).
/* === Case 2 === */
if valid-object(DOAccountDefaultMaster)
then do :
if DOAccountDefaultMaster:Available
then assign vcGLCode = DOAccountDefaultMaster:GLCode
vcDivisionCode = DOAccountDefaultMaster:DivisionCode
vcCostCentreCode = DOAccountDefaultMaster:CostCentreCode
no-error.
delete object DOAccountDefaultMaster no-error. /* Needed to free up memory */
end. /* if valid-object(DOAccountDefaultMaster) */
if vcGLCode = "":U or
vcGLCode = ?
then do :
if {&GLSYSTEMTYPE-EXCHANGEUNREALPROFIT} = "":U or
{&GLSYSTEMTYPE-EXCHANGEUNREALPROFIT} = ?
then do :
assign viLocalReturnStatus = -602
ocErrorMessage = "Internal error. The system cannot find the system GL account for exchange rate unrealized profit because the preprocessor for this type of account is not defined.":U.
Leave FINDACCOUNTBLOCK.
end. /* if {&GLSYSTEMTYPE-EXCHANGEUNREALPROFIT} = "":U or */
find first gl where
gl.sharedset_id = viDomainGLSharedSetID and
gl.glsystemtype = {&GLSYSTEMTYPE-EXCHANGEUNREALPROFIT}
no-lock no-error.
if not available gl
then do:
assign viLocalReturnStatus = -603
ocErrorMessage = "Internal error. The system cannot find the system GL account for exchange rate unrealized profit.":U.
Leave FINDACCOUNTBLOCK.
end. /* if not available gl */
/* === Case 3 */
assign oiGLID = GL.GL_ID
vcGLCode = GL.GLCode
vcDivisionCode = "":U
vcCostCentreCode = "":U.
end. /* if vcGLCode = "":U or */
end. /* if vcGLCode = "":U or */
end. /* if ilGetGainAccount = true : vdCreditLC > 0 /* meaning a Gain */ */
else do :
/* Find acdf (account defaults): currency and prod-line */
DOAccountDefaultMaster = new com.qad.eefin.tsetstatutorycurrency.AccountDefaultMaster (APMatchingLn.PvoDomain,
"PO":U,
"PUR_LOSS_ACCT":U,
APMatchingLn.APMatchingLnPvodCurrency,
vcProductLine,
"":U,
"":U,
"":U,
"":U).
/* === Case 4 === */
if valid-object(DOAccountDefaultMaster)
then do :
if DOAccountDefaultMaster:Available
then assign vcGLCode = DOAccountDefaultMaster:GLCode
vcDivisionCode = DOAccountDefaultMaster:DivisionCode
vcCostCentreCode = DOAccountDefaultMaster:CostCentreCode
no-error.
delete object DOAccountDefaultMaster no-error. /* Needed to free up memory */
end. /* if valid-object(DOAccountDefaultMaster) */
if vcGLCode = "":U or
vcGLCode = ?
then do :
/* Find acdf (account defaults): currency */
DOAccountDefaultMaster = new com.qad.eefin.tsetstatutorycurrency.AccountDefaultMaster (APMatchingLn.PvoDomain,
"PO":U,
"PUR_LOSS_ACCT":U,
APMatchingLn.APMatchingLnPvodCurrency,
"":U,
"":U,
"":U,
"":U,
"":U).
/* === Case 5 === */
if valid-object(DOAccountDefaultMaster)
then do :
if DOAccountDefaultMaster:Available
then assign vcGLCode = DOAccountDefaultMaster:GLCode
vcDivisionCode = DOAccountDefaultMaster:DivisionCode
vcCostCentreCode = DOAccountDefaultMaster:CostCentreCode
no-error.
delete object DOAccountDefaultMaster no-error. /* Needed to free up memory */
end. /* if valid-object(DOAccountDefaultMaster) */
if vcGLCode = "":U or
vcGLCode = ?
then do :
if {&GLSYSTEMTYPE-EXCHANGEUNREALLOSS} = "":U or
{&GLSYSTEMTYPE-EXCHANGEUNREALLOSS} = ?
then do :
assign viLocalReturnStatus = -604
ocErrorMessage = "Internal error. The system cannot find the system GL account for exchange rate unrealized loss because the preprocessor for this type of account is not defined":U.
Leave FINDACCOUNTBLOCK.
end. /* if {&GLSYSTEMTYPE-EXCHANGEUNREALLOSS} = "":U or */
find first gl where
gl.sharedset_id = viDomainGLSharedSetID and
gl.glsystemtype = {&GLSYSTEMTYPE-EXCHANGEUNREALLOSS}
no-lock no-error.
if not available gl
then do:
assign viLocalReturnStatus = -605
ocErrorMessage = "Internal error. The system cannot find the system GL account for exchange rate unrealized loss":U.
Leave FINDACCOUNTBLOCK.
end. /* if not available tqGLByGLSystemType */
/* === Case 6 */
assign oiGLID = GL.GL_ID
vcGLCode = GL.GLCode
vcDivisionCode = "":U
vcCostCentreCode = "":U.
end. /* if vcGLCode = "":U or */
end. /* if vcGLCode = "":U or */
end. /* if ilGetGainAccount <> true : vdCreditLC <= 0 /* meaning a Loss */ */
END. /* FINDACCOUNTBLOCK: DO : */
/* ============================================================================================= */
/* Transfer the account-information to the output-params after converting the Codes into the IDs */
/* ============================================================================================= */
if vcGLCode <> "":U and
vcGLCode <> ? and
(oiGLID = 0 or
oiGLID = ?)
then do :
find GL where
GL.SharedSet_ID = viDomainGLSharedSetID and
GL.GLCode = vcGLCode
no-lock no-error.
if available GL
then assign oiGLID = GL.GL_ID.
end. /* if vcGLCode <> "":U and */
if vcDivisionCode <> "":U and
vcDivisionCode <> ? and
(oiDivisionID = 0 or
oiDivisionID = ?)
then do :
find Division where
Division.SharedSet_ID = viDomainDivisionSharedSetID and
Division.DivisionCode = vcDivisionCode
no-lock no-error.
if available Division
then assign oiDivisionID = Division.Division_ID.
end. /* if vcDivisionCode <> "":U and */
if vcCostCentreCode <> "":U and
vcCostCentreCode <> ? and
(oiCostCentreID = 0 or
oiCostCentreID = ?)
then do :
find CostCentre where
CostCentre.SharedSet_ID = viDomainCostCentreSharedSetID and
CostCentre.CostCentreCode = vcCostCentreCode
no-lock no-error.
if available CostCentre
then assign oiCostCentreID = CostCentre.CostCentre_ID.
end. /* if vcCostCentreCode <> "":U and */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.