Parameters
| t_sExpNoteIds | input | temp-table | |
| tAdvances | output | temp-table | |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bexpensenote.p)
empty temp-table tAdvances.
<Q-2 run ExpNoteCInvoiceByExpNote (Start) in BExpenseNote >
<Q-5 run ExpNoteCInvoiceByCInvoice (Start) in BExpenseNote >
for each t_sExpNoteIds:
<Q-1 run ExpNoteCInvoiceByExpNote (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input t_sExpNoteIds.tiExpNote_ID, (ExpNote_ID)
output dataset tqExpNoteCInvoiceByExpNote) in BExpenseNote >
for each tqExpNoteCInvoiceByExpNote:
create tAdvances.
assign tAdvances.tiAdvanceYear = tqExpNoteCInvoiceByExpNote.tiPeriodYear
tAdvances.tcAdvanceJournal = tqExpNoteCInvoiceByExpNote.tcJournalCode
tAdvances.tiAdvanceVoucher = tqExpNoteCInvoiceByExpNote.tiCInvoiceVoucher
tAdvances.tcAdvanceCurrencyCode = tqExpNoteCInvoiceByExpNote.tcCurrencyCode
tAdvances.ttAdvanceDate = tqExpNoteCInvoiceByExpNote.ttCInvoiceDate
tAdvances.tcAdvanceReference = tqExpNoteCInvoiceByExpNote.tcCInvoiceReference
tAdvances.tcAdvanceDescription = tqExpNoteCInvoiceByExpNote.tcCInvoiceDescription
tAdvances.tdOpenBalanceTC = tqExpNoteCInvoiceByExpNote.tdCInvoiceBalanceDebitTC - tqExpNoteCInvoiceByExpNote.tdCInvoiceBalanceCreditTC
tAdvances.tdOpenBalanceLC = tqExpNoteCInvoiceByExpNote.tdCInvoiceBalanceDebitLC - tqExpNoteCInvoiceByExpNote.tdCInvoiceBalanceCreditLC
tAdvances.tdAdvanceExchangeRateTCLC = tqExpNoteCInvoiceByExpNote.tdCInvoiceExchangeRate
tAdvances.tdAdvanceExchangeRateScaleTCLC = tqExpNoteCInvoiceByExpNote.tdCinvoiceRateScale
tAdvances.tdToReturnTC = tqExpNoteCInvoiceByExpNote.tdExpNoteCInvoiceToReturnTC.
assign tAdvances.tiExpNote_ID = tqExpNoteCInvoiceByExpNote.tiExpNote_ID
tAdvances.tdOnExpNoteTC = tqExpNoteCInvoiceByExpNote.tdExpNoteCInvoiceDeductTC
tAdvances.tlAdvanceReturnRest = tqExpNoteCInvoiceByExpNote.tlExpNoteCInvoiceIsReturned.
/* Subtract other confirmed expense notes */
<Q-4 run ExpNoteCInvoiceByCInvoice (all) (Read) (NoCache)
(input tqExpNoteCInvoiceByExpNote.tiCInvoice_ID, (CInvoice_ID)
input {&EXPENSENOTESTATUS-CONFIRMED}, (ExpNoteCInvoiceStatusCode)
input viCompanyId, (CompanyId)
output dataset tqExpNoteCInvoiceByCInvoice) in BExpenseNote >
for each tqExpNoteCInvoiceByCInvoice where
tqExpNoteCInvoiceByCInvoice.tiExpNote_ID <> tAdvances.tiExpNote_ID
break by tqExpNoteCInvoiceByCInvoice.ttExpNoteConfirmationDate
by tqExpNoteCInvoiceByCInvoice.tiExpNoteYear
by tqExpNoteCInvoiceByCInvoice.tiExpNoteNumber:
if ((tqExpNoteCInvoiceByExpNote.tcExpNoteStatusCode = {&EXPENSENOTESTATUS-CONFIRMED} or
tqExpNoteCInvoiceByExpNote.tcExpNoteStatusCode = {&EXPENSENOTESTATUS-REGISTERED}) and
tqExpNoteCInvoiceByCInvoice.ttExpNoteConfirmationDate <= tqExpNoteCInvoiceByExpNote.ttExpNoteConfirmationDate and
((tqExpNoteCInvoiceByCInvoice.tiExpNoteYear = tqExpNoteCInvoiceByExpNote.tiExpNoteYear and
tqExpNoteCInvoiceByCInvoice.tiExpNoteNumber < tqExpNoteCInvoiceByExpNote.tiExpNoteNumber) or
(tqExpNoteCInvoiceByCInvoice.tiExpNoteYear < tqExpNoteCInvoiceByExpNote.tiExpNoteYear))) or
tqExpNoteCInvoiceByExpNote.tcExpNoteStatusCode = {&EXPENSENOTESTATUS-OPEN}
then do:
assign tAdvances.tdOpenBalanceTC = tAdvances.tdOpenBalanceTC
- tqExpNoteCInvoiceByCInvoice.tdExpNoteCInvoiceDeductTC
- tqExpNoteCInvoiceByCInvoice.tdExpNoteCInvoiceToReturnTC.
if tqExpNoteCInvoiceByCInvoice.tdExpNoteCInvoiceDeductTC <> 0 and
tqExpNoteCInvoiceByCInvoice.tdExpNoteCInvoiceDeductTC <> ?
then assign tAdvances.tdOpenBalanceLC = tAdvances.tdOpenBalanceLC - tqExpNoteCInvoiceByCInvoice.tdExpNoteCInvoiceDeductLC - /*round(tqExpNoteCInvoiceByCInvoice.tdExpNoteCInvoiceToReturnTC * tqExpNoteCInvoiceByCInvoice.tdExpNoteCInvoiceDeductLC / tqExpNoteCInvoiceByCInvoice.tdExpNoteCInvoiceDeductTC, viCompanyLCDec).*/
<M-7 RoundAmount
(input tqExpNoteCInvoiceByCInvoice.tdExpNoteCInvoiceToReturnTC * tqExpNoteCInvoiceByCInvoice.tdExpNoteCInvoiceDeductLC / tqExpNoteCInvoiceByCInvoice.tdExpNoteCInvoiceDeductTC (idUnroundedAmount),
input viCompanyLCid (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in business>.
end.
end.
assign tAdvances.tdUnexplainedTC = (if tAdvances.tlAdvanceReturnRest
then tAdvances.tdOpenBalanceTC - tAdvances.tdToReturnTC - tAdvances.tdOnExpNoteTC
else 0).
end.
end.
<Q-6 run ExpNoteCInvoiceByCInvoice (Stop) in BExpenseNote >
<Q-3 run ExpNoteCInvoiceByExpNote (Stop) in BExpenseNote >
Sample code: how to call this method 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 = "BExpenseNote".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "APIGetAdvancesInfo".
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/bexpensenote.apigetadvancesinfo.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tExpNoteIds").
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.