project QadFinancials > class BDInvoice > API query DInvoiceForMovementInvForBill (optimised)

Description

Select query for debtor Invoice movements, filter on invoice year, period and journal possible, not on posting level


query filter (table tFilter)


tcBusinessFieldNametcDataTypetcOperator
iiCompanyIdi
tBill.BillDatet=,>=,>,<>,<=,<
tBill.BillDueDatet=,>=,>,<>,<=,<
tBill.BillNumberi=,>=,>,<>,<=,<
tBill.BillYeari=,>=,>,<>,<=,<
tCompany.CompanyCodec=,>=,>,<>,<=,<,begins,can-do,matches
tCurrency2.CurrencyCodec=,>=,>,<>,<=,<,begins,can-do,matches
tCurrency1.CurrencyCodec=,>=,>,<>,<=,<,begins,can-do,matches
tDebtor.DebtorCodec=,>=,>,<>,<=,<,begins,can-do,matches
tDInvoice.DInvoiceBalanceCCd=,>=,>,<>,<=,<
tDInvoice.DInvoiceBalanceLCd=,>=,>,<>,<=,<
tDInvoice.DInvoiceBalanceTCd=,>=,>,<>,<=,<
tDInvoice.DInvoiceBatchc=,>=,>,<>,<=,<,begins,can-do,matches
tDInvoice.DInvoiceDatet=,>=,>,<>,<=,<
tDInvoice.DInvoiceDescriptionc=,>=,>,<>,<=,<,begins,can-do,matches
tDInvoice.DInvoiceDueDatet=,>=,>,<>,<=,<
tDInvoice.DInvoiceIsOpenl=,<>
tDInvoiceMovement.DInvoiceMovementDiscountTCd=,>=,>,<>,<=,<
tDInvoiceMovement.DInvoiceMovementTypec=,>=,>,<>,<=,<,begins,can-do,matches
tDInvoiceMovement.DInvoiceMovementYearPeriodi=,>=,>,<>,<=,<
tDInvoice.DInvoiceOriginalCreditCCd=,>=,>,<>,<=,<
tDInvoice.DInvoiceOriginalCreditLCd=,>=,>,<>,<=,<
tDInvoice.DInvoiceOriginalCreditTCd=,>=,>,<>,<=,<
tDInvoice.DInvoiceOriginalDebitCCd=,>=,>,<>,<=,<
tDInvoice.DInvoiceOriginalDebitLCd=,>=,>,<>,<=,<
tDInvoice.DInvoiceOriginalDebitTCd=,>=,>,<>,<=,<
tDInvoice.DInvoicePostingYearPeriodi=,>=,>,<>,<=,<
tDInvoice.DInvoiceTypec=,>=,>,<>,<=,<,begins,can-do,matches
tDInvoice.DInvoiceVoucheri=,>=,>,<>,<=,<
tGL.GLCodec=,>=,>,<>,<=,<,begins,can-do,matches
tJournal2.JournalCodec=,>=,>,<>,<=,<,begins,can-do,matches
tJournal1.JournalCodec=,>=,>,<>,<=,<,begins,can-do,matches
tDInvoice.LastModifiedDatet=,>=,>,<>,<=,<
tDInvoice.LastModifiedTimei=,>=,>,<>,<=,<
tDInvoice.LastModifiedUserc=,>=,>,<>,<=,<,begins,can-do,matches
tPeriod1.PeriodPeriodi=,>=,>,<>,<=,<
tPeriod2.PeriodPeriodi=,>=,>,<>,<=,<
tPeriod2.PeriodYeari=,>=,>,<>,<=,<
tPeriod1.PeriodYeari=,>=,>,<>,<=,<
tPeriod1.PeriodYearPeriodi=,>=,>,<>,<=,<
tPeriod2.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 DInvoice where
DInvoice.Company_Id = iiCompanyId AND

      first Bill (conditional-join) where
Bill.Company_Id = iiCompanyId AND
Bill.Bill_ID = DInvoice.Bill_ID AND

          first Company (conditional-join) where
Company.Company_Id = iiCompanyId AND
Company.Company_ID = Bill.Company_ID AND

      first Currency1 (inner-join) where
Currency1.Currency_ID = DInvoice.DInvoiceCurrency_ID AND

      first Debtor (inner-join) where
Debtor.SharedSet_Id = vi_DEBTOR_sharedset(iiCompanyId) AND
Debtor.Debtor_ID = DInvoice.Debtor_ID AND

      each DInvoiceMovement (inner-join) where
DInvoiceMovement.Company_Id = iiCompanyId AND
DInvoiceMovement.DInvoice_ID = DInvoice.DInvoice_ID AND

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

              first Currency2 (inner-join) where
Currency2.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.Period_ID = Posting.Period_ID AND
Period1.Company_ID > 0

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

      first Period2 (inner-join) where
Period2.Period_ID = DInvoice.Period_ID AND
Period2.Company_Id > 0


query resultset tqDInvoiceForMovementInvForBill


field namedata typedb fielddescription
tdAmountCCCalcdecimalcalculated
tdAmountLCCalcdecimalcalculated
tdAmountTCCalcdecimalcalculated
ttBillDatedateBill.BillDateBill Date
ttBillDueDatedateBill.BillDueDateBill Due Date
tiBillNumberintegerBill.BillNumberBill Number
tiBillYearintegerBill.BillYearBill Year
tcCompanyCodecharacterCompany.CompanyCodeEntity Code
tiDInvoice_IDintegerDInvoice.DInvoice_IDRecord ID
tdDInvoiceBalanceCCdecimalDInvoice.DInvoiceBalanceCCSC 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.
tdDInvoiceBalanceLCdecimalDInvoice.DInvoiceBalanceLCBC 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.
ttDInvoiceDueDatedateDInvoice.DInvoiceDueDateDue Date. This field displays the date when payment is due, calculated by the system based on the credit terms and the invoice date. User can modify the due date without affecting the credit terms.
If the credit terms have a base date specified, this is used in the due date calculations rather than the invoice creation date.
tcDInvoiceKeyIDcharactercalculated
tdDInvoiceMovementDiscountTCdecimalDInvoiceMovement.DInvoiceMovementDiscountTCCInvoiceMovementDiscountTC. The amount of payment discount in TC.
tiDInvoiceMovementYearPeriodintegerDInvoiceMovement.DInvoiceMovementYearPeriodYear/GL Period. This field indicates the accounting year and period for the invoice's movement.
tcDInvoiceMovTypeInvCalccharactercalculated
tcDInvoiceMovTypeMovCalccharactercalculated
tdDInvoiceOriginalCreditCCdecimalDInvoice.DInvoiceOriginalCreditCCSC 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.
tdDInvoiceOriginalCreditLCdecimalDInvoice.DInvoiceOriginalCreditLCBC 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.
tdDInvoiceOriginalDebitCCdecimalDInvoice.DInvoiceOriginalDebitCCSC 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.
tdDInvoiceOriginalDebitLCdecimalDInvoice.DInvoiceOriginalDebitLCBC 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.
tiDInvoicePostingYearPeriodintegerDInvoice.DInvoicePostingYearPeriodYear/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.
ttLastModifiedDatedateDInvoice.LastModifiedDateLast Modified Date
tiLastModifiedTimeintegerDInvoice.LastModifiedTimeLast Modified Time
tcLastModifiedUsercharacterDInvoice.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
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.
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.
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.
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
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
tcDInvoiceMovementTypecharacterDInvoiceMovement.DInvoiceMovementTypeCInvoiceMovementType. "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).
tiPostingLine_IDintegerDInvoiceMovement.PostingLine_IDLink to PostingLine
tcDInvoiceBatchcharacterDInvoice.DInvoiceBatchBatch Number. This field is used to identify a group of customer invoices created at one time using Evaluated Receipts Settlement (ERS) functions.
tiCompany_IDintegerDInvoice.Company_IDLink to Company
tiPeriodYearintegerPeriod1.PeriodYearGL Calendar Year
tcPostingJournalCodecharacterJournal1.JournalCodeA daybook code (maximum eight characters).
tiPeriodYearPeriodintegerPeriod1.PeriodYearPeriodGL Calendar Year/GL Period
tiPeriodYear2integerPeriod2.PeriodYearGL Calendar Year
tiPeriodPeriod2integerPeriod2.PeriodPeriodGL Period
tcDebtorCodecharacterDebtor.DebtorCodeA code (maximum eight characters) that identifies a customer. If the code you specify matches an existing supplier code, a warning message displays. You can choose to ignore the warning, and create the record. However, when a supplier and customer share the same code, they must reference the same business relation.
api annotation:If you leave the Customer Code field blank, the system automatically generates a number for the record based on the sequence defined in Customer Autonumber Create.
tiPeriodYearPeriod2integerPeriod2.PeriodYearPeriodGL Calendar Year/GL Period
tcInvJournalcharacterJournal2.JournalCodeA daybook code (maximum eight characters).
tiDInvoiceVoucherintegerDInvoice.DInvoiceVoucherVoucher.This field displays the numeric identifier assigned to the posting.
When the daybook of the journal entry is charged(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.
tcDInvoiceCurrencyCodecharacterCurrency1.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.
tdPostingLineCreditTCdecimalPostingLine.PostingLineCreditTCTC Credit
tdPostingLineDebitTCdecimalPostingLine.PostingLineDebitTCTC Debit
tcPostingLineCurrencyCodecharacterCurrency2.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).
tdDInvoiceBalanceTCdecimalDInvoice.DInvoiceBalanceTCBalance. This field displays the sum of the debit and credit amounts of all posting lines in transaction currency.
tlDInvoiceIsOpenlogicalDInvoice.DInvoiceIsOpenOpen.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
ttDInvoiceDatedateDInvoice.DInvoiceDateInvoice Date. This field indicates the invoice creation date.This field is normallly prior to the posting date and within the same accounting period as the posting date. The date must be within the upper and lower date limits of an open GL period.
The system uses the invoice date with the credit terms to calculate due date and discount date.
api annotation:This field defaults to the DInvoicePostingDate.
tcDInvoiceDescriptioncharacterDInvoice.DInvoiceDescriptionDescription. A brief description of the invoice. This field is mandatory.
tdDInvoiceOriginalCreditTCdecimalDInvoice.DInvoiceOriginalCreditTCTC 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.
tdDInvoiceOriginalDebitTCdecimalDInvoice.DInvoiceOriginalDebitTCTC 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.
tcDInvoiceTypecharacterDInvoice.DInvoiceTypeInvoice Type. This field displays the invoice type.
Invoice Correction and Credit Note Correction display as choices only when the appropriate daybook types have already been defined.
api annotation:PartialUpdate = yes - defaults to Invoice
tiJournal_IDintegerPosting.Journal_IDDaybook Code
tiPeriod_IDintegerPosting.Period_IDLink to Period
DInvoiceCustomcharactercalculatedcustom fields
Currency1Customcharactercalculatedcustom fields
DebtorCustomcharactercalculatedcustom fields
DInvoiceMovementCustomcharactercalculatedcustom fields
PostingLineCustomcharactercalculatedcustom fields
Currency2Customcharactercalculatedcustom fields
GLCustomcharactercalculatedcustom fields
PostingCustomcharactercalculatedcustom fields
Journal1Customcharactercalculatedcustom fields
Period1Customcharactercalculatedcustom fields
Journal2Customcharactercalculatedcustom fields
Period2Customcharactercalculatedcustom fields
BillCustomcharactercalculatedcustom fields
CompanyCustomcharactercalculatedcustom fields
ti_sequenceintegercalculatedprimary index
tc_rowidcharactercalculated = rowid(DInvoice),rowid(Bill),rowid(Company),rowid(Currency1),rowid(Debtor),rowid(DInvoiceMovement),rowid(PostingLine),rowid(Currency2),rowid(GL),rowid(Posting),rowid(Journal1),rowid(Period1),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 = "BDInvoice".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "DInvoiceForMovementInvForBill".
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/bdinvoice.dinvoiceformovementinvforbill.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.