project QadFinancials > class BPosting > method ValidateComponentPostPostingLine4
Parameters
blQueryStartedGLOpenItemByAll | input-output | logical | |
blClassStartedAndOpenedBCOAMask | input-output | logical | ClassStartedAndOpenedBCOAMask |
blCheckCOAMaskForThisPosting | input-output | logical | This parameter indicates if the GLMask needs to be checked for the company of the posting |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bposting.p)
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0
viLayerID = ?.
POSTINGLINEBLOCK:
do:
if t_sPosting.tc_Status <> "D":U and
(t_sPostingLine.tc_Status = "N":U or
t_sPostingLine.tc_Status = "C":U)
then do:
/* ============================================================================== */
/* If zero values are not allowed then check the debit and credit values */
/* Only do this on the LC-values as the TC-values can be empty for posting-lines */
/* that are created for ExchangeRate-differences (only LC-values are filled then) */
/* ============================================================================== */
if t_sPosting.PostingIsZeroValueAllowed <> true
then do:
assign vcMessage = "":U.
/* Check if DebitLC and CreditLC are empty */
if ((t_sPostingLine.PostingLineCreditLC = 0 or
t_sPostingLine.PostingLineCreditLC = ?) and
(t_sPostingLine.PostingLineDebitLC = 0 or
t_sPostingLine.PostingLineDebitLC = ?))
then do :
/* This can be a valid situation when TC is filled and the Rate is filled and LC is */
/* zero but only in case LC has become zero due to rounding of the LC amount */
assign vdAmountLCCalculated = <M-40 RoundAmount
(input (t_sPostingLine.PostingLineCreditTC - t_sPostingLine.PostingLineDebitTC) * t_sPostingLine.PostingLineExchangeRate * t_sPostingLine.PostingLineRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input ? (icCurrencyCode)) in BPosting>.
if vdAmountLCCalculated <> t_sPostingLine.PostingLineCreditLC - t_sPostingLine.PostingLineDebitLC
then assign vcMessage = trim(substitute(#T-62'The BC amounts for credit &1 and debit &2 cannot both be zero on a single posting line (account &3) unless the posting allows this situation.':254(55962)T-62#,string(t_sPostingLine.PostingLineCreditLC),string(t_sPostingLine.PostingLineDebitLC),string(t_sPostingLine.tcGLCode))).
end. /* if ((t_sPostingLine.PostingLineCreditLC = 0 or */
/* Do NOT Check if DebitTC and CreditTC are empty: see above */
/* Trow message */
if vcMessage <> "":U
then do :
assign vcMsgExplanation = <M-71 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<M-41 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingLine.PostingLineDebitTC':U (icFieldName),
input t_sPostingLine.PostingLineDebitTC (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-8825':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
end. /* if vcMessage <> "":U */
end. /* if t_sPosting.PostingIsZeroValueAllowed <> true */
/* ================================================================ */
/* Check if exchange rate is filled when Transaction Currency <> LC */
/* ================================================================ */
if t_sPostingLine.tcCurrencyCode <> vcCompanyLC and
((t_sPostingLine.PostingLineDebitTC <> 0 and
t_sPostingLine.PostingLineDebitTC <> ?) or
(t_sPostingLine.PostingLineCreditTC <> 0 and
t_sPostingLine.PostingLineCreditTC <> ?)) and
(t_sPostingLine.PostingLineExchangeRate = 0 or
t_sPostingLine.PostingLineExchangeRate = ? or
t_sPostingLine.PostingLineRateScale = 0 or
t_sPostingLine.PostingLineRateScale = ?)
then do:
assign vcMsgExplanation = <M-20 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(#T-72'No exchange rate was defined for this posting line even though the transaction currency is different than the base currency.':255(69667)T-72#)
viLocalReturnStatus = -1.
<M-52 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingLine.PostingLineExchangeRate':U (icFieldName),
input string(t_sPostingLine.PostingLineExchangeRate) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-8835':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* Check if exchange rate is filled when Transaction Currency <> LC */
/* ============================================================= */
/* Check if either DebitLC, either CreditLC is filled / Not both */
/* ============================================================= */
if t_sPostingLine.PostingLineCreditLC <> 0 and
t_sPostingLine.PostingLineCreditLC <> ? and
t_sPostingLine.PostingLineDebitLC <> 0 and
t_sPostingLine.PostingLineDebitLC <> ?
then do:
assign vcMsgExplanation = <M-4 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<M-42 run SetMessage
(input trim(#T-63'You must specify either the credit $1 or the debit $2 amount in base currency on the posting line.':250(978669107)T-63#) (icMessage),
input string(t_sPostingLine.PostingLineCreditLC) + chr(2) + string(t_sPostingLine.PostingLineDebitLC) (icArguments),
input 'tPostingLine.PostingLineDebitLC':U (icFieldName),
input t_sPostingLine.PostingLineDebitLC (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-8826':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
end. /* Check if either DebitLC, either CreditLC is filled / Not both */
/* ============================================================= */
/* Check if either DebitTC, either CreditTC is filled / Not both */
/* ============================================================= */
if t_sPostingLine.PostingLineCreditTC <> 0 and
t_sPostingLine.PostingLineCreditTC <> ? and
t_sPostingLine.PostingLineDebitTC <> 0 and
t_sPostingLine.PostingLineDebitTC <> ?
then do:
assign vcMsgExplanation = <M-44 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<M-43 run SetMessage
(input trim(#T-64'You must specify either the credit $1 or debit $2 amount in TC on a single posting line.':250(65724)T-64#) (icMessage),
input string(t_sPostingLine.PostingLineCreditTC) + chr(2) + string(t_sPostingLine.PostingLineDebitTC) (icArguments),
input 'tPostingLine.PostingLineDebitTC':U (icFieldName),
input t_sPostingLine.PostingLineDebitTC (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-8827':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
end. /* Check if either DebitTC, either CreditTC is filled / Not both */
/* ============= */
/* Check GL mask */
/* ============= */
if blCheckCOAMaskForThisPosting <> false
then do :
/* since start instance of BCOAMask costs a lot of time, we could first check whether domain is with COAMask.*/
<M-86 run CheckIsWithCOAMask
(input t_sPostingLine.Company_ID (iiCompanyId),
output vlIsWithCOAMask (olIsWithCOAMask),
input ? (iiDomainId),
output vlIsCOAMaskDiv (olIsCOAMaskDiv),
output vlIsCOAMaskDivAll (olIsCOAMaskDivAll),
output vlIsCOAMaskCC (olIsCOAMaskCC),
output vlIsCOAMaskCCAll (olIsCOAMaskCCAll),
output vlIsCOAMaskProj (olIsCOAMaskProj),
output vlIsCOAMaskProjAll (olIsCOAMaskProjAll),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0 then assign viLocalReturnStatus = viFcReturnSuper.
if vlIsWithCOAMask then
do:
/* Start and open BCOAMask in another transaction. This is much more performing then using ans instance-less call as the call to ApiGLMaskIsValid needs to be done multiple times (when it needs to be done once). It will be ClosedAndStopped outside the main loop in method ValidateComponentPost. */
if blClassStartedAndOpenedBCOAMask = false
then do :
<I-61 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "false"
&CLASS = "BCOAMask"}>
assign blClassStartedAndOpenedBCOAMask = true.
end. /* if blClassStartedAndOpenedBGLMask = false */
<M-74 run ValidateCOAMask
(input t_sPostingLine.tcGLCode (icGLCode),
input t_sPostingLine.tcDivisionCode (icDivisionCode),
input t_sPostingLine.tcCostCentreCode (icCostCentreCode),
input t_sPostingLine.tcProjectCode (icProjectCode),
input t_sPostingLine.tc_Rowid (icRowId),
input t_sPostingLine.Company_ID (iiCompanyId),
input vlIsCOAMaskDiv (ilIsCOAMaskDiv),
input vlIsCOAMaskDivAll (ilIsCOAMaskDivAll),
input vlIsCOAMaskCC (ilIsCOAMaskCC),
input vlIsCOAMaskCCAll (ilIsCOAMaskCCAll),
input vlIsCOAMaskProj (ilIsCOAMaskProj),
input vlIsCOAMaskProjAll (ilIsCOAMaskProjAll),
output viFcReturnSuper (oiReturnStatus)) in BCOAMask>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0 then assign viLocalReturnStatus = viFcReturnSuper.
end.
end. /* if blCheckGLMaskForThisPosting <> false */
/* ================================================== */
/* Allocation Key is mandatory for OPEN ITEM accounts */
/* ================================================== */
if t_sPostingLine.tcGLTypeCode = {&GLTYPECODE-OPEN} and
t_sPostingLine.tcAllocationType <> {&ALLOCATIONTYPE-LATER} and
(t_sPostingLine.tcAllocationKey = "":U or
t_sPostingLine.tcAllocationKey = ?)
then do:
assign vcMsgExplanation = <M-78 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<M-46 run SetMessage
(input trim(#T-66'You must enter an allocation key.':100(2734)T-66#) (icMessage),
input '':U (icArguments),
input 'tPostingLine.tcAllocationKey':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-8829':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
end. /* Allocation Key is mandatory for OPEN ITEM accounts */
/* =============================== */
/* Check allocation key uniqueness */
/* =============================== */
if t_sPostingLine.tcGLTypeCode = {&GLTYPECODE-OPEN} and
t_sPostingLine.tcAllocationType = "N":U and
t_sPostingLine.tcAllocationKey <> "":U and
t_sPostingLine.tcAllocationKey <> ?
then do:
if blQueryStartedGLOpenItemByAll = false
then do:
<Q-55 run GLOpenItemByAll (Start) in BGLOpenItem >
assign blQueryStartedGLOpenItemByAll = true.
end.
<Q-56 assign vlFcQueryRecordsAvailable = GLOpenItemByAll (Cache)
(input t_sPostingLine.GL_ID, (GL_ID)
input t_sPostingLine.PostingLine_ID, (PostingLineIDToSkip)
input t_sPostingLine.tcAllocationKey, (Key)
input ?, (CompanyId)) in BGLOpenItem >
if vlFcQueryRecordsAvailable <> false
then do:
assign vcMsgExplanation = <M-39 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<M-47 run SetMessage
(input #T-67'An allocation with this key already exists.':100(115)T-67# (icMessage),
input '':U (icArguments),
input 'tPostingLine.tcAllocationKey':U (icFieldName),
input t_sPostingLine.tcAllocationKey (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-8830':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
end. /* if vlFcQueryRecordsAvailable <> false */
end. /* Check allocation key uniqueness */
/* ============================================================= */
/* The Posting on Open Item Movements should have the same layer */
/* as the posting on the original Open Item. */
/* ============================================================= */
if t_sPostingLine.tcGLTypeCode = {&GLTYPECODE-OPEN} and
t_sPostingLine.tcAllocationType = "L":U
then do:
if blQueryStartedGLOpenItemByAll = false
then do:
<Q-57 run GLOpenItemByAll (Start) in BGLOpenItem >
assign blQueryStartedGLOpenItemByAll = true.
end. /* if blQueryStartedGLOpenItemByAll = false */
<Q-58 run GLOpenItemByAll (all) (Read) (Cache)
(input t_sPostingLine.GL_ID, (GL_ID)
input ?, (PostingLineIDToSkip)
input t_sPostingLine.tcAllocationKey, (Key)
input ?, (CompanyId)
output dataset tqGLOpenItemByAll) in BGLOpenItem >
find tqGLOpenItemByAll where
tqGLOpenItemByAll.tiGL_ID = t_sPostingLine.GL_ID and
tqGLOpenItemByAll.tcGLOpenItemKey = t_sPostingLine.tcAllocationKey and
tqGLOpenItemByAll.tcCurrencyCode = t_sPostingLine.tcCurrencyCode
no-error.
if not available tqGLOpenItemByAll
then do:
find bPostingLine where
bPostingLine.Currency_ID = t_sPostingLine.Currency_ID and
bPostingLine.GL_ID = t_sPostingLine.GL_ID and
bPostingLine.tcAllocationKey = t_sPostingLine.tcAllocationKey and
bPostingLine.tcAllocationType = "N":U
no-error.
if not available bPostingLine
then do:
assign vcMsgExplanation = <M-5 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<M-49 run SetMessage
(input trim(#T-69'The allocation key cannot found for account $1 and currency $2.':255(64930)T-69#) (icMessage),
input t_sPostingLine.tcGLCode + chr(2) + t_sPostingLine.tcCurrencyCode (icArguments),
input 'tPostingLine.tcAllocationKey':U (icFieldName),
input t_sPostingLine.tcAllocationKey (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-8832':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
leave POSTINGLINEBLOCK.
end. /* if not available bPostingLine */
end. /* else do */
end. /* if t_sPostingLine.tcGLTypeCode = {&GLTYPECODE-OPEN} and ... */
end. /* if t_sPosting.tc_Status <> "D":U and ... */
end. /* POSTNIGLINEBLOCK */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.