project QadFinancials > class BCInvoice > method DefaultValuesWHTCode
Description
This method will return the default values associated with a WHT and also the taxable fees and wht amount if required
Parameters
icCInvoiceRowId | input | character | CInvoice RowId |
icCInvoiceType | input | character | Invoice Type |
icWHTCode | input | character | |
bdCInvoiceWHTFeesDebitTC | input-output | decimal | |
bdCInvoiceWHTFeesCreditTC | input-output | decimal | |
icCInvoiceCurrencyCode | input | character | |
iiCInvoiceCurrencyId | input | integer | |
idCInvoiceExchangeRate | input | decimal | |
idCInvoiceExchangeRateScale | input | decimal | |
itCInvoicePostingDate | input | date | Posting Date of the invoice |
itCInvoiceDate | input | date | |
ocTx2TaxType | output | character | |
ocTx2Desc | output | character | |
odTx2TaxPct | output | decimal | |
odWHTBasePercentage | output | decimal | |
ocWHTAcct | output | character | |
ocWHTSubAcct | output | character | |
odCInvoiceWHTTaxableFeesDebitTC | output | decimal | |
odCInvoiceWHTTaxableFeesCreditTC | output | decimal | |
odCInvoiceWHTTaxableFeesDebitLC | output | decimal | |
odCInvoiceWHTTaxableFeesCreditLC | output | decimal | |
odCInvoiceWHTTaxableFeesDebitCC | output | decimal | |
odCInvoiceWHTTaxableFeesCreditCC | output | decimal | |
odCInvoiceWHTAmountDebitTC | output | decimal | |
odCInvoiceWHTAmountCreditTC | output | decimal | |
odCInvoiceWHTAmountDebitLC | output | decimal | |
odCInvoiceWHTAmountCreditLC | output | decimal | |
odCInvoiceWHTAmountDebitCC | output | decimal | |
odCInvoiceWHTAmountCreditCC | output | decimal | |
olWHTIsUpdAllow | output | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
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 bdCInvoiceWHTFeesDebitTC = ? then assign bdCInvoiceWHTFeesDebitTC = 0.
if bdCInvoiceWHTFeesCreditTC = ? then assign bdCInvoiceWHTFeesCreditTC = 0.
if icCInvoiceType = ? then assign icCInvoiceType = "":U.
/*****************************/
/* Default output parameters */
/*****************************/
assign ocTx2Desc = "":U
ocTx2TaxType = "":U
ocWHTAcct = "":U
ocWHTSubAcct = "":U
olWHTISUpdAllow = false
odWHTBasePercentage = 0
odTx2TaxPct = 0
odCInvoiceWHTAmountCreditCC = 0
odCInvoiceWHTAmountCreditLC = 0
odCInvoiceWHTAmountCreditTC = 0
odCInvoiceWHTAmountDebitCC = 0
odCInvoiceWHTAmountDebitLC = 0
odCInvoiceWHTAmountDebitTC = 0
odCInvoiceWHTTaxableFeesCreditCC = 0
odCInvoiceWHTTaxableFeesCreditLC = 0
odCInvoiceWHTTaxableFeesCreditTC = 0
odCInvoiceWHTTaxableFeesDebitCC = 0
odCInvoiceWHTTaxableFeesDebitLC = 0
odCInvoiceWHTTaxableFeesDebitTC = 0.
/*****************************/
/* Validate input parameters */
/*****************************/
if icCInvoiceRowId = "":U
then do:
assign vcMessage = trim(#T-68'The specified supplier invoice is not defined in the system or is invalid. ':80(2986)T-68#)
oiReturnStatus = -1.
<M-40 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-110919':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
return.
end.
if icCInvoiceType = "":U
then do:
assign vcMessage = trim(#T-41'The specified supplier invoice type is not defined in the system or is invalid.':80(996402287)T-41#)
oiReturnStatus = -1.
<M-73 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'CInvoice Type':U (icFieldName),
input icCInvoiceType (icFieldValue),
input 'S':U (icType),
input 2 (iiSeverity),
input '':U (icRowid),
input 'qadfin-795022':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
return.
end.
if icWHTCode = "":U
then do:
assign vcMessage = trim(#T-66'The specified WHT Code is not defined in the system or is invalid.':80(65675538)T-66#)
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-889063':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
return.
end.
/************************/
/* Get Supplier Invoice */
/************************/
find tCInvoice where
tCInvoice.tc_Rowid = icCInvoiceRowId
no-error.
if not available tCInvoice
then do:
assign vcMessage = trim(#T-36'The specified supplier invoice is not defined in the system or is invalid.':80(999890907)T-36#)
oiReturnStatus = -1.
<M-11 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-842054':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:
assign odWHTBasePercentage = 100.
<Q-37 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-77 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 */
assign ocTx2Desc = tqMfgTaxCodeByTaxCode.tctx2_desc
ocTx2TaxType = tqMfgTaxCodeByTaxCode.tctx2_tax_type
odTx2TaxPct = tqMfgTaxCodeByTaxCode.tdtx2_tax_pct
olWHTISUpdAllow = tqMfgTaxCodeByTaxCode.tltx2_update_tax.
if icCInvoiceType = {&INVOICETYPE-INVOICE} or
icCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then do:
assign ocWHTAcct = tqMfgTaxCodeByTaxCode.tctx2_ap_acct
ocWHTSubAcct = tqMfgTaxCodeByTaxCode.tctx2_ap_sub.
end. /* if icCInvoiceType */
else if icCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
icCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then do:
assign ocWHTAcct = tqMfgTaxCodeByTaxCode.tctx2_ap_cn_acct
ocWHTSubAcct = tqMfgTaxCodeByTaxCode.tctx2_ap_cn_sub.
end. /* else if icCInvoiceType */
end. /* if available tqMfgTaxCodeByTaxCode */
end. /* if icWHTCode <> "":U */
/*********************************************/
/* Update Taxable Fees and WHT Amount fields */
/*********************************************/
if (bdCInvoiceWHTFeesDebitTC <> 0 and
bdCInvoiceWHTFeesDebitTC <> ?) or
(bdCInvoiceWHTFeesCreditTC <> 0 and
bdCInvoiceWHTFeesCreditTC <> ?)
then do:
<M-15 run DefaultValuesWHTFees
(input icCInvoiceRowId (icCInvoiceRowId),
input-output bdCInvoiceWHTFeesDebitTC (bdCInvoiceWHTFeesDebitTC),
input-output bdCInvoiceWHTFeesCreditTC (bdCInvoiceWHTFeesCreditTC),
input icCInvoiceCurrencyCode (icCInvoiceCurrencyCode),
input iiCInvoiceCurrencyId (iiCInvoiceCurrencyId),
input idCInvoiceExchangeRate (idCInvoiceExchangeRate),
input idCInvoiceExchangeRateScale (idCInvoiceExchangeRateScale),
input odWHTBasePercentage (idWHTBasePercentage),
input odTx2TaxPct (idTxTaxPct),
input itCInvoicePostingDate (itCInvoicePostingDate),
input itCInvoiceDate (itCInvoiceDate),
output odCInvoiceWHTTaxableFeesDebitTC (odCInvoiceWHTTaxableFeesDebitTC),
output odCInvoiceWHTTaxableFeesCreditTC (odCInvoiceWHTTaxableFeesCreditTC),
output odCInvoiceWHTTaxableFeesDebitLC (odCInvoiceWHTTaxableFeesDebitLC),
output odCInvoiceWHTTaxableFeesCreditLC (odCInvoiceWHTTaxableFeesCreditLC),
output odCInvoiceWHTTaxableFeesDebitCC (odCInvoiceWHTTaxableFeesDebitCC),
output odCInvoiceWHTTaxableFeesCreditCC (odCInvoiceWHTTaxableFeesCreditCC),
output odCInvoiceWHTAmountDebitTC (odCInvoiceWHTAmountDebitTC),
output odCInvoiceWHTAmountCreditTC (odCInvoiceWHTAmountCreditTC),
output odCInvoiceWHTAmountDebitLC (odCInvoiceWHTAmountDebitLC),
output odCInvoiceWHTAmountCreditLC (odCInvoiceWHTAmountCreditLC),
output odCInvoiceWHTAmountDebitCC (odCInvoiceWHTAmountDebitCC),
output odCInvoiceWHTAmountCreditCC (odCInvoiceWHTAmountCreditCC),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper < 0 or viLocalReturnStatus = 0
then assign viLocalReturnStatus = viFcReturnSuper.
end. /* if idCInvoiceWHTFeesDebitTC <> 0 */
assign oiReturnStatus = viLocalReturnStatus.