project QadFinancials > class BCInvoice > method CalcAllSelectCInvoiceMovementInv

query calculated fields procedure

Description

Assign a value to query calculated fields


Parameters


iiCompanyIdinputintegerCompany id
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
query SelectCInvoiceMovementInv


program code (program1/bcinvoice.p)

assign vcInvoiceTypes  = {&INVOICETYPES}
       vcMovementTypes = {&MOVEMENTTYPES}.

create query vhQuery in widget-pool "non-persistent".
vhQuery:set-buffers(ih_Buffer).
vhQuery:query-prepare("for each ":U + ih_Buffer:table).
vhQuery:query-open().
vhQuery:get-first().

do while not vhQuery:query-off-end:

    /* CalcCInvoiceMovTypeInvCalc */
    /* work with a do because the translated and untranslated values can be the same */
    assign {&tcCInvoiceMovTypeInvCalc} = "?":U.
    do viCounter = num-entries(vcInvoiceTypes,chr(2)) to 1 by -2 :
        if entry(viCounter,vcInvoiceTypes,chr(2)) = {&tcCInvoiceType}
        then do :
            assign {&tcCInvoiceMovTypeInvCalc} = entry(viCounter - 1,vcInvoiceTypes,chr(2)) no-error.
            leave.
        end. /* if entry */
    end.    

    /* CalcCInvoiceMovTypeMovCalc */
    assign {&tcCInvoiceMovTypeMovCalc} = "?":U.
    do viCounter = num-entries(vcMovementTypes,chr(2)) to 1 by -2 : 
        if entry(viCounter,vcMovementTypes,chr(2)) = {&tcCInvoiceMovementType}
        then do :
            assign {&tcCInvoiceMovTypeMovCalc} = entry(viCounter - 1,vcMovementTypes,chr(2)) no-error.
            leave.
        end. /* if entry */
    end.

    /* assign the Net Amounts */
    assign {&tdAmountTCCalc} = {&tdPostingLineDebitTC} - {&tdPostingLineCreditTC}
           {&tdAmountLCCalc} = {&tdPostingLineDebitLC} - {&tdPostingLineCreditLC}
           {&tdAmountCCCalc} = {&tdPostingLineDebitCC} - {&tdPostingLineCreditCC}.

    /* assign the key */
    assign {&tcCInvoiceKeyCalc} = string ({&tiCInvoicePostingYearPeriod}) + '/' +
                                  {&tcJournalCode} + '/' +
                                  string ({&tiCInvoiceVoucher},'999999999').

    vhQuery:get-next().
end.

vhQuery:query-close().
delete object vhQuery.