Description
extra validations
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bbusinessrelation.p)
/* =========================================================================================== */
/* The head office address must always be defined for a business relation !! */
/* => check if there is for every business relation a tAddress record available eg new bus rel */
/* => go through all removed Address records and check for every BR if there is */
/* - a tAddress record that is not marked for deletion */
/* =========================================================================================== */
assign vcTypes = {&ADDRESSTYPECODESYSTEM-REMINDER} + chr(2) +
{&ADDRESSTYPECODESYSTEM-REMITTANCE} + chr(2) +
{&ADDRESSTYPECODESYSTEM-HEADOFFICE}
vlError = false.
do viCount = 1 to 3:
assign vcType = entry(viCount,vcTypes,chr(2)).
<Q-42 run AddressTypePrim (all) (Append) (NoCache)
(input ?, (AddressTypeId)
input vcType, (AddressTypeCode)
output dataset tqAddressTypePrim) in BAddressType >
find first tqAddressTypePrim where
tqAddressTypePrim.tcAddressTypeCode = vcType
no-error.
if not available tqAddressTypePrim
then assign vlError = true.
else do:
case vcType:
when {&ADDRESSTYPECODESYSTEM-HEADOFFICE} then assign viHeadOffice = tqAddressTypePrim.tiAddressType_ID.
when {&ADDRESSTYPECODESYSTEM-REMINDER} then assign viReminder = tqAddressTypePrim.tiAddressType_ID.
when {&ADDRESSTYPECODESYSTEM-REMITTANCE} then assign viRemittance = tqAddressTypePrim.tiAddressType_ID.
end case.
end.
end.
If vlError
then do:
assign vcMessage = trim(#T-79'One of the system address types is missing.':255(837)T-79#)
oiReturnStatus = -1.
<M-47 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-836385':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
end.
for each tBusinessRelation where
tBusinessRelation.BusinessRelation_ID <> 0 and
tBusinessRelation.BusinessRelation_ID <> ?
no-lock:
if not can-find(first tAddress where
tAddress.tc_ParentRowid = tBusinessRelation.tc_Rowid and
tAddress.AddressType_ID = viHeadOffice and
tAddress.tc_Status <> "D":U)
then do:
/* Becuase of the Partial Load, check if the Head Office is not already in the database */
assign vlFcQueryRecordsAvailable = false.
if tBusinessRelation.tc_Status <> "N":U
then do:
<Q-69 assign vlFcQueryRecordsAvailable = AddressByIDsAllInfo (NoCache)
(input tBusinessRelation.BusinessRelation_ID, (BusinessRelation_ID)
input viHeadOffice, (AddressType_ID)) in BBusinessRelation >
end.
if vlFcQueryRecordsAvailable <> true
then do:
assign vcMessage = trim(substitute(#T-16'A business relation must be linked to the head office address. Business relation: &1/&2.':255(836)t-16#, tBusinessRelation.BusinessRelationCode,string(tBusinessRelation.BusinessRelation_ID)))
oiReturnStatus = -1.
<M-11 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tBusinessRelation.tc_Rowid (icRowid),
input 'QADFIN-299':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
end.
end.
end.
for each tAddress where
tAddress.BusinessRelation_ID <> 0 and
tAddress.BusinessRelation_ID <> ? and
tAddress.tc_Status = "D":U
no-lock break by tAddress.BusinessRelation_ID :
if first-of (tAddress.BusinessRelation_ID)
then CHECKADDRESSFORBRBLOCK : do :
if can-find (first bAddress where
bAddress.tc_ParentRowid = tAddress.tc_ParentRowid and
bAddress.tc_Rowid <> tAddress.tc_Rowid and
bAddress.AddressType_ID = viHeadOffice and
bAddress.tc_Status <> "D":U)
then leave CHECKADDRESSFORBRBLOCK.
/* We have to check also database, as because partial data load not all addresses are read for business rel */
<Q-57 assign vlFcQueryRecordsAvailable = AddressByIDsAllInfo (NoCache)
(input tAddress.BusinessRelation_ID, (BusinessRelation_ID)
input viHeadOffice, (AddressType_ID)) in BBusinessRelation >
if vlFcQueryRecordsAvailable
then leave CHECKADDRESSFORBRBLOCK.
/* ============================================================= */
/* Give error-message when we're still in this entry of the loop */
/* ============================================================= */
find bBusinessRelation where
bBusinessRelation.tc_Rowid = tAddress.tc_ParentRowid
no-lock no-error.
assign vcMessage = trim(substitute(#T-17'A business relation must be linked to the head office address. Business relation: &1/&2.':255(836)t-17#, bBusinessRelation.BusinessRelationCode,string(tAddress.BusinessRelation_ID)))
oiReturnStatus = -1.
<M-3 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tAddress.tc_Rowid (icRowid),
input 'QADFIN-245':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
end. /* end if first-of + CHECKADDRESSFORBRRBLOCK */
end. /* end for each tAddress */
/* ================================================================================ */
/* only one address can be specified for head office, invoice, remittance, reminder */
/* ================================================================================ */
for each tAddress where
tAddress.BusinessRelation_ID <> 0 and
tAddress.BusinessRelation_ID <> ? and
(tAddress.AddressType_ID = viHeadOffice or
tAddress.AddressType_ID = viReminder or
tAddress.AddressType_ID = viRemittance or
tAddress.AddressType_ID = viInvoice) and
(tAddress.tc_Status = "C":U or
tAddress.tc_Status = "N":U)
no-lock,
each tBusinessRelation where
tBusinessRelation.tc_Rowid = tAddress.tc_ParentRowid
no-lock
break by tAddress.BusinessRelation_ID
by tAddress.AddressType_ID :
if first-of (tAddress.AddressType_ID)
then do :
find first bAddress where
bAddress.tc_ParentRowid = tAddress.tc_ParentRowid and
bAddress.AddressType_ID = tAddress.AddressType_ID and
bAddress.tc_Rowid <> tAddress.tc_Rowid and
bAddress.tc_Status <> "D":U
no-lock no-error.
if available bAddress
then do :
find bBusinessRelation where
bBusinessRelation.tc_Rowid = tAddress.tc_ParentRowid
no-lock no-error.
assign vcMessage = trim(substitute(#T-19'A business relation can only have one address for the following address types: Head Office, Reminder, and Remittance. Business relation: &1/&2.':255(64898)t-19#,bBusinessRelation.BusinessRelationCode,string(tAddress.BusinessRelation_ID))) + " ":U +
trim(substitute(#T-20'Addresses: &1, &2.':255(839)T-20#,string(tAddress.Address_ID),(if available bAddress then string(bAddress.Address_ID) else "?":U))).
oiReturnStatus = -1.
<M-9 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-247':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
end.
end.
end.