project QadFinancials > class BCInvoice > method ValidateComponentPostCreate
Description
This method is a submethod of ValidateComponentPost.
This method does some validations on supplier invoices.
Parameters
blStart2 | input-output | logical | Is query tqCInvoiceForLinkedInvoiceVal already started or not ? |
blStart10 | input-output | logical | obsolete parameter |
blStart11 | input-output | logical | obsolete parameter |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bcinvoice.p)
/* Validate Linked Invoice */
if t_sCInvoice.LinkedCInvoice_ID <> 0 and
t_sCInvoice.LinkedCInvoice_ID <> ?
then do:
<M-22 run ValidateComponentPostCreateLinkedInvoice
(input-output blStart2 (blStart2),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
end.
/* VAT amount must correspond with invoice amount. If not, give warning */
if t_sCInvoice.CInvoiceIsTaxable and
(t_sCInvoice.CInvoiceType = {&INVOICETYPE-INVOICE} or
t_sCInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTE} or
t_sCInvoice.CInvoiceType = {&INVOICETYPE-INVOICECORRECTION} or
t_sCInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION})
then do:
assign vdInvoiceAmountTC = if t_sCInvoice.CInvoiceType = {&INVOICETYPE-INVOICE} or
t_sCInvoice.CInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then t_sCInvoice.CInvoiceOriginalCreditTC
else t_sCInvoice.CInvoiceOriginalDebitTC
vdTotalTaxAmountTC = if t_sCInvoice.CInvoiceType = {&INVOICETYPE-INVOICE} or
t_sCInvoice.CInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then (t_sCInvoice.CInvoiceVatBaseDebitTC +
t_sCInvoice.CInvoiceVatDebitTC) -
(t_sCInvoice.CInvoiceVatBaseCreditTC +
t_sCInvoice.CInvoiceVatCreditTC)
else (t_sCInvoice.CInvoiceVatBaseCreditTC +
t_sCInvoice.CInvoiceVatCreditTC) -
(t_sCInvoice.CInvoiceVatBaseDebitTC +
t_sCInvoice.CInvoiceVatDebitTC).
if vdInvoiceAmountTC <> vdTotalTaxAmountTC
then do:
<M-23 run SetMessage
(input trim(#T-22'The sum of the base and tax amounts ($1) does not equal the invoice amount ($2).':255(65518)T-22#) (icMessage),
input string(vdTotalTaxAmountTC) + chr(2) + string(vdInvoiceAmountTC) (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 4 (iiSeverity),
input t_sCInvoice.tc_Rowid (icRowid),
input 'QadFin-7106':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if oiReturnStatus = 0
then assign oiReturnStatus = 1.
end.
end.
/* Give a warning if a credit note with the same amount, invoice date and supplier already exists. */
if t_sCInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTE} or
t_sCInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then do:
assign vlError = can-find(first bCInvoice where
bCInvoice.Creditor_ID = t_sCInvoice.Creditor_ID and
bCInvoice.CInvoiceCurrency_ID = t_sCInvoice.CInvoiceCurrency_ID and
bCInvoice.CInvoiceDate = t_sCInvoice.CInvoiceDate and
bCInvoice.CInvoiceType = t_sCInvoice.CInvoiceType and
bCInvoice.CInvoiceOriginalDebitTC = t_sCInvoice.CInvoiceOriginalDebitTC and
bCInvoice.tc_Rowid <> t_sCInvoice.tc_Rowid).
if not vlError
then do:
<Q-25 assign vlFcQueryRecordsAvailable = CInvoiceByOrigDateCreditorType (NoCache)
(input ?, (CompanyId)
input t_sCInvoice.CInvoiceType, (CInvoiceType)
input t_sCInvoice.CInvoiceOriginalDebitTC, (CInvoiceOriginalDebitTC)
input t_sCInvoice.CInvoiceDat, (CInvoiceDate)
input t_sCInvoice.Creditor_ID, (CreditorId)
input t_sCInvoice.CInvoiceCurrency_ID, (CurrencyId)
input t_sCInvoice.tc_Rowid, (SkipRowId)) in BCInvoice >
assign vlError = vlFcQueryRecordsAvailable <> false.
end.
if vlError
then do:
<M-26 run SetMessage
(input trim(#T-23'The invoice amount already exists on another credit note with the same invoice date and the same supplier.':150(45575)T-23#) (icMessage),
input '':U (icArguments),
input 'tCInvoice.tdCInvoiceOriginalTC':U (icFieldName),
input t_sCInvoice.tdCInvoiceOriginalTC (icFieldValue),
input 'W':U (icType),
input 4 (iiSeverity),
input t_sCInvoice.tc_Rowid (icRowid),
input 'QadFin-7107':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if oiReturnStatus = 0
then assign oiReturnStatus = 1.
end.
end. /* t_sCInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTE} */
/* CEE VAT Currency ================================================================= */
/* If Vat currency = CInvoice currency, exchange rate must be 1 */
/* ================================================================================== */
/* PWI 17/01/2011 i just put that in comment because maybe in the future we will used TAX currency and then it migth usesull to have those validations
if t_sCInvoice.VatCurrency_ID = t_sCInvoice.CInvoiceCurrency_ID and
(t_sCInvoice.CInvoiceVatExchangeRate <> 1 or
t_sCInvoice.CInvoiceVatRateScale <> 1)
then do:
assign vcMessage = #T-27'If the tax declaration currency matches the transactional currency, the tax exchange rate must be 1 (exchange rate: &1, scale factor: &2).':255(17000)T-27#
vcMessage = trim(substitute(vcMessage, t_sCInvoice.CInvoiceVatExchangeRate, t_sCInvoice.CInvoiceVatRateScale))
oiReturnStatus = -1.
<M-29 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input 'CInvoice.CInvoiceVatExchangeRate' (icFieldName),
input t_sCInvoice.CInvoiceVatExchangeRate (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input t_sCInvoice.tc_Rowid (icRowid),
input 'QadFin-7269':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
end.
/* CEE VAT Currency If Vat currency = local currency, exchange rate must be the same as on the invoice */
if t_sCInvoice.VatCurrency_ID = viCompanyLCId and
(t_sCInvoice.CInvoiceVatExchangeRate <> t_sCInvoice.CInvoiceExchangeRate or
t_sCInvoice.CInvoiceVatRateScale <> t_sCInvoice.CInvoiceRateScale)
then do:
assign vcMessage = #T-28'If the tax declaration currency matches the base currency, the tax exchange rate must be the same as the customer invoice exchange rate (customer invoice ex rate: &1, customer invoice scale: &2, Tax ex rate: &3, Tax scale: &4).':255(16999)T-28#
vcMessage = trim(substitute(vcMessage, t_sCInvoice.CInvoiceExchangeRate, t_sCInvoice.CInvoiceRateScale, t_sCInvoice.CInvoiceVatExchangeRate, t_sCInvoice.CInvoiceVatRateScale))
oiReturnStatus = -1.
<M-30 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input 'CInvoice.CInvoiceVatExchangeRate' (icFieldName),
input t_sCInvoice.CInvoiceVatExchangeRate (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input t_sCInvoice.tc_Rowid (icRowid),
input 'QadFin-7270':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
end.
*/