Description
ValidateComponentPost: Method that is called from ValidateComponent before the ancestor-code
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bwithholdingtax.p)
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
/* =============================================================================================== */
/* Table WHT holds some redundant fields: we make sure sure here that they are filled in all cases */
/* We only do this in create mode to avoid overhead */
/* =============================================================================================== */
REDUNDANTFIELDSBLOCK: DO :
for each t_sWHT where
t_sWHT.tc_Status = "N":U :
/* ========= WHTCompanyCode - WHTCompanyLCCurrencyCode */
if t_sWHT.Company_ID <> 0 and
t_sWHT.Company_ID <> ? and
(t_sWHT.WHTCompanyCode = "":U or
t_sWHT.WHTCompanyCode = ? or
t_sWHT.WHTCompanyLCCurrencyCode = "":U or
t_sWHT.WHTCompanyLCCurrencyCode = ?)
then do :
if t_sWHT.Company_ID = viCompanyId
then assign t_sWHT.WHTCompanyCode = vcCompanyCode
t_sWHT.WHTCompanyLCCurrencyCode = vcCompanyLC.
else do :
<Q-58 run CompanyPropertyByIDCodeCurr (all) (Read) (Cache)
(input t_sWHT.Company_ID, (CompanyId)
output dataset tqCompanyPropertyByIDCodeCurr) in BCompanyProperty>
Find tqCompanyPropertyByIDCodeCurr where
tqCompanyPropertyByIDCodeCurr.tiCompany_ID = t_sWHT.Company_ID
no-lock no-error.
If not available tqCompanyPropertyByIDCodeCurr
then do :
assign vcMessage = trim(substitute(#T-92'Unable to find the Entity based upon its ID (&1)':255(199544790)T-92#, string(t_sWHT.Company_ID) ))
viLocalReturnStatus = -1.
<M-81 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tWHT.Company_ID':U (icFieldName),
input string(t_sWHT.Company_ID) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-130722':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BWithholdingTax>
Leave REDUNDANTFIELDSBLOCK.
end. /* If not available tqCompanyPropertyByIDCodeCurr */
assign t_sWHT.WHTCompanyCode = tqCompanyPropertyByIDCodeCurr.tcCompanyPropertyCode
t_sWHT.WHTCompanyLCCurrencyCode = tqCompanyPropertyByIDCodeCurr.tcCurrencyCode.
end. /* Not if t_sWHT.Company_ID = viCompanyId */
end. /* if t_sWHT.Company_ID <> 0 and */
/* ========= WHTCreditorCode - WHTCreditorSharedSetCode - WHTCertFormat_ID */
if t_sWHT.Creditor_ID <> 0 and
t_sWHT.Creditor_ID <> ? and
(t_sWHT.WHTCreditorCode = "":U or
t_sWHT.WHTCreditorCode = ? or
t_sWHT.WHTCreditorSharedSetCode = "":U or
t_sWHT.WHTCreditorSharedSetCode = ? or
t_sWHT.WHTCertFormat_ID = 0 or
t_sWHT.WHTCertFormat_ID = ?)
then do :
<Q-72 run CreditorByIDCodeSharedSet (all) (Read) (Cache)
(input ?, (CompanyId)
input t_sWHT.Creditor_ID, (CreditorID)
output dataset tqCreditorByIDCodeSharedSet) in BCreditor>
Find tqCreditorByIDCodeSharedSet where
tqCreditorByIDCodeSharedSet.tiCreditor_ID = t_sWHT.Creditor_ID
no-lock no-error.
If not available tqCreditorByIDCodeSharedSet
then do :
assign vcMessage = trim(substitute(#T-82'Unable to find the Supplier based upon its ID (&1)':255(699906693)T-82#, string(t_sWHT.Creditor_ID) ))
viLocalReturnStatus = -1.
<M-18 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tWHT.Creditor_ID':U (icFieldName),
input string(t_sWHT.Creditor_ID) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-586151':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BWithholdingTax>
Leave REDUNDANTFIELDSBLOCK.
end. /* If not available tqCreditorByIDCodeSharedSet */
assign t_sWHT.WHTCreditorCode = tqCreditorByIDCodeSharedSet.tcCreditorCode
t_sWHT.WHTCreditorSharedSetCode = tqCreditorByIDCodeSharedSet.tcSharedSetCode
t_sWHT.WHTCertFormat_ID = tqCreditorByIDCodeSharedSet.tiWHTCertFormat_ID.
end. /* if t_sWHT.Creditor_ID <> 0 and */
/* ========= WHTPeriodYear - WHTPeriodPeriod */
if t_sWHT.WHTPaymentDate <> ? and
t_sWHT.Company_ID <> 0 and
t_sWHT.Company_ID <> ? and
(t_sWHT.WHTPeriodYear = 0 or
t_sWHT.WHTPeriodYear = ? or
t_sWHT.WHTPeriodPeriod = 0 or
t_sWHT.WHTPeriodPeriod = ?)
then do :
<Q-37 run PeriodByStartEndDateStatus (all) (Read) (Cache)
(input t_sWHT.Company_ID, (CompanyId)
input t_sWHT.WHTPaymentDate, (Date)
input ?, (PeriodStatus)
input ?, (PeriodId)
input ?, (PeriodIsPostingGLAllowed)
output dataset tqPeriodByStartEndDateStatus) in BPeriod>
Find tqPeriodByStartEndDateStatus where
tqPeriodByStartEndDateStatus.tiCompany_ID = t_sWHT.Company_ID and
tqPeriodByStartEndDateStatus.ttPeriodStartDate <= t_sWHT.WHTPaymentDate and
tqPeriodByStartEndDateStatus.ttPeriodEndDate >= t_sWHT.WHTPaymentDate
no-lock no-error.
If not available tqPeriodByStartEndDateStatus
then do :
assign vcDatetemp = <M-1 DisplayDate (input t_sWHT.WHTPaymentDate (itDate)) in BWithholdingTax>.
assign vcMessage = trim(substitute(#T-40'Unable to find the Period based upon the payment-date (&1)':255(447526283)T-40#, string(t_sWHT.WHTPaymentDate) ))
viLocalReturnStatus = -1.
<M-65 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tWHT.WHTPaymentDate':U (icFieldName),
input vcDatetemp (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-726557':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BWithholdingTax>
Leave REDUNDANTFIELDSBLOCK.
end. /* If not available tqPeriodByStartEndDateStatus */
assign t_sWHT.WHTPeriodYear = tqPeriodByStartEndDateStatus.tiPeriodYear
t_sWHT.WHTPeriodPeriod = tqPeriodByStartEndDateStatus.tiPeriodPeriod.
end. /* if t_sWHT.WHTPaymentDate <> ? and */
/* ========= WHTTaxType */
if t_sWHT.Vat_ID <> 0 and
t_sWHT.Vat_ID <> ? and
(t_sWHT.WHTTaxType = "":U or
t_sWHT.WHTTaxType = ?)
then do :
<Q-30 run VatForVatCodeTaxType (all) (Read) (NoCache)
(input ?, (VatCode)
input t_sWHT.Vat_ID, (VatID)
input ?, (VatInOut)
input ?, (DomainCode)
input ?, (DomainID)
output dataset tqVatForVatCodeTaxType) in BVAT>
Find first tqVatForVatCodeTaxType where /* First is needed as there can be multiple ones due to the joins in the query */
tqVatForVatCodeTaxType.tiVat_ID = t_sWHT.Vat_ID
no-lock no-error.
If not available tqVatForVatCodeTaxType
then do :
assign vcMessage = trim(substitute(#T-39'Unable to find the Taxes based upon its ID (&1)':255(955075950)T-39#, string(t_sWHT.Vat_ID) ))
viLocalReturnStatus = -1.
<M-95 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tWHT.Vat_ID':U (icFieldName),
input string(t_sWHT.Vat_ID) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-322587':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BWithholdingTax>
Leave REDUNDANTFIELDSBLOCK.
end. /* If not available tqVatForVatCodeTaxType */
assign t_sWHT.WHTTaxType = tqVatForVatCodeTaxType.tctx2_tax_type.
end. /* if t_sWHT.Vat_ID <> 0 and */
end. /* for each t_sWHT where */
END. /* REDUNDANTFIELDSBLOCK */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.