report procedure
Description
Reports invoices where the reporting daybook differs from the invoice daybook
Parameters
Internal usage
unused
program code (program7/breportingjournalreport.p)
/* ============================= */
/* Default return status */
/* ============================= */
assign oiReturnStatus = -98.
empty temp-table tqReportingJournalExceptReport.
<M-1 run GetReportLabels
(input 'ReportingJournalExceptReport':U (icReportName),
input icLanguageCode (icLanguageCode),
input tFilter (tFilter),
output tqHeader (tqHeader),
output tqFilter (tqFilter),
output tqText (tqText),
output viFcReturnSuper (oiReturnStatus)) in BReportingJournalReport>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-3 run SetDataItemsBasedOnFilterTT (output viFcReturnSuper (oiReturnStatus)) in BReportingJournalReport>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-6 run ReportingExceptionFilterValidation (output viFcReturnSuper (oiReturnStatus)) in BReportingJournalReport>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* if tax register is populated, add the daybooks and entities to filter */
if (vcTaxRegisterFilter <> "":U)
then do viTaxRegisterIterator = 1 to num-entries(vcTaxRegisterFilter,",":U):
assign vcCurrentTaxRegister = entry(viTaxRegisterIterator,vcTaxRegisterFilter,",":U).
<Q-7 run TaxRegisterByCompany (all) (Read) (NoCache)
(input vcCurrentTaxRegister, (TaxRegCode)
input ?, (CompanyId)
output dataset tqTaxRegisterByCompany) in BReportingJournalReport >
if (vcCompanyListFilter = ?) then assign vcCompanyListFilter = "":U.
for each tqTaxRegisterByCompany where
tqTaxRegisterByCompany.tcTaxRegCode = vcCurrentTaxRegister :
if lookup(tqTaxRegisterByCompany.tcCompanyCode, vcCompanyListFilter) = 0 then
assign vcCompanyListFilter = vcCompanyListFilter + ",":U + tqTaxRegisterByCompany.tcCompanyCode.
end.
<Q-10 run TaxRegisterByJournal (all) (Read) (NoCache)
(input ?, (CompanyId)
input vcCurrentTaxRegister, (TaxRegCode)
output dataset tqTaxRegisterByJournal) in BReportingJournalReport >
if (vcDaybookCodeListFilter = ?) then assign vcDaybookCodeListFilter = "":U.
for each tqTaxRegisterByJournal where
tqTaxRegisterByJournal.tcTaxRegCode = vcCurrentTaxRegister:
if lookup(tqTaxRegisterByJournal.tcJournalCode, vcDaybookCodeListFilter) = 0 then
assign vcDaybookCodeListFilter = vcDaybookCodeListFilter + ",":U + tqTaxRegisterByJournal.tcJournalCode.
end. /*for each tqTaxRegisterByJournal */
end. /* if (vcTaxRegisterFilter <> "":U) */
<M-11 run GetPostingDateFromFilter (output viFcReturnSuper (oiReturnStatus)) in BReportingJournalReport>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* if CompanyListFilter is still empty - default to all companies in this domain */
if (vcCompanyListFilter = "":U or vcCompanyListFilter = ?)
then do:
assign vcCompanyListFilter = "":U.
<Q-12 run CompanyByDomain (all) (Read) (NoCache)
(input ?, (CompanyId)
input viDomainID, (DomainId)
input true, (Active)
output dataset tqCompanyByDomain) in BCompany >
for each tqCompanyByDomain:
assign vcCompanyListFilter = vcCompanyListFilter + ",":U + tqCompanyByDomain.tcCompanyCode.
end.
end. /* if (vcCompanyListFilter = "":U */
/* Start the queries used in this do loop */
<Q-13 run CompanyPrim (Start) in BCompany >
<Q-15 run PostingByReportingJournalExcep (Start) in BReportingJournalReport >
/* get all the company codes */
do viCompanyIterator = 1 to num-entries(vcCompanyListFilter,",":U):
assign vcCurrentCompany = entry(viCompanyIterator,vcCompanyListFilter,",":U).
if (vcCurrentCompany = "":U or vcCurrentCompany = ?)
then next.
<Q-4 run CompanyPrim (all) (Read) (NoCache)
(input ?, (LookupCompanyId)
input vcCurrentCompany, (CompanyCode)
output dataset tqCompanyPrim) in BCompany >
find first tqCompanyPrim
where tqCompanyPrim.tcCompanyCode = vcCurrentCompany no-error.
if available tqCompanyPrim
then assign viCurrentCompany_ID = tqCompanyPrim.tiCompany_ID.
<Q-5 run PostingByReportingJournalExcep (all) (Read) (NoCache)
(input viCurrentCompany_ID, (CompanyId)
input vtFromPostingDateFilter1, (FromPostingDate)
input vtToPostingDateFilter1, (ToPostingDate)
output dataset tqPostingByReportingJournalExcep) in BReportingJournalReport >
for each tqPostingByReportingJournalExcep where
tqPostingByReportingJournalExcep.tiCompany_ID = viCurrentCompany_ID and
tqPostingByReportingJournalExcep.ttPostingDate >= vtFromPostingDateFilter1 and
tqPostingByReportingJournalExcep.ttPostingDate <= vtToPostingDateFilter1 :
if (vcDaybookCodeListFilter = ? or vcDaybookCodeListFilter = "":U or
lookup(tqPostingByReportingJournalExcep.tcJournalCode, vcDaybookCodeListFilter) > 0)
and
(vcReportingDaybookListFilter = ? or vcReportingDaybookListFilter = "":U or
lookup(tqPostingByReportingJournalExcep.tcReportingJournalCode, vcReportingDaybookListFilter)> 0)
then do:
create tqReportingJournalExceptReport.
assign
tqReportingJournalExceptReport.tcPostingYearPeriod = string(tqPostingByReportingJournalExcep.tiPostingYear, "9999":U) + "/":U +
string(tqPostingByReportingJournalExcep.tiPostingPeriod, "99":U)
tqReportingJournalExceptReport.tcInvoiceNumber = string(tqPostingByReportingJournalExcep.tiPostingYear, "9999":U) + "/":U +
string(tqPostingByReportingJournalExcep.tiPostingPeriod, "99":U) + "/":U +
tqPostingByReportingJournalExcep.tcJournalCode + "/":U +
string(tqPostingByReportingJournalExcep.tiPostingVoucher, "999999999":U)
tqReportingJournalExceptReport.tcCompany = vcCurrentCompany
tqReportingJournalExceptReport.tcDescription = tqPostingByReportingJournalExcep.tcReportingJournalDescription
tqReportingJournalExceptReport.tcDaybookCode = tqPostingByReportingJournalExcep.tcJournalCode
tqReportingJournalExceptReport.tcReportingDaybookCode = tqPostingByReportingJournalExcep.tcReportingJournalCode
tqReportingJournalExceptReport.ttPostingDate = tqPostingByReportingJournalExcep.ttPostingDate.
end. /*if (vcDaybookCodeListFilter = ? */
end. /* For each tqPostingByReportingJournalExcep*/
end. /* do viCompanyIterator = 1 */
/* Start the queries used in this do loop */
<Q-14 run CompanyPrim (Stop) in BCompany >
<Q-16 run PostingByReportingJournalExcep (Stop) in BReportingJournalReport >
/* ============================= */
/* Default return status */
/* ============================= */
if oiReturnStatus = -98 then
assign oiReturnStatus = 0.