project QadFinancials > class BBankEntry > method AdditionalUpdatesInvInstanceOpen
Description
AdditionalUpdatesInvInstanceOpen: method that takes care of the starting/opening of instances
Parameters
olBCInvoiceOpened | output | logical | Is BCInvoice already openend ? |
olBDInvoiceOpened | output | logical | Is BDInvoice already openend ? |
olBCDocumentOpened | output | logical | Is BCDocument already openend ? |
olBDDocumentOpened | output | logical | Is BDDocument already openend ? |
olBWithHoldingTaxOpened | output | logical | Is BWithHoldingTax component opened? |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bbankentry.p)
/* ======================================================== */
/* Check whether an instance of BCI/BDI is needed anyway */
/* ======================================================== */
assign vlReturn = true.
for each tBankState where
tBankState.tc_Status <> "D":U and
(tBankState.BankStateStatus = {&BANKSTATESTATUS-PARTALLOC} or
tBankState.BankStateStatus = {&BANKSTATESTATUS-ALLOC}) NO-LOCK:
if can-find(first tBankStateLine where
tBankStateLine.tc_ParentRowid = tBankState.tc_Rowid and
tBankStateLine.BankStateLineStatus = {&BANKSTATELINESTATUS-ALLOC} and
(tBankStateLine.tc_status = "N":U or
tBankStateLine.tc_status = "C":U) )
then do:
assign vlReturn = false.
leave.
end.
end.
if vlReturn then return.
/* ======================================================= */
/* Set default return-status */
/* ======================================================= */
assign oiReturnStatus = -98.
/* ===================================================== */
/* Check whether an instance of BCI is needed anyway */
/* Check whether an instance of BDI is needed anyway */
/* ===================================================== */
for each tBankState where
tBankState.tc_Status <> "D":U and
(tBankState.BankStateStatus = {&BANKSTATESTATUS-PARTALLOC} or
tBankState.BankStateStatus = {&BANKSTATESTATUS-ALLOC}) no-lock,
each tBankStateLine where
tBankStateLine.tc_ParentRowid = tBankState.tc_Rowid and
tBankStateLine.BankStateLineStatus = {&BANKSTATELINESTATUS-ALLOC} and
(tBankStateLine.tc_status = "N":U or
tBankStateLine.tc_status = "C":U)
by tBankStateLine.BankStateLineNumber :
if can-find(first tBankStateAlloc where
tBankStateAlloc.tc_ParentRowid = tBankStateLine.tc_Rowid and
(tBankStateAlloc.tc_Status = "N":U or
tBankStateAlloc.tc_Status = "C":U) and
((tBankStateAlloc.CInvoice_ID <> 0 and tBankStateAlloc.CInvoice_ID <> ?) or
tBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-NCINV}))
then assign olBCInvoiceOpened = true.
if can-find(first 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 <> ?) or
tBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-NDINV} or
tBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-DEDUCTIONINV}))
then assign olBDInvoiceOpened = true.
if can-find (first tBankStateAlloc where
tBankStateAlloc.tc_ParentRowid = tBankStateLine.tc_Rowid and
(tBankStateAlloc.tc_Status = "N":U or
tBankStateAlloc.tc_Status = "C":U) and
tBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-CCOLL})
then assign olBCDocumentOpened = true.
if can-find (first tBankStateAlloc where
tBankStateAlloc.tc_ParentRowid = tBankStateLine.tc_Rowid and
(tBankStateAlloc.tc_Status = "N":U or
tBankStateAlloc.tc_Status = "C":U) and
tBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-DCOLL})
then assign olBDDocumentOpened = true.
if can-find (first tBankStateAlloc where
tBankStateAlloc.tc_ParentRowid = tBankStateLine.tc_Rowid and
(tBankStateAlloc.tc_Status = "N":U or
tBankStateAlloc.tc_Status = "C":U) and
(tBankStateAlloc.CInvoice_ID <> 0 and
tBankStateAlloc.CInvoice_ID <> ?) and
(tBankStateAlloc.BankStateAllocWHTAmtTC <> 0 and
tBankStateAlloc.BankStateAllocWHTAmtTC <> ?))
then assign olBWithHoldingTaxOpened = true.
end. /* for each tBankState where */
/* ==================================================== */
/* Start and/or open the invoice instances if necessary */
/* ==================================================== */
if olBCInvoiceOpened
then do:
if viBCInvoiceBEID = 0 or viBCInvoiceBEID = ?
then do:
<I-1 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "True"
&CLASS = "BCInvoice"}>
assign vlBCInvoiceIsStartedFromBE = true.
end.
else do:
<I-2 {bFcOpenInstance
&CLASS = "BCInvoice"}>
end.
end. /* if olBCInvoiceOpened */
if olBDInvoiceOpened
then do:
if viBDInvoiceBEID = 0 or viBDInvoiceBEID = ?
then do:
<I-3 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "True"
&CLASS = "BDInvoice"}>
assign vlBDInvoiceIsStartedFromBE = true.
end.
else do:
<I-4 {bFcOpenInstance
&CLASS = "BDInvoice"}>
end.
end. /* if olBDInvoiceOpened */
if olBCDocumentOpened = true
then do :
if viBCDocumentBEID = ? or viBCDocumentBEID = 0
then do:
<I-9 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "true"
&CLASS = "BCDocument"}>
assign vlBCDocumentIsStartedFromBE = true.
end.
else do:
<I-10 {bFcOpenInstance
&CLASS = "BCDocument"}>
end.
if vlUseExtUniqueIDInBEForSetMsg
then do:
<M-41 run SetExternalUniqueIDForSetMessage
(input true (ilUseExternalUID),
output viFcReturnSuper (oiReturnStatus)) in BCDocument>
end.
end. /* if olBCDocumentOpened = true */
if olBDDocumentOpened = true
then do :
if viBDDocumentBEID = ? or viBDDocumentBEID = 0
then do:
<I-5 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "true"
&CLASS = "BDDocument"}>
assign vlBDDocumentIsStartedFromBE = true.
end.
else do:
<I-6 {bFcOpenInstance
&CLASS = "BDDocument"}>
end.
if vlUseExtUniqueIDInBEForSetMsg
then do:
<M-13 run SetExternalUniqueIDForSetMessage
(input true (ilUseExternalUID),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
end.
end. /* if olBDDocumentOpened = true */
if olBWithHoldingTaxOpened = true
then do:
if viBWithholdingTaxBankingEntryID = 0 or viBWithholdingTaxBankingEntryID = ?
then do:
<I-57 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "true"
&CLASS = "BWithholdingTax"}>
assign vlBWHTBEWasStartedHere = true.
end. /* if viBWithholdingTaxBankingEntryID = 0 or viBWithholdingTaxBankingEntryID = ? */
else do:
<I-59 {bFcOpenInstance
&CLASS = "BWithholdingTax"}>
end. /* else do */
end. /* if olBWithHoldingTaxOpened = true */
/* ====================== */
/* Set return-status = OK */
/* ====================== */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.