project QadFinancials > class BJournalEntry > API query SelectPostingVat (optimised)

Description

SelectPostingVat: query that returns all kind of information reagrding the vat/tax used on postings.
Notes:
- we have caluclated fields for the debtor-code and creditor-code as we already have the max (18) number of tables in a single query
- the optimise flag is turned on because the users may file on all kind of information


query filter (table tFilter)


tcBusinessFieldNametcDataTypetcOperator
iiCompanyIdi
tCurrency.CurrencyCodec=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.FromTxzTaxZonec=,>=,>,<>,<=,<,begins,can-do,matches
tGL.GLCodec=,>=,>,<>,<=,<,begins,can-do,matches
tGL.GLTypeCodec=,>=,>,<>,<=,<,begins,can-do,matches
tJournal.JournalCodec=,>=,>,<>,<=,<,begins,can-do,matches
tJournal.JournalControlc=,>=,>,<>,<=,<,begins,can-do,matches
tJournal.JournalTypeCodec=,>=,>,<>,<=,<,begins,can-do,matches
tPosting.PostingBusinessRelationTxtc=,>=,>,<>,<=,<,begins,can-do,matches
tPosting.PostingDatet=,>=,>,<>,<=,<
tPosting.PostingInvoiceReferenceTxtc=,>=,>,<>,<=,<,begins,can-do,matches
tPosting.PostingIsReplacementl=,<>
tPosting.PostingIsReversingl=,<>
tPosting.PostingOriginAddressCodec=,>=,>,<>,<=,<,begins,can-do,matches
tPosting.PostingPeriodi=,>=,>,<>,<=,<
tPostingVat.PostingVatBaseCreditCCd=,>=,>,<>,<=,<
tPostingVat.PostingVatBaseCreditLCd=,>=,>,<>,<=,<
tPostingVat.PostingVatBaseDebitCCd=,>=,>,<>,<=,<
tPostingVat.PostingVatBaseDebitLCd=,>=,>,<>,<=,<
tPostingVat.PostingVatExchangeRated=,>=,>,<>,<=,<
tPostingVat.PostingVatInOutc=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.PostingVatIsSuspDell=,<>
tPostingVat.PostingVatOwnTaxIDFederc=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.PostingVatOwnTaxIDMisc1c=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.PostingVatOwnTaxIDMisc2c=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.PostingVatOwnTaxIDMisc3c=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.PostingVatOwnTaxIDStatec=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.PostingVatRateScaled=,>=,>,<>,<=,<
tPostingVat.PostingVatTaxCreditCCd=,>=,>,<>,<=,<
tPostingVat.PostingVatTaxCreditLCd=,>=,>,<>,<=,<
tPostingVat.PostingVatTaxDebitCCd=,>=,>,<>,<=,<
tPostingVat.PostingVatTaxDebitLCd=,>=,>,<>,<=,<
tPostingVat.PostingVatTaxIDFederc=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.PostingVatTaxIDMisc1c=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.PostingVatTaxIDMisc2c=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.PostingVatTaxIDMisc3c=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.PostingVatTaxIDStatec=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.PostingVatTaxPointDatet=,>=,>,<>,<=,<
tPostingVat.PostingVatTaxTransTypec=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.PostingVatTransTypec=,>=,>,<>,<=,<,begins,can-do,matches
tPosting.PostingVoucheri=,>=,>,<>,<=,<
tPosting.PostingYeari=,>=,>,<>,<=,<
tPostingLine.PostingYearPeriodi=,>=,>,<>,<=,<
tPostingVat.ToTxzTaxZonec=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.TxclTaxClsc=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.TxenvTaxEnvc=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.TxtyTaxTypec=,>=,>,<>,<=,<,begins,can-do,matches
tPostingVat.TxuTaxUsagec=,>=,>,<>,<=,<,begins,can-do,matches
tVat.TxuTaxUsagec=,>=,>,<>,<=,<,begins,can-do,matches
tVat.VatCodec=,>=,>,<>,<=,<,begins,can-do,matches
tVat.VatDescriptionc=,>=,>,<>,<=,<,begins,can-do,matches
tVatGroup3.VatGroupCodec=,>=,>,<>,<=,<,begins,can-do,matches
tVatGroup6.VatGroupCodec=,>=,>,<>,<=,<,begins,can-do,matches
tVatGroup5.VatGroupCodec=,>=,>,<>,<=,<,begins,can-do,matches
tVatGroup1.VatGroupCodec=,>=,>,<>,<=,<,begins,can-do,matches
tVatGroup4.VatGroupCodec=,>=,>,<>,<=,<,begins,can-do,matches
tVatGroup2.VatGroupCodec=,>=,>,<>,<=,<,begins,can-do,matches
tVat.VatInOutc=,>=,>,<>,<=,<,begins,can-do,matches
tVat.VatIsAbsorbedl=,<>
tVat.VatIsRetainedl=,<>
tVatPeriod.VatPeriodPeriodi=,>=,>,<>,<=,<
tVatPeriod.VatPeriodYeari=,>=,>,<>,<=,<
tVat.VatTransactionTypec=,>=,>,<>,<=,<,begins,can-do,matches


Parameters (internal)


iiCompanyIdintegerCompany id


query condition


  each Posting where
Posting.Company_Id = iiCompanyId AND

      first Journal (inner-join) where
Journal.SharedSet_Id = vi_JOURNAL_sharedset(iiCompanyId) AND
Journal.Journal_ID = Posting.Journal_ID AND

      each PostingLine (inner-join) where
PostingLine.Company_Id = iiCompanyId AND
PostingLine.Posting_ID = Posting.Posting_ID AND

          first Currency (inner-join) where
Currency.Currency_ID = PostingLine.Currency_ID AND

          first GL (inner-join) where
GL.SharedSet_Id = vi_GL_sharedset(iiCompanyId) AND
GL.GL_ID = PostingLine.GL_ID AND
GL.GLTypeCode = {&GLTYPECODE-VAT}

          each PostingVat (inner-join) where
PostingVat.PostingLine_ID = PostingLine.PostingLine_ID AND

              first Vat (inner-join) where
Vat.Vat_ID = PostingVat.Vat_ID AND

              first VatPeriod (inner-join) where
VatPeriod.Company_Id = iiCompanyId AND
VatPeriod.VatPeriod_ID = PostingVat.VatPeriod_ID AND

              first VatRule (inner-join) where
VatRule.VatRule_ID = PostingVat.VatRule_ID AND

                  first VatGroup1 (conditional-join) where
VatGroup1.VatGroup_ID = VatRule.InvoiceVatGroup_ID AND

                  first VatGroup2 (conditional-join) where
VatGroup2.VatGroup_ID = VatRule.CreditNoteVatGroup_ID AND

                  first VatGroup3 (conditional-join) where
VatGroup3.VatGroup_ID = VatRule.AbsorbedInvoiceVatGroup_ID AND

                  first VatGroup4 (conditional-join) where
VatGroup4.VatGroup_ID = VatRule.AbsorbedCreditNVatGroup_ID AND

                  first VatGroup5 (conditional-join) where
VatGroup5.VatGroup_ID = VatRule.RetainVoucherVatGroup_ID AND

                  first VatGroup6 (conditional-join) where
VatGroup6.VatGroup_ID = VatRule.RetainCVoucherVatGroup_ID AND


query resultset tqSelectPostingVat


field namedata typedb fielddescription
tcGLTypeCodecharacterGL.GLTypeCodeA code identifying the type of account.
tcJournalControlcharacterJournal.JournalControlA type of daybook control: Financial/Operational/External-used to clearly separate postings based on their source.
tcJournalTypeCodeTrcharactercalculatedDaybook Type
tcPostingOriginAddressCodecharacterPosting.PostingOriginAddressCodeFor invoices created with Invoice Post and Print, the address code of the bill-to customer is stored in this field.
tdPostingVatBaseCreditCCdecimalPostingVat.PostingVatBaseCreditCCSC (Statutory Currency) Base Credit amount.
tdPostingVatBaseDebitCCdecimalPostingVat.PostingVatBaseDebitCCSC (Statutory Currency) Base Debit amount.
tlPostingVatIsSuspDellogicalPostingVat.PostingVatIsSuspDelSuspended/Delayed Tax
tdPostingVatTaxCreditCCdecimalPostingVat.PostingVatTaxCreditCCSC (Statutory Currency) Tax Credit amount.
api annotation:?
tdPostingVatTaxDebitCCdecimalPostingVat.PostingVatTaxDebitCCSC (Statutory Currency) Tax Debit amount.
api annotation:?
tiPostingYearPeriodintegerPostingLine.PostingYearPeriodThe GL calendar year/period for the journal entry.
api annotation:In Create mode, it will get be defaulted to the value for the field PostingYearPeriod of tPosting.
tiVat_IDintegerVat.Vat_IDRecord ID
tiPostingYearintegerPosting.PostingYearThe GL calendar year for the posting.
tiPostingPeriodintegerPosting.PostingPeriodThe GL period for the posting. The period must be open.
tcJournalCodecharacterJournal.JournalCodeA daybook code (maximum eight characters).
tiPostingVoucherintegerPosting.PostingVoucherVoucher is a sequential number that uniquely identifies the journal entry (within the combination of an entity and a daybook code).
api annotation:In create mode,enter 0 in this field - the voucher number is generated by the system. In Modify/Delete, the correct voucher number must be entered because this identifies the record.
ttPostingDatedatePosting.PostingDateThe accounting date on which the journal entry is posted. The posting date must be a valid calendar date and must be within the GL calendar year (PostingYear) and period (PostingPeriod).
tcPostingBusinessRelationTxtcharacterPosting.PostingBusinessRelationTxtWhen the posting is a transaction linked to a business relation (for example, an invoice posting), this field contains the Business Relation Name. Used for information purposes on reports and browses.
api annotation:Value for this field defaults to blank.
tcPostingInvoiceReferenceTxtcharacterPosting.PostingInvoiceReferenceTxtWhen the posting is part of an invoice posting, then this field contains the invoice number (Year/Daybook/Voucher extended with supplier invoice Reference in case of a supplier invoice). Used for information purpose on reports and browsers.
api annotation:Value for this field defaults to blank
tcCreditorCodecharactercalculatedCreditorCode
tcDebtorCodecharactercalculatedDebtorCode
tcGLCodecharacterGL.GLCodeA code identifying the GL account.
tcCurrencyCodecharacterCurrency.CurrencyCodeCurrency Code
tdPostingVatBaseDebitLCdecimalPostingVat.PostingVatBaseDebitLCBC (Base/Local Currency) Base Debit amount.
tdPostingVatBaseCreditLCdecimalPostingVat.PostingVatBaseCreditLCBC (Base/Local Currency) Base Credit amount.
tdPostingVatExchangeRatedecimalPostingVat.PostingVatExchangeRateTC/BC Exchange Rate.
api annotation:?
tdPostingVatRateScaledecimalPostingVat.PostingVatRateScaleScale Factor (TC/BC).
api annotation:?
tcPostingVatInOutcharacterPostingVat.PostingVatInOutIn/Out?
api annotation:Aivalable value for this field: "INPUT" represents purchases, "OUTPUT" represents sales.
ttPostingVatTaxPointDatedatePostingVat.PostingVatTaxPointDateThe date when this posting is taken into account in the Tax sub-adminstration.
api annotation:?
tcPostingVatTaxTransTypecharacterPostingVat.PostingVatTaxTransTypeTax Transaction Type?
api annotation:Available value for this field: 29 represents "AP Payment Check (Discount at Payment)", 55 represents "AP Transactions", 22 represents "AP Invoice", 18 represents "AR Invoice", 16 represents "AR Operational Invoice", 19 represents "AR Payment (Discount at Payment)", 56 represents "AR Transactions", 45 represents "Logistic Accounting - DO Shipment", 27 represents "Logistic Accounting - PO Receipt", 43 represents "Logistic Accounting - SO Shipment", 20 represents "Purchase Order", 21 represents "Purchase Order Receipt", 25 represents "Purchase Order Return"
tcPostingVatTransTypecharacterPostingVat.PostingVatTransTypeTransaction Type?
api annotation:Available value for this field is: ACQUISITION represents "IC Acquisition", BOTH represents "Both", EXPORT represents "Export", IN represents "IN", OUT represents "OUT", IMPORT represents "Import", INLAND-PURCHASE represents "INLAND-PURCHASE", INLAND-SALES represents "INLAND-SALES", PURCHASE represents "Inland Purchase", SALES represents "Inland Sales", SUPPLY represents "IC Supply", TRIANGULARPURCHASE represents "Triangular Purchase", TRIANGULARSALES represents "Triangular Sales".
tdPostingVatTaxDebitLCdecimalPostingVat.PostingVatTaxDebitLCBC (Base Currency) Tax Debit amount.
api annotation:?
tdPostingVatTaxCreditLCdecimalPostingVat.PostingVatTaxCreditLCBC (Base/Local) Tax Credit amount.
api annotation:?
tcPostingVatTaxIDFedercharacterPostingVat.PostingVatTaxIDFederFederal Tax?
api annotation:?
tcPostingVatTaxIDStatecharacterPostingVat.PostingVatTaxIDStateState Tax?
api annotation:?
tcPostingVatTaxIDMisc1characterPostingVat.PostingVatTaxIDMisc1Miscellaneous Tax 1. For reference and documentation
purposes, enter any other tax identification numbers that are useful.
api annotation:?
tcPostingVatTaxIDMisc2characterPostingVat.PostingVatTaxIDMisc2Miscellaneous Tax 2
tcPostingVatTaxIDMisc3characterPostingVat.PostingVatTaxIDMisc3Miscellaneous Tax 3
tcPostingVatOwnTaxIDFedercharacterPostingVat.PostingVatOwnTaxIDFederOwn Federal Tax?
api annotation:?
tcPostingVatOwnTaxIDStatecharacterPostingVat.PostingVatOwnTaxIDStateOwn State Tax?
api annotation:?
tcPostingVatOwnTaxIDMisc1characterPostingVat.PostingVatOwnTaxIDMisc1Own Miscellaneous Tax 1? For reference and documentation purposes, enter any other tax identification numbers that are useful.
api annotation:?
tcPostingVatOwnTaxIDMisc2characterPostingVat.PostingVatOwnTaxIDMisc2Own Miscellaneous Tax 2
tcPostingVatOwnTaxIDMisc3characterPostingVat.PostingVatOwnTaxIDMisc3Own Miscellaneous Tax 3
tcTxtyTaxTypecharacterPostingVat.TxtyTaxTypeTax Type
tcTxclTaxClscharacterPostingVat.TxclTaxClsTax Class. A tax class previously defined in Tax Class Maintenance. Tax classes group addresses taxed at specific rates or that are tax-exempt and help determine the default tax environment (set of tax types) for related transactions.
api annotation:The value of Tax Class defaults to the header of transactions created for this address
tcTxuTaxUsagecharacterPostingVat.TxuTaxUsageTax Usage. A tax usage code previously defined in Tax Usage Maintenance. Tax usage codes identify the normal use of items sold to this address. Common tax usages are retail, manufacturing, and industrialization.
api annotation:The value of Tax Usage defaults to the header of transactions created for this address.
tcTxenvTaxEnvcharacterPostingVat.TxenvTaxEnvTax Environment. A code (maximum 16 characters) that
identifies a set of tax types for a tax zone/tax class combination. On transactions, this code identifies the transaction or line-item tax environment.
api annotation:?
tcFromTxzTaxZonecharacterPostingVat.FromTxzTaxZoneFrom Tax Zone.
api annotation:?
tcToTxzTaxZonecharacterPostingVat.ToTxzTaxZoneTo Tax Zone
api annotation:?
tiVatPeriodYearintegerVatPeriod.VatPeriodYearTax Year
tiVatPeriodPeriodintegerVatPeriod.VatPeriodPeriodTax Period
tcVatCodecharacterVat.VatCodeTax Code
tcVatDescriptioncharacterVat.VatDescriptionDescription
tcVatInOutcharacterVat.VatInOutTax In/Out
tcVatTransactionTypecharacterVat.VatTransactionTypeTransaction Type
tlVatIsRetainedlogicalVat.VatIsRetainedRetained
tlVatIsAbsorbedlogicalVat.VatIsAbsorbedAbsorbed
tcTxuTaxUsage2characterVat.TxuTaxUsageTax Usage
tcInvoiceVatGroupCodecharacterVatGroup1.VatGroupCodeTax Group Code
tcCreditNoteVatGroupCodecharacterVatGroup2.VatGroupCodeTax Group Code
tcAbsordedInvoiceVatGroupCodecharacterVatGroup3.VatGroupCodeTax Group Code
tcAbsordedCNVatGroupCodecharacterVatGroup4.VatGroupCodeTax Group Code
tcRetainVoucherVatGroupCodecharacterVatGroup5.VatGroupCodeTax Group Code
tcRetainCNVatGroupCodecharacterVatGroup6.VatGroupCodeTax Group Code
tcJournalTypeCodecharacterJournal.JournalTypeCodeA daybook type code.
api annotation:Value for this field defaults to "Journal Entries".
ttLastModifiedDatedatePostingVat.LastModifiedDateLast Modified Date
tiLastModifiedTimeintegerPostingVat.LastModifiedTimeLast Modified Time
tcLastModifiedUsercharacterPostingVat.LastModifiedUserLast Modified User
tlPostingIsReversinglogicalPosting.PostingIsReversingIndicate whether the posting is a reversal of an existing posting.
api annotation:Value for this field defaults to "false".
tlPostingIsReplacementlogicalPosting.PostingIsReplacementIndicate whether the posting is a replacement of an existing posting.
api annotation:Value for this field defaults to "false". For reversal postings, either automatic or manual - this value defaults to "true".
tiCurrency_IDintegerPostingLine.Currency_IDCurrency Code
tiGL_IDintegerPostingLine.GL_IDGL Description
tiPostingVat_IDintegerPostingVat.PostingVat_IDRecord ID
tiVatPeriod_IDintegerPostingVat.VatPeriod_IDLink to VatPeriod
tiVatRule_IDintegerPostingVat.VatRule_IDLink to VatRule
tiAbsorbedCreditNVatGroup_IDintegerVatRule.AbsorbedCreditNVatGroup_IDTax Group Code
tiAbsorbedInvoiceVatGroup_IDintegerVatRule.AbsorbedInvoiceVatGroup_IDTax Group Code
tiCreditNoteVatGroup_IDintegerVatRule.CreditNoteVatGroup_IDCredit Note Tax Group
tiInvoiceVatGroup_IDintegerVatRule.InvoiceVatGroup_IDInvoice Tax Group
tiRetainCVoucherVatGroup_IDintegerVatRule.RetainCVoucherVatGroup_IDTax Group Code
tiRetainVoucherVatGroup_IDintegerVatRule.RetainVoucherVatGroup_IDTax Group Code
tiCompany_IDintegerPosting.Company_IDLink to Company
tiJournal_IDintegerPosting.Journal_IDDaybook Code
tiPosting_IDintegerPosting.Posting_IDRecord ID
PostingCustomcharactercalculatedcustom fields
JournalCustomcharactercalculatedcustom fields
PostingLineCustomcharactercalculatedcustom fields
CurrencyCustomcharactercalculatedcustom fields
GLCustomcharactercalculatedcustom fields
PostingVatCustomcharactercalculatedcustom fields
VatCustomcharactercalculatedcustom fields
VatPeriodCustomcharactercalculatedcustom fields
VatRuleCustomcharactercalculatedcustom fields
VatGroup1Customcharactercalculatedcustom fields
VatGroup2Customcharactercalculatedcustom fields
VatGroup3Customcharactercalculatedcustom fields
VatGroup4Customcharactercalculatedcustom fields
VatGroup5Customcharactercalculatedcustom fields
VatGroup6Customcharactercalculatedcustom fields
ti_sequenceintegercalculatedprimary index
tc_rowidcharactercalculated = rowid(Posting),rowid(Journal),rowid(PostingLine),rowid(Currency),rowid(GL),rowid(PostingVat),rowid(Vat),rowid(VatPeriod),rowid(VatRule),rowid(VatGroup1),rowid(VatGroup2),rowid(VatGroup3),rowid(VatGroup4),rowid(VatGroup5),rowid(VatGroup6)


Internal usage


unused


Sample code: how to call this query through RPCRequestService (QXtend Inbound)

define temp-table ttContext no-undo
    field propertyQualifier as character
    field propertyName as character
    field propertyValue as character
    index entityContext is primary unique
        propertyQualifier
        propertyName
    index propertyQualifier
        propertyQualifier.

define dataset dsContext for ttContext.

define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.

/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
       ttContext.propertyValue = "BJournalEntry".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "SelectPostingVat".
create ttContext.
assign ttContext.propertyName = "applicationId"
       ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
       ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
       ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
       ttContext.propertyValue = "".

/* Create input dataset */
create dataset vhInputDS.
vhInputDS:read-xmlschema("file", "xml/bjournalentry.selectpostingvat.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().

assign vhParameter::icRange = "A"
       vhParameter::icRowid = ""
       vhParameter::iiRownum = 0
       vhParameter::iiNumber = 5 /* Number of records to read */
       vhParameter::icSortColumns = ""
       vhParameter::ilCountOnly = false
       vhParameter::ilForwardRead = true
       vhParameter::iiMaximumBrowseRecordsToCount = 0.

vhParameter = vhInputDS:get-buffer-handle("tFilter").
vhParameter:buffer-create().

assign vhParameter::<field-name-1> = <field-value-1>
       vhParameter::<field-name-2> = <field-value-2>
       ...

/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").

if not vhServer:connected()
then do:
    message "Could not connect AppServer" view-as alert-box error title "Error".
    return.
end.

/* Run */
assign vhContextDS = dataset dsContext:handle.

run program/rpcrequestservice.p on vhServer
    (input-output dataset-handle vhContextDS by-reference,
           output dataset-handle vhExceptionDS,
     input        dataset-handle vhInputDS by-reference,
     input-output dataset-handle vhInputOutputDS by-reference,
           output dataset-handle vhOutputDS).

/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).

if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).

/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.

if valid-handle(vhInputDS)
then delete object vhInputDS.

if valid-handle(vhOutputDS)
then delete object vhOutputDS.

if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.