project QadFinancials > class BBankEntry > method AdditionalUpdatesInvDIMovements
Description
create di movements
Parameters
iiBJournalEntryId | input | integer | Instance of Journal Entry |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bbankentry.p)
/* ======================================================= */
/* Set default return-status */
/* Empty temp-table that is passed to a BDI-method */
/* ======================================================= */
assign oiReturnStatus = -98.
empty temp-table tBankDIMovement.
empty temp-table tDDocInvoiceXrefStageRef.
/* ====================================================================== */
/* Go through the already existing Invoices wherefor a movement is needed */
/* Existing ones : no prepayments */
/* ====================================================================== */
for each tBankStateAlloc where
tBankStateAlloc.tc_ParentRowid = tBankStateLine.tc_Rowid and
(tBankStateAlloc.tc_Status = "N":U or
tBankStateAlloc.tc_Status = "C":U) and
(tBankStateAlloc.DInvoice_ID <> 0 and
tBankStateAlloc.DInvoice_ID <> ?) :
create tBankDIMovement.
assign tBankDIMovement.tiDInvoiceId = tBankStateAlloc.DInvoice_ID
tBankDIMovement.tcGLAccountDivisionCode = "":U
tBankDIMovement.tdAmountDebitTC = if tBankStateAlloc.tcAllocAmountCrDt = {&CREDITDEBITABBREVIATION-DEBIT}
then tBankStateAlloc.BankStateAllocAmountTC
else 0
tBankDIMovement.tdAmountCreditTC = if tBankStateAlloc.tcAllocAmountCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
then tBankStateAlloc.BankStateAllocAmountTC
else 0
tBankDIMovement.tcPostingRowId = tBankStateLine.tcPostingRowId
tBankDIMovement.tlMovementIsForDraft = false
tBankDIMovement.tlIsUndoPayment = false.
if tBankStateAlloc.BankStateAllocType = {&INVOICETYPE-INVOICE} or
tBankStateAlloc.BankStateAllocType = {&INVOICETYPE-CREDITNOTECORRECTION} or /* defect 10132-3283 ddl */
tBankStateAlloc.BankStateAllocType = {&INVOICETYPE-FINANCECHARGE} /* defect FIN-1858 miz */
then assign tBankDIMovement.tdMovementDiscountTC = tBankStateAlloc.BankStateAllocDiscountTC.
else if tBankStateAlloc.BankStateAllocType = {&INVOICETYPE-INVOICECORRECTION} or
tBankStateAlloc.BankStateAllocType = {&INVOICETYPE-CREDITNOTE}
then assign tBankDIMovement.tdMovementDiscountTC = - tBankStateAlloc.BankStateAllocDiscountTC. /* defect 10132-3283 ddl */
for each tBankStateStageAlloc where
tBankStateStageAlloc.tc_ParentRowid = tBankStateAlloc.tc_Rowid and
(tBankStateStageAlloc.tc_Status = "N":U or
tBankStateStageAlloc.tc_Status = "C":U):
create tDDocInvoiceXrefStageRef.
assign tDDocInvoiceXrefStageRef.tc_Rowid = tBankStateStageAlloc.tc_Rowid
tDDocInvoiceXrefStageRef.DInvoiceStage_ID = tBankStateStageAlloc.DInvoiceStage_ID
tDDocInvoiceXrefStageRef.DDocInvoiceXrefStageAlloTC = tBankStateStageAlloc.BankStateStageAllocAmntTC
tDDocInvoiceXrefStageRef.DDocInvoiceXrefStageDiscTC = tBankStateStageAlloc.BankStateStageAllocDiscTC
tDDocInvoiceXrefStageRef.tiDInvoice_ID = tBankStateAlloc.DInvoice_ID
tDDocInvoiceXrefStageRef.DInvoiceStage_ID = tBankStateStageAlloc.DInvoiceStage_ID /* Fin-2138: tDDocInvoiceXrefStageRef.DInvoiceStage_ID needs to be assigned to make sure the stages on the invoice get updated */
tDDocInvoiceXrefStageRef.tc_Status = tBankStateStageAlloc.tc_Status.
end. /* for each tBankStateStageAlloc where */
end. /* for each tBankStateAlloc where */
/* ====================================================================== */
/* Call a method in BDI that will make the movements */
/* ====================================================================== */
if can-find(first tBankDIMovement)
then do:
<M-1 run CreateDInvoiceMovements
(input-output tBankDIMovement (tDIMovement),
input tDDocInvoiceXrefStageRef (tDInvoiceStageUpdates),
input-output iiBJournalEntryId (biBJournalEntryId),
input false (ilClearData),
input tBankStateLine.BankStateLinePostingDate (itPaymentTaxPointDate),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
assign vcMessage = trim(substitute(#T-3'Error &1 has occurred when creating the customer invoice. See other messages for more information.':150(329)t-3#, string(viExternalError))).
<M-2 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-969':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
return.
end. /* if viFcReturnSuper < 0 */
end. /* if can-find(first tBankDIMovement) */
/* ======================================================= */
/* Set return-status = OK */
/* ======================================================= */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.