Description
PreValidateComponent
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bpaymentselection.p)
empty temp-table tSumCheck.
assign vlStart1 = false
vlStart2 = false
vlStart3 = false
vlStart4 = false
vlStart5 = false
vlStart6 = false.
/* Read all the QCrossCyPostings - CA766880 */
<Q-74 run QCrossCyPostingByCompany (all) (Read) (NoCache)
(input ?, (CompanyId)
input ?, (DaemonId)
output dataset tqQCrossCyPostingByCompany) in BQCrossCyPosting >
/* In Confirm/Unconfirm processing, it doesn't need to go through all of the invoice. */
if vcActivityCode <> {&PAYMENTSELECTIONACTIVITY-REGISTER} and vcActivityCode <> {&PAYMENTSELECTIONACTIVITY-UNCONFIRM} then
do:
/* Get all the invoices which are part of an Initial payment selection - CA766880*/
assign vctempStatus = {&PAYMENTSELECTIONSTATUS-INITIAL} + ',' + {&PAYMENTSELECTIONSTATUS-PARTIALLY}.
<Q-84 run PaySelLineByPaySelStatus (all) (Read) (NoCache)
(input ?, (CompanyId)
input ?, (PaySelObject_ID)
input vctempStatus, (PaySelStatus)
output dataset tqPaySelLineByPaySelStatus) in BPaymentSelection>
end.
for each t_sPaySel where
t_sPaySel.tc_Status = "N":U or
t_sPaySel.tc_Status = "C":U:
/* Do Some vqalidations on the status and the activity which is being run - CA766880*/
<M-41 run ValidateComponentPost1 (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0 and oiReturnStatus >= 0
then assign oiReturnStatus = viFcReturnSuper.
/* Check Lines */
for each t_sPaySelLine where
t_sPaySelLine.tc_ParentRowid = t_sPaySel.tc_Rowid and
t_sPaySelLine.tc_Status <> "D":U and
t_sPaySelLine.PaySelLineIsConfirmed <> yes
break by t_sPaySelLine.tcCreditorCode:
/* New line was deselected -> no processing */
if t_sPaySelLine.tc_Status = "":U and
t_sPaySelLine.tc_Rowid begins "-":U
then next.
if t_sPaySel.tcPayFormatTypeCode <> t_sPaySelLine.PayFormatTypeCode
then do:
<M-45 run SetMessage
(input trim(#T-43'The payment format for the header and line do not match. Select a bank with the same payment format code as the header.':250(61361)T-43#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPaySelLine.tc_Rowid (icRowid),
input 'qadfin-69707':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
end.
if first-of(t_sPaySelLine.tcCreditorCode) and
t_sPaySelLine.PaySelLineObjectType <> {&PAYMENTSELECTIONTYPE-DEBTORCREDITNOTE} and
t_sPaySelLine.PaySelLineObjectType <> {&PAYMENTSELECTIONTYPE-DEBTORCNCORR}
then do:
if not vlStart1
then do:
<Q-13 run CreditorByCode (Start) in BCreditor >
assign vlStart1 = true.
end.
<Q-36 run CreditorByCode (all) (Read) (NoCache)
(input t_sPaySel.Company_ID, (CompanyId)
input t_sPaySelLine.tcCreditorCode, (CreditorCode)
output dataset tqCreditorByCode) in BCreditor >
find first tqCreditorByCode where
tqCreditorByCode.tcCreditorCode = t_sPaySelLine.tcCreditorCode
no-error.
if not available tqCreditorByCode
then do:
<M-23 run SetMessage
(input trim(#T-72'The specified supplier is not defined in the system.':250(61008)T-72#) (icMessage),
input '':U (icArguments),
input 'tPaySelLine.tcCreditorCode':U (icFieldName),
input t_sPaySelLine.tcCreditorCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPaySelLine.tc_Rowid (icRowid),
input 'qadfin-687045':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1
vlIndividualPayments = ?.
end.
else assign vlIndividualPayments = tqCreditorByCode.tlCreditorIsIndividualPaymnt.
end.
if vcActivityCode = {&PAYMENTSELECTIONACTIVITY-REGISTER} and
t_sPaySelLine.tc_Status = "":U
then assign t_sPaySelLine.tc_Status = "C":U.
if t_sPaySelLine.tc_Status <> "N":U
then do:
find t_iPaySelLine where
t_iPaySelLine.tc_Rowid = t_sPaySelLine.tc_Rowid
no-error.
if not available t_iPaySelLine
then do:
<M-22 run SetMessage
(input #T-270'Initial values for Payment Selection Line not found.':250(796634267)T-270# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPaySelLine.tc_Rowid (icRowid),
input 'qadfin-119113':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
next.
end.
end.
/* Line Identification for Error Messages - CA766880 */
assign vcLineDescript = if t_sPaySelLine.tcInternalNumber = ?
then "":U
else 'Internal Number:' + t_sPaySelLine.tcInternalNumber + " - ":U +
if t_sPaySelLine.tcExternalNumber = ?
then "":U
else 'External Number:' + t_sPaySelLine.tcExternalNumber + " - ":U +
if t_sPaySelLine.PaySelLineObjectType = ?
then "":U
else 'ObjectType: ' + t_sPaySelLine.PaySelLineObjectType.
if (vcActivityCode = {&PAYMENTSELECTIONACTIVITY-REGISTER} or
vcActivityCode = {&PAYMENTSELECTIONACTIVITY-EXECUTE} or
vcActivityCode = {&PAYMENTSELECTIONACTIVITY-EXECUTEAGAIN}) and
(t_sPaySelLine.BankNumber_ID = 0 or
t_sPaySelLine.BankNumber_ID = ?)
then do:
<M-26 run SetMessage
(input trim(#T-125'The specified bank account: $1 is invalid.':250(16071)T-125#) (icMessage),
input vcLineDescript (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input '':U (icType),
input 3 (iiSeverity),
input t_sPaySelLine.tc_Rowid (icRowid),
input 'qadfin-412995':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
end.
if (t_sPaySelLine.PaySelLineParentObject_ID = 0 or
t_sPaySelLine.PaySelLineParentObject_ID = ?) and
(t_sPaySelLine.tc_Status = "N":U or
t_sPaySelLine.tc_Status = "C":U and
t_sPaySelLine.PaySelLineParentObject_ID <> t_iPaySelLine.PaySelLineParentObject_ID)
then do:
<M-59 run SetMessage
(input #T-1'The link to object: $1 is missing.':250(16074)T-1# (icMessage),
input vcLineDescript (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPaySelLine.tc_Rowid (icRowid),
input 'qadfin-793105':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
end.
if t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENT} and
t_sPaySelLine.PaySelLineDiscountTC <> 0 and
t_sPaySelLine.PaySelLineDiscountTC <> ? and
(t_sPaySelLine.tc_Status = "N":U or
t_sPaySelLine.tc_Status = "C":U and
(t_sPaySelLine.PaySelLineObjectType <> t_iPaySelLine.PaySelLineObjectType or
t_sPaySelLine.PaySelLineDiscountTC <> t_iPaySelLine.PaySelLineDiscountTC))
then do:
<M-17 run SetMessage
(input trim(#T-15'You cannot specify a discount amount for a prepayment: ($1).':250(16075)T-15#) (icMessage),
input vcLineDescript (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPaySelLine.tc_Rowid (icRowid),
input 'qadfin-41273':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
end.
if t_sPaySelLine.PaySelLineObjectType <> {&PAYMENTSELECTIONTYPE-PREPAYMENT} and
abs(t_sPaySelLine.PaySelLineDiscountTC) > abs(t_sPaySelLine.PaySelLineAmountTC) and
(t_sPaySelLine.tc_Status = "N":U or
t_sPaySelLine.tc_Status = "C":U and
(t_sPaySelLine.PaySelLineObjectType <> t_iPaySelLine.PaySelLineObjectType or
t_sPaySelLine.PaySelLineDiscountTC <> t_iPaySelLine.PaySelLineDiscountTC or
t_sPaySelLine.PaySelLineAmountTC <> t_iPaySelLine.PaySelLineAmountTC))
then do:
<M-21 run SetMessage
(input #T-11'The discount amount ($1) exceeded the payment amount ($2): $3':250(16076)T-11# (icMessage),
input string(t_sPaySelLine.PaySelLineDiscountTC) + chr(2) + string(t_sPaySelLine.PaySelLineAmountTC) + chr(2) + vcLineDescript (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPaySelLine.tc_Rowid (icRowid),
input 'qadfin-149148':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
end.
if t_sPaySelLine.PaySelLineObjectType <> {&PAYMENTSELECTIONTYPE-PREPAYMENT} and
abs(t_sPaySelLine.PaySelLineAmountTC) + abs(t_sPaySelLine.PaySelLineDiscountTC) - abs(t_sPaySelLine.PaySelLineIntAmtTC)
> abs(t_sPaySelLine.tdOpenInvoiceAmountTC) and
(t_sPaySelLine.tc_Status = "N":U or
t_sPaySelLine.tc_Status = "C":U and
(t_sPaySelLine.PaySelLineObjectType <> t_iPaySelLine.PaySelLineObjectType or
t_sPaySelLine.PaySelLineAmountTC <> t_iPaySelLine.PaySelLineAmountTC or
t_sPaySelLine.PaySelLineDiscountTC <> t_iPaySelLine.PaySelLineDiscountTC or
t_sPaySelLine.tdOpenInvoiceAmountTC <> t_iPaySelLine.tdOpenInvoiceAmountTC))
then do:
<M-81 run SetMessage
(input trim(#T-56'The payment amount ($1) exceeded the open balance ($2): ($3).':250(16077)T-56#) (icMessage),
input string(abs(t_sPaySelLine.PaySelLineAmountTC) + abs(t_sPaySelLine.PaySelLineDiscountTC) - abs(t_sPaySelLine.PaySelLineIntAmtTC)) + chr(2) + string(t_sPaySelLine.tdOpenInvoiceAmountTC) + chr(2) + vcLineDescript (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPaySelLine.tc_Rowid (icRowid),
input 'qadfin-557677':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
end.
/* ================================================================================ */
/* For create/modify, the invoice should not be selected already on another session */
/* ================================================================================ */
if vcActivityCode = {&PAYMENTSELECTIONACTIVITY-CREATE}
then do:
if t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTE} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTECORR} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-INVOICE} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-INVOICECORR} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENTINV} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-ADJUSTMENT}
then do:
if t_sPaySelLine.PaySelLineWHTAmtTC <> 0 and t_sPaySelLine.PaySelLineWHTAmtTC <> ? and
t_sPaySelLine.tiInvoiceCompany_ID <> t_sPaySel.Company_ID
then do:
/* ========================================================================================================================= */
/* FIN-4840: Block WHT-cross-domain-postings when the two domains use a different sharedset for the exchnage-rates. */
/* Temporarely solution to avoid incorrect-data. The goal is that soon this will be tackled more fundamentally by extending */
/* method BExchangeRate:ApiGetExchangeRate with the possibility to retrieve rates from other companies than the current one. */
/* error only when not working with banking entry type */
/* ========================================================================================================================= */
<Q-7 run CInvoiceForSharedSet (all) (Read) (NoCache)
(input ?, (CompanyId)
input t_sPaySelLine.PaySelLineParentObject_ID, (CInvoiceID)
input {&SHAREDSETTYPE-EXCHANGERATE}, (SharedSetType)
output dataset tqCInvoiceForSharedSet) in BCInvoice>
find first tqCInvoiceForSharedSet where
tqCInvoiceForSharedSet.tiCInvoice_ID = t_sPaySelLine.PaySelLineParentObject_ID and
tqCInvoiceForSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-EXCHANGERATE}
no-lock no-error.
if available tqCInvoiceForSharedSet
then do:
/* Find the SharedSet of the Originating Company */
<Q-76 run CompanySSByCompanyIDCodeSSType (all) (Read) (Cache)
(input t_sPaySel.Company_ID, (CompanyId)
input {&SHAREDSETTYPE-EXCHANGERATE}, (SharedSetType)
input ?, (CompanyCode)
output dataset tqCompanySSByCompanyIDCodeSSType) in BCompany>
Find tqCompanySSByCompanyIDCodeSSType where
tqCompanySSByCompanyIDCodeSSType.tiCompany_ID = t_sPaySel.Company_ID
no-lock no-error.
If not available tqCompanySSByCompanyIDCodeSSType
then do :
assign vcMessage = trim(substitute(#T-37'Unable to find the exchange-rate shared-set for the originating-entity of the cross-company daemon request.':255(137926406)T-37#)) + chr(10) +
trim(substitute(#T-88'ID of the originating-entity: &1.':255(108003460)T-88#,t_sPaySel.Company_ID))
oiReturnStatus = -1.
<M-20 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPaySel.Company_ID' (icFieldName),
input string(t_sPaySel.Company_ID) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPaySel.tc_Status (icRowid),
input 'qadfin-562736':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end. /* If not available tqCompanySSByCompanyIDCodeSSType */
else assign viOriginatorCompanyExchRateSSID = tqCompanySSByCompanyIDCodeSSType.tiSharedSet_ID.
if viOriginatorCompanyExchRateSSID <> 0 and
viOriginatorCompanyExchRateSSID <> ? and
viOriginatorCompanyExchRateSSID <> tqCInvoiceForSharedSet.tiSharedSet_ID
then do :
assign vcMessage = trim(substitute(#T-10'The system does not allow to create transactions between entities that have a different exchange-rate shared-set.':255(915858584)T-10#)) + chr(10) +
trim(substitute(#T-289'ID of the originating-entity: &1.':255(108003460)T-289#,t_sPaySel.Company_ID)) + chr(10) +
trim(substitute(#T-52'ID of the target-entity: &1.':255(950817132)T-52#,tqCInvoiceForSharedSet.tiCompany_ID))
oiReturnStatus = -1.
<M-55 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPaySel.Company_ID' (icFieldName),
input string(t_sPaySel.Company_ID) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPaySel.tc_Status (icRowid),
input 'qadfin-103610':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end. /* if viOriginatorCompanyExchRateSSID <> tqCompanySSByCompanyIDCodeSSType.tiSharedSet_ID */
end. /* if available tqCInvoiceForSharedSet */
else do:
assign vcMessage = trim(substitute(#T-309'Unable to find the exchange-rate shared-set for the target-entity of the cross-company daemon request.':255(599339696)T-309#)) + chr(10) +
trim(substitute(#T-86'ID of the target-entity: &1.':255(541437529)T-86#,tqCInvoiceForSharedSet.tiCompany_ID))
oiReturnStatus = -1.
<M-39 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tqCInvoiceForSharedSet.tiCompany_ID' (icFieldName),
input string(tqCInvoiceForSharedSet.tiCompany_ID) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPaySel.tc_Status (icRowid),
input 'qadfin-127411':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end. /* If not available tqCInvoiceForSharedSet */
end. /* if t_sPaySelLine.PaySelLineWHTAmtTC <> 0 and t_sPaySelLine.PaySelLineWHTAmtTC <> ? .. */
if not vlStart2
then do:
<Q-47 run CInvoiceBySelected (Start) in BCInvoice >
assign vlStart2 = true.
end.
end.
else
if t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCREDITNOTE} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCNCORR}
then do:
if not vlStart3
then do:
<Q-19 run DInvoiceBySelected (Start) in BDInvoice >
assign vlStart3 = true.
end.
end.
<M-70 run ValidateComponentPostLine1
(input vcLineDescript (icLineDescript),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0 and oiReturnStatus >= 0
then assign oiReturnStatus = viFcReturnSuper.
end. /* If vcActivityCode = {&PAYMENTSELECTIONACTIVITY-CREATE} */
else
if vcActivityCode = {&PAYMENTSELECTIONACTIVITY-MODIFY}
then do:
if not vlStart4
then do:
<Q-35 run PaySelLineByIDs (Start) in BPaymentSelection >
assign vlStart4 = true.
end.
assign vctempStatus = {&PAYMENTSELECTIONSTATUS-INITIAL} + ',' + {&PAYMENTSELECTIONSTATUS-PARTIALLY}.
<Q-49 run PaySelLineByIDs (all) (Read) (Cache)
(input t_sPaySelLine.PaySelLineParentObject_ID, (ParentObject_ID)
input t_sPaySelLine.PaySelLineObjectType, (ObjectType)
input ?, (PaySel_ID)
input viCompanyId, (CompanyId)
input vctempStatus, (PaySelStatus)
output dataset tqPaySelLineByIDs) in BPaymentSelection>
/* Add one condition of Partialy Confirmed payment selection */
find first tqPaySelLineByIDs where
tqPaySelLineByIDs.tiPaySelLineParentObject_ID = t_sPaySelLine.PaySelLineParentObject_ID and
tqPaySelLineByIDs.tcPaySelLineObjectType = t_sPaySelLine.PaySelLineObjectType and
( tqPaySelLineByIDs.tcPaySelStatus = {&PAYMENTSELECTIONSTATUS-INITIAL} or
tqPaySelLineByIDs.tcPaySelStatus = {&PAYMENTSELECTIONSTATUS-PARTIALLY} ) and
tqPaySelLineByIDs.tiPaySel_ID <> t_sPaySelLine.PaySel_ID and
tqPaySelLineByIDs.tiPaySelLine_ID <> t_sPaySelLine.PaySelLine_ID
no-error.
if available tqPaySelLineByIDs
then do:
<M-58 run SetMessage
(input trim(#T-87'The object has been selected for payment in another session: $1.':250(16078)T-87#) (icMessage),
input vcLineDescript (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPaySelLine.tc_Rowid (icRowid),
input 'qadfin-482765':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
end.
end.
/* Individual Payments */
if vlIndividualPayments = true
then do:
if t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTE} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-INVOICECORR} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENTINV}
then do:
<M-30 run SetMessage
(input trim(#T-29'You cannot create prepayments, credit notes, or invoice corrections for supplier: $1 ($2).':250(16085)T-29#) (icMessage),
input t_sPaySelLine.tcCreditorCode + chr(2) + vcLineDescript (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPaySelLine.tc_Rowid (icRowid),
input 'qadfin-659499':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
end.
end.
/* No Individual Payments on Creditor */
else
if vlIndividualPayments = false
then do:
create tSumCheck.
assign tSumCheck.tcSumCreditorCode = t_sPaySelLine.tcCreditorCode
tSumCheck.tcBusinessRelationCode = t_sPaySelLine.tcBusinessRelationCode
tSumCheck.tcSumCurrencyCode = t_sPaySelLine.tcInvoiceCurrencyCode
tSumCheck.tcSumObjectType = t_sPaySelLine.PaySelLineObjectType
tSumCheck.tiSumObject_ID = t_sPaySelLine.PaySelLineParentObject_ID
tSumCheck.tiSumBank_ID = t_sPaySelLine.BankNumber_ID
tSumCheck.tcPaymentCrDt = t_sPaySelLine.tcPaymentCrDt
tSumCheck.tdSumOpenAmtTC = abs(t_sPaySelLine.tdOpenInvoiceAmountTC)
tSumCheck.tdSumPaymentAmtTC = if t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-ADJUSTMENT} and
t_sPaySelLine.PaySelLineAmountTC < 0
then t_sPaySelLine.PaySelLineAmountTC - t_sPaySelLine.PaySelLineDiscountTC
else abs(t_sPaySelLine.PaySelLineAmountTC) - abs(t_sPaySelLine.PaySelLineDiscountTC).
if t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENTINV} and
t_sPaySelLine.tcPaymentCrDt = vcCreditTR
then
tSumCheck.tdSumPaymentAmtTC = - tSumCheck.tdSumPaymentAmtTC.
end.
end.
if vcActivityCode = {&PAYMENTSELECTIONACTIVITY-CREATE}
then do:
for each t_sPaySelLine where
t_sPaySelLine.tc_ParentRowid = t_sPaySel.tc_Rowid and
t_sPaySelLine.tc_Status = "N":U and
(t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTE} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTECORR} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-INVOICE} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-INVOICECORR} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENTINV} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-ADJUSTMENT})
break by t_sPaySelLine.PaySelLineParentObject_ID:
if first-of(t_sPaySelLine.PaySelLineParentObject_ID)
then do:
assign vdOpenInvoiceAmountBankPay = 0
vdAllocationTotalByInvoice = 0.
if t_sPaySelLine.BankNumber_ID = 0 or
t_sPaySelLine.BankNumber_ID = ?
then do:
<Q-44 run CInvoiceBySelected (all) (Read) (Cache)
(input ?, (CompanyId)
input t_sPaySelLine.PaySelLineParentObject_ID, (CInvoiceID)
output dataset tqCInvoiceBySelected) in BCInvoice>
end.
else do:
<Q-50 run CInvoiceBankByCInvoiceID (all) (Read) (NoCache)
(input t_sPaySelLine.PaySelLineParentObject_ID, (CInvoiceId)
output dataset tqCInvoiceBankByCInvoiceID) in BCInvoice>
end.
end.
assign vdAllocationTotalByInvoice = vdAllocationTotalByInvoice
+ t_sPaySelLine.PaySelLineAmountTC
+ t_sPaySelLine.PaySelLineDiscountTC
+ t_sPaySelLine.PaySelLineWHTAmtTC.
if t_sPaySelLine.BankNumber_ID = 0 or
t_sPaySelLine.BankNumber_ID = ?
then do:
for first tqCInvoiceBySelected where
tqCInvoiceBySelected.tiCInvoice_ID = t_sPaySelLine.PaySelLineParentObject_ID:
assign vdOpenInvoiceAmountBankPay = vdOpenInvoiceAmountBankPay
+ tqCInvoiceBySelected.tdCInvoiceBalanceTC.
end.
end.
else do:
for first tqCInvoiceBankByCInvoiceID where
tqCInvoiceBankByCInvoiceID.tiCInvoice_ID = t_sPaySelLine.PaySelLineParentObject_ID and
tqCInvoiceBankByCInvoiceID.tiBankNumber_ID = t_sPaySelLine.BankNumber_ID:
assign vdOpenInvoiceAmountBankPay = vdOpenInvoiceAmountBankPay
+ tqCInvoiceBankByCInvoiceID.tdCInvoiceBankToPayTC.
end.
end.
if last-of(t_sPaySelLine.PaySelLineParentObject_ID)
then do:
if vdAllocationTotalByInvoice > vdOpenInvoiceAmountBankPay
then do:
assign vcContext = "vdAllocationTotalByInvoice=&1|vdOpenInvoiceAmountBankPay=&2":U
vcContext = substitute(vcContext, vdOpenInvoiceAmountBankPay)
vcContext = replace(vcContext, "|":U, chr(2)).
<M-16 run SetMessage
(input trim(#T-96'The balance of the invoice has been changed since you selected it. Please Verify. Reference: $1':255(369906059)T-96#) (icMessage),
input vcLineDescript (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPaySelLine.tc_Rowid (icRowid),
input 'qadfin-723843':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
end.
end. /* If last-of(t_sPaySelLine.PaySelLineParentObject_ID) */
end. /* For each t_sPaySelLine */
end. /* If vcActivityCode = {&PAYMENTSELECTIONACTIVITY-CREATE} */
for each t_sPaySelLine where
t_SPaySelLine.tlProposedLineIsSelected = true and
(t_sPaySelLine.tc_status = 'N':U or t_sPaySelLine.tc_status = 'C':U) and
(t_sPaySelLine.PaySelLineParentObject_ID <> 0 and t_sPaySelLine.PaySelLineParentObject_ID <> ?) and
(t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTE} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTECORR} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-INVOICE} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-INVOICECORR} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENTINV} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-ADJUSTMENT})
break by t_sPaySelLine.tcInvoiceCurrencyCode
by t_sPaySelLine.ttInvoiceDate:
if first-of(t_sPaySelLine.ttInvoiceDate)
then do:
if t_sPaySelLine.tcInvoiceCurrencyCode <> t_sPaySel.tcPaySelCurrencyCode
then do:
<M-312 run GetExchangeRate
(input ? (iiCompanyID),
input ? (iiFromCurrencyID),
input t_sPaySelLine.tcInvoiceCurrencyCode (icFromCurrencyCode),
input ? (iiToCurrencyID),
input t_sPaySel.tcPaySelCurrencyCode (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input t_sPaySelLine.ttInvoiceDate (itValidityDate),
output vdExchangeRate (odExchangeRate),
output vdExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper < 0
then assign oiReturnStatus = -3.
end.
end.
end. /* for each t_sPaySelLine where */
if oiReturnStatus = -3
then do:
<M-82 run SetMessage
(input trim(#T-64'For some invoices, no exchange rate exists between the corresponding Invoice Currency and Bank Currency $1. See other messages for more details.':255(195584259)T-64#) (icMessage),
input t_sPaySel.tcPaySelCurrencyCode (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-112421':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
end. /* if oiReturnStatus = -3 */
end. /* For each t_sPaySel */
if vlStart1
then do:
<Q-6 run CreditorByCode (Stop) in BCreditor >
end.
if vlStart2
then do:
<Q-40 run CInvoiceBySelected (Stop) in BCInvoice >
end.
if vlStart3
then do:
<Q-24 run DInvoiceBySelected (Stop) in BDInvoice >
end.
if vlStart4
then do:
<Q-61 run PaySelLineByIDs (Stop) in BPaymentSelection >
end.
/* No summary validations within execution */
if vcActivityCode <> {&PAYMENTSELECTIONACTIVITY-EXECUTE} and
vcActivityCode <> {&PAYMENTSELECTIONACTIVITY-EXECUTEAGAIN}
then do:
<M-42 run ValidateComponentPostSummary (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
end.