project QadFinancials > class BDDocument > method ValidateComponentPost
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bddocument.p)
assign vlStart1 = false
vlStart2 = false
vlStart3 = false.
for each t_sDDocument where
t_sDDocument.tc_Status <> "":U:
if t_sDDocument.tc_Status <> "N":U
then do:
/* Get initial values */
find t_iDDocument where
t_iDDocument.tc_Rowid = t_sDDocument.tc_Rowid
no-error.
if not available t_iDDocument
then do:
<M-87 run SetMessage
(input trim(#T-71'Initial values not found for customer payment with row ID $1.':250(1653)T-71#) (icMessage),
input t_sDDocument.tc_Rowid (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-878987':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
return.
end.
end.
/* Combination of DocumentType, DocumentStatus and GL must be defined in DDocumentStatus */
if t_sDDocument.tc_Status = "N":U or
t_sDDocument.tc_Status = "C":U and
(t_sDDocument.DDocumentType <> t_iDDocument.DDocumentType or
t_sDDocument.DDocumentStatus <> t_iDDocument.DDocumentStatus or
t_sDDocument.tcGLCode <> t_iDDocument.tcGLCode)
then do:
<Q-34 assign vlFcQueryRecordsAvailable = DDocumentStatusPrim (NoCache)
(input ?, (DDocumentStatusID)
input t_sDDocument.DDocumentStatus, (DDocumentStatusStatus)
input t_sDDocument.DDocumentType, (DDocumentStatusDocumentType)
input t_sDDocument.tcGLCode, (BankGLCode)
input t_sDDocument.Company_ID, (CompanyId)) in BDDocumentStatus >
if not vlFcQueryRecordsAvailable
then do:
assign vcDDocumentStatus = <M-70 GetDDocumentStatusTranslation (input t_sDDocument.DDocumentStatus (icStatus)) in BDDocument>
vcDDocumentType = <M-72 GetDDocumentTypeTranslation (input t_sDDocument.DDocumentType (icType)) in BDDocument>.
<M-80 run SetMessage
(input trim(#T-67'The $1 status has not been defined for payment type $2 and bank account code $3.':250(897)T-67#) (icMessage),
input vcDDocumentStatus + chr(2) + vcDDocumentType + chr(2) + t_sDDocument.tcGLCode (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-253191':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
end.
/* For new documents: Check if new document has valid status */
/* For existing documents: Check for valid status changes */
if t_sDDocument.tc_Status = "N":U or
t_sDDocument.DDocumentStatus <> t_iDDocument.DDocumentStatus
then do:
<M-54 run ValidateComponentDDocumentStatus
(input t_sDDocument.tc_Rowid (icRowId),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
end.
end.
if t_sDDocument.tc_Status = "C":U
then do:
/* A paid or bounced document cannot be changed anymore */
if t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-BOUNCED} or
t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-PAID}
then do:
<M-33 run SetMessage
(input trim(#T-32'A document with status $1 or $2 cannot be changed.':250(499731262)T-32#) (icMessage),
input {&DOCUMENTSTATUS-PAID-TR} + chr(2) + {&DOCUMENTSTATUS-BOUNCED-TR} (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-664762':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
next.
end.
/* You can only change the status for a paid conditionally document */
if t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-PAIDCON}
then do:
buffer-compare t_sDDocument
except t_sDDocument.DDocumentStatus
t_sDDocument.tcBusinessRelationCode
t_sDDocument.tcBusinessRelationName
t_sDDocument.tcBusinessRelationSearch
t_sDDocument.tlInvoicesLinked
t_sDDocument.ttPostingDate
t_sDDocument.tcPayFormatTypeCode
t_sDDocument.tcDebtorBankNumber
t_sDDocument.tcOwnBankNumber
t_sDDocument.tc_ParentRowid
t_sDDocument.tc_Rowid
t_sDDocument.tc_Status
to t_iDDocument
save vlEqual.
if not vlEqual
then do:
<M-62 run SetMessage
(input trim(#T-63'You can only change the status of a document with status $1.':250(306793892)T-63#) (icMessage),
input {&DOCUMENTSTATUS-PAIDCON-TR} (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-820000':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
end.
end.
/* It is not allowed to change bank gl code when status is Incasso or Disconto */
if (t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-INCASSO} or
t_iDDocument.DDocumentStatus = {&DOCUMENTSTATUS-DISCONT}) and
t_iDDocument.tcGLCode <> t_sDDocument.tcGLCode
then do:
<M-56 run SetMessage
(input trim(#T-52'You cannot modify the bank account code for a document with status $1 or $2.':250(383600103)T-52#) (icMessage),
input {&DOCUMENTSTATUS-INCASSO-TR} + chr(2) + {&DOCUMENTSTATUS-DISCONT-TR} (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-791552':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
next.
end.
/* It is not allowed to bounced the payment if prepayment already paid */
/* This is valid for the payment where prepayment is created */
if (t_sDDocument.DDocumentStatus = {&DOCUMENTSTATUS-BOUNCED}) or
(t_sDDocument.DDocumentStatus = {&DOCUMENTSTATUS-INIT}) or
(t_sDDocument.DDocumentStatus = {&DOCUMENTSTATUS-VOID})
then do:
find t_sDDocumentInvoiceXref where
t_sDDocumentInvoiceXref.DDocument_ID = t_sDDocument.DDocument_ID and
t_sDDocumentInvoiceXref.tcDInvoiceType = {&INVOICETYPE-PREPAYMENT} and
t_sDDocumentInvoiceXref.tcAllocAmountCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
no-error.
if available t_sDDocumentInvoiceXref
then do:
<Q-84 run DInvoiceByIDAllInfo (all) (Read) (NoCache)
(input ?, (CompanyId)
input t_sDDocumentInvoiceXref.DInvoice_ID, (DInvoiceID)
output dataset tqDInvoiceByIDAllInfo) in BDInvoice >
find first tqDInvoiceByIDAllInfo no-error.
if available tqDInvoiceByIDAllInfo
then do:
if (tqDInvoiceByIDAllInfo.tdDInvoiceOriginalDebitTC <> tqDInvoiceByIDAllInfo.tdDInvoiceBalanceDebitTC) or
(tqDInvoiceByIDAllInfo.tdDInvoiceOriginalCreditTC <> tqDInvoiceByIDAllInfo.tdDInvoiceBalanceCreditTC)
then do:
assign oiReturnStatus = -1
vcMessage = trim(substitute(#T-24'Customer Payment (Reference : &1/&2/&3) can't be done because linked prepayment already paid.':255(651542104)T-24#,t_sDDocument.DDocumentYear,t_sDDocument.DDocumentNumber,t_sDDocumentInvoiceXref.tcDInvoiceReference)).
<M-79 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-254384':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
end. /* if (tqDInvoiceByIDAllInfo.tdDInvoiceOriginalDebitTC <> tqDInvoiceByIDAllInfo.tdDInvoiceBalanceDebitTC) or */
end. /* if available tqDInvoiceByIDAllInfo */
end. /* if available t_sDDocumentInvoiceXref */
end. /* if (t_sDDocument.DDocumentStatus = {&DOCUMENTSTATUS-BOUNCED}) or */
/* It is not allowed to bounced or init the payment if deduction already for collection */
/* This is valid for the payment where deduction is created */
if (t_iDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-BOUNCED}
and t_iDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-INIT}
and t_iDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-VOID})
and
(
(t_sDDocument.DDocumentStatus = {&DOCUMENTSTATUS-BOUNCED}) or
(t_sDDocument.DDocumentStatus = {&DOCUMENTSTATUS-INIT}) or
(t_sDDocument.DDocumentStatus = {&DOCUMENTSTATUS-VOID})
)
then do:
find t_sDDocumentInvoiceXref where
t_sDDocumentInvoiceXref.DDocument_ID = t_sDDocument.DDocument_ID and
t_sDDocumentInvoiceXref.tcDInvoiceType = {&INVOICETYPE-DEDUCTION}
no-error.
if available t_sDDocumentInvoiceXref
then do:
<M-96 run ApiLoadDeductionDetail
(input t_sDDocumentInvoiceXref.DInvoice_ID (iiSelectedInvoiceID),
output tApiDInvoiceDeduction (tApiDInvoiceDeduction),
output vcDInvoiceDescription (ocDInvoiceDescription),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
find first tApiDInvoiceDeduction where tApiDInvoiceDeduction.DInvoiceDeductionStatus = {&INVOICEDEDUCTSTATUS-WRITE-OFF} no-error.
/* to-do
for each tApiDInvoiceDeduction no-lock:
if tApiDInvoiceDeduction.DInvoiceDeductionStatus <> {&INVOICEDEDUCTSTATUS-PENDING}
and tApiDInvoiceDeduction.DInvoiceDeductionStatus <> {} then
do:
return.
end.
end.
*/
/*
if available tApiDInvoiceDeduction
then do:
assign oiReturnStatus = -1
vcMessage = trim(#T-47'the status of the payment cannot be changed to Bounced, Initial or Void, since there exist auto written-off deduction invoices.':150(266264599)T-47#).
<M-45 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-69285':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
end.
*/
/* end of auto write-off */
end. /*end available for */
end. /*end validte for deduction type */
end.
if t_sDDocument.tc_Status = "D":U
then do:
/* Only INITIAL Documents can be deleted */
if t_iDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-INIT}
then do:
<M-27 run SetMessage
(input trim(#T-2'Only documents with status $1 can be deleted.':250(57149460)T-2#) (icMessage),
input {&DOCUMENTSTATUS-INIT-TR} (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-550231':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
end.
end.
if t_sDDocument.tc_Status = "N":U or t_sDDocument.tc_Status = "C":U
then do:
/* Make sure only AR payment format is allowed */
if t_sDDocument.tcPayFormatTypeCode <> ? and
t_sDDocument.tcPayFormatTypeCode <> "":U
then do:
<Q-10 run PayFormatTypeByType (all) (Read) (NoCache)
(input t_sDDocument.tcPayFormatTypeCode, (PayFormatTypeCode)
output dataset tqPayFormatTypeByType) in BPaymentFormat >
find first tqPayFormatTypeByType where
tqPayFormatTypeByType.tcPayFormatTypeCode = t_sDDocument.tcPayFormatTypeCode no-error.
if available tqPayFormatTypeByType and tqPayFormatTypeByType.tcPayFormatTypeModule <> {&PAYFORMATMODULE-AR}
then do:
assign vcMessage = trim(substitute(#T-43'Only AR payment format is allowed.':150(208124074)T-43#,t_sDDocument.tcPayFormatTypeCode))
oiReturnStatus = -1.
<M-25 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tDDocument.tcPayFormatTypeCode' (icFieldName),
input t_sDDocument.tcPayFormatTypeCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-533368':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
end.
else if not available tqPayFormatTypeByType
then do:
assign vcMessage = trim(substitute(#T-97'Invalid payment format':150(852684638)T-97#,t_sDDocument.tcPayFormatTypeCode))
oiReturnStatus = -1.
<M-46 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tDDocument.tcPayFormatTypeCode':U (icFieldName),
input t_sDDocument.tcPayFormatTypeCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-38441':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
end.
end. /* if t_sDDocument.tcPayFormatTypeCode is defined */
/* The bank on the document must be linked to the invoice */
if t_sDDocument.DDocumentSubType = {&DOCUMENTSUBTYPE-AUTO}
then do:
for each t_sDDocumentInvoiceXref where
t_sDDocumentInvoiceXref.tc_ParentRowid = t_sDDocument.tc_Rowid and
t_sDDocumentInvoiceXref.tc_status <> "D":U
break by t_sDDocumentInvoiceXref.DInvoice_ID:
if first-of(t_sDDocumentInvoiceXref.DInvoice_ID) and
(t_sDDocumentInvoiceXref.tc_Status <> 'N':U or t_sDDocumentInvoiceXref.tcDInvoiceType <> {&INVOICETYPE-PREPAYMENT})
then do:
<Q-11 run DInvoiceBankByDInvoiceID (all) (Read) (NoCache)
(input t_sDDocumentInvoiceXref.DInvoice_ID, (DInvoiceId)
output dataset tqDInvoiceBankByDInvoiceID) in BDInvoice >
if not can-find(first tqDInvoiceBankByDInvoiceID where
tqDInvoiceBankByDInvoiceID.tcBankNumber = t_sDDocument.tcDebtorBankNumber)
then do:
assign vcMessage = trim(substitute(#T-5'Bank (&1) is not associated with invoice (&2).':150(61010)T-5#,t_sDDocument.tcDebtorBankNumber,t_sDDocumentInvoiceXref.tcDInvoiceReference))
oiReturnStatus = -1.
<M-22 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-323738':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
end.
end.
end. /* for each t_sDDocumentInvoiceXref */
end.
for each t_sDDocumentInvoiceXref where
t_sDDocumentInvoiceXref.tc_ParentRowid = t_sDDocument.tc_Rowid and
t_sDDocumentInvoiceXref.tc_status <> "D":U:
if ((t_sDDocumentInvoiceXref.tcDInvoiceType = {&INVOICETYPE-INVOICECORRECTION} or
t_sDDocumentInvoiceXref.tcDInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}) AND
t_sDDocumentInvoiceXref.tdNewBalance > 0) or
((t_sDDocumentInvoiceXref.tcDInvoiceType <> {&INVOICETYPE-INVOICECORRECTION} and
t_sDDocumentInvoiceXref.tcDInvoiceType <> {&INVOICETYPE-CREDITNOTECORRECTION}) AND
t_sDDocumentInvoiceXref.tdNewBalance < 0)
then do:
assign vcMessage = trim(substitute(#T-95'Overallocation of an Invoice or Credit note is not allowed. You have assigned &1 surplus.':255(999890083)T-95#,abs(t_sDDocumentInvoiceXref.tdNewBalance)))
oiReturnStatus = -1.
<M-77 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-473242':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
end.
if (t_sDDocumentInvoiceXref.DDocumentInvoiceXrefAlloTC * t_sDDocumentInvoiceXref.tdDInvoiceBalance < 0)
then do:
assign vcMessage = trim(#T-53'Allcation of negative amount is not allowed.':255(221094027)T-53#)
oiReturnStatus = -1.
<M-83 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-597635':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
end.
end.
if t_sDDocument.BankNumber_ID <> ? and t_sDDocument.BankNumber_ID <> 0
then do:
<Q-37 run BankNumberOwnBankGLByID (all) (Read) (Cache)
(input t_sDDocument.BankNumber_ID, (BankNumber_ID)
input ?, (CompanyId)
output dataset tqBankNumberOwnBankGLByID) in BBankNumber>
if can-find (first tqBankNumberOwnBankGLByID)
then do:
if (t_sDDocument.tcGLCode <> ? and t_sDDocument.tcGLCode <> "":U) or
(t_sDDocument.GL_ID <> ? and t_sDDocument.GL_ID <> 0)
then do:
if t_sDDocument.tcGLCode <> ? and t_sDDocument.tcGLCode <> "":U
then find first tqBankNumberOwnBankGLByID where
tqBankNumberOwnBankGLByID.tcGLCode = t_sDDocument.tcGLCode
no-error.
else if t_sDDocument.GL_ID <> ? and t_sDDocument.GL_ID <> 0
then find first tqBankNumberOwnBankGLByID where
tqBankNumberOwnBankGLByID.tiGL_ID = t_sDDocument.GL_ID
no-error.
if not available tqBankNumberOwnBankGLByID
then do:
assign vcMessage = trim(substitute(#T-81'The customer bank (&1) is not associated with the GL (&2)':250(280728268)T-81#,t_sDDocument.tcDebtorBankNumber,t_sDDocument.tcGLCode))
oiReturnStatus = -1.
<M-35 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-904624':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
end. /* if not available tqBankNumberOwnBankGLByID */
end. /* if (t_sDDocument.tcGLCode <> ? and t_sDDocument.tcGLCode <> "":U) or */
if (t_sDDocument.DDocumentType <> ? and t_sDDocument.DDocumentType <> "":U)
then do:
if not can-find(first tqBankNumberOwnBankGLByID where
tqBankNumberOwnBankGLByID.tcPayFormatTypePayInstrument = t_sDDocument.DDocumentType)
then do:
assign vcMessage = trim(substitute(#T-14'The customer bank (&1) is not associated with document type of (&2)':250(615778830)T-14#,t_sDDocument.tcDebtorBankNumber,t_sDDocument.DDocumentType))
oiReturnStatus = -1.
<M-30 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-849143':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
end. /* if not can-find(first tqBankNumberOwnBankGLByID where */
end. /* t_sDDocument.DDocumentType is defined */
end. /* if can-find (first tqBankNumberOwnBankGLByID */
end. /* t_sDDocument.BankNumber_ID is defined */
/* Issue a warning if the DDocumentReference is used for the same customer */
if t_sDDocument.DDocumentReference <> ? and t_sDDocument.DDocumentReference <> "":U
then do:
<Q-60 assign vlFcQueryRecordsAvailable = DDocumentByDebtorReference (NoCache)
(input t_sDDocument.Company_ID, (CompanyId)
input t_sDDocument.Debtor_ID, (DebtorID)
input t_sDDocument.tcDebtorCode, (DebtorCode)
input t_sDDocument.DDocumentReference, (Reference)
input t_sDDocument.DDocumentType, (PayFormatPayInstrument)
input t_sDDocument.DDocument_ID, (DDocumentID)) in BDDocument >
if vlFcQueryRecordsAvailable <> false
then do:
assign vcMessage = trim(substitute(#T-13'The Payment Reference that you entered already exists for Payment &1 Created on &2 by user &3':255(58167500)T-13#,
string(t_sDDocument.DDocumentNumber),string(t_sDDocument.DDocumentCreationDate),t_sDDocument.tcCreationUsrLogin))
oiReturnStatus = if oiReturnStatus <> 0
then oiReturnStatus
else 1.
<M-7 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tDDocument.DDocumentReference':U (icFieldName),
input t_sDDocument.DDocumentReference (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-255860':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
end.
end.
end.
/* Validate payment amount cannot be negative */
if (t_sDDocument.tc_Status = "N":U or
t_sDDocument.tc_Status = "C":U) and
t_sDDocument.DDocumentOriginalDebitTC < 0
then do:
assign oiReturnStatus = -1
vcMessage = #T-19'Payment amount cannot be negative.':255(70946)T-19#.
<M-9 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-910258':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
end.
if t_sDDocument.tc_Status = "C":U
then do:
<Q-57 run DDocumentPostingLineForPostingDate (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input t_sDDocument.DDocument_ID, (Document_ID)
output dataset tqDDocumentPostingLineForPostDat) in BDDocument >
find first tqDDocumentPostingLineForPostDat where
tqDDocumentPostingLineForPostDat.ttPostingDate > t_sDDocument.ttPostingDate no-error.
if available tqDDocumentPostingLineForPostDat
then do:
assign vcMessage = trim(substitute(#T-39'A status change of payment cannot have an earlier posting date &1 than any previous posting date of the payment. A previous posting date &2 exists.':255(333685938)T-39#,
t_sDDocument.ttPostingDate,tqDDocumentPostingLineForPostDat.ttPostingDate))
oiReturnStatus = -1.
<M-94 run SetMessage
(input vcMessage (icMessage),
input t_sDDocument.tc_Rowid (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-903532':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
end. /* if available tqDDocumentPostingLineForPostDat */
end. /* if t_sDDocument.tc_Status = "C":U */
/* Check Posting Date exceeds Due Date */
if t_sDDocument.tc_Status <> "D":U and
(vcActivityCode = "Create" or
vcActivityCode = "Modify" or
vcActivityCode = "Create upto Accepted status" or
vcActivityCode = "Create upto Portfolio status" or
vcActivityCode = "Modify upto Accepted status" or
vcActivityCode = "Modify upto Portfolio status") and
t_sDDocument.DDocumentStatus <> {&DOCUMENTSTATUS-PAID}
then do:
if t_sDDocument.DDocumentDueDate < t_sDDocument.ttPostingDate
then do:
vcDatetemp = <M-23 DisplayDate (input t_sDDocument.ttpostingDate (itDate)) in BDDocument>.
vcDatetemp1 = <M-65 DisplayDate (input t_sDDOcument.DDocumentDueDate (itDate)) in BDDocument>.
<M-15 run SetMessage
(input #T-91'This payment is created with Posting Date $1 and Due Date $2. Confirming the payment in BankingEntry or other Payment functions will only be possible with a posting date $1 or later':255(243426160)T-91# (icMessage),
input string(vcDatetemp) + chr(2) + string(vcDatetemp1) (icArguments),
input 't_sDDocument.ttpostingDate':U (icFieldName),
input vcDatetemp (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input t_sDDocument.tc_Rowid (icRowid),
input 'qadfin-343402':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = 1.
end. /* if t_sDDocument.DDocumentDueDate < t_sDDocument.ttPostingDate */
end. /* if t_sDDocument.tc_Status <> "D":U */
end.