project QadFinancials > class BCInvoice > API query SelectCInvoiceMovementInv (optimised)

Description

Use this query in case you want to lookup a creditor invoice movement; This query should only be used by UI-components!!!!
In this query you can filter on period and journal of the invoice himself, not on posting


query filter (table tFilter)


tcBusinessFieldNametcDataTypetcOperator
iiCompanyIdi
tCInvoice.CInvoiceBalanceCCd=,>=,>,<>,<=,<
tCInvoice.CInvoiceBalanceLCd=,>=,>,<>,<=,<
tCInvoice.CInvoiceBalanceTCd=,>=,>,<>,<=,<
tCInvoice.CInvoiceDatet=,>=,>,<>,<=,<
tCInvoice.CInvoiceDescriptionc=,>=,>,<>,<=,<,begins,can-do,matches
tCInvoice.CInvoiceDueDatet=,>=,>,<>,<=,<
tCInvoice.CInvoiceHoldAmountTCd=,>=,>,<>,<=,<
tCInvoice.CInvoiceIsOpenl=,<>
tCInvoiceMovement.CInvoiceMovementDiscountTCd=,>=,>,<>,<=,<
tCInvoiceMovement.CInvoiceMovementTypec=,>=,>,<>,<=,<,begins,can-do,matches
tCInvoiceMovement.CInvoiceMovementYearPeriodi=,>=,>,<>,<=,<
tCInvoice.CInvoiceOriginalCreditCCd=,>=,>,<>,<=,<
tCInvoice.CInvoiceOriginalCreditLCd=,>=,>,<>,<=,<
tCInvoice.CInvoiceOriginalCreditTCd=,>=,>,<>,<=,<
tCInvoice.CInvoiceOriginalDebitCCd=,>=,>,<>,<=,<
tCInvoice.CInvoiceOriginalDebitLCd=,>=,>,<>,<=,<
tCInvoice.CInvoiceOriginalDebitTCd=,>=,>,<>,<=,<
tCInvoice.CInvoicePostingYearPeriodi=,>=,>,<>,<=,<
tCInvoice.CInvoiceTypec=,>=,>,<>,<=,<,begins,can-do,matches
tCInvoice.CInvoiceVoucheri=,>=,>,<>,<=,<
tCreditor.CreditorCodec=,>=,>,<>,<=,<,begins,can-do,matches
tCurrency1.CurrencyCodec=,>=,>,<>,<=,<,begins,can-do,matches
tCurrency2.CurrencyCodec=,>=,>,<>,<=,<,begins,can-do,matches
tGL.GLCodec=,>=,>,<>,<=,<,begins,can-do,matches
tJournal1.JournalCodec=,>=,>,<>,<=,<,begins,can-do,matches
tJournal2.JournalCodec=,>=,>,<>,<=,<,begins,can-do,matches
tCInvoice.LastModifiedDatet=,>=,>,<>,<=,<
tCInvoice.LastModifiedTimei=,>=,>,<>,<=,<
tCInvoice.LastModifiedUserc=,>=,>,<>,<=,<,begins,can-do,matches
tPeriod1.PeriodPeriodi=,>=,>,<>,<=,<
tPeriod2.PeriodPeriodi=,>=,>,<>,<=,<
tPeriod2.PeriodYeari=,>=,>,<>,<=,<
tPeriod1.PeriodYeari=,>=,>,<>,<=,<
tPeriod2.PeriodYearPeriodi=,>=,>,<>,<=,<
tPeriod1.PeriodYearPeriodi=,>=,>,<>,<=,<
tPosting.PostingDatet=,>=,>,<>,<=,<
tPosting.PostingInvoiceReferenceTxtc=,>=,>,<>,<=,<,begins,can-do,matches
tPostingLine.PostingLineCreditCCd=,>=,>,<>,<=,<
tPostingLine.PostingLineCreditLCd=,>=,>,<>,<=,<
tPostingLine.PostingLineCreditTCd=,>=,>,<>,<=,<
tPostingLine.PostingLineDebitCCd=,>=,>,<>,<=,<
tPostingLine.PostingLineDebitLCd=,>=,>,<>,<=,<
tPostingLine.PostingLineDebitTCd=,>=,>,<>,<=,<
tPostingLine.PostingLineExchangeRated=,>=,>,<>,<=,<
tPostingLine.PostingLineTextc=,>=,>,<>,<=,<,begins,can-do,matches
tPosting.PostingPeriodi=,>=,>,<>,<=,<
tPosting.PostingSystemDatet=,>=,>,<>,<=,<
tPosting.PostingVoucheri=,>=,>,<>,<=,<
tPosting.PostingYeari=,>=,>,<>,<=,<


Parameters (internal)


iiCompanyIdintegerCompany id


query condition


  each CInvoice where
CInvoice.Company_Id = iiCompanyId AND

      each CInvoiceMovement (inner-join) where
CInvoiceMovement.Company_Id = iiCompanyId AND
CInvoiceMovement.CInvoice_ID = CInvoice.CInvoice_ID AND

          first PostingLine (inner-join) where
PostingLine.Company_Id = iiCompanyId AND
PostingLine.PostingLine_ID = CInvoiceMovement.PostingLine_ID AND

              first Currency1 (inner-join) where
Currency1.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

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

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

                  first Period1 (inner-join) where
Period1.Company_Id = iiCompanyId AND
Period1.Period_ID = Posting.Period_ID AND

      first Creditor (inner-join) where
Creditor.SharedSet_Id = vi_CREDITOR_sharedset(iiCompanyId) AND
Creditor.Creditor_ID = CInvoice.Creditor_ID AND

      first Currency2 (inner-join) where
Currency2.Currency_ID = CInvoice.CInvoiceCurrency_ID AND

      first Journal2 (inner-join) where
Journal2.SharedSet_Id = vi_JOURNAL_sharedset(iiCompanyId) AND
Journal2.Journal_ID = CInvoice.Journal_ID AND

      first Period2 (inner-join) where
Period2.Company_Id = iiCompanyId AND
Period2.Period_ID = CInvoice.Period_ID AND


query resultset tqSelectCInvoiceMovementInv


field namedata typedb fielddescription
tdAmountCCCalcdecimalcalculatedNet amount in SC
tdAmountLCCalcdecimalcalculatedNet amount in BC
tdAmountTCCalcdecimalcalculatedNet Amount in TC
tiCInvoice_IDintegerCInvoice.CInvoice_IDRecord ID
tdCInvoiceBalanceCCdecimalCInvoice.CInvoiceBalanceCCSC Balance. This field displays the sum of the debit and credit amounts of all posting lines in statutory currency.
This field is calculated by the system using the TC Balance and the SC rate.
ttCInvoiceDueDatedateCInvoice.CInvoiceDueDateDue Date.This field indicates the date when payment become due.
This field can be modified without affecting the credit terms.
This field is calculated by the system based on the credit terms and the invoice date.
tcCInvoiceKeyCalccharactercalculatedConcatenated field of the key fields of the invoice
tdCInvoiceMovementDiscountTCdecimalCInvoiceMovement.CInvoiceMovementDiscountTCCInvoiceMovementDiscountTC. The amount of payment discount in TC.
tiCInvoiceMovementYearPeriodintegerCInvoiceMovement.CInvoiceMovementYearPeriodYear/GL Period. This field indicates the accounting year and period for the invoice's movement.
tdCInvoiceOriginalCreditCCdecimalCInvoice.CInvoiceOriginalCreditCCSC Invoice Amount (CR). This field displays the credit total invoice amount in the statutory currency.
This field is calculated by the system using the TC Invoice Amount(CR) and the SC Rate.
tdCInvoiceOriginalDebitCCdecimalCInvoice.CInvoiceOriginalDebitCCSC Invoice Amount (DR). This field displays the debit total invoice amount in the statutory currency.
This field is calculated by the system using the TC Invoice Amount(CR) and the SC Rate.
tiCInvoicePostingYearPeriodintegerCInvoice.CInvoicePostingYearPeriodYear/Period. This field indicates the accounting year and period for the invoice.
If you modify these fields, the posting and tax dates are changed correspondingly.
api annotation:This field defaults to the accounting year and period associated with the posting date.
ttLastModifiedDatedateCInvoice.LastModifiedDateLast Modified Date
tiLastModifiedTimeintegerCInvoice.LastModifiedTimeLast Modified Time
tcLastModifiedUsercharacterCInvoice.LastModifiedUserLast Modified User
tdPostingLineCreditCCdecimalPostingLine.PostingLineCreditCCSC Credit
api annotation:Partial Update = yes - it will get a default value depending on the value of PostingLinCreditTC, PostingLineCCRate & PostingLineCCScale.
SC Amount = TC Amount * Exchange rate (TC/SC) * Scale Factor (TC/SC). If Partial Update is false, you should enter the correct value for this field
tdPostingLineDebitCCdecimalPostingLine.PostingLineDebitCCSC Debit
api annotation:Partial Update = yes - it will get a default value depending on the value of PostingLineDebitTC, PostingLineCCRate & PostingLineCCScale.
SC Amount = TC Amount * Exchange rate (TC/SC) * Scale Factor (TC/SC). If Partial Update is false, enter the correct value for this field.
tdPostingLineExchangeRatedecimalPostingLine.PostingLineExchangeRateExchange Rate
api annotation:Default value for this field depends on the exchang erate shared set specified for the current domain.
tcPostingLineTextcharacterPostingLine.PostingLineTextDescription
api annotation:Value for this field defaults to blank. Note: if a new record is created through the user interface, the default value is as same as the value of "PostingText" of tPosting.
tiPostingPeriodintegerPosting.PostingPeriodThe GL period for the posting. The period must be open.
ttPostingSystemDatedatePosting.PostingSystemDateThe system date of the posting corresponding to "PostingDate".
api annotation:In Create mode, when Partial Update = yes - this field gets a default value which is the current date of the system.
tiPostingYearintegerPosting.PostingYearThe GL calendar year for the posting.
tiPeriodPeriodintegerPeriod1.PeriodPeriodGL Period
tiPeriodYearintegerPeriod1.PeriodYearGL Calendar Year
tiPeriodYearPeriodintegerPeriod1.PeriodYearPeriodGL Calendar Year/GL Period
tdCInvoiceBalanceLCdecimalCInvoice.CInvoiceBalanceLCBC Balance. This field displays the sum of the debit and credit amounts of all posting lines in base currency.
This field is calculated by the system using the TC Balance and the Exchange rate.
tiPeriodYearPeriod2integerPeriod2.PeriodYearPeriodGL Calendar Year/GL Period
tdCInvoiceOriginalCreditLCdecimalCInvoice.CInvoiceOriginalCreditLCBC Invoice Amount(CR). This field displays the credit total invoice amount in the base currency.
This field is calculated by the system using the TC Invoice Amount(CR) and the Exchange rate.
tdCInvoiceOriginalDebitLCdecimalCInvoice.CInvoiceOriginalDebitLCBC Invoice Amount(DR). This field displays the debit total invoice amount in the base currency.
This field is calculated by the system using the TC Invoice Amount(DR) and the Exchange rate.
tdPostingLineCreditLCdecimalPostingLine.PostingLineCreditLCBC Credit
api annotation:Partial Update = yes - it will get a default value depends on the value of PostingLineCreditTC, PostingLineExchangeRate & PostingLineRateScale.
BC Amount = TC Amount * Exchange rate (TC/BC) * Scale Factor (TC/BC). If Partial Update is false, enter a value for this field.
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
tdPostingLineDebitLCdecimalPostingLine.PostingLineDebitLCBC Debit
api annotation:Partial Update = yes - it will get a default value depending on the value of PostingLineDebitTC, PostingLineExchangeRate and PostingLineRateScale.
BC Amount = TC Amount * Exchange rate (TC/BC) * Scale Factor (TC/BC). If Partial Update = false, enter the correct value into this field.
tcCInvoiceMovTypeInvCalccharactercalculatedCInvoiceTypeCalc; Creditor Invoice Type nl Invoice or Credit Note
tiPeriodYear2integerPeriod2.PeriodYearGL Calendar Year
tiPeriodPeriod2integerPeriod2.PeriodPeriodGL Period
tcCInvoiceMovTypeMovCalccharactercalculatedCInvoiceMovTypeMovCalc; calculated field with the movement-type
tcMovementJournalcharacterJournal1.JournalCodeA daybook code (maximum eight characters).
tcCreditorCodecharacterCreditor.CreditorCodeSupplier Code
tcJournalCodecharacterJournal2.JournalCodeA daybook code (maximum eight characters).
tiCInvoiceVoucherintegerCInvoice.CInvoiceVoucherVoucher. This field displays the numeric identifier assigned to the posting.
When the daybook of the journal entry is changed (after transfer), the voucher is cleared.
Voucher must be unique in one GL period.
When the user input is zero, the system automatically assign a value not used yet for this field.
tcCInvoiceCurrencyCodecharacterCurrency2.CurrencyCodeCurrency Code
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.
tcGLCodecharacterGL.GLCodeA code identifying the GL account.
tdPostingLineDebitTCdecimalPostingLine.PostingLineDebitTCTC Debit
tdPostingLineCreditTCdecimalPostingLine.PostingLineCreditTCTC Credit
tcPostingLineCurrencyCodecharacterCurrency1.CurrencyCodeCurrency Code
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).
tdCInvoiceBalanceTCdecimalCInvoice.CInvoiceBalanceTCBalance. This field displays the sum of the debit and credit amounts of all posting lines in transaction currency.
tlCInvoiceIsOpenlogicalCInvoice.CInvoiceIsOpenOpen.This field indicates if the invoice has been completely paid.
This field is updated automatically when complete payment is confirmed.
This field is read-only.
api annotation:PartialUpdate = yes - defaults to true
ttCInvoiceDatedateCInvoice.CInvoiceDateInvoice Date. This field indicates the invoice creation date.
The system uses this field with the credit terms to calculate due date and discount date.
api annotation:This field defaults from the system date.
tcCInvoiceDescriptioncharacterCInvoice.CInvoiceDescriptionDescription. A brief description of the invoice. The system generates a default description based on the Reference and Supplier Code.
tdCInvoiceOriginalDebitTCdecimalCInvoice.CInvoiceOriginalDebitTCTC AP Amount. This field displays the debit total invoice amount in the transaction currency.
If you modify this field, the system automatically recalculates the exchange rate to ensure that the TC Invoice Amount remains the same.
tdCInvoiceOriginalCreditTCdecimalCInvoice.CInvoiceOriginalCreditTCTC Invoice Amount CR. This field displays the credit total invoice amount in the transaction currency.
If you modify this field, the system automatically recalculates the exchange rate to ensure that the BC Invoice Amount remains the same.
tdCInvoiceHoldAmountTCdecimalCInvoice.CInvoiceHoldAmountTCTC Hold Amount. This field displays the amount of the invoice total that is not to be paid.
If this field is not blank, the hold amount is taken into account during payment processing.
Hold amounts must be:
For invoices or correction invoices: Less than the invoice total and greater than zero.
For credit notes or correction credit notes: Greater than the document total and less than zero.
The hold amount for a negative payment must always be set to zero.
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.
tiPeriod_IDintegerPosting.Period_IDLink to Period
tiJournal_IDintegerPosting.Journal_IDDaybook Code
tiCompany_IDintegerCInvoice.Company_IDLink to Company
tcCInvoiceMovementTypecharacterCInvoiceMovement.CInvoiceMovementTypeCInvoiceMovementType. "Initial" indicates that the movement represents the initial creation of the invoice, "movement" stands for all subsequent modifications of the invoice balance (payments, adjustments etc).
CInvoiceCustomcharactercalculatedcustom fields
CInvoiceMovementCustomcharactercalculatedcustom fields
PostingLineCustomcharactercalculatedcustom fields
Currency1Customcharactercalculatedcustom fields
GLCustomcharactercalculatedcustom fields
PostingCustomcharactercalculatedcustom fields
Journal1Customcharactercalculatedcustom fields
Period1Customcharactercalculatedcustom fields
CreditorCustomcharactercalculatedcustom fields
Currency2Customcharactercalculatedcustom fields
Journal2Customcharactercalculatedcustom fields
Period2Customcharactercalculatedcustom fields
ti_sequenceintegercalculatedprimary index
tc_rowidcharactercalculated = rowid(CInvoice),rowid(CInvoiceMovement),rowid(PostingLine),rowid(Currency1),rowid(GL),rowid(Posting),rowid(Journal1),rowid(Period1),rowid(Creditor),rowid(Currency2),rowid(Journal2),rowid(Period2)


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 = "BCInvoice".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "SelectCInvoiceMovementInv".
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/bcinvoice.selectcinvoicemovementinv.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.