Description
This empty method allows to do additional updates on class temp-tables after records were received (and validated) from outside, using method SetPublicTables.
You can start instances of other business classes to do those updates.
Parameters
| oiReturnStatus | output | integer | |
Internal usage
QadFinancials
program code (program/bvatperiod.p)
/* ======================================================================================================= */
/* First, we load all relevant VAT Period records in a separate temp-table. This will make it easier to do */
/* some additional validations, because we can just check this temp-table and don't have to check both the */
/* instance temp-table and the database. */
/* ======================================================================================================= */
assign vcMessage = "":U.
empty temp-table tVatPeriodTemp.
for each tVatPeriod where
tVatPeriod.tc_Status <> "D":U:
create tVatPeriodTemp.
buffer-copy tVatPeriod to tVatPeriodTemp.
end.
<Q-1 run VATPeriodByStartDate (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (Year)
input ?, (StartDate)
output dataset tqVATPeriodByStartDate) in BVATPeriod >
for each tqVATPeriodByStartDate:
if can-find (first tVatPeriodTemp where
tVatPeriodTemp.Company_ID = tqVATPeriodByStartDate.tiCompany_ID and
tVatPeriodTemp.VatPeriodYear = tqVATPeriodByStartDate.tiVatPeriodYear and
tVatPeriodTemp.VatPeriodPeriod = tqVATPeriodByStartDate.tiVatPeriodPeriod) or
can-find (first tVatPeriod where
tVatPeriod.Company_ID = tqVATPeriodByStartDate.tiCompany_ID and
tVatPeriod.VatPeriodYear = tqVATPeriodByStartDate.tiVatPeriodYear and
tVatPeriod.VatPeriodPeriod = tqVATPeriodByStartDate.tiVatPeriodPeriod and
tVatPeriod.tc_Status = "D":U)
then next.
create tVatPeriodTemp.
assign tVatPeriodTemp.Company_ID = tqVATPeriodByStartDate.tiCompany_ID
tVatPeriodTemp.VatPeriodEndDate = tqVATPeriodByStartDate.ttVatPeriodEndDate
tVatPeriodTemp.VatPeriodPeriod = tqVATPeriodByStartDate.tiVatPeriodPeriod
tVatPeriodTemp.VatPeriodStartDate = tqVATPeriodByStartDate.ttVatPeriodStartDate
tVatPeriodTemp.VatPeriodStatus = tqVATPeriodByStartDate.tcVatPeriodStatus
tVatPeriodTemp.VatPeriodYear = tqVATPeriodByStartDate.tiVatPeriodYear
tVatPeriodTemp.VatPeriodYearPeriod = (tqVATPeriodByStartDate.tiVatPeriodYear * 100) + tqVATPeriodByStartDate.tiVatPeriodPeriod
tVatPeriodTemp.VatPeriod_ID = tqVATPeriodByStartDate.tiVatPeriod_ID
tVatPeriodTemp.tc_Rowid = tqVATPeriodByStartDate.tc_Rowid.
end.
/* =========================================== */
/* Now we can easily do some extra validations */
/* =========================================== */
for each tVatPeriod where
tVatPeriod.tc_Status <> "D":U:
/* ============================================= */
/* The year of a VAT Period must be consecutive */
/* This means that either: */
/* * The previous year is already defined */
/* * This is the first year being defined */
/* ============================================= */
if not can-find (first tVatPeriodTemp where
tVatPeriodTemp.Company_ID = tVatPeriod.Company_ID and
tVatPeriodTemp.VatPeriodYear = tVatPeriod.VatPeriodYear - 1) and
can-find (first tVatPeriodTemp where
tVatPeriodTemp.Company_ID = tVatPeriod.Company_ID and
tVatPeriodTemp.VatPeriodYear < tVatPeriod.VatPeriodYear)
then do:
assign vcMessage = trim (subst (#T-8'You first must define the tax periods for &1.':100(3871)T-8#, string (tVatPeriod.VatPeriodYear - 1)))
oiReturnStatus = -1.
<M-2 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tVatPeriod.VatPeriodYear':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tVatPeriod.tc_Rowid (icRowid),
input 'QADFIN-190':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
end.
/* ============================================== */
/* The period of a VAT Period must be consecutive */
/* This means that either: */
/* * The previous period is already defined */
/* * This is the first period being defined */
/* ============================================== */
if tVatPeriod.VatPeriodPeriod > 1 and
not can-find (first tVatPeriodTemp where
tVatPeriodTemp.Company_ID = tVatPeriod.Company_ID and
tVatPeriodTemp.VatPeriodYear = tVatPeriod.VatPeriodYear and
tVatPeriodTemp.VatPeriodPeriod = tVatPeriod.VatPeriodPeriod - 1)
then do:
assign vcMessage = trim (subst (#T-9'You first must define tax period &1/&2.':100(3872)T-9#, string (tVatPeriod.VatPeriodYear), string (tVatPeriod.VatPeriodPeriod - 1)))
oiReturnStatus = -1.
<M-5 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tVatPeriod.VatPeriodPeriod':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tVatPeriod.tc_Rowid (icRowid),
input 'QADFIN-195':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
end.
/* ============================================= */
/* The start date of a VAT Period must be unique */
/* ============================================= */
if can-find (first tVatPeriodTemp where
tVatPeriodTemp.Company_ID = tVatPeriod.Company_ID and
tVatPeriodTemp.VatPeriodStartDate = tVatPeriod.VatPeriodStartDate and
tVatPeriodTemp.tc_Rowid <> tVatPeriod.tc_Rowid)
then do:
assign vcMessage = trim (#T-10'The start date of a tax period must be unique.':100(3873)T-10#)
oiReturnStatus = -1.
<M-3 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tVatPeriod.VatPeriodStartDate':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tVatPeriod.tc_Rowid (icRowid),
input 'QADFIN-191':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
end.
/* ================================================================ */
/* The start date of a VAT Period must be consecutive */
/* This means that either: */
/* * There is a period with end date 1 day before this start date */
/* * This is the first period being defined */
/* ================================================================ */
if not can-find (first tVatPeriodTemp where
tVatPeriodTemp.Company_ID = tVatPeriod.Company_ID and
tVatPeriodTemp.VatPeriodEndDate = tVatPeriod.VatPeriodStartDate - 1) and
can-find (first tVatPeriodTemp where
tVatPeriodTemp.Company_ID = tVatPeriod.Company_ID and
tVatPeriodTemp.VatPeriodEndDate < tVatPeriod.VatPeriodStartDate)
then do:
assign vcMessage = trim (subst (#T-11'You first must define a tax period ending on &1.':100(3874)T-11#, string (tVatPeriod.VatPeriodStartDate - 1)))
oiReturnStatus = -1.
<M-4 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tVatPeriod.VatPeriodStartDate':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tVatPeriod.tc_Rowid (icRowid),
input 'QADFIN-192':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
end.
/* ====================================== */
/* VAT Periods are not allowed to overlap */
/* ====================================== */
if can-find (first tVatPeriodTemp where
tVatPeriodTemp.Company_ID = tVatPeriod.Company_ID and
tVatPeriodTemp.VatPeriodStartDate <= tVatPeriod.VatPeriodStartDate and
tVatPeriodTemp.VatPeriodEndDate >= tVatPeriod.VatPeriodStartDate and
tVatPeriodTemp.tc_Rowid <> tVatPeriod.tc_Rowid) or
can-find (first tVatPeriodTemp where
tVatPeriodTemp.Company_ID = tVatPeriod.Company_ID and
tVatPeriodTemp.VatPeriodStartDate <= tVatPeriod.VatPeriodEndDate and
tVatPeriodTemp.VatPeriodEndDate >= tVatPeriod.VatPeriodEndDate and
tVatPeriodTemp.tc_Rowid <> tVatPeriod.tc_Rowid) or
can-find (first tVatPeriodTemp where
tVatPeriodTemp.Company_ID = tVatPeriod.Company_ID and
tVatPeriodTemp.VatPeriodStartDate >= tVatPeriod.VatPeriodStartDate and
tVatPeriodTemp.VatPeriodEndDate <= tVatPeriod.VatPeriodEndDate and
tVatPeriodTemp.tc_Rowid <> tVatPeriod.tc_Rowid) or
can-find (first tVatPeriodTemp where
tVatPeriodTemp.Company_ID = tVatPeriod.Company_ID and
tVatPeriodTemp.VatPeriodStartDate <= tVatPeriod.VatPeriodStartDate and
tVatPeriodTemp.VatPeriodEndDate >= tVatPeriod.VatPeriodEndDate and
tVatPeriodTemp.tc_Rowid <> tVatPeriod.tc_Rowid)
then do:
assign vcMessage = trim (#T-12'Tax periods cannot overlap in time.':100(3875)T-12#)
oiReturnStatus = -1.
<M-6 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tVatPeriod.VatPeriodStartDate':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tVatPeriod.tc_Rowid (icRowid),
input 'QADFIN-202':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
end.
end.
if not can-find (first tVatPeriod where
tVatPeriod.tc_Status <> "D":U)
then do:
find first tVatPeriod.
if can-find (first tVatPeriodTemp where
tVatPeriodTemp.Company_ID = tVatPeriod.Company_ID and
tVatPeriodTemp.VatPeriodYear < tVatPeriod.VatPeriodYear) and
can-find (first tVatPeriodTemp where
tVatPeriodTemp.Company_ID = tVatPeriod.Company_ID and
tVatPeriodTemp.VatPeriodYear > tVatPeriod.VatPeriodYear)
then do:
assign vcMessage = trim (#T-13'You can only delete the first or last tax year.':100(3876)T-13#)
oiReturnStatus = -1.
<M-7 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tVatPeriod.tc_Rowid (icRowid),
input 'QADFIN-279':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
end.
end.
if oiReturnStatus < 0
then return.
<ANCESTOR-CODE>