project QadFinancials > class BAPMatching > method GetPendingVouchersNoLogChargesTax
Description
Submethod of GetPendingVouchersNoLogCharges
Parameters
ilAutoSelect | input | logical | Auto-select |
ilCallGTM | input | logical | Shoudl we call GTM |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program7/bapmatching.p)
/* ========================================================================================================= */
/* ALL DATA WE USE IN HERE SHOULD BE AVAILABLE AS THIS METHOD AND ITS CALLING METHOD ARE IN THE SAME SEGMENT */
/* ========================================================================================================= */
/* ====================== */
/* Default return-status */
/* ====================== */
assign oiReturnStatus = -98.
/* ============ */
/* Tax handling */
/* ============ */
if tqPendingVoucherForMatchingNoLC.tctx2_tax_code <> ? and
tqPendingVoucherForMatchingNoLC.tctx2_domain <> ? and
tqPendingVoucherForMatchingNoLC.tctx2_tax_code <> "":U and
tqPendingVoucherForMatchingNoLC.tctx2_domain <> "":U
then do:
<Q-49 run CreditorByCodeForWHT (all) (Read) (Cache)
(input tAPMatching.Company_ID, (CompanyId)
input tqPendingVoucherForMatchingNoLC.tcpvo_supplier, (CreditorCode)
input true, (CreditorIsWHT)
output dataset tqCreditorByCodeForWHT) in BCreditor>
assign vlCreditorIsWht = can-find (tqCreditorByCodeForWHT where
tqCreditorByCodeForWHT.tcCreditorCode = tqPendingVoucherForMatchingNoLC.tcpvo_supplier and
tqCreditorByCodeForWHT.tlCreditorIsWHT = true).
if tqPendingVoucherForMatchingNoLC.tctx2d_tr_type = {&VATTAXTRANSACTIONTYPE-APWHT} and
vlDomainIsWHT = true and
vlCreditorIsWht = true
then do:
/* ================================ */
/* everything for withholding taxes */
/* ================================ */
<M-36 run GetPendingVouchersNoLogChargesTaxWHT
(input ilAutoSelect (ilAutoSelect),
input ilCallGTM (ilCallGTM),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then Return.
end. /* end if tqPendingVoucherForMatchingNoLC.tctx2d_tr_type = {&VATTAXTRANSACTIONTYPE-APWHT} */
else if tqPendingVoucherForMatchingNoLC.tctx2d_tr_type <> {&VATTAXTRANSACTIONTYPE-APWHT}
then do:
/* ==================================================================================== */
/* Always create t_iAPMatchingLnTax records based upon the tx2d_det records as we need */
/* this information for reversing the taxes of the receipt. */
/* Note 0: The tc_parentrowid of these records is just the pvoDomain+pvoID+pvodLieID */
/* Note 1: we here use the receipt-amounts as we do not yet know the matched-qty */
/* Note 2: we only create this record once (even if a pvod is used multiple times) */
/* ==================================================================================== */
if not can-find (first t_iAPMatchingLnTax where
t_iAPMatchingLnTax.tc_ParentRowid = trim(tPendingVoucherAPM.PvoDomain) + "-":U + trim(string(tPendingVoucherAPM.PvoID)) + "-":U + trim(string(tPendingVoucherAPM.PvodLineID)) and
t_iAPMatchingLnTax.tcVatCode = tqPendingVoucherForMatchingNoLC.tctx2_tax_code)
then do :
create t_iAPMatchingLnTax.
assign t_iAPMatchingLnTax.tcDomainCode = tqPendingVoucherForMatchingNoLC.tctx2_domain
t_iAPMatchingLnTax.tcVatCode = tqPendingVoucherForMatchingNoLC.tctx2_tax_code
t_iAPMatchingLnTax.tcVatInOut = {&VATINOUT-INPUT}
t_iAPMatchingLnTax.APMatchingLnTaxTaxType = tqPendingVoucherForMatchingNoLC.tctx2d_tax_type
t_iAPMatchingLnTax.APMatchingLnTaxTaxTrType = tqPendingVoucherForMatchingNoLC.tctx2d_tr_type
t_iAPMatchingLnTax.APMatchingLnTaxBaseTC = tqPendingVoucherForMatchingNoLC.tdtx2d_tottax
t_iAPMatchingLnTax.APMatchingLnTaxBaseLC = tqPendingVoucherForMatchingNoLC.tdtx2d_taxable_amt
t_iAPMatchingLnTax.APMatchingLnTaxTaxTC = tqPendingVoucherForMatchingNoLC.tdtx2d_cur_tax_amt
t_iAPMatchingLnTax.APMatchingLnTaxTaxLC = tqPendingVoucherForMatchingNoLC.tdtx2d_tax_amt
t_iAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = (tqPendingVoucherForMatchingNoLC.tltx2_rcpt_tax_point = true or tqPendingVoucherForMatchingNoLC.tltx2_usage_tax_point = true)
t_iAPMatchingLnTax.APMatchingLnTaxIsDiscAtInv = (tqPendingVoucherForMatchingNoLC.tltx2_inv_disc = true)
t_iAPMatchingLnTax.APMatchingLnTaxIsAbsRet = (if tqPendingVoucherForMatchingNoLC.tdtx2d_abs_ret_amt <> 0 and tqPendingVoucherForMatchingNoLC.tdtx2d_abs_ret_amt <> ? then true else false)
t_iAPMatchingLnTax.APMatchingLnTaxIsUpdAllow = tqPendingVoucherForMatchingNoLC.tltx2_update_tax
t_iAPMatchingLnTax.APMatchingLnTaxIsSuspDel = tqPendingVoucherForMatchingNoLC.tltx2_stx_dltx_use
t_iAPMatchingLnTax.APMatchingLnTaxTaxPct = tqPendingVoucherForMatchingNoLC.tdtx2_tax_pct
t_iAPMatchingLnTax.APMatchingLnTaxRecovTaxPct = tqPendingVoucherForMatchingNoLC.tdtx2_pct_recv
t_iAPMatchingLnTax.APMatchingLnTaxARRecTaxTC = (if t_iAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = true then tqPendingVoucherForMatchingNoLC.tdtx2d_cur_recov_amt else 0)
t_iAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC = (if t_iAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = true then tqPendingVoucherForMatchingNoLC.tdtx2d_cur_tax_amt - tqPendingVoucherForMatchingNoLC.tdtx2d_cur_recov_amt else 0)
t_iAPMatchingLnTax.APMatchingLnTaxAIRecTaxTC = (if t_iAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = false then tqPendingVoucherForMatchingNoLC.tdtx2d_cur_recov_amt else 0)
t_iAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC = (if t_iAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = false then tqPendingVoucherForMatchingNoLC.tdtx2d_cur_tax_amt - tqPendingVoucherForMatchingNoLC.tdtx2d_cur_recov_amt else 0)
t_iAPMatchingLnTax.APMatchingLnTaxIsRevCharge = tqPendingVoucherForMatchingNoLC.tltx2_reverse_charge
t_iAPMatchingLnTax.tcNormalTaxGLCode = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then tqPendingVoucherForMatchingNoLC.tctx2_ap_cn_acct
else tqPendingVoucherForMatchingNoLC.tctx2_ap_acct
t_iAPMatchingLnTax.tcNormalTaxDivisionCode = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then tqPendingVoucherForMatchingNoLC.tctx2_ap_cn_sub
else tqPendingVoucherForMatchingNoLC.tctx2_ap_sub
t_iAPMatchingLnTax.tcAbsRetTaxGLCode = (if t_iAPMatchingLnTax.APMatchingLnTaxIsAbsRet = true
then if tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then tqPendingVoucherForMatchingNoLC.tctx2_apr_cn_acct
else tqPendingVoucherForMatchingNoLC.tctx2_apr_acct
else "":U)
t_iAPMatchingLnTax.tcAbsRetTaxDivisionCode = (if t_iAPMatchingLnTax.APMatchingLnTaxIsAbsRet = true
then if tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then tqPendingVoucherForMatchingNoLC.tctx2_apr_cn_sub
else tqPendingVoucherForMatchingNoLC.tctx2_apr_sub
else "":U)
t_iAPMatchingLnTax.tcSuspDelTaxGLCode = (if t_iAPMatchingLnTax.APMatchingLnTaxIsSuspDel = true
then if tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then tqPendingVoucherForMatchingNoLC.tctx2_dltx_cn_acct
else tqPendingVoucherForMatchingNoLC.tctx2_dltx_inv_acct
else "":U)
t_iAPMatchingLnTax.tcSuspDelTaxDivisionCode = (if t_iAPMatchingLnTax.APMatchingLnTaxIsSuspDel = true
then if tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then tqPendingVoucherForMatchingNoLC.tctx2_dltx_cn_sub
else tqPendingVoucherForMatchingNoLC.tctx2_dltx_inv_sub
else "":U)
t_iAPMatchingLnTax.tc_ParentRowid = trim(tPendingVoucherAPM.PvoDomain) + "-":U + trim(string(tPendingVoucherAPM.PvoID)) + "-":U + trim(string(tPendingVoucherAPM.PvodLineID))
t_iAPMatchingLnTax.tc_Rowid = string(viRowidPendingVoucherTaxAPM)
viRowidPendingVoucherTaxAPM = viRowidPendingVoucherTaxAPM + 1.
end. /* if not can-find (first t_iAPMatchingLnTax where */
/* =============================================================================== */
/* Create MatchingLnTax in case GTM does not need to be called */
/* If GTM needs to be called then this is done by the parent-method of this method */
/* The amounts here do depend upon the fact whether a pvo is selected or not */
/* =============================================================================== */
if ilCallGTM = false
then do:
create tPendingVoucherTaxAPM.
assign tPendingVoucherTaxAPM.tcDomainCode = tqPendingVoucherForMatchingNoLC.tctx2_domain
tPendingVoucherTaxAPM.tcVatCode = tqPendingVoucherForMatchingNoLC.tctx2_tax_code
tPendingVoucherTaxAPM.tcVatInOut = {&VATINOUT-INPUT}
tPendingVoucherTaxAPM.APMatchingLnTaxTaxType = tqPendingVoucherForMatchingNoLC.tctx2d_tax_type
tPendingVoucherTaxAPM.APMatchingLnTaxTaxTrType = tqPendingVoucherForMatchingNoLC.tctx2d_tr_type
tPendingVoucherTaxAPM.APMatchingLnTaxBaseTC = (if ilAutoSelect = true then tqPendingVoucherForMatchingNoLC.tdtx2d_tottax else 0)
tPendingVoucherTaxAPM.APMatchingLnTaxBaseLC = (if ilAutoSelect = true then tqPendingVoucherForMatchingNoLC.tdtx2d_taxable_amt else 0)
tPendingVoucherTaxAPM.APMatchingLnTaxTaxTC = (if ilAutoSelect = true then tqPendingVoucherForMatchingNoLC.tdtx2d_cur_tax_amt else 0)
tPendingVoucherTaxAPM.APMatchingLnTaxTaxLC = (if ilAutoSelect = true then tqPendingVoucherForMatchingNoLC.tdtx2d_tax_amt else 0)
tPendingVoucherTaxAPM.APMatchingLnTaxIsAccrRcp = (tqPendingVoucherForMatchingNoLC.tltx2_rcpt_tax_point = true or tqPendingVoucherForMatchingNoLC.tltx2_usage_tax_point = true)
tPendingVoucherTaxAPM.APMatchingLnTaxIsDiscAtInv = (tqPendingVoucherForMatchingNoLC.tltx2_inv_disc = true)
tPendingVoucherTaxAPM.APMatchingLnTaxIsAbsRet = (if tqPendingVoucherForMatchingNoLC.tdtx2d_abs_ret_amt <> 0 and tqPendingVoucherForMatchingNoLC.tdtx2d_abs_ret_amt <> ? then true else false)
tPendingVoucherTaxAPM.APMatchingLnTaxIsUpdAllow = tqPendingVoucherForMatchingNoLC.tltx2_update_tax
tPendingVoucherTaxAPM.APMatchingLnTaxIsSuspDel = tqPendingVoucherForMatchingNoLC.tltx2_stx_dltx_use
tPendingVoucherTaxAPM.APMatchingLnTaxTaxPct = tqPendingVoucherForMatchingNoLC.tdtx2_tax_pct
tPendingVoucherTaxAPM.APMatchingLnTaxRecovTaxPct = tqPendingVoucherForMatchingNoLC.tdtx2_pct_recv
tPendingVoucherTaxAPM.APMatchingLnTaxARRecTaxTC = (if tPendingVoucherTaxAPM.APMatchingLnTaxIsAccrRcp = true and ilAutoSelect = true then tqPendingVoucherForMatchingNoLC.tdtx2d_cur_recov_amt else 0)
tPendingVoucherTaxAPM.APMatchingLnTaxARNRecTaxTC = (if tPendingVoucherTaxAPM.APMatchingLnTaxIsAccrRcp = true and ilAutoSelect = true then tqPendingVoucherForMatchingNoLC.tdtx2d_cur_tax_amt - tqPendingVoucherForMatchingNoLC.tdtx2d_cur_recov_amt else 0)
tPendingVoucherTaxAPM.APMatchingLnTaxAIRecTaxTC = (if tPendingVoucherTaxAPM.APMatchingLnTaxIsAccrRcp = false and ilAutoSelect = true then tqPendingVoucherForMatchingNoLC.tdtx2d_cur_recov_amt else 0)
tPendingVoucherTaxAPM.APMatchingLnTaxAINRecTaxTC = (if tPendingVoucherTaxAPM.APMatchingLnTaxIsAccrRcp = false and ilAutoSelect = true then tqPendingVoucherForMatchingNoLC.tdtx2d_cur_tax_amt - tqPendingVoucherForMatchingNoLC.tdtx2d_cur_recov_amt else 0)
tPendingVoucherTaxAPM.APMatchingLnTaxIsRevCharge = tqPendingVoucherForMatchingNoLC.tltx2_reverse_charge
tPendingVoucherTaxAPM.tcNormalTaxGLCode = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then tqPendingVoucherForMatchingNoLC.tctx2_ap_cn_acct
else tqPendingVoucherForMatchingNoLC.tctx2_ap_acct
tPendingVoucherTaxAPM.tcNormalTaxDivisionCode = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then tqPendingVoucherForMatchingNoLC.tctx2_ap_cn_sub
else tqPendingVoucherForMatchingNoLC.tctx2_ap_sub
tPendingVoucherTaxAPM.tcAbsRetTaxGLCode = (if tPendingVoucherTaxAPM.APMatchingLnTaxIsAbsRet = true
then if tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then tqPendingVoucherForMatchingNoLC.tctx2_apr_cn_acct
else tqPendingVoucherForMatchingNoLC.tctx2_apr_acct
else "":U)
tPendingVoucherTaxAPM.tcAbsRetTaxDivisionCode = (if tPendingVoucherTaxAPM.APMatchingLnTaxIsAbsRet = true
then if tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then tqPendingVoucherForMatchingNoLC.tctx2_apr_cn_sub
else tqPendingVoucherForMatchingNoLC.tctx2_apr_sub
else "":U)
tPendingVoucherTaxAPM.tcSuspDelTaxGLCode = (if tPendingVoucherTaxAPM.APMatchingLnTaxIsSuspDel = true
then if tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then tqPendingVoucherForMatchingNoLC.tctx2_dltx_cn_acct
else tqPendingVoucherForMatchingNoLC.tctx2_dltx_inv_acct
else "":U)
tPendingVoucherTaxAPM.tcSuspDelTaxDivisionCode = (if tPendingVoucherTaxAPM.APMatchingLnTaxIsSuspDel = true
then if tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then tqPendingVoucherForMatchingNoLC.tctx2_dltx_cn_sub
else tqPendingVoucherForMatchingNoLC.tctx2_dltx_inv_sub
else "":U)
tPendingVoucherTaxAPM.tc_ParentRowid = tPendingVoucherAPM.tc_Rowid
tPendingVoucherTaxAPM.tc_Rowid = string(viRowidPendingVoucherTaxAPM)
tPendingVoucherTaxAPM.tc_Status = "N":U
viRowidPendingVoucherTaxAPM = viRowidPendingVoucherTaxAPM + 1.
if tqPendingVoucherForMatchingNoLC.tdprh_ps_qty <> 0 and
tqPendingVoucherForMatchingNoLC.tdprh_ps_qty <> ? and
tqPendingVoucherForMatchingNoLC.tdpvod_trans_qty <> tqPendingVoucherForMatchingNoLC.tdprh_ps_qty
then assign vdPendingVoucherLineQty = abs(tqPendingVoucherForMatchingNoLC.tdpvod_trans_qty / tqPendingVoucherForMatchingNoLC.tdprh_ps_qty)
tPendingVoucherTaxAPM.APMatchingLnTaxBaseTC = <M-37 RoundAmount
(input tPendingVoucherTaxAPM.APMatchingLnTaxBaseTC * vdPendingVoucherLineQty (idUnroundedAmount),
input ? (iiCurrencyID),
input tqPendingVoucherForMatchingNoLC.tcpvo_curr (icCurrencyCode)) in BApplicationProperty>
tPendingVoucherTaxAPM.APMatchingLnTaxBaseLC = <M-83 RoundAmount
(input tPendingVoucherTaxAPM.APMatchingLnTaxBaseLC * vdPendingVoucherLineQty (idUnroundedAmount),
input ? (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
tPendingVoucherTaxAPM.APMatchingLnTaxTaxTC = <M-21 RoundAmount
(input tPendingVoucherTaxAPM.APMatchingLnTaxTaxTC * vdPendingVoucherLineQty (idUnroundedAmount),
input ? (iiCurrencyID),
input tqPendingVoucherForMatchingNoLC.tcpvo_curr (icCurrencyCode)) in BApplicationProperty>
tPendingVoucherTaxAPM.APMatchingLnTaxTaxLC = <M-57 RoundAmount
(input tPendingVoucherTaxAPM.APMatchingLnTaxTaxLC * vdPendingVoucherLineQty (idUnroundedAmount),
input ? (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
tPendingVoucherTaxAPM.APMatchingLnTaxARRecTaxTC = <M-38 RoundAmount
(input tPendingVoucherTaxAPM.APMatchingLnTaxARRecTaxTC * vdPendingVoucherLineQty (idUnroundedAmount),
input ? (iiCurrencyID),
input tqPendingVoucherForMatchingNoLC.tcpvo_curr (icCurrencyCode)) in BApplicationProperty>
tPendingVoucherTaxAPM.APMatchingLnTaxARNRecTaxTC = <M-84 RoundAmount
(input tPendingVoucherTaxAPM.APMatchingLnTaxARNRecTaxTC * vdPendingVoucherLineQty (idUnroundedAmount),
input ? (iiCurrencyID),
input tqPendingVoucherForMatchingNoLC.tcpvo_curr (icCurrencyCode)) in BApplicationProperty>
tPendingVoucherTaxAPM.APMatchingLnTaxAIRecTaxTC = <M-76 RoundAmount
(input tPendingVoucherTaxAPM.APMatchingLnTaxAIRecTaxTC * vdPendingVoucherLineQty (idUnroundedAmount),
input ? (iiCurrencyID),
input tqPendingVoucherForMatchingNoLC.tcpvo_curr (icCurrencyCode)) in BApplicationProperty>
tPendingVoucherTaxAPM.APMatchingLnTaxAINRecTaxTC = <M-1 RoundAmount
(input tPendingVoucherTaxAPM.APMatchingLnTaxAINRecTaxTC * vdPendingVoucherLineQty (idUnroundedAmount),
input ? (iiCurrencyID),
input tqPendingVoucherForMatchingNoLC.tcpvo_curr (icCurrencyCode)) in BApplicationProperty>.
end. /* if ilCallGTM = false and */
end. /* end else if tqPendingVoucherForMatchingNoLC.tctx2d_tr_type = {&VATTAXTRANSACTIONTYPE-APWHT} */
end. /* if tqPendingVoucherForMatchingNoLC.tctx2_tax_code <> ? and */
/* =================== */
/* Return-status = OK */
/* =================== */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.