project QadFinancials > class BCInvoice > business logic query CInvoiceForWHTDefaulting

Description

CInvoiceForWHTDefaulting: This query lists all CInvoice records and underlaying CInvoiceWHT and related Vat and tx2_mstr records based on creditor invoice id.

Result-set is indexed on CInvoice_ID

Note the result-set can hold mutliple entries for every VAT-record as each VAT-record can have multiple Tx2_mstr-records as the join is only on VatCode (and not on Domain as well)


Parameters


iiCompanyIdintegerCompany id
iiCInvoiceIDintegerCInvoice ID
ilCInvoiceIsWHTlogicalDoes the invoice holds WHT
icDomainCodecharacterDomainCode: This is used to make sure we get the correct record from tx2_mstr joined from table Vat.
Therefore we have a condition on tx2_mstr.tx2_domain


query condition


  each CInvoice where
CInvoice.Company_Id = iiCompanyId AND
CInvoice.CInvoice_ID = iiCInvoiceID AND
CInvoice.CInvoiceIsWHT = ilCInvoiceIsWHT

      each CInvoiceWHT (inner-join) where
CInvoiceWHT.CInvoice_ID = CInvoice.CInvoice_ID AND

          first Vat (outer-join) where
Vat.Vat_ID = CInvoiceWHT.Vat_ID AND

              first tx2_mstr (conditional-join) where
tx2_mstr.tx2_tax_code = Vat.VatCode AND
tx2_mstr.tx2_domain = icDomainCode


query resultset tqCInvoiceForWHTDefaulting


field namedata typedb fielddescription
tiCInvoice_IDintegerCInvoice.CInvoice_IDRecord ID
tiCInvoiceCurrency_IDintegerCInvoice.CInvoiceCurrency_IDCurrency Code
tlCInvoiceIsWHTlogicalCInvoice.CInvoiceIsWHTWithholding Tax
tcCInvoiceTypecharacterCInvoice.CInvoiceTypeInvoice Type. This field identifies the invoice type.
The value can be Invoice Correction and Credit Note Correction type only when the appropriate daybook types have already been defined.
tiCInvoiceWHT_IDintegerCInvoiceWHT.CInvoiceWHT_IDRecord ID
tdCInvoiceWHTBaseAmtCreditTCdecimalCInvoice.CInvoiceWHTBaseAmtCreditTCTC WHT Base Amount (CR)
tdCInvoiceWHTBaseAmtDebitTCdecimalCInvoice.CInvoiceWHTBaseAmtDebitTCTC WHT Base Amount (DR)
tdCInvoiceWHTTotAmtCreditCCdecimalCInvoice.CInvoiceWHTTotAmtCreditCCSC WHT Total Amount (CR)
tdCInvoiceWHTTotAmtCreditLCdecimalCInvoice.CInvoiceWHTTotAmtCreditLCBC WHT Total Amount (CR)
tdCInvoiceWHTTotAmtCreditTCdecimalCInvoice.CInvoiceWHTTotAmtCreditTCTC WHT Total Amount (CR)
tdCInvoiceWHTTotAmtDebitCCdecimalCInvoice.CInvoiceWHTTotAmtDebitCCSC WHT Total Amount (DR)
tdCInvoiceWHTTotAmtDebitLCdecimalCInvoice.CInvoiceWHTTotAmtDebitLCBC WHT Total Amount (DR)
tdCInvoiceWHTTotAmtDebitTCdecimalCInvoice.CInvoiceWHTTotAmtDebitTCTC WHT Total Amount (DR)
tiCompany_IDintegerCInvoice.Company_IDLink to Company
tctx2_domaincharactertx2_mstr.tx2_domainDomain
tltx2_update_taxlogicaltx2_mstr.tx2_update_taxUpdate Tax Allowed
tiVat_IDintegerCInvoiceWHT.Vat_IDLink to Vat
tcVatCodecharacterVat.VatCodeTax Code


Internal usage


QadFinancials
method BCInvoice.DefaultWHTDataBasedOnCInvoice