validation procedure
Description
This method validates State Tax IDs. This validation includes:
Validating that the head office address exists.
Validates that the state tax ID is correct.
In the case of EU countries, the EU VAT number validation is run.
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bdebtor.p)
/* return when the state tax and business relation is empty */
if t_sDebtor.DebtorTaxIDState = '':U or
t_sDebtor.DebtorTaxIDState = ? or
t_sDebtor.tcBusinessRelationCode = ? or
t_sDebtor.tcBusinessRelationCode = '':U
then return.
if oiReturnStatus = 0
then oiReturnStatus = -98.
if t_sDebtor.BusinessRelation_ID <> 0 and
t_sDebtor.BusinessRelation_ID <> ? and
(t_sDebtor.tc_Status = "N":U or
(t_sDebtor.tc_Status = "C" and
can-find (t_iDebtor where
t_iDebtor.tc_Rowid = t_sDebtor.tc_Rowid and
(t_iDebtor.BusinessRelation_ID <> t_sDebtor.BusinessRelation_ID or
t_iDebtor.DebtorTaxIDState <> t_sDebtor.DebtorTaxIDState) )))
then do:
/* check if the country is EU country, if yes, validate it with country tax format */
<Q-2 run AddressByBusinessRelationType (all) (Read) (NoCache)
(input t_sDebtor.tcBusinessRelationCode, (BusinessRelationCode)
input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
output dataset tqAddressByBusinessRelationType) in BBusinessRelation >
find tqAddressByBusinessRelationType where
tqAddressByBusinessRelationType.tcBusinessRelationCode = t_sDebtor.tcBusinessRelationCode and
tqAddressByBusinessRelationType.tcAddressTypeCode = {&ADDRESSTYPECODESYSTEM-HEADOFFICE}
no-error.
if available tqAddressByBusinessRelationType and
tqAddressByBusinessRelationType.tlCountryIsEUCountry = true and
tqAddressByBusinessRelationType.tiCountry_ID <> 0 and
tqAddressByBusinessRelationType.tiCountry_ID <> ?
then do :
/* this assignment is according to GuideLines Writting Busienss Logic v2.0 5.5, no need to start and stop instance */
/* this usage also was refered in description of CheckVatNumber class definition */
Assign vhFcComponent = ?.
<M-3 run ApiCheckVatNumber
(input tqAddressByBusinessRelationType.tiCountry_ID (iiCountryId),
input tqAddressByBusinessRelationType.tcCountryCode (icCountryCode),
input t_sDebtor.DebtorTaxIDState (icVatNumber),
input true (ilMessage),
output vcDummyVatNumberShort (ocVatNumberShort),
output vcDummyVatNumberLong (ocVatNumberLong),
output viFcReturnSuper (oiReturnStatus)) in BCountry>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
end. /* end of if available tqaddress... */
end. /* if t_sDebtor.BusinessRelation_ID <> 0 and */
/* Validate format of the Tax ID */
if t_sDebtor.DebtorIsTaxable and
t_sDebtor.BusinessRelation_ID <> ? and
t_sDebtor.BusinessRelation_ID <> 0
then do:
/* Start BFormatSet component for validation */
if viBFormatSetBDebID = ? or
viBFormatSetBDebID = 0
then do:
<I-53 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "no"
&CLASS = "BFormatSet"}>
end.
else
if not valid-handle(vhBFormatSetBDebInst)
then do:
<I-80 {bFcOpenInstance
&CLASS = "BFormatSet"}>
end.
<Q-94 run AddressByAddressBusRelType (all) (Read) (Cache)
(input ?, (AddressTypeId)
input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
input t_sDebtor.BusinessRelation_ID, (BusinessRelationId)
input ?, (BusinessRelationCode)
input ?, (AddressId)
output dataset tqAddressByAddressBusRelType) in BBusinessRelation>
find first tqAddressByAddressBusRelType where
tqAddressByAddressBusRelType.tiBusinessRelation_ID = t_sDebtor.BusinessRelation_ID and
tqAddressByAddressBusRelType.tcAddressTypeCode = {&ADDRESSTYPECODESYSTEM-HEADOFFICE}
no-error.
if not available tqAddressByAddressBusRelType
then do:
assign vcMessage = #T-16'Cannot read Customer head office address definition (Customer = &1).':255(473136780)T-16#
vcMessage = substitute(vcMessage, t_sDebtor.DebtorCode).
<M-89 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDebtor.tc_Rowid (icRowid),
input 'qadfin-689938':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDebtor>
assign oiReturnStatus = -1.
end.
else do:
/* Federal tax validations - validation executed even it is blank */
<M-83 run ValidateFormat
(input {&FORMATSETTYPE-TAXID} (icFormatType),
input t_sDebtor.DebtorTaxIDState (icValueToValidate),
input 'Debtor':U (icTableName),
input 'DebtorTaxIDState':U (icFieldName),
input tqAddressByAddressBusRelType.tcCountryCode (icCountryCode),
input tqAddressByAddressBusRelType.tcStateCode (icStateCode),
input tqAddressByAddressBusRelType.tcAddressTypeCode (icAddressType),
input 'E':U (icErrorType),
output viFcReturnSuper (oiReturnStatus)) in BFormatSet>
if viFcReturnSuper < 0 or
viFcReturnSuper > 0 and (oiReturnStatus = 0 or oiReturnStatus = -98)
then assign oiReturnStatus = viFcReturnSuper.
end.
end. /* if t_sDebtor.DebtorIsTaxable */
if oiReturnStatus = -98
then oiReturnStatus = 0.