project QadFinancials > class BDInvoice > method DefaultValuesLinkedInvoice
Parameters
icDInvoiceRowId | input | character | Row ID of customer invoice |
iiLinkedDInvoicePostingYear | input | integer | |
icLinkedJournalCode | input | character | |
iiLinkedDInvoiceVoucher | input | integer | |
iiDInvoicePostingYear | input | integer | |
icDAJournalCode | input | character | |
iiDAVoucher | input | integer | |
ocVatCurrencyCode | output | character | |
odDInvoiceVatExchangeRate | output | decimal | |
odDInvoiceVatRateScale | output | decimal | |
ocTransactionStartCountryCode | output | character | |
ocTransactionEndCountryCode | output | character | |
ocDAJournalCode | output | character | |
oiDAVoucher | output | integer | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bdinvoice.p)
if iiLinkedDInvoicePostingYear = ?
then assign iiLinkedDInvoicePostingYear = 0.
if icLinkedJournalCode = ?
then assign icLinkedJournalCode = "":U.
if iiLinkedDInvoiceVoucher = ?
then assign iiLinkedDInvoiceVoucher = 0.
if iiLinkedDInvoicePostingYear <> 0 and
icLinkedJournalCode <> "":U and
iiLinkedDInvoiceVoucher <> 0
then do:
<Q-1 run DInvoiceByLinkedInvoice (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input iiLinkedDInvoicePostingYear, (LinkedDInvoicePostingYear)
input iiLinkedDInvoiceVoucher, (LinkedDInvoiceVoucher)
input icLinkedJournalCode, (LinkedJournalCode)
output dataset tqDInvoiceByLinkedInvoice) in BDInvoice >
find first tqDInvoiceByLinkedInvoice where
tqDInvoiceByLinkedInvoice.tiCompany_ID = viCompanyId and
tqDInvoiceByLinkedInvoice.tiDInvoicePostingYear = iiLinkedDInvoicePostingYear and
tqDInvoiceByLinkedInvoice.tcJournalCode = icLinkedJournalCode and
tqDInvoiceByLinkedInvoice.tiDInvoiceVoucher = iiLinkedDInvoiceVoucher
no-error.
end. /* if iiLinkedDInvoicePostingYear <> 0 */
if iiLinkedDInvoicePostingYear = 0 or
icLinkedJournalCode = "":U or
iiLinkedDInvoiceVoucher = 0 or
not available tqDInvoiceByLinkedInvoice
then do:
if iiDInvoicePostingYear <> 0 and
iiDInvoicePostingYear <> ? and
icDAJournalCode <> "":U and
icDAJournalCode <> ? and
iiDAVoucher <> 0 and
iiDAVoucher <> ?
then do:
/* Determine the type of daybook to be used. */
<Q-11 run JournalBeginsForJEDefault (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input icDAJournalCode, (JournalCode)
input {&JOURNALCONTROL-LOGISTIC}, (JournalControl)
input '':U, (JournalTypeCode)
output dataset tqJournalBeginsForJEDefault) in BJournal >
find first tqJournalBeginsForJEDefault where
tqJournalBeginsForJEDefault.tcJournalCode = icDAJournalCode and
tqJournalBeginsForJEDefault.tcJournalControl = {&JOURNALCONTROL-LOGISTIC}
no-lock no-error.
if available tqJournalBeginsForJEDefault then
assign vlJournalIsOperational = TRUE.
else assign vlJournalIsOperational = FALSE.
/* Release the voucher number. */
assign vhFcComponent= ?.
if vlCCNIsConsecutNr = FALSE or
vlJournalIsOperational = TRUE
then do:
<M-2 run ReleaseNumber
(input viCompanyId (iiCompanyId),
input iiDInvoicePostingYear (iiNumbrYear),
input icDAJournalCode (icNumbrType),
input iiDAVoucher (iiNumbr),
input viFcCurrentInstanceId (iiInstanceId),
input vcFcComponentName (icClassName),
output viFcReturnSuper (oiReturnStatus)) in BNumber>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end. /* if vlCCNIsConsecutNr = FALSE */
assign ocDAJournalCode = "":U
oiDAVoucher = 0.
end. /* if iiDInvoicePostingYear <> 0 */
return.
end. /* if iiLinkedDInvoicePostingYear = 0 */
assign ocTransactionEndCountryCode = tqDInvoiceByLinkedInvoice.tcTransactionEndCountryCode
ocTransactionStartCountryCode = tqDInvoiceByLinkedInvoice.tcTransactionStartCountryCode
ocVatCurrencyCode = tqDInvoiceByLinkedInvoice.tcVatCurrencyCode
odDInvoiceVatExchangeRate = tqDInvoiceByLinkedInvoice.tdDInvoiceVatExchangeRate
odDInvoiceVatRateScale = tqDInvoiceByLinkedInvoice.tdDInvoiceVatRateScale.
if iiDInvoicePostingYear <> 0 and
iiDInvoicePostingYear <> ?
then do:
if icDAJournalCode = "":U or
icDAJournalCode = ?
then do:
<M-4 run GetDAJournalCode
(output ocDAJournalCode (ocDAJournalCode),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end. /* if icDAJournalCode = "":U */
else assign ocDAJournalCode = icDAJournalCode.
if ocDAJournalCode = "":U or
ocDAJournalCode = ? or
ocDAJournalCode = icDAJournalCode
then assign oiDAVoucher = iiDAVoucher.
else do:
<M-3 run DefaultValuesDAJournal
(input icDInvoiceRowId (icDInvoiceRowId),
input-output ocDAJournalCode (bcDAJournalCode),
input iiDInvoicePostingYear (iiDInvoicePostingYear),
input iiDInvoicePostingYear (iiOldDinvoicePostingYear),
input icDAJournalCode (icOldDAJournalCode),
input iiDAVoucher (iiOldDAVoucher),
output oiDAVoucher (oiDAVoucher),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end. /* if ocDAJournalCode = "":U */
end. /* if iiDInvoicePostingYear <> 0 */
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 = "BDInvoice".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "DefaultValuesLinkedInvoice".
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.defaultvalueslinkedinvoice.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icDInvoiceRowId = <parameter value>
vhParameter::iiLinkedDInvoicePostingYear = <parameter value>
vhParameter::icLinkedJournalCode = <parameter value>
vhParameter::iiLinkedDInvoiceVoucher = <parameter value>
vhParameter::iiDInvoicePostingYear = <parameter value>
vhParameter::icDAJournalCode = <parameter value>
vhParameter::iiDAVoucher = <parameter value>.
/* 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.