Description
Changes the status of the passed in payment selection - supported status are confirm or unconfirm.
Parameters
icPaymentSelectionCode | input | character | |
icPostingJournal | input | character | |
iiPostingPeriod | input | integer | |
iiPostingYear | input | integer | |
itExecutionDate | input | date | |
itPostingDate | input | date | |
olEndOfProcessing | output | logical | |
oiExecutedLines | output | integer | |
ilDocumentPerDueDate | input | logical | |
ilCreditDirectlyOnBank | input | logical | |
ocPreviousStatus | output | character | |
t_sPaySelPayCodeRef | input | temp-table | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program3/bpaymentselection.p)
assign
oiExecutedLines = 0
olEndOfProcessing = false.
empty temp-table tSupplierInvoiceGroups.
if (vcActivityCode <> {&PAYMENTSELECTIONACTIVITY-REGISTER} and
vcActivityCode <> {&PAYMENTSELECTIONACTIVITY-UNCONFIRM})
then do:
assign
vcMessage = trim(substitute(#T-46'Activity code &1 is not supported.':255(743756959)T-46#,vcActivityCode)).
oiReturnStatus = -1.
olEndOfProcessing = true.
<M-71 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input icPaymentSelectionCode (icFieldValue),
input 'E':U (icType),
input 2 (iiSeverity),
input '' (icRowid),
input 'qadfin-599825':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end.
/* Ensure that the icSelection code isn't blank. */
if icPaymentSelectionCode = ? or
icPaymentSelectionCode = ""
then do:
assign
vcMessage = #T-53'Supplier Payment Selection Code cannot be blank':255(575763120)T-53#
oiReturnStatus = -1.
<M-27 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input icPaymentSelectionCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-258035':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
return.
end.
/* Get the ID */
<Q-42 run PaySelPrim (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input 0, (PaySel_ID)
input icPaymentSelectionCode, (PaySelCode)
output dataset tqPaySelPrim) in BPaymentSelection>
find first tqPaySelPrim where tqPaySelPrim.tcPaySelCode = icPaymentSelectionCode no-error.
if not available tqPaySelPrim
then do:
assign
vcMessage = trim(#T-61'Invalid selection Code Entered':255(786893276)T-61#)
oiReturnStatus = -1
olEndOfProcessing = true.
<M-59 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input icPaymentSelectionCode (icFieldValue),
input '':U (icType),
input 2 (iiSeverity),
input '' (icRowid),
input 'qadfin-899480':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output oiReturnStatus (oiReturnStatus)) in BPaymentSelection>
end. /* If no available tqPaySelPrim */
empty temp-table tPaySelPayCodeRef.
for each t_sPaySelPayCodeRef:
create tPaySelPayCodeRef.
buffer-copy t_sPaySelPayCodeRef to tPaySelPayCodeRef.
end.
<M-43 run DataLoad
(input '':U (icRowids),
input tqPaySelPrim.tiPaySel_ID (icPkeys),
input '':U (icObjectIds),
input '' (icFreeform),
input no (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0
then do:
olEndOfProcessing = true.
<M-88 run SetMessage
(input #T-21'The data could not be loaded. The system was unable to modify the payment selection.':100(2965)T-21# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input '':U (icType),
input 2 (iiSeverity),
input '':U (icRowid),
input 'qadfin-164005':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
return.
end.
/* Check if there is at least one line to process - if not we can return */
if vcActivityCode = {&PAYMENTSELECTIONACTIVITY-REGISTER} and
not can-find (first tPaySelLine where
tPaySelLine.PaySelLineIsConfirmed <> yes)
then do :
assign olEndOfProcessing = true.
return.
end.
/* Check if there is at least one line to process - if not we can return */
if vcActivityCode = {&PAYMENTSELECTIONACTIVITY-UNCONFIRM} and
not can-find (first tPaySelLine where
tPaySelLine.PaySelLineIsConfirmed = yes)
then do :
assign olEndOfProcessing = true.
return.
end.
find first tPaySel where tPaySel.PaySel_ID = tqPaySelPrim.tiPaySel_ID no-error.
/* Default the values. */
<M-98 run DefaultValuesForApiConfirm
(input-output iiPostingYear (biPostingYear),
input-output iiPostingPeriod (biPostingPeriod),
input-output itPostingDate (btPostingDate),
input-output icPostingJournal (bcPostingJournal),
input-output itExecutionDate (btExecutionDate),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if (oiReturnStatus < 0) then
do:
olEndOfProcessing = true.
return.
end.
assign
tPaySel.PaySelDate = itExecutionDate
tPaySel.tiPostingYear = iiPostingYear
tPaySel.tiPostingPeriod = iiPostingPeriod
tPaySel.ttPostingDate = itPostingDate
tPaySel.tcPostingJournal = icPostingJournal
tPaySel.tlDocumentPerDueDate = ilDocumentPerDueDate
tPaySel.tlCreditDirectlyOnBank = ilCreditDirectlyOnBank.
/* Split supplier invoice. */
if vcActivityCode = {&PAYMENTSELECTIONACTIVITY-REGISTER}
then do:
<M-36 run SplitSupplierInvoice (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>.
end.
else if vcActivityCode = {&PAYMENTSELECTIONACTIVITY-UNCONFIRM}
then do:
<M-44 run SplitSupplierInvoiceUnconfirm (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>.
end.
viLastInvGroupNbr = 0.
for last tSupplierInvoiceGroups where tSupplierInvoiceGroups.tcPaySelLineStatus <> 'C' break by tSupplierInvoiceGroups.tiGroupNumber:
viLastInvGroupNbr = tSupplierInvoiceGroups.tiGroupNumber.
end.
/* If there's no available PaySelLine to confirm/unconfirm, then update PaySelStatus and return */
if viLastInvGroupNbr = 0
then do:
if vcActivityCode = {&PAYMENTSELECTIONACTIVITY-REGISTER}
then do:
<M-55 run GetPaymentInstrument
(input tPaySel.BankPayFormat_ID (iiBankPayFormatID),
output vcPaymentInstrument (ocPaymentInstrument),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign vcPaySelStatus = if vcPaymentInstrument = {&DOCUMENTTYPECREDITOR-ELECTRONIC}
then {&PAYMENTSELECTIONSTATUS-REGISTERED}
else {&PAYMENTSELECTIONSTATUS-TRANSFERRED}.
end.
else if vcActivityCode = {&PAYMENTSELECTIONACTIVITY-UNCONFIRM}
then do:
assign vcPaySelStatus = {&PAYMENTSELECTIONSTATUS-INITIAL}.
end.
assign vcFindFirstClause = 'for each PaySel where PaySel.PaySel_ID = ' + string(tqPaySelPrim.tiPaySel_ID).
<M-80 run StartPersistence
(output vhFcComponent (ohPersistence),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0
then do :
assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end.
<M-91 run WriteDirect
(input 'PaySel':U (icTableName),
input vcFindFirstClause (icPrepare),
input 'payselstatus':U (icFieldList),
input 'C':U (icFieldListDataTypes),
input vcPaySelStatus (icAbsolute),
input '':U (icIncremental),
input {&TARGETPROCEDURE} (ihClass),
input vcUserLogin (icUserLogin),
output viFcReturnSuper (oiReturnStatus)) in Progress>
assign olEndOfProcessing = true.
return.
end.
<M-20 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if (oiReturnStatus < 0) then
do:
olEndOfProcessing = true.
return.
end.
for each tSupplierInvoiceGroups where
tiGroupNumber = viLastInvGroupNbr break by tiGroupNumber:
oiExecutedLines = oiExecutedLines + 1.
if first-of(tiGroupNumber) then
do:
/* Start CInvoice Instance if necessary. */
if(viBCInvoicePaySelID=0 or viBCInvoicePaySelID = ?) then do:
<I-67 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "true"
&CLASS = "BCInvoice"}>
vlBCInvIsStartedFromPaySel = true.
end.
else do:
<I-12 {bFcOpenInstance
&CLASS = "BCInvoice"}>
end.
<M-87 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if (oiReturnStatus < 0) then
do:
olEndOfProcessing = true.
return.
end.
<M-48 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if (oiReturnStatus < 0) then
do:
olEndOfProcessing = true.
return.
end.
end.
end.
/* After save, record the paysel status */
find first tPaySel where tPaySel.PaySelCode = icPaymentSelectionCode no-error.
assign ocPreviousStatus = tPaySel.PaySelStatus.
/* For last group */
if viLastInvGroupNbr <= 1 then assign olEndOfProcessing = true.