Parameters
| iiDDocumentID | input | integer | |
| iiAddressTypeID | input | integer | |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bdcollection.p)
find first tDDocument where tDDocument.DDocument_ID = iiDDocumentID no-error.
if not available tDDocument
then do:
<M-3 run SetMessage
(input #T-53'Customer Payment with ID: $1 cannot be found':255(808304297)T-53# (icMessage),
input string(iiDDocumentID) (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'qadfin-152523':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
assign
oiReturnStatus = -1.
return.
end.
<M-7 run FillProDataSetDebtor (input tDDocument.Debtor_ID (iiDebtorID),
input iiAddressTypeID (iiAddressTypeID),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
find first tPaymentCurrency where tPaymentCurrency.Currency_ID = tDDocument.Currency_ID no-error.
if not available tPaymentCurrency and tDDocument.Currency_ID <> 0 and tDDocument.Currency_ID <> ?
then do:
<Q-8 run CurrencyByIDAllInfo (all) (Read) (NoCache)
(input tDDocument.Currency_ID, (Currency_ID)
output dataset tqCurrencyByIDAllInfo) in BCurrency >
find first tqCurrencyByIDAllInfo no-error.
if available tqCurrencyByIDAllInfo
then do:
create tPaymentCurrency.
vhBufferForProDataSet = dataset tqCurrencyByIDAllInfo:get-buffer-handle(1).
<M-9 run BufferCopy (input vhBufferForProDataSet (ihFrom),
input buffer tPaymentCurrency:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
if viFcReturnSuper < 0
then do:
assign
oiReturnStatus = viFcReturnSuper.
return.
end.
else if viFcReturnSuper > 0
then do:
if oiReturnStatus = -98 or oiReturnStatus >=0 then
assign
oiReturnStatus = viFcReturnSuper.
end.
end. /*if available tqCurrencyByIDAllInfo then do*/
end. /* if not available tPaymentCurrency */
find first tDebtorGLBankNumber where tDebtorGLBankNumber.BankNumber_ID = tDDocument.BankNumber_ID no-error.
if not available tDebtorGLBankNumber and tDDocument.BankNumber_ID <> 0 and tDDocument.BankNumber_ID <> ?
then do:
<Q-20 run BankNumberByIDAllInfo (all) (Read) (NoCache)
(input tDDocument.BankNumber_ID, (BankNumber_ID)
input ?, (BankNumberIsDefault)
output dataset tqBankNumberByIDAllInfo) in BBankNumber >
find first tqBankNumberByIDAllInfo no-error.
if available tqBankNumberByIDAllInfo
then do:
create tDebtorGLBankNumber.
vhBufferForProDataSet = dataset tqBankNumberByIDAllInfo:get-buffer-handle(1).
<M-11 run BufferCopy
(input vhBufferForProDataSet (ihFrom),
input buffer tDebtorGLBankNumber:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
if viFcReturnSuper < 0
then do:
assign oiReturnStatus = viFcReturnSuper.
return.
end.
else if viFcReturnSuper > 0
then do:
if oiReturnStatus = -98 or oiReturnStatus >=0 then
assign oiReturnStatus = viFcReturnSuper.
end.
<Q-46 run BankAccFormatPrim (all) (Read) (NoCache)
(input tDebtorGLBankNumber.BankAccFormat_ID, (BankAcctFormatId)
input ?, (BankAcctFormatCode)
output dataset tqBankAccFormatPrim) in BBankAccountFormat >
find first tqBankAccFormatPrim no-error.
if available tqBankAccFormatPrim then
tDebtorGLBankNumber.tcBankAccFormatCode = tqBankAccFormatPrim.tcBankAccFormatCode.
/* Fill Debtor Bank Business Relation*/
if tDebtorGLBankNumber.BankBusinessRelation_ID <> 0
then do:
<Q-26 run BusinessRelationByIDAllInfo (all) (Read) (NoCache)
(input tDebtorGLBankNumber.BankBusinessRelation_ID, (BusinessRelation_ID)
output dataset tqBusinessRelationByIDAllInfo) in BBusinessRelation >
find first tqBusinessRelationByIDAllInfo no-error.
if not available tqBusinessRelationByIDAllInfo
then do:
<M-27 run SetMessage
(input #T-97'No Business Relation record is available':50(667051905)T-97# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'D':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-8428':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
assign
oiReturnStatus = -1.
return.
end. /* if not available tqBusinessRelationByIDAllInfo */
else do:
assign
vhBufferForBusinessRelation = dataset tqBusinessRelationByIDAllInfo:get-buffer-handle(1).
for first tqBusinessRelationByIDAllINfo:
find first tDebtorBankBusRel
where tDebtorBankBusRel.BusinessRelation_ID = tqBusinessRelationByIDAllInfo.tiBusinessRelation_ID no-error.
if not available tDebtorBankBusRel
then do: /* to avoid duplicate key issue */
create tDebtorBankBusRel.
<M-28 run BufferCopy
(input vhBufferForBusinessRelation (ihFrom),
input buffer tDebtorBankBusRel:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end. /* if not available tDebtorBankBusRel */
<Q-29 run ContactByIDAllInfo (all) (Read) (NoCache)
(input tDebtorBankBusRel.BusinessRelation_ID, (BusinessRelation_ID)
output dataset tqContactByIDAllInfo) in BBusinessRelation >
assign vhBufferForContact = dataset tqContactByIDAllInfo:get-buffer-handle(1).
for each tqContactByIDAllInfo:
find first tDebtorBankContact where tDebtorBankContact.Contact_ID = tqContactByIDAllInfo.tiContact_ID no-error.
if not available tDebtorBankContact
then do: /* to avoid duplicate key issue */
create tDebtorBankContact.
<M-30 run BufferCopy
(input vhBufferForContact (ihFrom),
input buffer tDebtorBankContact:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end. /* then do: */
end. /*for each tqContactByIDAllInfo*/
<Q-44 run AddressByIDsAllInfo (all) (Read) (NoCache)
(input tDebtorBankBusRel.BusinessRelation_ID, (BusinessRelation_ID)
input iiAddressTypeID, (AddressType_ID)
output dataset tqAddressByIDsAllInfo) in BBusinessRelation >
find first tqAddressByIDsAllInfo no-error.
if not available tqAddressByIDsAllInfo
then do:
<M-31 run SetMessage
(input #T-80'No Address Record Is Available For the Bank':255(491011321)T-80# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'D':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-8429':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
assign
oiReturnStatus = -1.
return.
end. /* end of if not available tqAddressByIDsAllInfo */
else do:
assign
vhBufferForAddress = dataset tqAddressByIDsAllInfo:get-buffer-handle(1).
for first tqAddressByIDsAllInfo:
find first tDebtorBankAddress where tDebtorBankAddress.Address_ID = tqAddressByIDsAllInfo.tiAddress_ID no-error.
if not available tDebtorBankAddress
then do: /* to avoid duplicate key issue */
create tDebtorBankAddress.
<M-35 run BufferCopy
(input vhBufferForAddress (ihFrom),
input buffer tDebtorBankAddress:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
find first tDebtorBankCountry where tDebtorBankCountry.Country_ID = tDebtorBankAddress.Country_ID no-error.
if not available tDebtorBankCountry and tDebtorBankAddress.Country_ID <>0
then do:
<Q-36 run CountryByIDAllInfo (all) (Read) (NoCache)
(input tDebtorBankAddress.Country_ID, (Country_ID)
output dataset tqCountryByIDAllInfo) in BCountry >
find first tqCountryByIDAllInfo no-error.
if not available tqCountryByIDAllInfo
then do:
<M-37 run SetMessage
(input #T-89'No Country Record Found for This Bank':255(861826301)T-89# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'D':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-8430':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
assign
oiReturnStatus = -1.
return.
end. /* end of if not available tqCountryByIDAllInfo */
else do:
assign
vhBufferForCountry = dataset tqCountryByIDAllInfo:get-buffer-handle(1).
for first tqCountryByIDAllInfo:
find first tDebtorBankCountry where tDebtorBankCountry.Country_ID = tqCountryByIDAllInfo.tiCountry_ID no-error.
if not available tDebtorBankCountry
then do: /* to avoid duplicate key issue */
create tDebtorBankCountry.
<M-41 run BufferCopy
(input vhBufferForCountry (ihFrom),
input buffer tDebtorBankCountry:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end. /* to avoid duplicate key issue */
end. /* for each tqCountryByIDAllInfo*/
end. /* tqCountryAllInfo else do */
end. /* if tDebtorBankAddress.Country_ID <>0 */
find first tDebtorBankState where tDebtorBankState.State_ID = tDebtorBankAddress.State_ID no-error.
if not available tDebtorBankState and tDebtorBankAddress.State_ID<>0
then do:
<Q-42 run StateByIDAllInfo (all) (Read) (NoCache)
(input tDebtorBankAddress.State_ID, (State_ID)
output dataset tqStateByIDAllInfo) in BState >
assign
vhBufferForState = dataset tqStateByIDAllInfo:get-buffer-handle(1).
for each tqStateByIDAllInfo:
find first tDebtorBankState where tDebtorBankState.State_ID = tqStateByIDAllInfo.tiState_ID no-error.
if not available tDebtorBankState
then do: /* to avoid duplicate key issue */
create tDebtorBankState.
<M-43 run BufferCopy
(input vhBufferForState (ihFrom),
input buffer tDebtorBankState:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
end. /* to avoid dupliate key issue */
end. /* for each tqStataByIDAllInfo */
end. /* if tBankAddress.State_ID<>0 */
end. /* for each tqAddressByIDAllInfo */
end. /* tqAddressAllInfo else do */
end. /*for first tqBusinessRelationByIDAllINfo */
end. /* tqBusinessRelationByIDAllInfo else do */
end. /* if tDebtorGLBankNumber.BankBusinessRelation_ID <> 0 */
end. /* if available tqBusinessRelationByIDAllInfo */
end. /* if not available tDebtorGLBankNumber */
if tDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-INIT}
then do:
<Q-19 run DDocuInvoiceXrefbyIdAllInfo (all) (Read) (NoCache)
(input ?, (CompanyID)
input iiDDocumentID, (DocumentID)
output dataset tqDDocuInvoiceXrefbyIdAllInfo) in BDDocument >
viCounter = iiDDocumentID.
for each tqDDocuInvoiceXrefbyIdAllInfo:
viCounter = viCounter + 1.
<Q-13 run DInvoiceByIDAllInfo (all) (Read) (NoCache)
(input ?, (CompanyId)
input tqDDocuInvoiceXrefbyIdAllInfo.tiDInvoice_ID, (DInvoiceID)
output dataset tqDInvoiceByIDAllInfo) in BDInvoice >
for each tqDInvoiceByIDAllInfo on error undo, throw:
vhBufferForProDataSet = dataset tqDInvoiceByIDAllInfo:get-buffer-handle(1).
create tDInvoice.
<M-14 run BufferCopy (input vhBufferForProDataSet (ihFrom),
input buffer tDInvoice:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BDCollection>
if viFcReturnSuper < 0
then do:
assign
oiReturnStatus = viFcReturnSuper.
return.
end.
else if viFcReturnSuper > 0
then do:
if oiReturnStatus = -98 or oiReturnStatus >=0 then
assign
oiReturnStatus = viFcReturnSuper.
end.
tDInvoice.tiDDocumentID = tqDDocuInvoiceXrefbyIdAllInfo.tiDDocument_ID.
end.
end. /* end of for each tqDDocumentInvoiceXrefAllInfobyId */
end. /* end not initial */