project QadFinancials > class BDInvoice > method ValidateComponentAllStages
Description
ValidateComponentAllStages: submethod of ValidateComponentAll that tackles the validations related to stage payment conditions
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bdinvoice.p)
/* ====================================== */
/* Specific validations for StagedPayCond */
/* ====================================== */
if t_sDInvoice.tcNormalPaymentConditionType = {&PAYMENTCONDITIONPAYMENTTYPE-STAGED} and
(t_sDInvoice.DInvoiceType = {&INVOICETYPE-INVOICE} or
t_sDInvoice.DInvoiceType = {&INVOICETYPE-FINANCECHARGE} or
t_sDInvoice.DInvoiceType = {&INVOICETYPE-INVOICECORRECTION} or
t_sDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTE} or
t_sDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}) and
(t_sDInvoice.tc_Status = "N":U or
(t_sDInvoice.tc_Status = "C":U and
(t_sDInvoice.tdDInvoiceOriginalTC <> t_iDInvoice.tdDInvoiceOriginalTC or
t_sDInvoice.NormalPaymentCondition_ID <> t_iDInvoice.NormalPaymentCondition_ID or
can-find (first t_sDInvoiceStage where
t_sDInvoiceStage.tc_ParentRowid = t_sDInvoice.tc_Rowid and
t_sDInvoiceStage.tc_Status <> "":U) )))
then do:
/* ================================================== */
/* Total stage amount must be equal to invoice amount */
/* ================================================== */
assign
vdTotalAmount = 0.
for each t_sDInvoiceStage where
t_sDInvoiceStage.tc_ParentRowid = t_sDInvoice.tc_Rowid and
t_sDInvoiceStage.tc_Status <> "D":U:
assign
vdTotalAmount = vdTotalAmount + t_sDInvoiceStage.DInvoiceStageAmountTC.
end. /* for each t_sDInvoiceStage */
if absolute(vdTotalAmount) <> absolute(t_sDInvoice.tdDInvoiceOriginalTC)
then do :
assign vcMessage = trim(substitute(#T-61'The total amount of stage lines (&1) should be equal to the original amount of the customer invoice (&2).':255(782163501)T-61#,vdTotalAmount,t_sDInvoice.tdDInvoiceOriginalTC)) + chr(10) +
trim(substitute(#T-37'Invoice: &1/&2/&3':255(930835863)T-37#,t_sDInvoice.DInvoicePostingYear, t_sDInvoice.tcJournalCode, t_sDInvoice.DInvoiceVoucher))
oiReturnStatus = -1.
<M-38 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tDInvoice.tdDInvoiceOriginalTC' (icFieldName),
input string(t_sDInvoice.tdDInvoiceOriginalTC) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-411602':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
end. /* if absolute(vdTotalAmount) <> absolute(t_sDInvoice.tdDInvoiceOriginalTC) */
/* ======================================================== */
/* The applied-amt per stage cannot exceed the stage-amount */
/* ======================================================== */
for each t_sDInvoiceStage where
t_sDInvoiceStage.tc_ParentRowid = t_sDInvoice.tc_Rowid and
t_sDInvoiceStage.tc_Status <> "D":U:
/* If there is payed less amount then stage amount, it is OK; otherwise error */
if abs(t_sDInvoiceStage.DInvoiceStageAmtAppliedTC) > abs(t_sDInvoiceStage.DInvoiceStageAmountTC)
then do:
assign vcMessage = trim(substitute(#T-10'The applied-amount (&1) on an invoice-stage cannot exceed the stage-amount (&2).':255(728076707)T-10#,t_sDInvoiceStage.DInvoiceStageAmtAppliedTC, t_sDInvoiceStage.DInvoiceStageAmountTC)) + chr(10) +
trim(substitute(#T-80'Invoice: &1/&2/&3':255(3067347)T-80#,t_sDInvoice.DInvoicePostingYear, t_sDInvoice.tcJournalCode, t_sDInvoice.DInvoiceVoucher))
oiReturnStatus = -1.
<M-34 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tDInvoice.tcNormalPaymentConditionType':U (icFieldName),
input t_sDInvoice.tcNormalPaymentConditionType (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-180330':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
end. /* if abs(t_sDInvoiceStage.DInvoiceStageAmtAppliedTC) > abs(t_sDInvoiceStage.DInvoiceStageAmountTC) */
end. /* for each t_sDInvoiceStage where */
/* ================================================== */
/* Only one bank record allowed for staged payments */
/* ================================================== */
find t_sDInvoiceBank where
t_sDInvoiceBank.DInvoice_ID = t_sDInvoice.DInvoice_ID and
t_sDInvoiceBank.tc_Status <> "D":U and
(can-find(first t_iDinvoiceBank where
t_iDInvoiceBank.DInvoiceBank_ID = t_sDInvoiceBank.DInvoiceBank_ID) or
t_sDInvoiceBank.tc_Status <> "":U) no-error.
if ambiguous t_sDInvoiceBank
then do :
assign vcMessage = trim(substitute(#T-26'Credit terms type cannot be Staged when multiple bank accounts are used.':255(732014933)T-26#)) + chr(10) +
trim(substitute(#T-1'Invoice: &1/&2/&3':255(3067347)T-1#,t_sDInvoice.DInvoicePostingYear, t_sDInvoice.tcJournalCode, t_sDInvoice.DInvoiceVoucher))
oiReturnStatus = -1.
<M-65 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tDInvoice.tcNormalPaymentConditionType':U (icFieldName),
input t_sDInvoice.tcNormalPaymentConditionType (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-681778':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
end. /* if ambiguous t_sDInvoiceBank */
end. /* if t_sDInvoice.tcNormalPaymentConditionType = {&PAYMENTCONDITIONPAYMENTTYPE-STAGED} and */