| icDraftReference | input | character | Description for the draft instance. This parameter will have a value when creating a draft instance. |
| icDraftFormName | input | character | This parameter will have a value when creating a draft instance. |
| ilDraftIsShared | input | logical | This parameter will have a value when creating a draft instance. |
| oiReturnStatus | output | integer | Return status of the method. |
<ANCESTOR-CODE>
/* ================================================================= */
/* If the instance contains uncommitted cinvoices, do not wait for */
/* housekeeping to release the reserved number. Release it now. */
/* When saving a draft instance, store the number to protect it */
/* from being released by housekeeping. */
/* (do not release numbr when cancelling a draft) */
/* ================================================================= */
if viCurrentDraftInstanceId = 0
then for each tCInvoice where
tCInvoice.CInvoiceVoucher <> 0 and
tCInvoice.CInvoiceVoucher <> ?:
if tCInvoice.tc_Status = "C":U or
tCInvoice.tc_Status = "":U
then do:
find first t_iCInvoice where
t_iCInvoice.tc_Rowid = tCInvoice.tc_Rowid
no-lock no-error.
if not available t_iCInvoice
then do:
<M-12 run SetMessage
(input trim(#T-13'The system cannot find initial values for supplier invoice $1 $2 $3.':255(65420)t-13#) (icMessage),
input string(tCInvoice.CInvoicePostingYear) + chr(2) + tCInvoice.tcJournalCode + chr(2) + string(tCInvoice.CInvoiceVoucher) (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tCInvoice.tc_Rowid (icRowid),
input 'QadFin-7959':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
next.
end.
end.
if tCInvoice.tc_Status = "N":U or
((tCInvoice.tc_Status = "C":U or
tCInvoice.tc_Status = "":U) and
t_iCInvoice.CInvoiceIsInitialStatus = true and
(t_iCInvoice.CInvoiceVoucher = 0 or
t_iCInvoice.CInvoiceVoucher = ?) and
(tCInvoice.CInvoiceVoucher <> 0 and
tCInvoice.CInvoiceVoucher <> ?))
then do:
if vlCIDomainIsConsecutNr = false
then do:
assign vhFcComponent = ?.
if icDraftReference = "":U
then do:
<M-2 run ReleaseNumber
(input viCompanyId (iiCompanyId),
input tCInvoice.CInvoicePostingYear (iiNumbrYear),
input tCInvoice.tcJournalCode (icNumbrType),
input tCInvoice.CInvoiceVoucher (iiNumbr),
input viFcCurrentInstanceId (iiInstanceId),
input vcFcComponentName (icClassName),
output viFcReturnSuper (oiReturnStatus)) in BNumber>
/* ===================================================================================================== */
/* Following test is needed in case the posting was created externaly (methods ApiStdMaintainTT() */
/* and ApiStdMaintainMultiTT() in BCInvoiceJournalEntry, BDInvoiceJournalEntry and BPosting */
/* If the number was provided externaly and the action was 'validate', then Transaction.AbortTransaction */
/* is called (end thus ExitInstance in all components) which will try to release a number that was never */
/* picked-up by a call towards BNumber.GetNumber() */
/* ===================================================================================================== */
if viFcReturnSuper = -4 /* -4 means an invalid read : thus the number-record does not yet even exists */
then assign viFcReturnSuper = 0.
end.
else do:
<M-4 run StoreNumber (input viCompanyId (iiCompanyID),
input tCInvoice.CInvoicePostingYear (iiNumbrYear),
input tCInvoice.tcJournalCode (icNumbrType),
input tCInvoice.CInvoiceVoucher (iiNumbr),
output viFcReturnSuper (oiReturnStatus)) in BNumber>
end.
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end. /* if vlCIDomainIsConsecutNr = false */
end.
end.
if viCurrentDraftInstanceId = 0
then for each tCInvoice where
tCInvoice.tc_Status = "N":U and
tCInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTE} and
tCInvoice.tiCAVoucher <> 0 and
tCInvoice.tiCAVoucher <> ?:
assign vhFcComponent = ?.
if icDraftReference = "":U
then do:
<M-3 run ReleaseNumber
(input viCompanyId (iiCompanyId),
input tCInvoice.CInvoicePostingYear (iiNumbrYear),
input tCInvoice.tcCAJournalCode (icNumbrType),
input tCInvoice.tiCAVoucher (iiNumbr),
input viFcCurrentInstanceId (iiInstanceId),
input vcFcComponentName (icClassName),
output viFcReturnSuper (oiReturnStatus)) in BNumber>
/* ===================================================================================================== */
/* Following test is needed in case the posting was created externaly (methods ApiStdMaintainTT() */
/* and ApiStdMaintainMultiTT() in BCInvoiceJournalEntry, BDInvoiceJournalEntry and BPosting */
/* If the number was provided externaly and the action was 'validate', then Transaction.AbortTransaction */
/* is called (end thus ExitInstance in all components) which will try to release a number that was never */
/* picked-up by a call towards BNumber.GetNumber() */
/* ===================================================================================================== */
if viFcReturnSuper = -4 /* -4 means an invalid read : thus the number-record does not yet even exists */
then assign viFcReturnSuper = 0.
end.
else do:
<M-5 run StoreNumber (input viCompanyId (iiCompanyID),
input tCInvoice.CInvoicePostingYear (iiNumbrYear),
input tCInvoice.tcCAJournalCode (icNumbrType),
input tCInvoice.tiCAVoucher (iiNumbr),
output viFcReturnSuper (oiReturnStatus)) in BNumber>
end.
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end.
if viCurrentDraftInstanceId = 0
then
for each tCInvoice where
tCInvoice.tc_Status = "N":U and
tCInvoice.CInvoiceRegistrationNr <> 0 and
tCInvoice.CInvoiceRegistrationNr <> ? :
assign vhFcComponent = ?.
if icDraftReference = "":U
then do:
/* release the registration number */
<M-9 run ReleaseNumber
(input viCompanyId (iiCompanyId),
input 9999 (iiNumbrYear),
input {&SUPPLIERINVOICEREGNUMBER} (icNumbrType),
input tCInvoice.CInvoiceRegistrationNr (iiNumbr),
input viFcCurrentInstanceId (iiInstanceId),
input vcFcComponentName (icClassName),
output viFcReturnSuper (oiReturnStatus)) in BNumber>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end.
else do:
<M-11 run StoreNumber
(input viCompanyId (iiCompanyID),
input 9999 (iiNumbrYear),
input {&SUPPLIERINVOICEREGNUMBER} (icNumbrType),
input tCInvoice.CInvoiceRegistrationNr (iiNumbr),
output viFcReturnSuper (oiReturnStatus)) in BNumber>
end.
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end.
/* ====================================================================================== */
/* Release or store the WHT number */
/* WHT Numbers are retrieved in BCInvoice, BBankEntry, BCDocument and BOpenItemAdjustment */
/* The Numbers are stored in BWithHoldingTax.PostSave */
/* ====================================================================================== */
if viCurrentDraftInstanceId = 0
then do:
/* The WHT Numbers that are retrieved are stored in a data item, since the normal temp-table can be cleared when errors occured somewhere */
do viReleaseNumberCount = num-entries(vcReleaseWHTNumberListCI, chr(4)) to 1 by -1
on error undo, throw:
assign viReleaseWHTNumber = integer(entry(viReleaseNumberCount, vcReleaseWHTNumberListCI, chr(4))) no-error.
if error-status:error
then do:
assign vcMessage = trim(substitute(#T-74'Error releasing WHT Number.':255(183355101)T-74#)) + chr(10) +
trim(substitute(#T-73'WHT Number List: &1':255(517036178)T-73#, trim(vcReleaseWHTNumberListCI))).
oiReturnStatus = -3.
<M-46 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 2 (iiSeverity),
input '':U (icRowid),
input 'qadfin-817042':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
return.
end. /* if error-status:error */
assign vhFcComponent = ?.
if icDraftReference = "":U
then do:
<M-60 run ReleaseNumber
(input viCompanyId (iiCompanyId),
input 9999 (iiNumbrYear),
input 'WHT':U (icNumbrType),
input viReleaseWHTNumber (iiNumbr),
input viFcCurrentInstanceId (iiInstanceId),
input vcFcComponentName (icClassName),
output viFcReturnSuper (oiReturnStatus)) in BNumber>
end.
else do:
<M-70 run StoreNumber
(input viCompanyId (iiCompanyID),
input 9999 (iiNumbrYear),
input 'WHT':U (icNumbrType),
input viReleaseWHTNumber (iiNumbr),
output viFcReturnSuper (oiReturnStatus)) in BNumber>
end.
if viFcReturnSuper <> -4 and /* it can be that the number is already committed in BWHT */
(viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0))
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end. /* do viReleaseNumberCount = num-entries(vcReleaseWHTNumberListCI, chr(4)) to 1 by -1 */
end. /* if viCurrentDraftInstanceId = 0 */