project QadFinancials > class BPosting > method ValidateComponentPre
Description
Validations that need to be done before ANCESTOR CODE.
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bposting.p)
/* IMPORTANT: This method is defined as Private & is not shown in descendant classes */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
empty temp-table tApiQPostingLine.
/* ======================= */
/* Go through all postings */
/* ======================= */
POSTINGBLOCK:
for each t_sPosting
break by t_sPosting.PostingDate:
find t_iPosting where
t_iPosting.tc_Rowid = t_sPosting.tc_Rowid
no-error.
/* Assign fields in t_sPosting */
if t_sPosting.tc_Status = "N":U or
t_sPosting.tc_Status = "C":U
then do:
<M-3 run ValidateComponentPreAssignPosting1 (output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viLocalReturnStatus < 0
then leave POSTINGBLOCK.
end. /* tc_status = "N" or "C" */
/* ================================================================ */
/* Get a new Number and Release the Old number in case it is needed */
/* ================================================================ */
if t_sPosting.tc_Status = "C":U and
can-find(t_iPosting where t_iPosting.tc_Rowid = t_sPosting.tc_Rowid and
t_iPosting.PostingYear <> t_sPosting.PostingYear)
then do:
<M-17 run GetPostingNumber
(input t_sPosting.tc_Rowid (ictcRowid),
input t_sPosting.PostingYear (iiYear),
input t_sPosting.tcJournalCode (icJournalCode),
output t_sPosting.PostingVoucher (oiVoucher),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viLocalReturnStatus < 0
then leave POSTINGBLOCK.
/* Start&Open BNumber (AddToTrx=false) as in a loop below we will be calling BNumber repetively and this */
/* is more performing then using vhFcComponent=?. BNumber will be closed and stopped after the loop */
if viBNumberFromBPostingID = 0 or viBNumberFromBPostingID = ?
then do :
<I-27 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "false"
&CLASS = "BNumber"}>
end. /* if viBNumberFromBPostingID = 0 or viBNumberFromBPostingID = ? */
<M-19 run ReleaseNumber
(input t_iPosting.Company_ID (iiCompanyId),
input t_iPosting.PostingYear (iiNumbrYear),
input t_iPosting.tcJournalCode (icNumbrType),
input t_iPosting.PostingVoucher (iiNumbr),
input viFcCurrentInstanceId (iiInstanceId),
input vcFcComponentName (icClassName),
output viExternalReturnStatus (oiReturnStatus)) in BNumber>
/* Close&Stop BNumber that is started with a different transaction before the previous loop */
/* It is very hard to put this Close&Stop outside the loop as some submethods like GetPostingNumber Start/Stop BNumber themselves as well; that's why we just keep it like this */
if viBNumberFromBPostingID <> 0 and viBNumberFromBPostingID <> ?
then do :
<I-41 {bFcCloseAndStopInstance
&CLASS = "BNumber"}>
end. /* if viBNumberFromBPostingID <> 0 and viBNumberFromBPostingID <> ? */
if (viExternalReturnStatus <> 0 and viExternalReturnStatus <> -4) and
viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viExternalReturnStatus.
if viLocalReturnStatus < 0
then leave POSTINGBLOCK.
end. /* if t_sPosting.tc_Status = "C":U and */
/* Reset the exch-rate related fields */
if first-of(t_sPosting.PostingDate)
then assign vcCurrencyCode = ?
vlCurrencyFetched = false.
/* Reset balance fields for each new posting before going through all lines */
assign vdBalanceLC = 0
vdbalanceCC = 0
vdBalanceTC = 0
vdExchRateLC = 0
vdExchRateScaleLC = 0
vdExchRateCC = 0
vdExchRateScaleCC = 0
vlExchRateLCDiff = false
vlExchRateCCDiff = false
vlZeroTCLineForLC = false
vlZeroTCLineForCC = false
viCurrencyCount = 0
viPostingLineCount = 0
viLCCCRoundingGLID = 0
vcLCCCRoundingGLCode = '':U.
/* ================================================================================================================================= */
/* Go through the lines of the posting */
/* We use a by PostingLineSequence: when comparing the rates for the lines in the SI-Postings, we first want to handle the one on */
/* the control-account before handling the one on the CIREC as the first one will always have thwe highest (or eual) value on it and */
/* this way we minimize the impact on comparing values and rates */
/* ================================================================================================================================= */
POSTINGLINEBLOCK:
for each t_sPostingLine where
t_sPostingLine.tc_ParentRowid = t_sPosting.tc_Rowid
break by t_sPostingLine.tcCurrencyCode
by t_sPostingLine.PostingLineSequence :
/* ====================================================== */
/* Find the original posting-line */
/* ====================================================== */
find t_iPostingLine where
t_iPostingLine.tc_Rowid = t_sPostingLine.tc_Rowid
no-error.
/* Unknown value for tcAllocationType will cause validation errors later on. */
if t_sPostingLine.tcAllocationType = ?
then assign t_sPostingLine.tcAllocationType = "".
if available t_iPosting and t_sPosting.tc_Status <> 'D':U
then do:
if ( t_iPosting.tcLayerTypeCode = {&LAYERTYPECODE-OFFICIAL} or
t_iPosting.tcLayerTypeCode = {&LAYERTYPECODE-MANAGEMENT} ) and
vcActivityCode = "Modify":U and
t_sPostingLine.tc_Status = "C":U
then assign t_sPostingLine.tc_Status = "":U.
if t_iPosting.tcLayerTypeCode = {&LAYERTYPECODE-TRANSIENT} and
(vcActivityCode = "Modify":U or
vcActivityCode = "TransientModify":U or
t_iPosting.tcJournalTypeCode = {&JOURNALTYPE-CIREC}) and
t_sPostingLine.tc_Status = "":U
then assign t_sPostingLine.tc_Status = "C":U.
end. /* if available t_iPosting */
/* Update t_table status */
if t_sPostingLine.tc_Status = "D":U then
do:
for each tPostingVat where tPostingVat.tc_ParentRowid = t_sPostingLine.tc_Rowid:
assign tPostingVat.tc_Status = "D":U.
end.
for each tPostingWHT where tPostingWHT.tc_ParentRowid = t_sPostingLine.tc_Rowid:
assign tPostingWHT.tc_Status = "D":U.
end.
end.
/* ============================================================================= */
/* Assign Redundant fields and force the system to update when appropriate */
/* compare the new values on PostingHeader with the original values of the Lines */
/* ============================================================================= */
if t_sPosting.tc_Status <> 'D' and
(t_sPosting.tc_Status = 'N' or
(available t_iPostingLine and
(t_iPostingLine.Company_ID <> t_sPosting.Company_ID or
t_iPostingLine.Period_ID <> t_sPosting.Period_ID or
t_iPostingLine.PostingYearPeriod <> t_sPosting.PostingYearPeriod or
t_iPostingLine.PostingDate <> t_sPosting.PostingDate)))
then do :
assign t_sPostingLine.tc_Status = if t_sPostingLine.tc_Status = ''
then 'C'
else t_sPostingLine.tc_Status
t_sPostingLine.Period_ID = t_sPosting.Period_ID
t_sPostingLine.PostingYearPeriod = t_sPosting.PostingYearPeriod
t_sPostingLine.PostingDate = t_sPosting.PostingDate
t_sPostingLine.Company_ID = t_sPosting.Company_ID.
end. /* redundant fields */
/* reset cross company fields */
if t_sPostingLine.CrossCompanyPostingLine_ID = ?
then assign t_sPostingLine.CrossCompanyPostingLine_ID = 0.
/* Reset some currency-related fields */
if first-of(t_sPostingLine.tcCurrencyCode)
then assign vlCurrencyFetched = false
vcCurrencyCode = ?.
/* ======================================================================== */
/* Assign fields in t_sPostingLine */
/* ======================================================================== */
if t_sPostingLine.tc_Status = "N":U or
t_sPostingLine.tc_Status = "C":U
then do:
<M-4 run ValidateComponentPreAssignPostingLine
(input-output vcCurrencyCode (bcCurrencyCode),
input-output vlCurrencyFetched (blCurrencyFetched),
input-output vdExchangeRate (bdExchangeRate),
input-output vdExchangeRateScale (bdExchangeRateScale),
input-output vdCCExchangeRate (bdCCExchangeRate),
input-output vdCCExchangeRateScale (bdCCExchangeRateScale),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viLocalReturnStatus < 0
then leave POSTINGBLOCK.
end. /* t_sPostingLine.tc_Status = "N" or "C" */
/* ============================================= */
/* validation for excel integration */
/* ============================================= */
if vcActivityCode = "ExcelIntegration":U
then do:
<Q-32 run GLForGLTypeInfo (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input t_sPostingLine.tcGLCode, (GLCode)
output dataset tqGLForGLTypeInfo) in BGL>
find first tqGLForGLTypeInfo where
tqGLForGLTypeInfo.tcGLCode = t_sPostingLine.tcGLCode
no-error.
if available tqGLForGLTypeInfo
then do:
if (tqGLForGLTypeInfo.tcGLTypeCode = {&GLTYPECODE-DEBT} or
tqGLForGLTypeInfo.tcGLTypeCode = {&GLTYPECODE-CRED} or
tqGLForGLTypeInfo.tcGLTypeCode = {&GLTYPECODE-DDOC} or
tqGLForGLTypeInfo.tcGLTypeCode = {&GLTYPECODE-CDOC} or
tqGLForGLTypeInfo.tcGLTypeCode = {&GLTYPECODE-INVCTRL} or
tqGLForGLTypeInfo.tcGLTypeCode = {&GLTYPECODE-WIPCTRL} or
(tqGLForGLTypeInfo.tcGLTypeCode = {&GLTYPECODE-SYST} and
tqGLForGLTypeInfo.tcGLSystemTypeCode = {&GLSYSTEMTYPE-VOUPAY}))
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-74 run SetMessage
(input substitute(trim(#T-90'The GL account &1 does not allow manual postings or postings with Journal Entry Excel integration.':255(416239020)T-90#), t_sPostingLine.tcGLCode) (icMessage),
input '':U (icArguments),
input 'tPostingLine.tcGLTypeCode' (icFieldName),
input string(tqGLForGLTypeInfo.tcGLTypeCode) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'qadfin-958293':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
end. /* if (tqGLForGLTypeInfo.tcGLTypeCode = {&GLTYPECODE-DEBT} or */
if tqGLForGLTypeInfo.tlGLIsAutomaticAccount <> false
then do:
assign vcMsgExplanation = <M-91 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<M-36 run SetMessage
(input #T-10'The GL account does not allow manual postings.':100(2729)T-10# (icMessage),
input '':U (icArguments),
input 'tPostingLine.tcGLCode' (icFieldName),
input string(tqGLForGLTypeInfo.tcGLCode) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'qadfin-611472':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
end. /* if tqGLForGLTypeInfo.tlGLIsAutomaticAccount <> false */
end. /* if available tqGLForGLTypeInfo */
end. /* if excel integration */
/* ========================================================================================== */
/* In Case of XLS integrations, we assign LC and CC fields when not supplied for TAX accounts */
/* ========================================================================================== */
if vcActivityCode = "JournalEntryTransExcelIntegration":U or
vcActivityCode = "JournalEntryExcelIntegrationRepair":U or
vcActivityCode = "ExcelIntegration":U
then do:
if t_sPostingLine.tcGLTypeCode = {&GLTYPECODE-VAT} and
t_sPostingLine.tc_Status <> "D":U
then do:
find first t_sPostingVat where
t_sPostingVat.tc_ParentRowid = t_sPostingLine.tc_Rowid
no-error.
if available t_sPostingVat
then do:
if t_sPostingLine.PostingLineDebitTC = 0 or t_sPostingLine.PostingLineDebitTC = ?
then assign t_sPostingLine.PostingLineDebitTC = t_sPostingVat.PostingVatTaxDebitTC.
if t_sPostingLine.PostingLineCreditTC = 0 or t_sPostingLine.PostingLineCreditTC = ?
then assign t_sPostingLine.PostingLineCreditTC = t_sPostingVat.PostingVatTaxCreditTC.
end. /* if available t_sPostingVat */
/* ==================================== */
/* Assign LC in case it is not supplied */
/* ==================================== */
if t_sPostingLine.PostingLineDebitLC = ? or t_sPostingLine.PostingLineDebitLC = 0 or
t_sPostingLine.PostingLineCreditLC = ? or t_sPostingLine.PostingLineCreditLC = 0
then do:
if t_sPostingLine.Currency_ID = viCompanyLCId
then assign t_sPostingLine.PostingLineDebitLC = t_sPostingLine.PostingLineDebitTC
t_sPostingLine.PostingLineCreditLC = t_sPostingLine.PostingLineCreditTC
t_sPostingLine.PostingLineExchangeRate = 1
t_sPostingLine.PostingLineRateScale = 1.
else do:
<M-76 run GetExchangeRate
(input t_sPosting.Company_ID (iiCompanyID),
input ? (iiFromCurrencyID),
input t_sPostingLine.tcCurrencyCode (icFromCurrencyCode),
input viCompanyLCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input t_sPosting.PostingDate (itValidityDate),
output vdRate (odExchangeRate),
output vdRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave POSTINGLINEBLOCK.
assign t_sPostingLine.PostingLineExchangeRate = vdRate
t_sPostingLine.PostingLineRateScale = vdRateScale.
if t_sPostingLine.PostingLineDebitLC = ? or t_sPostingLine.PostingLineDebitLC = 0
then assign t_sPostingLine.PostingLineDebitLC = <M-87 RoundAmount
(input t_sPostingLine.PostingLineDebitTC * vdRate * vdRatescale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BPosting>.
if t_sPostingLine.PostingLineCreditLC = ? or t_sPostingLine.PostingLineCreditLC = 0
then assign t_sPostingLine.PostingLineCreditLC = <M-13 RoundAmount
(input t_sPostingLine.PostingLineCreditTC * vdRate * vdRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BPosting>.
end. /* if t_sPostingLine.Currency_ID = viCompanyLCId */
end. /* if t_sPostingLine.PostingLineDebitLC = ? or */
else
if t_sPostingLine.PostingLineDebitTC - t_sPostingLine.PostingLineCreditTC = 0
then assign t_sPostingLine.PostingLineExchangeRate = 0
t_sPostingLine.PostingLineRateScale = 0.
else assign t_sPostingLine.PostingLineExchangeRate = absolute(round((t_sPostingLine.PostingLineDebitLC - t_sPostingLine.PostingLineCreditLC) / (t_sPostingLine.PostingLineDebitTC - t_sPostingLine.PostingLineCreditTC), 10))
t_sPostingLine.PostingLineRateScale = 1.
/* ==================================== */
/* Assign CC in case it is not supplied */
/* ==================================== */
if t_sPostingLine.PostingLineDebitCC = ? or t_sPostingLine.PostingLineDebitCC = 0 or
t_sPostingLine.PostingLineCreditCC = ? or t_sPostingLine.PostingLineCreditCC = 0
then do:
if viCompanyCCId = t_sPostingLine.Currency_ID
then assign t_sPostingLine.PostingLineDebitCC = t_sPostingLine.PostingLineDebitTC
t_sPostingLine.PostingLineCreditCC = t_sPostingLine.PostingLineCreditTC
t_sPostingLine.PostingLineCCRate = 1
t_sPostingLine.PostingLineCCScale = 1.
else
if vlDomainIsStatutory = false
then assign t_sPostingLine.PostingLineDebitCC = t_sPostingLine.PostingLineDebitLC
t_sPostingLine.PostingLineCreditCC = t_sPostingLine.PostingLineCreditLC
t_sPostingLine.PostingLineCCRate = t_sPostingLine.PostingLineExchangeRate
t_sPostingLine.PostingLineCCScale = t_sPostingLine.PostingLineRateScale.
else do:
<M-71 run GetExchangeRate
(input t_sPosting.Company_ID (iiCompanyID),
input ? (iiFromCurrencyID),
input t_sPostingLine.tcCurrencyCode (icFromCurrencyCode),
input viCompanyCCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-STATUTORY} (icExchangeRateTypeCode),
input t_sPosting.PostingDate (itValidityDate),
output vdRate (odExchangeRate),
output vdRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave POSTINGLINEBLOCK.
assign t_sPostingLine.PostingLineCCRate = vdRate
t_sPostingLine.PostingLineCCScale = vdRateScale.
if t_sPostingLine.PostingLineDebitCC = ? or t_sPostingLine.PostingLineDebitCC = 0
then assign t_sPostingLine.PostingLineDebitCC = <M-98 RoundAmount
(input t_sPostingLine.PostingLineDebitTC * vdRate * vdRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input '':U (icCurrencyCode)) in BPosting>.
if t_sPostingLine.PostingLineCreditCC = ? or t_sPostingLine.PostingLineCreditCC = 0
then assign t_sPostingLine.PostingLineCreditCC = <M-66 RoundAmount
(input t_sPostingLine.PostingLineCreditTC * vdRate * vdRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input '':U (icCurrencyCode)) in BPosting>.
end. /* Not if viCompanyCCId = viCompanyLCId */
end. /* if t_sPostingLine.PostingLineDebitCC = ? or */
else
if t_sPostingLine.PostingLineDebitTC - t_sPostingLine.PostingLineCreditTC = 0
then assign t_sPostingLine.PostingLineCCRate = 0
t_sPostingLine.PostingLineCCScale = 0.
else assign t_sPostingLine.PostingLineCCRate = absolute(round((t_sPostingLine.PostingLineDebitCC - t_sPostingLine.PostingLineCreditCC) / (t_sPostingLine.PostingLineDebitTC - t_sPostingLine.PostingLineCreditTC), 10))
t_sPostingLine.PostingLineCCScale = 1.
end. /* if t_sPostingLine.tcGLTypeCode = {&GLTYPECODE-VAT} */
end. /* In Case of XLS integrations, we assign LC and CC fields when not supplied */
/* Fill up business relation code for intercompany posting */
if t_sPosting.tc_Status <> "D":U and
t_sPostingLine.tc_Status <> "D":U and
t_sPostingLine.tcCrossCompanyCode <> "":U and
t_sPostingLine.tcCrossCompanyCode <> ? and
(t_sPostingLine.tcIntercoBusinessRelationCode = ? or
t_sPostingLine.tcIntercoBusinessRelationCode = '':U)
then do:
<M-7 run CalcCrossCompanyBusinessRelation
(input ? (iiCrossCompanyId),
input t_sPostingLine.tcCrossCompanyCode (icCrossCompanyCode),
output t_sPostingLine.tcIntercoBusinessRelationCode (ocBusinessRelationICCode),
output t_sPostingLine.IntercoBusinessRelation_ID (oiBusinessRelationId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viLocalReturnStatus < 0
then leave POSTINGBLOCK.
end. /* if t_sPosting.tc_Status <> "D":U and */
/* Calculate balance LC and CC */
if vlPostingMustBeBalanced = true and
t_sPosting.tc_Status <> "D":U and
t_sPostingLine.tc_Status <> "D":U
then assign vdBalanceLC = vdBalanceLC + t_sPostingLine.PostingLineDebitLC - t_sPostingLine.PostingLineCreditLC
vdBalanceCC = vdBalanceCC + t_sPostingLine.PostingLineDebitCC - t_sPostingLine.PostingLineCreditCC
vdBalanceTC = vdBalanceTC + t_sPostingLine.PostingLineDebitTC - t_sPostingLine.PostingLineCreditTC.
if t_sPosting.tc_Status <> "D":U and
t_sPostingLine.tc_Status <> "D":U
then do:
/* Count the number of Currencies in the posting */
if first-of(t_sPostingLine.tcCurrencyCode)
then assign viCurrencyCount = viCurrencyCount + 1.
/* Find out if the LC-Rate on all lines is the same - if there is a very small difference between the rates that has no significant impact */
/* on the rounded values then consider them the same here */
if vdExchRateLC = 0
then assign vdExchRateLC = t_sPostingLine.PostingLineExchangeRate
vdExchRateScaleLC = t_sPostingLine.PostingLineRateScale.
else
if (vdExchRateLC <> t_sPostingLine.PostingLineExchangeRate or
vdExchRateScaleLC <> t_sPostingLine.PostingLineRateScale) and
(t_sPostingLine.PostingLineDebitTC <> 0 or
t_sPostingLine.PostingLineCreditTC <> 0 or
t_sPostingLine.PostingLineDebitLC <> 0 or
t_sPostingLine.PostingLineCreditLC <> 0)
then if <M-33 RoundAmount
(input (t_sPostingLine.PostingLineDebitTC - t_sPostingLine.PostingLineCreditTC) * t_sPostingLine.PostingLineExchangeRate * t_sPostingLine.PostingLineRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input '':U (icCurrencyCode)) in BPosting> <>
<M-59 RoundAmount
(input (t_sPostingLine.PostingLineDebitTC - t_sPostingLine.PostingLineCreditTC) * vdExchRateLC * vdExchRateScaleLC (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input '':U (icCurrencyCode)) in BPosting>
then assign vlExchRateLCDiff = true.
/* Find out if the CC-Rate on all lines is the same - if there is a very small difference between the rates that has no significant impact */
/* on the rounded values then consider then the same here */
if vdExchRateCC = 0
then assign vdExchRateCC = t_sPostingLine.PostingLineCCRate
vdExchRateScaleCC = t_sPostingLine.PostingLineCCScale.
else
if (vdExchRateCC <> t_sPostingLine.PostingLineCCRate or
vdExchRateScaleCC <> t_sPostingLine.PostingLineCCScale) and
(t_sPostingLine.PostingLineDebitTC <> 0 or
t_sPostingLine.PostingLineCreditTC <> 0 or
t_sPostingLine.PostingLineDebitCC <> 0 or
t_sPostingLine.PostingLineCreditCC <> 0)
then if <M-94 RoundAmount
(input (t_sPostingLine.PostingLineDebitTC - t_sPostingLine.PostingLineCreditTC) * t_sPostingLine.PostingLineCCRate * t_sPostingLine.PostingLineCCScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input '':U (icCurrencyCode)) in BPosting> <>
<M-16 RoundAmount
(input (t_sPostingLine.PostingLineDebitTC - t_sPostingLine.PostingLineCreditTC) * vdExchRateCC * vdExchRateScaleCC (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input '':U (icCurrencyCode)) in BPosting>
then assign vlExchRateCCDiff = true.
/* Find out if there are Lines with only LC/CC filled but TC empty */
if t_sPostingLine.PostingLineDebitTC = 0 and t_sPostingLine.PostingLineCreditTC = 0 and
(t_sPostingLine.PostingLineDebitLC <> 0 or t_sPostingLine.PostingLineCreditLC <> 0)
then assign vlZeroTCLineForLC = true.
if t_sPostingLine.PostingLineDebitTC = 0 and t_sPostingLine.PostingLineCreditTC = 0 and
(t_sPostingLine.PostingLineDebitCC <> 0 or t_sPostingLine.PostingLineCreditCC <> 0)
then assign vlZeroTCLineForCC = true.
end. /* if t_sPosting.tc_Status <> "D":U and */
/* =================================== */
/* Go through the VAT of a PostingLine */
/* =================================== */
POSTINGVATBLOCK:
for each t_sPostingVat where
t_sPostingVat.tc_ParentRowid = t_sPostingLine.tc_Rowid:
/* Fill up the main table ID field on the 3th and 4th level tables to improve performance on dataload */
if t_sPosting.tc_Status <> "D":U and
t_sPostingLine.tc_Status <> "D":U and
(t_sPostingVat.tc_Status = "N":U or
t_sPostingVat.tc_Status = "C":U)
then assign t_sPostingVat.Posting_ID = t_sPosting.Posting_ID.
/* Call a submethod that assigns the VatGroup on PostingVat and that */
/* takes casre of the inflight-creation of vatgroups in certain cases */
/* Only where Vat or Vatgroup is changed or where the journal on the header is changed */
if t_sPostingVat.tc_Status <> "D":U and
(t_sPostingVat.VatGroup_ID = 0 or
t_sPostingVat.VatGroup_ID = ?) and
t_sPosting.tcJournalCode <> "":U and
t_sPosting.tcJournalCode <> ?
then do:
<M-1 run ValidateComponentPreAssignVatGroup (output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viLocalReturnStatus < 0
then leave POSTINGBLOCK.
end. /* Inflight creation of VatGroups */
/* Updates to PostingVat records: Periods */
if t_sPostingVat.tc_Status = "N":U or
(t_sPostingVat.tc_Status = "C":U and
can-find(t_iPostingVat where
t_iPostingVat.tc_Rowid = t_sPostingVat.tc_Rowid and
t_iPostingVat.PostingVatTaxPointDate <> t_sPostingVat.PostingVatTaxPointDate))
then do:
<M-5 run ValidateComponentPreAssignPostingVat
(input-output vcCurrencyCode (bcCurrencyCode),
input-output vlCurrencyFetched (blCurrencyFetched),
input-output vdCCExchangeRate (bdCCExchangeRate),
input-output vdCCExchangeRateScale (bdCCExchangeScale),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viLocalReturnStatus < 0
then leave POSTINGBLOCK.
end. /* PostingVat assigns for period */
end. /* for each t_sPostingVat */
/* ================================================== */
/* Fill up the main table ID field on the 3th and 4th */
/* level tables to improve performance on dataload */
/* Count the posting-lines in the posting */
/* ================================================== */
if t_sPosting.tc_Status <> "D":U and
t_sPostingLine.tc_Status <> "D":U
then do:
assign viPostingLineCount = viPostingLineCount + 1.
for each t_sPostingSaf where
t_sPostingSaf.tc_ParentRowid = t_sPostingLine.tc_Rowid and
(t_sPostingSaf.tc_Status = "N":U or
t_sPostingSaf.tc_Status = "C":U):
assign t_sPostingSaf.Posting_ID = t_sPosting.Posting_ID.
end. /* for each */
for each t_sPostingVatDelay where
t_sPostingVatDelay.tc_ParentRowid = t_sPostingLine.tc_Rowid and
(t_sPostingVatDelay.tc_Status = "N":U or
t_sPostingVatDelay.tc_Status = "C":U):
assign t_sPostingVatDelay.Posting_ID = t_sPosting.Posting_ID.
end. /* for each */
end. /* if t_sPosting.tc_Status <> "D":U and */
end. /* for each t_sPostingLine (POSTINGLINEBLOCK) */
/* ================================= */
/* Make posting balance on LC and CC */
/* ================================= */
if t_sPosting.tc_Status <> "D":U and
vlPostingMustBeBalanced = true and
viCurrencyCount = 1 and
vdBalanceTC = 0 and
(vdBalanceLC <> 0 or vdBalanceCC <> 0)
then do:
<M-20 run ValidateComponentPreBalancePosting
(input vdBalanceTC (idBalanceTC),
input vdBalanceLC (idBalanceLC),
input vdBalanceCC (idBalanceCC),
input viPostingLineCount (iiNumberOfPostingLinesInPosting),
input viCurrencyCount (iiNumberOfCurrenciesInPosting),
input vlZeroTCLineForLC (ilPostingLineWithTCZeroForLC),
input vlZeroTCLineForCC (ilPostingLineWithTCZeroForCC),
input vlExchRateLCDiff (ilDifferentLCExchRatesInPosting),
input vlExchRateCCDiff (ilDifferentCCExchRatesInPosting),
input-output viLCCCRoundingGLID (biLCCCRoundingGLID),
input-output vcLCCCRoundingGLCode (bcLCCCRoundingGLCode),
input-output vdLCRoundingMethodUnit (bdLCRoundingMethodUnit),
input-output vdCCRoundingMethodUnit (bdCCRoundingMethodUnit),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave POSTINGBLOCK.
end. /* if vlPostingMustBeBalanced = true and */
end. /* for each t_sPosting (POSTINGBLOCK) */
assign oiReturnStatus = viLocalReturnStatus.