project QadFinancials > class BDDocument > method AdditionalUpdatesPostingDocCtrl
Parameters
icPostingRowid | input | character | |
blStart2 | input-output | logical | |
blStart7 | input-output | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bddocument.p)
/* Error handling */
assign oiReturnStatus = -98
viLocalReturn = 0.
MAIN_BLOCK:
do on error undo, leave:
assign vcAllocationKey = trim(trim(substring(<M-35 GetDDocumentTypeTranslation (input tDDocument.DDocumentType (icType)) in BDDocument>, 1, 25, "CHARACTER")) + " ":U +
string(tDDocument.DDocumentYear, "9999":U) + "/":U +
string(tDDocument.DDocumentNumber, "999999999":U)).
/* ====================================== */
/* First, handle some specific situations */
/* ====================================== */
/* Specific situation 1: old status = Paid C., new status = Paid or Bounced */
if tDDocument.tc_Status = "C":U and
t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-PAIDCON} and
(tDDocument.DDocumentStatus = {&DOCUMENTSTATUS-PAID} or
tDDocument.DDocumentStatus = {&DOCUMENTSTATUS-BOUNCED})
then do:
/* => Document Amount must be posted on the GL linked to the Disconto Status (Credit) */
<M-11 run AdditionalUpdatesGetStatusInfo
(input tDDocument.DDocumentType (icDDocumentType),
input {&DOCUMENTSTATUS-DISCONT} (icDDocumentStatus),
input tDDocument.tcGLCode (icBankGLCode),
input-output blStart2 (blStart2),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
<M-28 run AdditionalUpdatesPostingDocCtrl2
(input tDDocumentStatusInfo.tlGLIsDivisionAccount (ilGLIsDivisionAccount),
input icPostingRowid (icPostingRowid),
input tDDocumentStatusInfo.tcGLCode (icGLCode),
input false (ilDebit),
input t_iDDocument.DDocumentStatus (icDDocumentStatus),
input '':U (icAllocationKey),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
/* => Document Amount must be posted on the GL linked to the Paid C. Status (Debit) */
<M-14 run AdditionalUpdatesGetStatusInfo
(input tDDocument.DDocumentType (icDDocumentType),
input {&DOCUMENTSTATUS-PAIDCON} (icDDocumentStatus),
input tDDocument.tcGLCode (icBankGLCode),
input-output blStart2 (blStart2),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
<M-29 run AdditionalUpdatesPostingDocCtrl2
(input tDDocumentStatusInfo.tlGLIsDivisionAccount (ilGLIsDivisionAccount),
input icPostingRowid (icPostingRowid),
input tDDocumentStatusInfo.tcGLCode (icGLCode),
input true (ilDebit),
input tDDocument.DDocumentStatus (icDDocumentStatus),
input '':U (icAllocationKey),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
/* => Document Amount must be posted on the GL linked to the Bounced Status (Credit), only when new status is Bounced */
if tDDocument.DDocumentStatus = {&DOCUMENTSTATUS-BOUNCED}
then do:
<M-33 run AdditionalUpdatesGetStatusInfo
(input tDDocument.DDocumentType (icDDocumentType),
input {&DOCUMENTSTATUS-BOUNCED} (icDDocumentStatus),
input tDDocument.tcGLCode (icBankGLCode),
input-output blStart2 (blStart2),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
<M-34 run AdditionalUpdatesPostingDocCtrl2
(input tDDocumentStatusInfo.tlGLIsDivisionAccount (ilGLIsDivisionAccount),
input icPostingRowid (icPostingRowid),
input tDDocumentStatusInfo.tcGLCode (icGLCode),
input false (ilDebit),
input t_iDDocument.DDocumentStatus (icDDocumentStatus),
input vcAllocationKey (icAllocationKey),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
end.
end.
/* Specific situation 2: old status = Disconto, new status = Paid C. */
else if tDDocument.tc_Status = "C":U and
t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-DISCONT} and
tDDocument.DDocumentStatus = {&DOCUMENTSTATUS-PAIDCON}
then do:
/* => Document Amount must be posted on the GL linked to the Paid C. Status (Credit) */
<M-17 run AdditionalUpdatesGetStatusInfo
(input tDDocument.DDocumentType (icDDocumentType),
input tDDocument.DDocumentStatus (icDDocumentStatus),
input tDDocument.tcGLCode (icBankGLCode),
input-output blStart2 (blStart2),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
<M-30 run AdditionalUpdatesPostingDocCtrl2
(input tDDocumentStatusInfo.tlGLIsDivisionAccount (ilGLIsDivisionAccount),
input icPostingRowid (icPostingRowid),
input tDDocumentStatusInfo.tcGLCode (icGLCode),
input false (ilDebit),
input tDDocument.DDocumentStatus (icDDocumentStatus),
input '':U (icAllocationKey),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
end.
else if tDDocument.tc_Status = "C":U and
(t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-INCASSO} or
t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-DISCONT})and
tDDocument.DDocumentStatus = {&DOCUMENTSTATUS-BOUNCED}
then do:
/* => Document Amount must be posted on the GL linked to the Paid C. Status (Credit) */
<M-13 run AdditionalUpdatesGetStatusInfo
(input t_iDDocument.DDocumentType (icDDocumentType),
input t_iDDocument.DDocumentStatus (icDDocumentStatus),
input t_iDDocument.tcGLCode (icBankGLCode),
input-output blStart2 (blStart2),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
<M-18 run AdditionalUpdatesPostingDocCtrl2
(input tDDocumentStatusInfo.tlGLIsDivisionAccount (ilGLIsDivisionAccount),
input icPostingRowid (icPostingRowid),
input tDDocumentStatusInfo.tcGLCode (icGLCode),
input false (ilDebit),
input tDDocument.DDocumentStatus (icDDocumentStatus),
input '':U (icAllocationKey),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
end.
/* ================================ */
/* Now handle the normal situations */
/* ================================ */
else do:
if tDDocument.tc_Status <> "N":U and
t_iDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-INIT}
then do:
/* => Document Amount must be posted on the GL linked to the old status (Credit) */
<M-20 run AdditionalUpdatesGetStatusInfo
(input t_iDDocument.DDocumentType (icDDocumentType),
input t_iDDocument.DDocumentStatus (icDDocumentStatus),
input t_iDDocument.tcGLCode (icBankGLCode),
input-output blStart2 (blStart2),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
<M-31 run AdditionalUpdatesPostingDocCtrl2
(input tDDocumentStatusInfo.tlGLIsDivisionAccount (ilGLIsDivisionAccount),
input icPostingRowid (icPostingRowid),
input tDDocumentStatusInfo.tcGLCode (icGLCode),
input false (ilDebit),
input t_iDDocument.DDocumentStatus (icDDocumentStatus),
input '':U (icAllocationKey),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
end.
if tDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-INIT} and
tDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-PAID} and
tDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-BOUNCED}
then do:
/* => Document Amount must be posted on the GL linked to the new status (Debit) */
<M-23 run AdditionalUpdatesGetStatusInfo
(input tDDocument.DDocumentType (icDDocumentType),
input tDDocument.DDocumentStatus (icDDocumentStatus),
input tDDocument.tcGLCode (icBankGLCode),
input-output blStart2 (blStart2),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
<M-32 run AdditionalUpdatesPostingDocCtrl2
(input tDDocumentStatusInfo.tlGLIsDivisionAccount (ilGLIsDivisionAccount),
input icPostingRowid (icPostingRowid),
input tDDocumentStatusInfo.tcGLCode (icGLCode),
input true (ilDebit),
input tDDocument.DDocumentStatus (icDDocumentStatus),
input '':U (icAllocationKey),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
end.
else if tDDocument.DDocumentStatus = {&DOCUMENTSTATUS-PAID} and
not <M-36 MethodIsCalledFromBankEntry
() in BDDocument>
then do:
/* => Document Amount must be posted on the Bank GL (Debit) */
empty temp-table tDefaultSafsDDoc.
<M-39 run AdditionalUpdatesPostingDocCtrl3
(output vdBankDebitTC (odBankDebitTC),
output vdBankDebitLC (odBankDebitLC),
output vdBankDebitCC (odBankDebitCC),
input icPostingRowid (icPostingRowid),
input vcAllocationKey (icAllocationKey),
output vdBankLCExchangeRate (odBankLCExchangeRate),
output vdBankLCExchangeRateScale (odBankLCExchangeRateScale),
output vdBankCCExchangeRate (odBankCCExchangeRate),
output vdBankCCExchangeRateScale (odBankCCExchangeRateScale),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
<M-37 run AddStandardPosting
(input icPostingRowid (icPostingtcRowid),
input tDDocument.tcGLCode (icGLCode),
input '':U (icDivisionCode),
input '':U (icCostCentreCode),
input '':U (icCostCentreText),
input '':U (icProjectCode),
input '':U (icProjectText),
input '':U (icIntercoBusinessRelationCode),
input if available tqGLForCurrency then tqGLForCurrency.tcCurrencyCode else tDDocument.tcCurrencyCode (icCurrencyCode),
input vdBankDebitTC (idDebitTC),
input vdBankDebitLC (idDebitLC),
input vdBankDebitCC (idDebitCC),
input 0 (idDebitPC),
input 0 (idCreditTC),
input 0 (idCreditLC),
input 0 (idCreditCC),
input 0 (idCreditPC),
input 0 (idQty),
input tDDocument.tcPostingText (icLineText),
input '':U (icSafText),
input tDefaultSafsDDoc (tDefaultSafs),
input '':U (icExchangeRateType),
input vdBankLCExchangeRate (idExchangeRate),
input vdBankLCExchangeRateScale (idExchangeRateScale),
input vdBankCCExchangeRate (idPostingLineCCRate),
input vdBankCCExchangeRateScale (idPostingLineCCScale),
output viPostingLineId (oiPostingLineId),
input ? (iiSafStructureId),
input ? (icSafStructureCode),
input vcAllocationKey (icAllocationKey),
input false (ilLinkedCrCyDaemonReqExists),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
<M-38 run AdditionalUpdatesDDocumentPostingLine
(input viPostingLineId (iiPostingLineId),
input tDDocument.DDocumentStatus (icDDocumentStatus),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
end.
end.
end. /* MAIN-BLOCK */
/* Error handling */
assign oiReturnStatus = viLocalReturn.