project QadFinancials > class BCInvoice > method ValidateComponentPostCreateLinkedInvoice
Description
This method is a submethod for ValidateComponentPostCreate.
This method validates the Linked Invoice of the Creditor Invoice.
Parameters
blStart2 | input-output | logical | Is query tqCInvoiceForLinkedInvoiceVal already started or not ? |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bcinvoice.p)
if t_sCInvoice.CInvoiceIsInitialStatus = true
then do:
<M-16 run SetMessage
(input 'It is not allowed to link an invoice which has status initial':U (icMessage),
input '':U (icArguments),
input 'tCInvoice.tiLinkedCInvoiceVoucher':U (icFieldName),
input t_sCInvoice.tiLinkedCInvoiceVoucher (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCInvoice.tc_Rowid (icRowid),
input 'QadFin-7930':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
return.
end.
find bCInvoice where
bCInvoice.CInvoice_ID = t_sCInvoice.LinkedCInvoice_ID
no-error.
if available bCInvoice
then assign vdLinkedCInvoiceBalanceCreditTC = bCInvoice.CInvoiceBalanceCreditTC
vdLinkedCInvoiceBalanceDebitTC = bCInvoice.CInvoiceBalanceDebitTC
viLinkedCInvoiceCurrencyId = bCInvoice.CInvoiceCurrency_ID
vlLinkedCInvoiceIsOpen = bCInvoice.CInvoiceIsOpen
vlLinkedCInvoiceIsSelected = bCInvoice.CInvoiceIsSelected
vcLinkedCInvoiceType = bCInvoice.CInvoiceType
viLinkedCreditorId = bCInvoice.Creditor_ID
vlLinkedCInvoiceIsWHT = bCInvoice.CInvoiceIsWHT.
else do:
if not blStart2
then do:
<Q-2 run CInvoiceForLinkedInvoiceVal (Start) in BCInvoice >
assign blStart2 = true.
end.
<Q-3 run CInvoiceForLinkedInvoiceVal (all) (Read) (Cache)
(input ?, (CompanyId)
input t_sCInvoice.LinkedCInvoice_ID, (CInvoiceId)
output dataset tqCInvoiceForLinkedInvoiceVal) in BCInvoice >
find first tqCInvoiceForLinkedInvoiceVal where
tqCInvoiceForLinkedInvoiceVal.tiCInvoice_ID = t_sCInvoice.LinkedCInvoice_ID
no-error.
if available tqCInvoiceForLinkedInvoiceVal
then do:
assign vdLinkedCInvoiceBalanceCreditTC = tqCInvoiceForLinkedInvoiceVal.tdCInvoiceBalanceCreditTC
vdLinkedCInvoiceBalanceDebitTC = tqCInvoiceForLinkedInvoiceVal.tdCInvoiceBalanceDebitTC
viLinkedCInvoiceCurrencyId = tqCInvoiceForLinkedInvoiceVal.tiCInvoiceCurrency_ID
vlLinkedCInvoiceIsOpen = tqCInvoiceForLinkedInvoiceVal.tlCInvoiceIsOpen
vlLinkedCInvoiceIsSelected = tqCInvoiceForLinkedInvoiceVal.tlCInvoiceIsSelected
vcLinkedCInvoiceType = tqCInvoiceForLinkedInvoiceVal.tcCInvoiceType
viLinkedCreditorId = tqCInvoiceForLinkedInvoiceVal.tiCreditor_ID
vlLinkedCInvoiceIsWHT = tqCInvoiceForLinkedInvoiceVal.tlCInvoiceIsWHT.
end.
else do:
<M-15 run SetMessage
(input trim(#T-15'Linked invoice not found.':250(17256)T-15#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7927':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
return.
end.
end.
if t_sCInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTE} and
vcLinkedCInvoiceType <> {&INVOICETYPE-INVOICE} and
vcLinkedCInvoiceType <> {&INVOICETYPE-CREDITNOTECORRECTION}
then do:
<M-4 run SetMessage
(input trim(#T-2'You can only link $1 to $2.':255(65440)T-2#) (icMessage),
input {&INVOICETYPE-INVOICE-TR} + chr(2) + {&INVOICETYPE-CREDITNOTE-TR} (icArguments),
input 'tCInvoice.tiLinkedCInvoiceVoucher':U (icFieldName),
input t_sCInvoice.tiLinkedCInvoiceVoucher (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCInvoice.tc_Rowid (icRowid),
input 'QadFin-7055':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
end.
else
if t_sCInvoice.CInvoiceType = {&INVOICETYPE-INVOICECORRECTION} and
vcLinkedCInvoiceType <> {&INVOICETYPE-INVOICE}
then do:
<M-5 run SetMessage
(input trim(#T-6'You can only link $1 to $2.':255(65440)T-6#) (icMessage),
input {&INVOICETYPE-INVOICE-TR} + chr(2) + {&INVOICETYPE-INVOICECORRECTION-TR} (icArguments),
input 'tCInvoice.tiLinkedCInvoiceVoucher':U (icFieldName),
input t_sCInvoice.tiLinkedCInvoiceVoucher (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCInvoice.tc_Rowid (icRowid),
input 'QadFin-7057':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
end.
else
if t_sCInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION} and
vcLinkedCInvoiceType <> {&INVOICETYPE-CREDITNOTE}
then do:
<M-7 run SetMessage
(input trim(#T-8'You can only link $1 to $2.':255(65440)T-8#) (icMessage),
input {&INVOICETYPE-CREDITNOTE-TR} + chr(2) + {&INVOICETYPE-CREDITNOTECORRECTION-TR} (icArguments),
input 'tCInvoice.tiLinkedCInvoiceVoucher':U (icFieldName),
input t_sCInvoice.tiLinkedCInvoiceVoucher (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCInvoice.tc_Rowid (icRowid),
input 'QadFin-7058':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
end.
if t_sCInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTE} and
vcLinkedCInvoiceType = {&INVOICETYPE-INVOICE} and
(viLinkedCreditorId <> t_sCInvoice.Creditor_ID or
viLinkedCInvoiceCurrencyId <> t_sCInvoice.CInvoiceCurrency_ID or
vdLinkedCInvoiceBalanceCreditTC < abs(t_sCInvoice.CInvoiceOriginalDebitTC) or
vlLinkedCInvoiceIsOpen <> true or
vlLinkedCInvoiceIsSelected <> false)
then do:
assign vcMessage = trim(#T-51'You can only specify open, unselected invoices for the same supplier and currency and that have a balance amount greater than or equal to the credit note amount.':255(278501178)T-51#)
oiReturnStatus = -1.
<M-56 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tCInvoice.tiLinkedCInvoiceVoucher':U (icFieldName),
input t_sCInvoice.tiLinkedCInvoiceVoucher (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCInvoice.tc_Rowid (icRowid),
input 'qadfin-590587':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
end.
if t_sCInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION} and
(viLinkedCreditorId <> t_sCInvoice.Creditor_ID or
viLinkedCInvoiceCurrencyId <> t_sCInvoice.CInvoiceCurrency_ID or
vdLinkedCInvoiceBalanceDebitTC < abs(t_sCInvoice.CInvoiceOriginalDebitTC) or
vlLinkedCInvoiceIsOpen <> true or
vlLinkedCInvoiceIsSelected <> false)
then do:
<M-10 run SetMessage
(input trim(#T-11'You can only specify open, unselected credit notes for the same supplier and currency, and that have a balance amount greater than or equal to the correction amount.':255(65516)t-11#) (icMessage),
input '':U (icArguments),
input 'tCInvoice.tiLinkedCInvoiceVoucher':U (icFieldName),
input t_sCInvoice.tiLinkedCInvoiceVoucher (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCInvoice.tc_Rowid (icRowid),
input 'QadFin-7104':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
end.
if t_sCInvoice.CInvoiceType = {&INVOICETYPE-INVOICECORRECTION} and
(viLinkedCreditorId <> t_sCInvoice.Creditor_ID or
viLinkedCInvoiceCurrencyId <> t_sCInvoice.CInvoiceCurrency_ID or
vdLinkedCInvoiceBalanceCreditTC < abs(t_sCInvoice.CInvoiceOriginalCreditTC) or
vlLinkedCInvoiceIsOpen <> true or
vlLinkedCInvoiceIsSelected <> false)
then do:
<M-12 run SetMessage
(input trim(#T-13'You can only specify open, unselected invoices for the same supplier and currency, that have a balance amount greater than or equal to the correction amount.':255(65517)t-13#) (icMessage),
input '':U (icArguments),
input 'tCInvoice.tiLinkedCInvoiceVoucher':U (icFieldName),
input t_sCInvoice.tiLinkedCInvoiceVoucher (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCInvoice.tc_Rowid (icRowid),
input 'QadFin-7105':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
end.
if t_sCInvoice.CInvoiceType = {&INVOICETYPE-INVOICE} and
vcLinkedCInvoiceType = {&INVOICETYPE-PREPAYMENT} and
(viLinkedCreditorId <> t_sCInvoice.Creditor_ID or
viLinkedCInvoiceCurrencyId <> t_sCInvoice.CInvoiceCurrency_ID or
vdLinkedCInvoiceBalanceDebitTC < abs(t_sCInvoice.CInvoiceOriginalCreditTC) or
vlLinkedCInvoiceIsOpen <> true or
vlLinkedCInvoiceIsSelected <> false)
then do:
assign vcMessage = trim(#T-92'You can only specify open, unselected prepayments for the same supplier and currency and that have a balance amount greater than or equal to the invoice amount.':255(196957747)T-92#)
oiReturnStatus = -1.
<M-81 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tCInvoice.tiLinkedCInvoiceVoucher':U (icFieldName),
input t_sCInvoice.tiLinkedCInvoiceVoucher (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCInvoice.tc_Rowid (icRowid),
input 'qadfin-618833':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
end.