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/btaxregister.p)
<ANCESTOR-CODE>
for each t_sTaxReg where
t_sTaxReg.tc_Status <> "D":U:
if t_sTaxReg.tc_Status <> "N":U
then do:
find t_iTaxReg where
t_iTaxReg.tc_Rowid = t_sTaxReg.tc_Rowid no-error.
if not available t_iTaxReg
then do:
<M-5 run SetMessage
(input trim(#T-3'Could not find initial values for tax register.':255(733745729)T-3#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sTaxReg.tc_Rowid (icRowid),
input 'QadFin-9464':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output oiReturnStatus (oiReturnStatus)) in BTaxRegister>
assign oiReturnStatus = -1.
return.
end.
end.
/*************************/
/* Validate Journal Code */
/*************************/
if (t_sTaxReg.TaxRegType <> "":U and
t_sTaxReg.TaxRegType <> ?)
then do:
if t_sTaxReg.TaxRegType = {&DAYBOOKSETTYPE-AP}
then do:
for each t_sTaxRegJournal
where t_sTaxRegJournal.TaxReg_ID = t_sTaxReg.TaxReg_ID and
(t_sTaxRegJournal.tc_Status = 'N':U or
t_sTaxRegJournal.tc_Status = 'C':U or
t_sTaxReg.TaxRegType <> t_iTaxReg.TaxRegType):
/*if the type changed the journals are invalid */
if t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-CREDITORINVOICE} and
t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-CREDITORCREDITNOTE} and
t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-CREDITORINVOICECORRECT} and
t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-CREDITORCREDITNOTECORRECT} and
t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-BANKINGENTRY} and
t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-CASHENTRY} and
t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-JOURNALENTRY}
then do:
<M-6 run SetMessage
(input trim(substitute(#T-8'Invalid Daybook Code &1. Only daybooks for AP may be entered.':255(413967153)T-8#,t_sTaxRegJournal.tcJournalCode)) (icMessage),
input '':U (icArguments),
input 'tTaxRegJournal.tcJournalCode':U (icFieldName),
input t_sTaxRegJournal.tcJournalCode (icFieldValue),
input 'E':U (icType),
input 1 (iiSeverity),
input t_sTaxRegJournal.tc_Rowid (icRowid),
input 'QadFin-9561':U:U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output oiReturnStatus (oiReturnStatus)) in BTaxRegister>
assign oiReturnStatus = -1.
return.
end. /* for each t_sTaxRegJournal */
end. /* if t_sTaxReg.TaxRegType = {&DAYBOOKSETTYPE-AP} */
end. /* if t_sTaxReg.TaxRegType = */
if t_sTaxReg.TaxRegType = {&DAYBOOKSETTYPE-AR}
then do:
for each t_sTaxRegJournal
where t_sTaxRegJournal.TaxReg_ID = t_sTaxReg.TaxReg_ID and
(t_sTaxRegJournal.tc_Status = 'N':U or
t_sTaxRegJournal.tc_Status = 'C':U or
t_sTaxReg.TaxRegType <> t_iTaxReg.TaxRegType):
/*if the type changed the journals are invalid */
if t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-DEBTORINVOICE} and
t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-DEBTORCREDITNOTE} and
t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-DEBTORINVOICECORRECT} and
t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-DEBTORCREDITNOTECORRECT} and
t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-DEBTORFINANCECHARGE} and
t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-BANKINGENTRY} and
t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-CASHENTRY} and
t_sTaxRegJournal.tcJournalTypeCode <> {&JOURNALTYPE-JOURNALENTRY}
then do:
<M-9 run SetMessage
(input trim(substitute(#T-11'Invalid Daybook Code &1. Only daybooks for AR may be entered.':255(332070307)T-11#,t_sTaxRegJournal.tcJournalCode)) (icMessage),
input '':U (icArguments),
input 'tTaxRegJournal.tcJournalCode':U (icFieldName),
input t_sTaxRegJournal.tcJournalCode (icFieldValue),
input 'E':U (icType),
input 1 (iiSeverity),
input t_sTaxRegJournal.tc_Rowid (icRowid),
input 'QadFin-9607':U:U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output oiReturnStatus (oiReturnStatus)) in BTaxRegister>
assign oiReturnStatus = -1.
return.
end. /* for each t_sTaxRegJournal */
end. /* if t_sTaxReg.TaxRegType = {&DAYBOOKSETTYPE-AR} */
end. /* if t_sTaxReg.TaxRegType = */
end. /* if t_sTaxReg.TaxRegType <> t_iTaxReg.TaxRegType */
/*************************/
/* Validate Final Report */
/*************************/
if t_sTaxReg.TaxRegIsFinal
then do:
<M-14 run SetMessage
(input trim(#T-16'This Tax Register has been used to generate a Final report. Changing its details may affect the consistency between the previous report and all future reports generated with this Tax Register':255(583993954)T-16#) (icMessage),
input t_sTaxReg.TaxRegIsFinal (icArguments),
input 'tTaxReg.TaxRegIsFinal':U (icFieldName),
input t_sTaxReg.TaxRegIsFinal (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input t_sTaxReg.tc_Rowid (icRowid),
input 'QadFin-9639':U:U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output oiReturnStatus (oiReturnStatus)) in BTaxRegister>
assign oiReturnStatus = 1.
return.
end.
end. /* for each t_sTaxReg where t_sTaxReg.tc_Status <> "D":U: */
for each t_sTaxReg where
t_sTaxReg.tc_Status = "D":U:
/*******************/
/* Validate Delete */
/*******************/
if t_sTaxReg.TaxRegIsFinal
then do:
<M-19 run SetMessage
(input trim(#T-21'You cannot delete this Tax Register because a final report has been generated using it.':255(915907776)T-21#) (icMessage),
input t_sTaxReg.TaxRegIsFinal (icArguments),
input 'tTaxReg.TaxRegIsFinal':U (icFieldName),
input t_sTaxReg.TaxRegIsFinal (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sTaxReg.tc_Rowid (icRowid),
input 'QadFin-9551':U:U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output oiReturnStatus (oiReturnStatus)) in BTaxRegister>
assign oiReturnStatus = -1.
return.
end.
end. /* for each t_sTaxReg where t_sTaxReg.tc_Status = "D":U: */