Description
Write here all tests on database update (new / modify / delete) that cannot be coded with a validation mask.
The type of update can be found in tc_status (N/C/D).
If you find incorrect data, you must write an entry in tFcMessages (using SetMessage) and set the return status of this method to either +1 or -1.
Return status +1 = data will still be accepted.
Return status -1 = data will not be accepted.
This method is run from SetPublicTables, before transferring the received data into the class temp-tables.
Parameters
| oiReturnStatus | output | integer | |
Internal usage
unused
program code (program/bvatperiod.p)
/* ====================================== */
/* update extra fields that are not on UI */
/* ====================================== */
for each t_sVatPeriod where
t_sVatPeriod.tc_status = "C":U or
t_sVatPeriod.tc_status = "N":U :
assign t_sVatPeriod.VatPeriodYearPeriod = integer(string(t_sVatPeriod.VatPeriodYear, "9999":U) + string(t_sVatPeriod.VatPeriodPeriod, "99":U)).
end. /* for each */
/* ================================================================== */
/* When the status is set to 'open' then we indiciate that the period */
/* period is not checked (~validated) to set it as reported */
/* ================================================================== */
for each t_sVatPeriod where
t_sVatPeriod.VatPeriodStatus = {&VATPERIODSTATUS-OPEN} and
t_sVatPeriod.tc_Status = "C":U :
find t_iVatperiod where
t_iVatPeriod.tc_Rowid = t_sVatPeriod.tc_Rowid and
t_iVatPeriod.VatPeriodStatus <> {&VATPERIODSTATUS-OPEN}
no-lock no-error.
if available t_iVatperiod
then assign t_sVatPeriod.VatPeriodIsReportChecked = false.
end. /* for each t_sVatPeriod where */
<ANCESTOR-CODE>
/* Can be removed for the moment because no period closing function already exist
/* ============================================================================================== */
/* A Period cannot be set to Reported or Frozen if the CheckForReported has not yet been executed */
/* ============================================================================================== */
for each t_sVatPeriod where
t_sVatPeriod.VatPeriodIsReportChecked = false and
t_sVatPeriod.VatPeriodStatus = {&VATPERIODSTATUS-REPORTED} and
(t_sVatPeriod.tc_Status = "C":U or
t_sVatPeriod.tc_Status = "N":U)
no-lock :
assign vcMessage = trim(substitute(#T-4'Tax periods (&1) cannot be set to Reported or Frozen when they have not yet been checked. Use the Period Closing function to check the tax periods.':255(3864)t-4#,string(t_sVatPeriod.VatPeriodYear) + "/":U + string(t_sVatPeriod.VatPeriodPeriod)))
oiReturnStatus = -1.
<M-3 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input tVatPeriod.tc_Status (icFieldName),
input 'tVatPeriod.tc_Status':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tVatPeriod.tc_Rowid (icRowid),
input 'QADFIN-657':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
end. /* for each t_sVatPeriod */
*/
/* ============================================================ */
/* Modify of Year, Period, Startdate and Enddate isonly allowed */
/* if there is no posting on the period yet */
/* ============================================================ */
for each t_sVatPeriod where
t_sVatPeriod.tc_Status = "C":U and
can-find (first t_iVatPeriod where
t_iVatPeriod.tc_Rowid = t_sVatPeriod.tc_Rowid and
(t_iVatPeriod.VatPeriodYear <> t_sVatPeriod.VatPeriodYear or
t_iVatPeriod.VatPeriodPeriod <> t_sVatPeriod.VatPeriodPeriod or
t_iVatPeriod.VatPeriodStartDate <> t_sVatPeriod.VatPeriodStartDate or
t_iVatPeriod.VatPeriodEndDate <> t_sVatPeriod.VatPeriodEndDate))
no-lock:
<Q-1 run PostingVATByPeriodPeriodMark (all) (Read) (NoCache)
(input t_sVatPeriod.Company_ID, (CompanyId)
input t_sVatPeriod.VatPeriod_ID, (VATPeriodID)
input t_sVatPeriod.PeriodMark_ID, (PeriodMarkID)
output dataset tqPostingVATByPeriodPeriodMark) in BPosting >
find first tqPostingVATByPeriodPeriodMark no-lock no-error.
if available tqPostingVATByPeriodPeriodMark
then do:
assign vcMessage = trim(#T-5'You cannot modify the year, period, start, and end date of the tax period because postings exist for the tax period with that period mark.':255(3865)t-5#) + chr(10) +
trim(substitute(#T-6'Tax period: &1/&2.':255(3866)T-6#,string(t_sVatPeriod.VatPeriodYear),string(t_sVatPeriod.VatPeriodPeriod))) + chr(10) +
trim(substitute(#T-7'Period mark: &1.':255(3076)T-7#,string(t_sVatPeriod.tcPeriodMarkCode))) + chr(10) +
trim(substitute(#T-8'Posting Date: &1, Voucher: &2':255(3077)T-8#,string(tqPostingVATByPeriodPeriodMark.ttPostingDate),string(tqPostingVATByPeriodPeriodMark.tiVatPeriod_ID)))
oiReturnStatus = -1.
<M-2 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tVatPeriod.tcPeriodMarkCode':U (icFieldName),
input t_sVatPeriod.tcPeriodMarkCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sVatPeriod.tc_Rowid (icRowid),
input 'QADFIN-491':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
end. /* if av tqPostingVATByPeriodPeriodMark*/
end. /* for each t_sVatPeriod where */
/* ======================== */
/* Return in case of errors */
/* ======================== */
if oiReturnStatus < 0
then return.