Description
Some parts of APIExpNoteRegister needs to be moved to a separate method (due to limited buffer size).
Parameters
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program3/bexpensenote.p)
/* Create All New Invoices - Posting CIREC vs. CREDITOR CONTROL ACC. */
<M-4 run CreateCInvoices
(input-output tOpenBalanceEN (tOpenBalanceCI),
input viBJournalEntry8ID (iiBJournalEntryId),
input ? (iiPostingId),
input ? (icPONbrInv),
output vcNewRecordInfo (ocNewRecordInfo),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = min(-1, viFcReturnSuper).
return.
end.
/* Process new IDs retrieved from BCInvoice.CreateCInvoices */
do viCounter = num-entries(vcNewRecordInfo , ",":U) to 1 by -2 :
create tCreatedCInvoice.
assign tCreatedCInvoice.tiCInvoice_ID = integer(entry(viCounter , vcNewRecordInfo, ",":U))
tCreatedCInvoice.tiExpNote_ID = integer(entry(viCounter - 1, vcNewRecordInfo, ",":U)) no-error.
/* Complete allocation reference */
find first tMFPostingENRef where
tMFPostingENRef.tiRefExpNote_ID = tCreatedCInvoice.tiExpNote_ID
no-error.
if available tMFPostingENRef
then do:
find first tAllocCInvoice where
tAllocCInvoice.tiPostingId = tMFPostingENRef.tiRefPosting_ID
no-error.
if available tAllocCInvoice
then assign tAllocCInvoice.tiCInvoiceId = tCreatedCInvoice.tiCInvoice_ID.
end.
/* Complete reference for compensations between advances and the new invoice */
for each tAdjustments where
tAdjustments.tiAdjExpNote_ID = tCreatedCInvoice.tiExpNote_ID:
assign tAdjustments.tiNewCInvoice_ID = tCreatedCInvoice.tiCInvoice_ID.
end.
end.
/* New CInvoice needs to be linked to the original ExpNote */
for each tCreatedCInvoice:
find first tExpNote where
tExpNote.ExpNote_ID = tCreatedCInvoice.tiExpNote_ID no-error.
if available tExpNote
then do:
/* link the newly created CInvoice to the ExpNote */
<M-1 run AddDetailLine (input 'ExpNoteCInvoice':U (icTable),
input tExpNote.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BExpenseNote>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = min(-1, viFcReturnSuper).
return.
end.
assign tExpNoteCInvoice.CInvoice_ID = tCreatedCInvoice.tiCInvoice_ID
tExpNoteCInvoice.ExpNoteCInvoiceTypeCode = {&INVOICETYPE-INVOICE}
tExpNoteCInvoice.ExpNoteCInvoiceStatusCode = {&EXPENSENOTESTATUS-REGISTERED}.
end.
end. /* for each tCreatedCInvoice */
/* release the linked invoices */
empty temp-table tSelectedCInvoiceFromExpNote.
for each tExpNote,
each tExpNoteCInvoice where tExpNoteCInvoice.ExpNote_ID = tExpNote.ExpNote_ID and
tExpNoteCInvoice.tc_Status <> "N":U:
find first tSelectedCInvoiceFromExpNote where
tSelectedCInvoiceFromExpNote.tiCInvoiceId = tExpNoteCInvoice.CInvoice_ID
no-error.
if not available tSelectedCInvoiceFromExpNote
then do:
create tSelectedCInvoiceFromExpNote.
assign tSelectedCInvoiceFromExpNote.tiCInvoiceId = tExpNoteCInvoice.CInvoice_ID.
end.
assign tSelectedCInvoiceFromExpNote.tlCInvoiceIsSelected = no.
end.
<M-3 run UpdateCInvoiceIsSelected (input tSelectedCInvoiceFromExpNote (tSelectedCInvoice),
input false (ilClearData),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = min(-1, viFcReturnSuper).
return.
end.