project QadFinancials > class BDDocument > method ValidateComponentDDocumentStatus
Parameters
icRowId | input | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bddocument.p)
find t_sDDocument where
t_sDDocument.tc_Rowid = icRowId
no-error.
if not available t_sDDocument
then do:
<M-3 run SetMessage
(input trim(#T-16'The system cannot find a customer payment with row ID $1.':250(1651)T-16#) (icMessage),
input icRowId (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-2543':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
return.
end.
assign vcDDocumentStatus = <M-4 GetDDocumentStatusTranslation (input t_sDDocument.DDocumentStatus (icStatus)) in BDDocument>
vlCalledFromBankEntry = <M-28 MethodIsCalledFromBankEntry
() in BDDocument>.
if t_sDDocument.tc_Status = "C":U then
do:
if t_sDDocument.DDocumentStatus = {&DOCUMENTSTATUS-BOUNCED}
or t_sDDocument.DDocumentStatus = {&DOCUMENTSTATUS-INIT} then
do:
if can-find(t_sDDocumentInvoiceXref where t_sDDocumentInvoiceXref.tcDInvoiceType = {&INVOICETYPE-DEDUCTION}
and t_sDDocumentInvoiceXref.DDocument_ID = t_sDDocument.DDocument_ID)
then do:
/* Deduction invoice could be rejected as a normal invoice. In this case, bounced payment with rejected deduction
invoice, the warming message should not be pop-up.
In another case, payment with new deduction invoice (auto-write off), when to bounce the payment, it needs to reminder
user.
*/
<Q-2 run GetPostingInfoByDocumentID (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input t_sDDocument.DDocument_ID, (DDocumentID)
output dataset tqGetPostingInfoByDocumentID) in BDDocument>
for first tqGetPostingInfoByDocumentID:
assign vcDeductionPostingKey = string(tqGetPostingInfoByDocumentID.tiPostingYear) + '/':U + tqGetPostingInfoByDocumentID.tcJournalCode + '/':U + string(tiPostingVoucher, "999999999":U)
vcDeductionStatusList = string({&INVOICEDEDUCTSTATUS-APPROVEWRITEOFF}) + ',':U + string({&INVOICEDEDUCTSTATUS-WRITE-OFF}) + ',':U + string({&INVOICEDEDUCTSTATUS-CREDITED}).
<Q-61 run GetDeductionByDDocIDStatus (first) (Read) (NoCache)
(input ?, (CompanyId)
input t_sDDocument.DDocument_ID, (DDocumentID)
input vcDeductionStatusList, (DeductionStatusList)
output dataset tqGetDeductionByDDocIDStatus) in BDDocument>
for each tqGetDeductionByDDocIDStatus:
<Q-81 run GetPostingTextByDInvoiceID (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tqGetDeductionByDDocIDStatus.tiDInvoice_ID, (DInvoiceID)
output dataset tqGetPostingTextByDInvoiceID) in BDInvoice>
if can-find(first tqGetPostingTextByDInvoiceID where tqGetPostingTextByDInvoiceID.tcPostingText begins vcDeductionPostingKey) then
do:
<M-29 run SetMessage
(input #T-82'This payment contains deductions that are already Written-off/Credited. It will cause a credit balance of the deduction. Please correct this manually':255(86246545)T-82# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-538059':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
oiReturnStatus = 1.
end.
end. /* for each tqGetDeductionByDDocIDStatus */
end. /*for first tqGetPostingInfoByDocumentID*/
end. /* if can-find deduction invoice */
end.
end.
/* Status depends on activity */
if (t_sDDocument.tc_Status = "N":U or
t_sDDocument.tc_Status = "C":U) and
((vcActivityCode = "Create upto Initial Status":U or
vcActivityCode = "Modify upto Initial Status":U) and
t_sDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-INIT}) or
((vcActivityCode = "Create upto Accepted Status":U or
vcActivityCode = "Modify upto Accepted Status":U) and
t_sDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-ACCEPT} and
t_sDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-INIT} and
t_sDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-PORTFOLIO}) or
((vcActivityCode = "Create upto Portfolio Status":U or
vcActivityCode = "Modify upto Portfolio Status":U) and
t_sDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-PORTFOLIO} and
t_sDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-INIT})
then do:
assign vcMessage = trim(substitute(#T-31'The selected status (&1) is not allowed for this activity (&2).':255(999890654)T-31#, trim(t_sDDocument.DDocumentStatus), trim(vcActivityCode) ))
oiReturnStatus = -1.
<M-32 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tDDocument.DDocumentStatus':U (icFieldName),
input t_sDDocument.DDocumentStatus (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'QadFin-9165':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
end. /* if (t_sDDocument.tc_Status = "N":U or */
if t_sDDocument.tc_Status = "N":U
then do:
if vcAllowedDDocStatusUptoActivity = "":U
then do:
if not can-do({&DOCUMENTSTATUS-INIT} + ",":U + {&DOCUMENTSTATUS-ACCEPT} + ",":U + {&DOCUMENTSTATUS-PORTFOLIO} + ",":U + {&DOCUMENTSTATUS-INCASSO} + ",":U + {&DOCUMENTSTATUS-DISCONT} + ",":U + {&DOCUMENTSTATUS-PAID}, t_sDDocument.DDocumentStatus)
then do:
<M-5 run SetMessage
(input trim(#T-17'The following are valid statuses for newly created customer payments: $1, $2, $3, $4 and $5.':250(1652)T-17#) (icMessage),
input {&DOCUMENTSTATUS-INIT-TR} + chr(2) + {&DOCUMENTSTATUS-ACCEPT-TR} + chr(2) + {&DOCUMENTSTATUS-PORTFOLIO-TR} + chr(2) + {&DOCUMENTSTATUS-INCASSO-TR} + chr(2) + {&DOCUMENTSTATUS-DISCONT-TR} + chr(2) + {&DOCUMENTSTATUS-PAID-TR} (icArguments),
input 'tDDocument.DDocumentStatus':U (icFieldName),
input vcDDocumentStatus (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'QADFIN-2547':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
end.
end.
end.
else
if t_sDDocument.tc_Status = "C":U
then do:
find t_iDDocument where
t_iDDocument.tc_Rowid = t_sDDocument.tc_Rowid
no-error.
if not available t_iDDocument
then do:
<M-6 run SetMessage
(input trim(#T-18'Initial values not found for customer payment with row ID $1.':250(1653)T-18#) (icMessage),
input icRowId (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'QADFIN-2548':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
return.
end.
assign vcDDocumentStatusInit = <M-13 GetDDocumentStatusTranslation (input t_iDDocument.DDocumentStatus (icStatus)) in BDDocument>.
if vcAllowedDDocStatusUptoActivity = ""
then do:
if t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-INIT} or
t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-ACCEPT} or
t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-PORTFOLIO}
then do:
if not can-do({&DOCUMENTSTATUS-INIT} + ",":U + {&DOCUMENTSTATUS-ACCEPT} + ",":U + {&DOCUMENTSTATUS-PORTFOLIO} + ",":U + {&DOCUMENTSTATUS-INCASSO} + ",":U + {&DOCUMENTSTATUS-DISCONT}, t_sDDocument.DDocumentStatus)
then do:
<M-7 run SetMessage
(input trim(#T-19'The following are valid new statuses for existing customer payments with status '$1': $2, $3, $4, $5, $6.':250(1654)T-19#) (icMessage),
input vcDDocumentStatusInit + chr(2) + {&DOCUMENTSTATUS-INIT-TR} + chr(2) + {&DOCUMENTSTATUS-ACCEPT-TR} + chr(2) + {&DOCUMENTSTATUS-PORTFOLIO-TR} + chr(2) + {&DOCUMENTSTATUS-INCASSO-TR} + chr(2) + {&DOCUMENTSTATUS-DISCONT-TR} (icArguments),
input 'tDDocument.DDocumentStatus':U (icFieldName),
input vcDDocumentStatus (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'QADFIN-2549':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
end.
end.
else
if t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-INCASSO}
then do:
if not can-do({&DOCUMENTSTATUS-INIT} + ",":U + {&DOCUMENTSTATUS-ACCEPT} + ",":U + {&DOCUMENTSTATUS-PORTFOLIO} + ",":U + {&DOCUMENTSTATUS-INCASSO} + ",":U + {&DOCUMENTSTATUS-DISCONT} + ",":U + {&DOCUMENTSTATUS-PAID} + ",":U + {&DOCUMENTSTATUS-BOUNCED}, t_sDDocument.DDocumentStatus)
then do:
assign vcArguments = vcDDocumentStatusInit + chr(2) +
{&DOCUMENTSTATUS-INIT-TR} + chr(2) +
{&DOCUMENTSTATUS-ACCEPT-TR} + chr(2) +
{&DOCUMENTSTATUS-PORTFOLIO-TR} + chr(2) +
{&DOCUMENTSTATUS-INCASSO-TR} + chr(2) +
{&DOCUMENTSTATUS-DISCONT-TR} + chr(2) +
{&DOCUMENTSTATUS-PAID-TR} + chr(2) +
{&DOCUMENTSTATUS-BOUNCED-TR}.
<M-8 run SetMessage
(input trim(#T-20'The following are valid new statuses for existing customer payments with status '$1': $2, $3, $4, $5, $6, $7, $8.':250(1655)T-20#) (icMessage),
input vcArguments (icArguments),
input 'tDDocument.DDocumentStatus':U (icFieldName),
input vcDDocumentStatus (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'QADFIN-2550':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
end.
end.
else
if t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-DISCONT}
then do:
if not can-do({&DOCUMENTSTATUS-INIT} + ",":U + {&DOCUMENTSTATUS-ACCEPT} + ",":U + {&DOCUMENTSTATUS-PORTFOLIO} + ",":U + {&DOCUMENTSTATUS-INCASSO} + ",":U + {&DOCUMENTSTATUS-DISCONT} + ",":U + {&DOCUMENTSTATUS-PAIDCON} + ",":U + {&DOCUMENTSTATUS-BOUNCED}, t_sDDocument.DDocumentStatus)
then do:
assign vcArguments = vcDDocumentStatusInit + chr(2) +
{&DOCUMENTSTATUS-INIT-TR} + chr(2) +
{&DOCUMENTSTATUS-ACCEPT-TR} + chr(2) +
{&DOCUMENTSTATUS-PORTFOLIO-TR} + chr(2) +
{&DOCUMENTSTATUS-INCASSO-TR} + chr(2) +
{&DOCUMENTSTATUS-DISCONT-TR} + chr(2) +
{&DOCUMENTSTATUS-PAIDCON-TR} + chr(2) +
{&DOCUMENTSTATUS-BOUNCED-TR}.
<M-10 run SetMessage
(input trim(#T-22'The following are valid new statuses for existing customer payments with status '$1': $2, $3, $4, $5, $6, $7, $8.':250(1655)T-22#) (icMessage),
input vcArguments (icArguments),
input 'tDDocument.DDocumentStatus':U (icFieldName),
input vcDDocumentStatus (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'QADFIN-2544':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
end.
if t_sDDocument.DDocumentStatus = {&DOCUMENTSTATUS-PAIDCON}
then do:
if not vlCalledFromBankEntry
then do:
<M-11 run SetMessage
(input trim(#T-23'You can only change a customer payment from status $1 to status $2 using the Bank Entry program.':250(1656)T-23#) (icMessage),
input {&DOCUMENTSTATUS-DISCONT-TR} + chr(2) + vcDDocumentStatus (icArguments),
input 'tDDocument.DDocumentStatus':U (icFieldName),
input vcDDocumentStatus (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'QADFIN-2545':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
end.
end.
end.
else
if t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-PAIDCON}
then do:
if not can-do({&DOCUMENTSTATUS-PAID} + ",":U + {&DOCUMENTSTATUS-BOUNCED}, t_sDDocument.DDocumentStatus)
then do:
<M-12 run SetMessage
(input trim(#T-24'The following are valid new statuses for existing customer payments with status '$1': $2, $3.':250(1657)T-24#) (icMessage),
input vcDDocumentStatusInit + chr(2) + {&DOCUMENTSTATUS-PAID-TR} + chr(2) + {&DOCUMENTSTATUS-BOUNCED-TR} (icArguments),
input 'tDDocument.DDocumentStatus':U (icFieldName),
input vcDDocumentStatus (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'QADFIN-2546':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
end.
end.
end.
else do:
if not can-do(vcAllowedDDocStatusUptoForVal, t_sDDocument.DDocumentStatus)
then do:
<M-14 run SetMessage
(input #T-27'The following are valid new statuses for existing customer payments with status $1: $2, $3, $4, $5, $6.':250(63586)T-27# (icMessage),
input vcDDocumentStatusInit + chr(2) + vcallowedDDocStatusUptoActTR (icArguments),
input 'tDDocument.DDocumentStatus':U (icFieldName),
input vcDDocumentStatus (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'QADFIN-2905':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
end.
if not can-do(vcAllowedDDocStatusUptoForVal, t_iDDocument.DDocumentStatus)
then do:
<M-15 run SetMessage
(input trim(#T-26'You cannot modify status $1.':250(930)T-26#) (icMessage),
input vcDDocumentStatusInit (icArguments),
input 'tDDocument.DDocumentStatus':U (icFieldName),
input vcDDocumentStatus (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'QADFIN-2906':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
end.
end.
end.