project QadFinancials > class BAPMatching > method GetPendingVouchersLogCharges
Description
Submethod of GetPendingVouchers
Parameters
icAPMatchingTcRowid | input | character | icAPMatchingTcRowid: Rowid (converted to character) of the matching. This corresponds with field tAPMatching.tc_rowid. |
icCreditorCode | input | character | |
ilIncludeEmptyCreditors | input | logical | |
icCurrencyCode | input | character | |
idCInvoiceTCLCRate | input | decimal | |
idCInvoiceTCLCScale | input | decimal | |
idCInvoiceTCCCRate | input | decimal | |
idCInvoiceTCCCScale | input | decimal | |
idCInvoiceTotalAmountTC | input | decimal | |
idCInvoiceARRecTaxTC | input | decimal | |
idCInvoiceARNRecTaxTC | input | decimal | |
itTransactionDateFrom | input | date | |
itTransactionDateTill | input | date | |
itTransactionDate | input | date | |
itTransactionDetailDateFrom | input | date | |
itTransactionDetailDateTill | input | date | |
itTransactionDetailDate | input | date | |
icExternalReferenceFrom | input | character | |
icExternalReferenceTo | input | character | |
icExternalReference | input | character | |
icInternalReferenceFrom | input | character | |
icInternalReferenceTo | input | character | |
icInternalReference | input | character | |
icShipToFrom | input | character | |
icShipToTo | input | character | |
icShipTo | input | character | |
icItemNumberFrom | input | character | |
icItemNumberTo | input | character | |
icItemNumber | input | character | |
icLogisticChargeFrom | input | character | |
icLogisticChargeTo | input | character | |
icLogisticCharge | input | character | |
icShipFromFrom | input | character | |
icShipFromTo | input | character | |
icShipFrom | input | character | |
ilAutoSelect | input | logical | |
icOrderFrom | input | character | |
icOrderTo | input | character | |
icOrder | input | character | |
ilCallGTM | input | logical | ilCallGTM: Set to true in case you want this method to call GTM to recalculate the taxes. If false, then the taxes will just be taken from the pending-voucher |
iiApiPvoId | input | integer | |
iiApiPvodLineId | input | integer | Pending voucher detail ID |
idApiMatchAmtTC | input | decimal | Match amount of the logistic charge. This parameter is valid only , when PvoID and PvoLineID paramters are supplied. It means, this procedure processes only one pending voucher record. |
ilApiIsPvodFinished | input | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program7/bapmatching.p)
/* ====================== */
/* Default return-status */
/* ====================== */
assign oiReturnStatus = -98.
<Q-6 assign vlFcQueryRecordsAvailable = CheckVertexIsEnabled (NoCache)
(input vcDomainCode, (DomainCode)
input {&VERTEX-MODULE}, (VertexModule)
input {&VERTEX-FIELD}, (VertexField)
input TRUE, (VertexLogical)) in BMfgControlWorkTable>
assign vlIsVertexEnabled = vlFcQueryRecordsAvailable.
/* ===================================================================================================================== */
/* GetPendingVouchersNoLogChargesQuery: submethod of GetPendingVouchersNoLogCharges that holds the query-call to query */
/* BMfgPendingVoucher:PendingVoucherForMatchingNoLC(). This metthod can be used for customisations and thus provides */
/* customers to take actions to extend the content of tqPendingVoucherForMatchingNoLC */
/* After calling this submethod, temp-table tqPendingVoucherForMatchingLC will be filled */
/* Note: the result-set of the query can contain multiple records for a single pvod_det as taxes are joined in the query */
/* ===================================================================================================================== */
<M-11 run GetPendingVouchersLogChargesQuery
(input icAPMatchingTcRowid (icAPMatchingTcRowid),
input icCreditorCode (icCreditorCode),
input ilIncludeEmptyCreditors (ilIncludeEmptyCreditors),
input icCurrencyCode (icCurrencyCode),
input idCInvoiceTCLCRate (idCInvoiceTCLCRate),
input idCInvoiceTCLCScale (idCInvoiceTCLCScale),
input idCInvoiceTCCCRate (idCInvoiceTCCCRate),
input idCInvoiceTCCCScale (idCInvoiceTCCCScale),
input idCInvoiceTotalAmountTC (idCInvoiceTotalAmountTC),
input idCInvoiceARRecTaxTC (idCInvoiceARRecTaxTC),
input idCInvoiceARNRecTaxTC (idCInvoiceARNRecTaxTC),
input itTransactionDateFrom (itTransactionDateFrom),
input itTransactionDateTill (itTransactionDateTill),
input itTransactionDate (itTransactionDate),
input itTransactionDetailDateFrom (itTransactionDetailDateFrom),
input itTransactionDetailDateTill (itTransactionDetailDateTill),
input itTransactionDetailDate (itTransactionDetailDate),
input icExternalReferenceFrom (icExternalReferenceFrom),
input icExternalReferenceTo (icExternalReferenceTo),
input icExternalReference (icExternalReference),
input icInternalReferenceFrom (icInternalReferenceFrom),
input icInternalReferenceTo (icInternalReferenceTo),
input icInternalReference (icInternalReference),
input icShipToFrom (icShipToFrom),
input icShipToTo (icShipToTo),
input icShipTo (icShipTo),
input icItemNumberFrom (icItemNumberFrom),
input icItemNumberTo (icItemNumberTo),
input icItemNumber (icItemNumber),
input icLogisticChargeFrom (icLogisticChargeFrom),
input icLogisticChargeTo (icLogisticChargeTo),
input icLogisticCharge (icLogisticCharge),
input icShipFromFrom (icShipFromFrom),
input icShipFromTo (icShipFromTo),
input icShipFrom (icShipFrom),
input ilAutoSelect (ilAutoSelect),
input icOrderFrom (icOrderFrom),
input icOrderTo (icOrderTo),
input icOrder (icOrder),
input ilCallGTM (ilCallGTM),
input iiApiPvoId (iiApiPvoId),
input iiApiPvodLineId (iiApiPvodLineId),
input idApiMatchAmtTC (idApiMatchAmtTC),
input ilApiIsPvodFinished (ilApiIsPvodFinished),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then Return.
/* =============================== */
/* Go through the query result set */
/* =============================== */
for each tqPendingVoucherForMatchingLC
break by tqPendingVoucherForMatchingLC.tcpvod_domain
by tqPendingVoucherForMatchingLC.tipvod_id
by tqPendingVoucherForMatchingLC.tipvod_id_line :
/* =============================================== */
/* Skip PVO's without supplier (unless asked for) */
/* Skip PVO's on companies you dont have access to */
/* =============================================== */
if tqPendingVoucherForMatchingLC.tcpvo_order_type = "":U or
tqPendingVoucherForMatchingLC.tcpvo_order_type = ?
then assign vcPvodCompCode = if tqPendingVoucherForMatchingLC.tcpvod_order_type = {&PENDINGVOUCHER-ORDERTYPE-PO}
then tqPendingVoucherForMatchingLC.tcShipToCompanyCode
else tqPendingVoucherForMatchingLC.tcShipFromCompanyCode
viPvodCompID = if tqPendingVoucherForMatchingLC.tcpvod_order_type = {&PENDINGVOUCHER-ORDERTYPE-PO}
then tqPendingVoucherForMatchingLC.tiShipToCompanyID
else tqPendingVoucherForMatchingLC.tiShipFromCompanyID.
else assign vcPvodCompCode = if tqPendingVoucherForMatchingLC.tcpvo_order_type = {&PENDINGVOUCHER-ORDERTYPE-PO}
then tqPendingVoucherForMatchingLC.tcShipToCompanyCode
else tqPendingVoucherForMatchingLC.tcShipFromCompanyCode
viPvodCompID = if tqPendingVoucherForMatchingLC.tcpvo_order_type = {&PENDINGVOUCHER-ORDERTYPE-PO}
then tqPendingVoucherForMatchingLC.tiShipToCompanyID
else tqPendingVoucherForMatchingLC.tiShipFromCompanyID.
if vcPvodCompCode = ? or
vcPvodCompCode = "":U or
not can-do(vcListAccessibleCompanyCodes,vcPvodCompCode)
then do:
if iiApiPvoId <> ? and iiApiPvoId <> 0
then do:
assign oiReturnStatus = -3
vcMsgAPMatching = trim(substitute(#T-70'The system cannot create a matching line because the pending invoice (&1/&2/&3) references an entity (&4) that you do not have access to or the entity is blank.':255(609629664)T-70#,tqPendingVoucherForMatchingLC.tcpvo_domain,string(tqPendingVoucherForMatchingLC.tipvo_id),string(tqPendingVoucherForMatchingLC.tipvod_id_line),(if tqPendingVoucherForMatchingLC.tcShipToCompanyCode <> ? and tqPendingVoucherForMatchingLC.tcShipToCompanyCode <> "":U then tqPendingVoucherForMatchingLC.tcShipToCompanyCode else tqPendingVoucherForMatchingLC.tcShipFromCompanyCode ))).
<M-88 run SetMessage
(input vcMsgAPMatching (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-49086':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
end.
next.
end.
if tqPendingVoucherForMatchingLC.tcpvo_supplier = "":U and
ilIncludeEmptyCreditors = false
then next.
/* =========================================================================================== */
/* Create output record (for every first tqPendingVoucher-record for a pvod_det) */
/* =========================================================================================== */
if first-of (tqPendingVoucherForMatchingLC.tipvod_id)
then do :
/* ==================== */
/* Create output record */
/* ==================== */
create tPendingVoucherHeader.
assign tPendingVoucherHeader.tcPvodLgCharge = tqPendingVoucherForMatchingLC.tcpvo_lc_charge
tPendingVoucherHeader.tlIsSelected = (ilAutoSelect = true)
tPendingVoucherHeader.tcCurrencyCode = tqPendingVoucherForMatchingLC.tcpvo_curr
tPendingVoucherHeader.tlSplittProRata = true
tPendingVoucherHeader.tlCloseAccruals = tqPendingVoucherForMatchingLC.tllc_close_accruals
tPendingVoucherHeader.tcPvodOrder = tqPendingVoucherForMatchingLC.tcpvo_order
tPendingVoucherHeader.tcPvodSupplier = tqPendingVoucherForMatchingLC.tcpvo_supplier
tPendingVoucherHeader.tcPvodIntRef = substring(tqPendingVoucherForMatchingLC.tcpvo_internal_ref, 1, 50, "CHARACTER")
tPendingVoucherHeader.tcPvodExtRef = substring(tqPendingVoucherForMatchingLC.tcpvo_external_ref, 1, 50, "CHARACTER")
tPendingVoucherHeader.ttPvodTransDate = tqPendingVoucherForMatchingLC.ttpvo_trans_date
tPendingVoucherHeader.ttPvodEffDate = tqPendingVoucherForMatchingLC.ttpvo_eff_date
tPendingVoucherHeader.tcPvodSite = if (tqPendingVoucherForMatchingLC.tcpvo_order_type = {&PENDINGVOUCHER-ORDERTYPE-SO} OR
tqPendingVoucherForMatchingLC.tcpvo_order_type = {&PENDINGVOUCHER-ORDERTYPE-DO})
then tqPendingVoucherForMatchingLC.tcpvo_shipfrom
else tqPendingVoucherForMatchingLC.tcpvo_shipto
tPendingVoucherHeader.tcPvodCompCode = vcPvodCompCode
tPendingVoucherHeader.tcPvoDomain = tqPendingVoucherForMatchingLC.tcpvo_domain
tPendingVoucherHeader.tiPvoID = tqPendingVoucherForMatchingLC.tipvo_id
tPendingVoucherHeader.tlIsPvodFinished = (tPendingVoucherHeader.tlIsSelected = true AND tqPendingVoucherForMatchingLC.tllc_close_accruals).
/* ========================================================================================================== */
/* Update qty and price details of the output record (for every first tqPendingVoucher-record for a pvod_det) */
/* ========================================================================================================== */
if iiApiPvoId = ? or iiApiPvoId = 0
then /* Quering of the data from the user interface, system propose the whole amount to be matched */
assign tPendingVoucherHeader.tdPvodUnitPrice = tqPendingVoucherForMatchingLC.tdpvo_accrued_amt - tqPendingVoucherForMatchingLC.tdpvo_vouchered_amt
tPendingVoucherHeader.tdMatchUnitPrice = if tPendingVoucherHeader.tlIsSelected then tPendingVoucherHeader.tdPvodUnitPrice else 0
tPendingVoucherHeader.tdAccruedAmountTC = tqPendingVoucherForMatchingLC.tdpvo_accrued_amt
tPendingVoucherHeader.tdInvoicedAmountTC = tqPendingVoucherForMatchingLC.tdpvo_vouchered_amt
tPendingVoucherHeader.tdVarianceAmountTC = tPendingVoucherHeader.tdAccruedAmount - tPendingVoucherHeader.tdInvoicedAmount - tPendingVoucherHeader.tdMatchUnitPrice.
else /* Quering of the data from the API integration, this case only one pending voucher is retrieved and price is also supplied */
assign tPendingVoucherHeader.tdPvodUnitPrice = tqPendingVoucherForMatchingLC.tdpvo_accrued_amt - tqPendingVoucherForMatchingLC.tdpvo_vouchered_amt
tPendingVoucherHeader.tdMatchUnitPrice = idAPIMatchAmtTC
tPendingVoucherHeader.tdAccruedAmountTC = tqPendingVoucherForMatchingLC.tdpvo_accrued_amt
tPendingVoucherHeader.tdInvoicedAmountTC = tqPendingVoucherForMatchingLC.tdpvo_vouchered_amt
tPendingVoucherHeader.tdVarianceAmountTC = tPendingVoucherHeader.tdAccruedAmount - tPendingVoucherHeader.tdInvoicedAmount - tPendingVoucherHeader.tdMatchUnitPrice
tPendingVoucherHeader.tlIsPvodFinished = (ilApiIsPvodFinished or tPendingVoucherHeader.tdVarianceAmountTC = 0).
end. /* if first-of (tqPendingVoucherForMatchingLC.tipvod_id) */
/* =========================================================================================== */
/* Create output records for matching line */
/* =========================================================================================== */
if first-of (tqPendingVoucherForMatchingLC.tipvod_id_line)
then do :
/* ======================================= */
/* Create output records for matching line */
/* ======================================= */
create tPendingVoucherAPM.
assign tPendingVoucherAPM.APMatchingLnPvodIsLgCharge = true
tPendingVoucherAPM.APMatchingLnIsPvodFinished = true
tPendingVoucherAPM.APMatchingLnIsVarGLPosting = true
tPendingVoucherAPM.APMatchingLnPvodCCCode = tqPendingVoucherForMatchingLC.tcpvod_accrual_cc
tPendingVoucherAPM.APMatchingLnPvodPrjCode = tqPendingVoucherForMatchingLC.tcpvod_project
tPendingVoucherAPM.APMatchingLnPvodDivCode = tqPendingVoucherForMatchingLC.tcpvod_accrual_sub
tPendingVoucherAPM.APMatchingLnPvodExchRate = tqPendingVoucherForMatchingLC.tdpvod_ex_rate
tPendingVoucherAPM.APMatchingLnPvodExchRate2 = tqPendingVoucherForMatchingLC.tdpvod_ex_rate2
tPendingVoucherAPM.APMatchingLnPvodGLCode = tqPendingVoucherForMatchingLC.tcpvod_accrual_acct
tPendingVoucherAPM.APMatchingLnPvodUomConv = 1
tPendingVoucherAPM.PvodLineID = tqPendingVoucherForMatchingLC.tipvod_id_line
tPendingVoucherAPM.PvoDomain = tqPendingVoucherForMatchingLC.tcpvo_domain
tPendingVoucherAPM.PvoID = tqPendingVoucherForMatchingLC.tipvo_id
tPendingVoucherAPM.tcGLCode = tqPendingVoucherForMatchingLC.tcpvo_accrual_acct
tPendingVoucherAPM.tcDivisionCode = tqPendingVoucherForMatchingLC.tcpvo_accrual_sub
tPendingVoucherAPM.tcCostCentreCode = tqPendingVoucherForMatchingLC.tcpvo_accrual_cc
tPendingVoucherAPM.tcProjectCode = tqPendingVoucherForMatchingLC.tcpvo_project
tPendingVoucherAPM.APMatchingLnPvodCurrency = tqPendingVoucherForMatchingLC.tcpvo_curr
tPendingVoucherAPM.APMatchingLnPvodExtRef = substring(tqPendingVoucherForMatchingLC.tcpvo_external_ref,1,50,'character':U)
tPendingVoucherAPM.APMatchingLnPvodIntRef = substring(tqPendingVoucherForMatchingLC.tcpvo_internal_ref,1,50,'character':U)
tPendingVoucherAPM.APMatchingLnPvodItem = tqPendingVoucherForMatchingLC.tcpvod_part
tPendingVoucherAPM.APMatchingLnPvodLgCharge = tqPendingVoucherForMatchingLC.tcpvo_lc_charge
tPendingVoucherAPM.APMatchingLnPvodTransDate = tqPendingVoucherForMatchingLC.ttpvo_trans_date
tPendingVoucherAPM.ttAPMatchingLnPvodEffDate = tqPendingVoucherForMatchingLC.ttpvo_eff_date
tPendingVoucherAPM.APMatchingLnPvodOrder = tqPendingVoucherForMatchingLC.tcpvod_order
tPendingVoucherAPM.APMatchingLnPvodOrderLnNbr = tqPendingVoucherForMatchingLC.tipvo_line
tPendingVoucherAPM.APMatchingLnPvodOrderType = (if tqPendingVoucherForMatchingLC.tcpvo_order_type = {&PENDINGVOUCHER-ORDERTYPE-DO}
then {&APMATCHINGLNPVODORDERTYPE-DISTRIB}
else if tqPendingVoucherForMatchingLC.tcpvo_order_type = {&PENDINGVOUCHER-ORDERTYPE-SO}
then {&APMATCHINGLNPVODORDERTYPE-SALES}
else {&APMATCHINGLNPVODORDERTYPE-PURCHASE})
tPendingVoucherAPM.APMatchingLnPvodSupplItem = "":U
tPendingVoucherAPM.APMatchingLnPvodUoM = (if tqPendingVoucherForMatchingLC.tcprh_um = ? then "":U else tqPendingVoucherForMatchingLC.tcprh_um)
tPendingVoucherAPM.APMatchingLnPvodItemType = if tqPendingVoucherForMatchingLC.tcprh_type = "":U
then {&APMATCHINGLNPVODITEMTYPE-NORMAL}
else if tqPendingVoucherForMatchingLC.tcprh_type = "S":U
then {&APMATCHINGLNPVODITEMTYPE-SUBCONTRACT}
else {&APMATCHINGLNPVODITEMTYPE-MEMO}
tPendingVoucherAPM.APMatchingLnPvodReceiptQty = 1
tPendingVoucherAPM.APMatchingLnPvodSite = (if tqPendingVoucherForMatchingLC.tcpvo_order_type = {&PENDINGVOUCHER-ORDERTYPE-SO} Or
tqPendingVoucherForMatchingLC.tcpvo_order_type = {&PENDINGVOUCHER-ORDERTYPE-DO}
then tqPendingVoucherForMatchingLC.tcpvo_shipfrom
else tqPendingVoucherForMatchingLC.tcpvo_shipto)
tPendingVoucherAPM.APMatchingLnPvodConvFactor = 1
tPendingVoucherAPM.APMatchingLnPvodCompCode = vcPvodCompCode
tPendingVoucherAPM.APMatchingLnPvodCompID = viPvodCompID
tPendingVoucherAPM.APMatchingLnPvodPliKeyId = 0
tPendingVoucherAPM.APMatchingLnPvodPlidLine = 0
tPendingVoucherAPM.APMatchingLnPvodPackingQty = tqPendingVoucherForMatchingLC.tdprh_ps_qty
tPendingVoucherAPM.APMatchingLnPvodIsTaxable = (if tqPendingVoucherForMatchingLC.tlpvod_taxable = ? then false else tqPendingVoucherForMatchingLC.tlpvod_taxable)
tPendingVoucherAPM.APMatchingLnPvodTaxEnv = (if tqPendingVoucherForMatchingLC.tctx2d_tax_env = ? then "":U else tqPendingVoucherForMatchingLC.tctx2d_tax_env)
tPendingVoucherAPM.APMatchingLnPvodTaxClass = (if tqPendingVoucherForMatchingLC.tctx2d_taxc = ? then "":U else tqPendingVoucherForMatchingLC.tctx2d_taxc)
tPendingVoucherAPM.APMatchingLnPvodTaxUsage = (if tqPendingVoucherForMatchingLC.tctx2d_tax_usage = ? then "":U else tqPendingVoucherForMatchingLC.tctx2d_tax_usage)
tPendingVoucherAPM.APMatchingLnPvodSupplier = tqPendingVoucherForMatchingLC.tcpvo_supplier
tPendingVoucherAPM.APMatchingLnPvodPayCond = "":U
tPendingVoucherAPM.APMatchingLnIsTaxable = tPendingVoucherAPM.APMatchingLnPvodIsTaxable
tPendingVoucherAPM.APMatchingLnTaxEnv = tPendingVoucherAPM.APMatchingLnPvodTaxEnv
tPendingVoucherAPM.APMatchingLnTaxClass = tPendingVoucherAPM.APMatchingLnPvodTaxClass
tPendingVoucherAPM.APMatchingLnTaxUsage = tPendingVoucherAPM.APMatchingLnPvodTaxUsage
tPendingVoucherAPM.APMatchingLnPvodInvoicedTC = tqPendingVoucherForMatchingLC.tdpvo_vouchered_amt
tPendingVoucherAPM.APMatchingLnPvodAccruedTC = tqPendingVoucherForMatchingLC.tdpvo_accrued_amt
tPendingVoucherAPM.tlIsNeededToRecallGTM = false
tPendingVoucherAPM.tlIsSelected = ilAutoSelect
tPendingVoucherAPM.tc_Status = "N":U
tPendingVoucherAPM.tc_Rowid = string(viRowidPendingVoucherAPM)
tPendingVoucherAPM.APMatchingLnPvodFromTaxZone = (if vlIsVertexEnabled then tqPendingVoucherForMatchingLC.tctx2d_zone_from else "":U)
tPendingVoucherAPM.APMatchingLnPvodToTaxZone = (if vlIsVertexEnabled then tqPendingVoucherForMatchingLC.tctx2d_zone_to else "":U)
viRowidPendingVoucherAPM = viRowidPendingVoucherAPM + 1.
/* ================================================ */
/* Check if accrual account is not an Op Alloc Code */
/* ================================================ */
if tPendingVoucherAPM.APMatchingLnPvodGLCode <> ? and
tPendingVoucherAPM.APMatchingLnPvodGLCode <> "":U
then do:
<Q-23 assign vlFcQueryRecordsAvailable = AlMstrByDomainCode (Cache)
(input tPendingVoucherAPM.PvoDomain, (Domain)
input tPendingVoucherAPM.APMatchingLnPvodGLCode, (Code)) in BMfgAllocationAccount>
if vlFcQueryRecordsAvailable <> false
then assign tPendingVoucherAPM.APMatchingLnPvodOpAllocCode = tPendingVoucherAPM.APMatchingLnPvodGLCode
tPendingVoucherAPM.APMatchingLnPvodGLCode = "":U.
else assign tPendingVoucherAPM.APMatchingLnPvodOpAllocCode = "":U.
end. /* if tPendingVoucherAPM.APMatchingLnPvodGLCode <> ? and */
if tPendingVoucherAPM.tcGLCode <> ? and
tPendingVoucherAPM.tcGLCode <> "":U
then do:
<Q-94 assign vlFcQueryRecordsAvailable = AlMstrByDomainCode (Cache)
(input tPendingVoucherAPM.PvoDomain, (Domain)
input tPendingVoucherAPM.tcGLCode, (Code)) in BMfgAllocationAccount>
if vlFcQueryRecordsAvailable <> false
then assign tPendingVoucherAPM.APMatchingLnOpAllocCode = tPendingVoucherAPM.tcGLCode
tPendingVoucherAPM.tcGLCode = "":U.
else assign tPendingVoucherAPM.APMatchingLnOpAllocCode = "":U.
end. /* if tPendingVoucherAPM.tcGLCode <> ? and */
/* ================================ */
/* Assign the Prices and Quantities */
/* ================================ */
if iiApiPvoId = ? or iiApiPvoId = 0 /* quering pending vouchers from the UI */
then
assign tPendingVoucherAPM.APMatchingLnPvodOpenQty = 1
tPendingVoucherAPM.APMatchingLnMatchQty = 1
tPendingVoucherAPM.APMatchingLnPvodUnitPrice = tqPendingVoucherForMatchingLC.tdpvod_accrued_amt - tqPendingVoucherForMatchingLC.tdpvod_vouchered_amt
tPendingVoucherAPM.APMatchingLnMatchUnitPrice = tPendingVoucherAPM.APMatchingLnPvodUnitPrice
tPendingVoucherAPM.APMatchingLnPvodOpenAmtTC = tPendingVoucherAPM.APMatchingLnPvodUnitPrice
tPendingVoucherAPM.APMatchingLnMatchAmtTC = tPendingVoucherAPM.APMatchingLnMatchUnitPrice
tPendingVoucherAPM.APMatchingLnMatchAmtLC = <M-69 RoundAmount
(input tPendingVoucherAPM.APMatchingLnMatchAmtTC * tPendingVoucherAPM.APMatchingLnPvodExchRate2 / tPendingVoucherAPM.APMatchingLnPvodExchRate (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input ? (icCurrencyCode)) in business>.
else /* quering pending vouchers from the API */
assign tPendingVoucherAPM.APMatchingLnPvodOpenQty = 1
tPendingVoucherAPM.APMatchingLnMatchQty = 1
tPendingVoucherAPM.APMatchingLnPvodUnitPrice = tqPendingVoucherForMatchingLC.tdpvod_accrued_amt - tqPendingVoucherForMatchingLC.tdpvod_vouchered_amt
tPendingVoucherAPM.APMatchingLnMatchUnitPrice = idAPIMatchAmtTC
tPendingVoucherAPM.APMatchingLnPvodOpenAmtTC = tPendingVoucherAPM.APMatchingLnPvodUnitPrice
tPendingVoucherAPM.APMatchingLnMatchAmtTC = tPendingVoucherAPM.APMatchingLnMatchUnitPrice
tPendingVoucherAPM.APMatchingLnMatchAmtLC = <M-90 RoundAmount
(input tPendingVoucherAPM.APMatchingLnMatchAmtTC * tPendingVoucherAPM.APMatchingLnPvodExchRate2 / tPendingVoucherAPM.APMatchingLnPvodExchRate (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input ? (icCurrencyCode)) in BApplicationProperty>
tPendingVoucherAPM.APMatchingLnIsPvodFinished = (ilApiIsPvodFinished or tPendingVoucherAPM.APMatchingLnMatchUnitPrice = tPendingVoucherAPM.APMatchingLnPvodUnitPrice)
tPendingVoucherAPM.tlLogChargeHeaderIsFinished = tPendingVoucherAPM.APMatchingLnIsPvodFinished
tPendingVoucherAPM.tlLogChargeHeaderIsSelected = true
tPendingVoucherAPM.tdLogChargeHeaderMatchedAmountTC = tPendingVoucherAPM.APMatchingLnMatchUnitPrice.
/* =========================================================================== */
/* Call - via a submethod - method in BCosting the returns the costing methods */
/* =========================================================================== */
<M-19 run GetPendingVouchersAssignCostMethodsCCRate
(input icAPMatchingTcRowid (icAPMatchingTcRowid),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then Return.
/* ==================================================================================== */
/* Compose the Amount and the Qty of this Pvod that is located on other APMatchingLines */
/* linked to this Pvod and with APMatching.APMatchingStatus = Initial */
/* The field that are assigned here, exist just for informational reasons (no BL-logic) */
/* ==================================================================================== */
<M-38 run GetPendingVouchersAssignPendingMatchFields
(input icAPMatchingTcRowid (icAPMatchingTcRowid),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then Return.
/* =============================================== */
/* Set Taxable to false in case there are no taxes */
/* =============================================== */
if tPendingVoucherAPM.APMatchingLnPvodIsTaxable = true and
(tqPendingVoucherForMatchingLC.tctx2d_tax_env = ? or
tqPendingVoucherForMatchingLC.tctx2d_tax_env = "":U) and
(tqPendingVoucherForMatchingLC.tctx2d_taxc = ? or
tqPendingVoucherForMatchingLC.tctx2d_taxc = "":U) and
(tqPendingVoucherForMatchingLC.tctx2d_tax_usage = ? or
tqPendingVoucherForMatchingLC.tctx2d_tax_usage = "":U)
then assign tPendingVoucherAPM.APMatchingLnPvodIsTaxable = false
tPendingVoucherAPM.APMatchingLnIsTaxable = false.
end. /* if first-of (tqPendingVoucherForMatchingLC.tipvod_id_line) */
/* ============ */
/* Tax handling */
/* ============ */
if (tqPendingVoucherForMatchingLC.tctx2_tax_code <> ? and
tqPendingVoucherForMatchingLC.tctx2_domain <> ? and
tqPendingVoucherForMatchingLC.tctx2_tax_code <> "":U and
tqPendingVoucherForMatchingLC.tctx2_domain <> "":U)
then do :
/* ============================================================================================================================================= */
/* If this method is called from the UI (iiApiPvodID is empty) then we set AutoSelect to true in case it was unknown (this should never happen) */
/* If this method is called from EDI or ERS (iiApiPvodID is filled) and AutoSelect is unknown, */
/* then: when the Price and Qty of the input match the values of the PVO then we set AutoSelect to true */
/* when the Price and Qty of the input differs from the values of the PVO then we set AutoSelect to false - as then GTM aught to be called */
/* ============================================================================================================================================= */
if iiApiPvoID = ? or
iiApiPvoID = 0
then assign vlAutoSelectForTheTaxAndWHT = (if ilAutoSelect = ? then true else ilAutoSelect).
else if ilAutoSelect = ?
then if idApiMatchAmtTC = tqPendingVoucherForMatchingLC.tdpvod_accrued_amt - tqPendingVoucherForMatchingLC.tdpvod_vouchered_amt
then assign vlAutoSelectForTheTaxAndWHT = true.
else assign vlAutoSelectForTheTaxAndWHT = false.
else assign vlAutoSelectForTheTaxAndWHT = ilAutoSelect.
/* ============================================== */
/* Run submethod that will create the tax-details */
/* ============================================== */
<M-31 run GetPendingVouchersLogChargesTax
(input ilCallGTM (ilCallGTM),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then Return.
end. /* if tqPendingVoucherForMatchingLC.tctx2_tax_code <> ? and */
/* ====================================================================================================== *
* Handling of the Tax Included *
* ====================================================================================================== */
if tqPendingVoucherForMatchingLC.tltx2d_tax_in
then do:
assign vdTaxIncludedTotal = tqPendingVoucherForMatchingLC.tdtx2d_cur_tax_amt
vdTaxIncludedInvoiced = vdTaxIncludedTotal * tqPendingVoucherForMatchingLC.tdpvo_vouchered_amt / tqPendingVoucherForMatchingLC.tdpvo_accrued_amt
vdTaxIncludedInvoiced = <M-26 RoundAmount
(input vdTaxIncludedInvoiced (idUnroundedAmount),
input ? (iiCurrencyID),
input tqPendingVoucherForMatchingLC.tcpvo_curr (icCurrencyCode)) in BAPMatching>
vdTaxIncludedOpen = vdTaxIncludedTotal - vdTaxIncludedInvoiced.
assign tPendingVoucherHeader.tdPvodUnitPrice = tPendingVoucherHeader.tdPvodUnitPrice - vdTaxIncludedOpen
tPendingVoucherHeader.tdAccruedAmountTC = tqPendingVoucherForMatchingLC.tdpvo_accrued_amt - vdTaxIncludedTotal
tPendingVoucherHeader.tdInvoicedAmountTC = tqPendingVoucherForMatchingLC.tdpvo_vouchered_amt - vdTaxIncludedInvoiced
tPendingVoucherHeader.tdVarianceAmountTC = tPendingVoucherHeader.tdAccruedAmount - tPendingVoucherHeader.tdInvoicedAmount - tPendingVoucherHeader.tdMatchUnitPrice
tPendingVoucherAPM.APMatchingLnPvodUnitPrice = tPendingVoucherAPM.APMatchingLnPvodUnitPrice - vdTaxIncludedOpen
tPendingVoucherAPM.APMatchingLnPvodOpenAmtTC = tPendingVoucherAPM.APMatchingLnPvodOpenAmtTC - vdTaxIncludedOpen
tPendingVoucherAPM.APMatchingLnMatchAmtTC = tPendingVoucherAPM.APMatchingLnMatchUnitPrice
tPendingVoucherAPM.APMatchingLnMatchAmtLC = <M-56 RoundAmount
(input tPendingVoucherAPM.APMatchingLnMatchAmtTC * tPendingVoucherAPM.APMatchingLnPvodExchRate2 / tPendingVoucherAPM.APMatchingLnPvodExchRate (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input ? (icCurrencyCode)) in business>.
end. /* if tqPendingVoucherForMatchingLC.tltx2_tax_in */
end. /* for each tq */
/* =================== */
/* Return-status = OK */
/* =================== */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.