project QadFinancials > class BCInvoice > method GetWHTDescriptionAndCCExch
Description
As GTM doesn't return the VAT description or the CC values, this methods returns those to the UI
Parameters
icCInvoiceRowId | input | character | |
icWHTCode | input | character | Withholding Tax Code |
icCInvoiceCurrencyCode | input | character | |
iiCInvoiceCurrencyID | input | integer | |
idFeeDebitTC | input | decimal | This should be the TC-Fee and not the Taxable-TC-Fee |
idFeeCreditTC | input | decimal | This should be the TC-Fee and not the Taxable-TC-Fee |
idTaxFeeDebitTC | input | decimal | This should be the TC-WHT amount |
idTaxFeeCreditTC | input | decimal | This should be the TC-WHT amount |
itCInvoicePostingDate | input | date | |
itCInvoiceDate | input | date | |
odCCExchangeRate | output | decimal | |
odCCExchangeScale | output | decimal | |
odFeeDebitCC | output | decimal | This is the SC-Taxable-Fee and not the SC-Fee |
odFeeCreditCC | output | decimal | This is the SC-Taxable-Fee and not the SC-Fee |
odTaxFeeDebitCC | output | decimal | This is the SC-WHT amount |
odTaxFeeCreditCC | output | decimal | This is the SC-WHT amount |
ocVatDescription | output | character | |
odWHTBasePercentage | output | decimal | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bcinvoice.p)
assign
oiReturnStatus = -98
viLocalReturnStatus = 0.
/******************************/
/* Normalize input parameters */
/******************************/
if icCInvoiceRowId = ? then assign icCInvoiceRowId = "":U.
if icWHTCode = ? then assign icWHTCode = "":U.
if idFeeDebitTC = ? then assign idFeeDebitTC = 0.
if idTaxFeeCreditTC = ? then assign idTaxFeeCreditTC = 0.
/*****************************/
/* Default output parameters */
/*****************************/
assign ocVatDescription = "":U
odFeeCreditCC = 0
odFeeDebitCC = 0
odTaxFeeCreditCC = 0
odTaxFeeDebitCC = 0
odCCExchangeRate = 0
odCCExchangeScale = 0.
/*****************************/
/* Validate input parameters */
/*****************************/
if icCInvoiceRowId = "":U
then do:
assign vcMessage = trim(#T-72'The specified supplier invoice is not defined in the system or is invalid. ':80(2986)T-72#)
oiReturnStatus = -1.
<M-52 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'CInvoiceRowid':U (icFieldName),
input icCInvoiceRowId (icFieldValue),
input 'S':U (icType),
input 2 (iiSeverity),
input '':U (icRowid),
input 'qadfin-886737':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
return.
end. /* if icCInvoiceRowId */
if icWHTCode = "":U
then do:
assign vcMessage = trim(#T-42'The specified WHT Code is not defined in the system or is invalid.':80(65675538)T-42#)
oiReturnStatus = -1.
<M-74 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'WHT Code':U (icFieldName),
input icWHTCode (icFieldValue),
input 'S':U (icType),
input 2 (iiSeverity),
input '':U (icRowid),
input 'qadfin-843584':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
return.
end. /* if icWHTCode */
/***********************/
/* Get Currency ID */
/***********************/
if iiCInvoiceCurrencyId = 0 and
icCInvoiceCurrencyCode <> "":U
then do:
<Q-19 run CurrencyPrim (all) (Read) (NoCache)
(input icCInvoiceCurrencyCode, (CurrencyCode)
input ?, (Currency_ID)
output dataset tqCurrencyPrim) in BCurrency >
find first tqCurrencyPrim where tqCurrencyPrim.tcCurrencyCode = icCInvoiceCurrencyCode no-error.
if available tqCurrencyPrim
then assign iiCInvoiceCurrencyId = tqCurrencyPrim.tiCurrency_ID.
end. /* if iiCInvoiceCurrencyId = 0 */
else if available tCInvoice and
iiCInvoiceCurrencyId = 0 and
icCInvoiceCurrencyCode = "":U
then assign iiCInvoiceCurrencyId = tCInvoice.CInvoiceCurrency_ID.
/************************/
/* Get Supplier Invoice */
/************************/
find tCInvoice where
tCInvoice.tc_Rowid = icCInvoiceRowId
no-error.
if not available tCInvoice
then do:
assign vcMessage = trim(#T-96'The specified supplier invoice is not defined in the system or is invalid.':80(999890907)T-96#)
oiReturnStatus = -1.
<M-59 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'D':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-688056':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
return.
end. /* if not available tCInvoice */
/******************/
/* Get Tax Fields */
/******************/
if icWHTCode <> "":U and
icWHTCode <> ?
then do:
<Q-37 run VATPrim (all) (Read) (NoCache)
(input ?, (VatId)
input icWHTCode, (VatCode)
input ?, (DomainId)
input vcDomainCode, (DomainCode)
input {&VATINOUT-INPUT}, (VatInOut)
output dataset tqVATPrim) in BVAT >
find first tqVatPrim where
tqVATPrim.tcVatCode = icWHTCode
no-lock no-error.
assign ocVatDescription = if available tqVATPrim
then tqVATPrim.tcVatDescription
else "":U.
/* Get WHT Base Percentage from Tax Base linked to the tax code */
assign odWHTBasePercentage = 100.
<Q-87 run MfgTaxCodeByTaxCode (all) (Read) (Cache)
(input icWHTCode, (TaxCode)
input vcDomainCode, (DomainCode)
input ?, (DiscountAtPayment)
input ?, (IsTaxByLine)
output dataset tqMfgTaxCodeByTaxCode) in BMfgTaxCode>
find first tqMfgTaxCodeByTaxCode
where tqMfgTaxCodeByTaxCode.tctx2_tax_code = icWHTCode no-error.
if available tqMfgTaxCodeByTaxCode
then do:
if tqMfgTaxCodeByTaxCode.tctx2_base <> "" and
tqMfgTaxCodeByTaxCode.tctx2_base <> ?
then do:
<Q-49 run GeneralizedCodeForSecurity (all) (Read) (Cache)
(input vcDomainCode, (DomainCode)
input 'txb_base', (CodeFldName)
input tqMfgTaxCodeByTaxCode.tctx2_base, (CodeValue)
output dataset tqGeneralizedCodeForSecurity) in BMfgGeneralizedCode>
find first tqGeneralizedCodeForSecurity where
tqGeneralizedCodeForSecurity.tccode_domain = vcDomainCode and
tqGeneralizedCodeForSecurity.tccode_fldname = 'txb_base' and
tqGeneralizedCodeForSecurity.tccode_value = tqMfgTaxCodeByTaxCode.tctx2_base
no-lock no-error.
if available tqGeneralizedCodeForSecurity
then do:
assign vcWHTBasePercentage = substring(tqGeneralizedCodeForSecurity.tccode_cmmt, 1, 9, "CHARACTER").
if vcWHTBasePercentage <> "" and
vcWHTBasePercentage <> ?
then assign odWHTBasePercentage = decimal(vcWHTBasePercentage) no-error.
if error-status:error
then assign odWHTBasePercentage = 100.
end. /* if available tqGeneralizedCodeForSecurity */
end. /* if tqMfgTaxCodeByTaxCode.tctx2_base <> "" and */
end. /* if tqMfgTaxCodeByTaxCode.tctx2_base <> "" and */
end. /* if icWHTCode <> "":U */
/************/
/* TC to CC */
/************/
if icCInvoiceCurrencyCode <> "":U and
icCInvoiceCurrencyCode = vcCompanyCC
then do:
assign odCCExchangeRate = 1
odCCExchangeScale = 1.
end. /* if icCInvoiceCurrencyCode */
else do:
<M-33 run GetExRateByEntityInvoiceFlag
(input itCInvoiceDate (itCInvoiceDate),
input itCInvoicePostingDate (itCInvoicePostingDate),
input ? (iiFromCurrencyId),
input icCInvoiceCurrencyCode (icFromCurrencyCode),
input viCompanyCCId (iiToCurrencyId),
input vcCompanyCC (icToCurrencyCode),
input 0 (iiExchangeRateTypeId),
input {&EXCHANGERATETYPE-VAT} (icExchangeRateTypeCode),
output odCCExchangeRate (odCInvoiceExchangeRate),
output odCCExchangeScale (odCInvoiceRateScale),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper < 0 or viLocalReturnStatus = 0
then assign viLocalReturnStatus = viFcReturnSuper.
end. /* else do */
assign
odTaxFeeDebitCC = <M-78 RoundAmount
(input idTaxFeeDebitTC * odCCExchangeRate * odCCExchangeScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BCInvoice>
odTaxFeeCreditCC = <M-23 RoundAmount
(input idTaxFeeCreditTC * odCCExchangeRate * odCCExchangeScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BCInvoice>
odFeeDebitCC = <M-85 RoundAmount
(input idFeeDebitTC * odWHTBasePercentage / 100 * odCCExchangeRate * odCCExchangeScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BCInvoice>
odFeeCreditCC = <M-80 RoundAmount
(input idFeeCreditTC * odWHTBasePercentage / 100 * odCCExchangeRate * odCCExchangeScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BCInvoice>.
assign oiReturnStatus = viLocalReturnStatus.