Parameters
Internal usage
QadFinancials
program code (program3/bbusinessrelation.p)
/* =================================================================================================== */
/* Method : CreateRemittanceAddress */
/* Desc : This method will save a new remittance address for the business relation. */
/* AdditionalUpdates method of Bank Import Line will call this method to create */
/* remittance address for further bank file payments convenience. */
/* The Check of existing of remittance address should be done in parent method */
/* --------------------------------------------------------------------------------------------------- */
/* Params: (I) RemittanceAddressToCreate address to be created */
/* (I) ClearData flag to tell if needs to clear data */
/* =================================================================================================== */
if oiReturnStatus = 0
then oiReturnStatus = -98.
if ilClearData = true
then do:
/* clear the class table */
<M-1 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
end. /* end of if ilClearData */
/* get head office address type ID before the for each loop */
/* This will be used to find head office address */
<Q-10 run AddressTypeByCode (all) (Read) (NoCache)
(input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
output dataset tqAddressTypeByCode) in BAddressType >
find first tqAddressTypeByCode no-error.
if available tqAddressTypeByCode
then do:
/* only handle those address which Business Relation ID is valid */
for each tRemittanceAddressToCreate where tRemittanceAddressToCreate.BusinessRelation_ID > 0:
<M-2 run DataLoad
(input '':U (icRowids),
input string(tremittanceAddressToCreate.BusinessRelation_ID) (icPkeys),
input '':U (icObjectIds),
input '':U (icFreeform),
input ilClearData (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do :
assign vcMessage = trim(#T-4'Data could not be loaded: unable to load the Business Relation.':100(68390)T-4#).
<M-5 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 1 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7653':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
return.
end. /* end of if viFcReturnSuper < 0 */
end. /* end of if tRemittanceAddressToCreate.BusinessRelation_ID > 0 */
/* To Create new address for the Businesss Relation */
find first tBusinessRelation
where tBusinessRelation.BusinessRelation_ID = tRemittanceAddressToCreate.BusinessRelation_ID
no-error.
if available tBusinessRelation
then do:
<M-6 run AddDetailLine
(input 'Address':U (icTable),
input tBusinessRelation.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
buffer-copy tRemittanceAddressToCreate
except tRemittanceAddressToCreate.Address_ID
tRemittanceAddressToCreate.tc_ParentRowid
tRemittanceAddressToCreate.tc_Rowid
tRemittanceAddressToCreate.tc_Status
tRemittanceAddressToCreate.BusinessRelation_ID
to tAddress.
/* Fill up the field AddressLogicKeyString, default to string(tAddress.Address_ID)*/
assign tAddress.AddressLogicKeyString = string(tAddress.Address_ID).
/* check to see if there are any other address of this type. IF there is used the last number + 1 */
for each bAddress where bAddress.BusinessRelation_ID = tAddress.BusinessRelation_ID
and bAddress.AddressType_ID = tAddress.AddressType_ID
and bAddress.AddressLogicKeyString <> "":U
by integer(bAddress.AddressLogicKeyString) :
assign tAddress.AddressLogicKeyString = string(bAddress.Address_ID).
end.
/* get mandatory fields value from head office address because they can not be
retrieved from BankImportLine */
find first bAddress where bAddress.AddressType_ID = tqAddressTypeByCode.tiAddressType_ID
no-error.
if available bAddress
then do:
assign tAddress.AddressStreet1 = bAddress.AddressStreet1
tAddress.Country_ID = bAddress.Country_ID
tAddress.TxzTaxZone = bAddress.TxzTaxZone
tAddress.AddressIsSendToPostal = bAddress.AddressIsSendToPostal
tAddress.AddressIsTaxable = bAddress.AddressIsTaxable
tAddress.AddressIsTaxInCity = bAddress.AddressIsTaxInCity
tAddress.AddressIsTaxIncluded = bAddress.AddressIsTaxIncluded
tAddress.BusinessRelation_ID = tBusinessRelation.BusinessRelation_ID
tAddress.AddressIsTemporary = false.
/* Copy values from head office for those fields are mandatory
but possible are blank in Bank Import Line */
if tAddress.tcCountryCode = '':U then assign tAddress.tcCountryCode = bAddress.tcCountryCode.
if tAddress.AddressCity = '':U then assign tAddress.AddressCity = bAddress.AddressCity.
end. /* end of if available bAddress */
end. /* end of if available tBusinessRelation */
end. /* end of for each tRemittanceAddressToCreate */
end. /* end of if available tqAddressByType */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.