report procedure
Description
Third Party Compensation Report
Parameters
Internal usage
unused
program code (program7/bcreditorreport.p)
empty temp-table tqCreditorWithholdingTaxDue.
<M-47 run GetReportLabels
(input 'CreditorWithholdingTaxDue' (icReportName),
input icLanguageCode (icLanguageCode),
input tFilter (tFilter),
output tqHeader (tqHeader),
output tqFilter (tqFilter),
output tqText (tqText),
output oiReturnStatus (oiReturnStatus)) in BCreditorReport>
if oiReturnStatus <> 0 then
return.
<M-76 run SetDataItemsBasedOnFilterTT (output oiReturnStatus (oiReturnStatus)) in BCreditorReport>
if viAccYearFilter1 = ? then
viAccYearFilter1 = Year(now).
if viPaymentMonth = ? then
viPaymentMonth = Month(now).
if vcCurrencyCodeFilter1 = ? then
do:
<Q-35 run DomainPropertyForCurrency (all) (Read) (NoCache)
(input viDomainID, (DomainID)
output dataset tqDomainPropertyForCurrency) in BDomainProperty >
find first tqDomainPropertyForCurrency no-error.
if available tqDomainPropertyForCurrency then
vcCurrencyCodeFilter1 = tqDomainPropertyForCurrency.tcBaseCurrencyCode.
end.
/*
<Q-4 run GetWHTWithPayment (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input vcFromCreditorCodeFilter1, (FromCreditorCode)
input vcToCreditorCodeFilter1, (ToCreditorCode)
input vcPaySelCodeFilter, (PaymentSelCode)
input viToCDocumentNumberFilter, (PaymentNumberTo)
input viFromCDocumentNumberFilter, (PaymentNumberFrom)
input viAccYearFilter1, (Year)
input viPaymentMonth, (Month)
input vcCertificateFormatFilter, (CertFormatCode)
input viFromWHTNumberFilter, (WHTNumberFrom)
input viToWHTNumberFilter, (WHTNumberTo)
output dataset tqGetWHTWithPayment) in BCreditorReport >
*/
<Q-32 run GetWHTWithPayments (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input vcCertificateFormatFilter, (CertFormatCode)
input vcFromCreditorCodeFilter1, (FromCreditorCode)
input viPaymentMonth, (Month)
input viFromCDocumentNumberFilter, (PaymentNumberFrom)
input viToCDocumentNumberFilter, (PaymentNumberTo)
input vcPaySelCodeFilter, (PaymentSelCode)
input vcToCreditorCodeFilter1, (ToCreditorCode)
input viFromWHTNumberFilter, (WHTNumberFrom)
input viToWHTNumberFilter, (WHTNumberTo)
input viAccYearFilter1, (Year)
output dataset tqGetWHTWithPayments) in BCreditorReport >
define buffer bufCreditorWithholdingTaxDue for tqCreditorWithholdingTaxDue.
for each tqGetWHTWithPayments break by tqGetWHTWithPayments.tcCreditorCode :
Create tqCreditorWithholdingTaxDue.
buffer-copy tqGetWHTWithPayments to tqCreditorWithholdingTaxDue.
tqCreditorWithholdingTaxDue.tcCurrencyBC = vcCurrencyCodeFilter1.
tqCreditorWithholdingTaxDue.tcCInvoiceReference = string(tqGetWHTWithPayments.tiCInvoicePostingYear)
+ "/" + tqGetWHTWithPayments.tcJournalCode + "/" + string(tqGetWHTWithPayments.tiCInvoiceVoucher, "999999999").
assign vhFcComponent = ?.
<Q-97 run CurrencyById (all) (Read) (NoCache)
(input tqGetWHTWithPayments.tiCInvoiceCurrency_ID, (CurrencyId)
output dataset tqCurrencyById) in BCurrency >
for first tqCurrencyById:
end.
if available tqCurrencyById then
do:
if tqCurrencyById.tcCurrencyCode = vcCurrencyCodeFilter1 then
assign
vdVATExchangeRateTC2RC = 1
vdVATExchangeRateTC2RCS = 1
vdExchangeRateTC2RC = 1
vdExchangeRateTC2RCS = 1.
else
do:
/* Exchange rate from TC to Report Currency */
<M-83 run GetExchangeRate
(input ? (iiCompanyID),
input tqGetWHTWithPayments.tiCInvoiceCurrency_ID (iiFromCurrencyID),
input ? (icFromCurrencyCode),
input ? (iiToCurrencyID),
input vcCurrencyCodeFilter1 (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-VAT} (icExchangeRateTypeCode),
input today (itValidityDate),
output vdVATExchangeRateTC2RC (odExchangeRate),
output vdVATExchangeRateTC2RCS (odExchangeScaleFactor),
output oiReturnStatus (oiReturnStatus)) in BCreditorReport>
if oiReturnStatus < 0 then
return.
<M-73 run GetExchangeRate
(input ? (iiCompanyID),
input tqGetWHTWithPayments.tiCInvoiceCurrency_ID (iiFromCurrencyID),
input ? (icFromCurrencyCode),
input ? (iiToCurrencyID),
input vcCurrencyCodeFilter1 (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input today (itValidityDate),
output vdExchangeRateTC2RC (odExchangeRate),
output vdExchangeRateTC2RCS (odExchangeScaleFactor),
output oiReturnStatus (oiReturnStatus)) in BCreditorReport>
if oiReturnStatus < 0 then
return.
end.
end.
vdExchangeRateTC2RC = vdExchangeRateTC2RC * vdExchangeRateTC2RCS.
vdVATExchangeRateTC2RC = vdVATExchangeRateTC2RC * vdVATExchangeRateTC2RCS.
if tqGetWHTWithPayments.tcWHTChargeType = "WHTFEE" then
do:
assign
tqCreditorWithholdingTaxDue.tdCInvoiceWHTFee = (tqGetWHTWithPayments.tdWHTChargeAmtCreditTC - tqGetWHTWithPayments.tdWHTChargeAmtDebitTC)
* vdExchangeRateTC2RC
tqCreditorWithholdingTaxDue.tdCInvoiceWHTExpense = 0.
end.
if tqGetWHTWithPayments.tcWHTChargeType = "WHTEXPENSE" then
do:
assign
tqCreditorWithholdingTaxDue.tdCInvoiceWHTFee = 0
tqCreditorWithholdingTaxDue.tdCInvoiceWHTExpense = (tqGetWHTWithPayments.tdWHTChargeAmtCreditTC - tqGetWHTWithPayments.tdWHTChargeAmtDebitTC)
* vdExchangeRateTC2RC.
end.
assign
tqCreditorWithholdingTaxDue.tdWHTTotAmt = (tqGetWHTWithPayments.tdWHTTotAmtCreditLC - tqGetWHTWithPayments.tdWHTTotAmtDebitLC)
* vdExchangeRateTC2RC
tqCreditorWithholdingTaxDue.tdCInvoiceOriginal = (tqGetWHTWithPayments.tdCInvoiceOriginalCreditTC - tqGetWHTWithPayments.tdCInvoiceOriginalDebitTC)
* vdExchangeRateTC2RC
tqCreditorWithholdingTaxDue.tdWHTAmt = (tqGetWHTWithPayments.tdWHTAmtCreditTC - tqGetWHTWithPayments.tdWHTAmtDebitTC)
* vdVATExchangeRateTC2RC
tqCreditorWithholdingTaxDue.tdWHTTaxableFees = (tqGetWHTWithPayments.tdWHTTaxableFeesCreditTC - tqGetWHTWithPayments.tdWHTTaxableFeesDebitTC)
* vdExchangeRateTC2RC
tqCreditorWithholdingTaxDue.tdWHTTax = (tqGetWHTWithPayments.tdWHTVATAmtCreditTC - tqGetWHTWithPayments.tdWHTVATAmtDebitTC)
* vdExchangeRateTC2RC
tqCreditorWithholdingTaxDue.tdWHTTotalPaid = (tqGetWHTWithPayments.tdWHTPaidAmtDebitTC - tqGetWHTWithPayments.tdWHTPaidAmtCreditTC)
* vdExchangeRateTC2RC.
assign
vdTotalAmountPaid = vdTotalAmountPaid + tqCreditorWithholdingTaxDue.tdWHTTotalPaid
vdTotalWHTAmount = vdTotalWHTAmount + tqCreditorWithholdingTaxDue.tdWHTAmt.
if vlWHTByPaymentFilter and vcWHTDescription <> "" and vcWHTDescription <> ? then
do:
tqCreditorWithholdingTaxDue.tcVATDescription = vcWHTDescription.
end.
end.
if vlWHTByPaymentFilter and (vcWHTDescription = "" or vcWHTDescription = ?) then
do:
for each tqCreditorWithholdingTaxDue break by tqCreditorWithholdingTaxDue.tiCDocument_ID by tqCreditorWithholdingTaxDue.tdWHTAmt desc:
if first-of (tqCreditorWithholdingTaxDue.tiCDocument_ID) then
do:
for each bufCreditorWithholdingTaxDue where bufCreditorWithholdingTaxDue.tiCDocument_ID = tqCreditorWithholdingTaxDue.tiCDocument_ID:
bufCreditorWithholdingTaxDue.tcVatDescription = tqCreditorWithholdingTaxDue.tcVatDescription.
end.
end.
end.
end.