project QadFinancials > class BBox1099 > method ValidateComponent
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/bbox1099.p)
/* A box cannot be created that has the an identical */
/* reference to a box in the same calender year */
for each t_sBox1099 where (t_sBox1099.tc_Status = "N":U):
<Q-60 run Box1099ByYear (all) (Read) (NoCache)
(input t_sBox1099.Box1099CalendarYear, (BoxYear)
output dataset tqBox1099ByYear) in BBox1099 >
for first tqBox1099ByYear where tqBox1099ByYear.tcBox1099Reference = t_sBox1099.Box1099Reference
and tqBox1099ByYear.tcBox1099Code = t_sBox1099.Box1099Code
and tqBox1099ByYear.tc_rowid <> t_sBox1099.tc_Rowid no-lock:
assign
vcMessage = #T-44'A box for this calendar year already exists with this code and reference':99(64334)t-44#
oiReturnStatus = -1.
<M-43 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input 'Box1099CalendarYear':U (icFieldName),
input t_sBox1099.Box1099CalendarYear (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBox1099.tc_rowid (icRowid),
input 'QadFin-6765':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcreturnsuper (oiReturnStatus)) in BBox1099>
return.
end.
for each t_sBox1099PurchaseTypeLink where (t_sBox1099PurchaseTypeLink.tc_Status = "N":U):
<Q-73 run PurTypeLinkByYear (all) (Read) (NoCache)
(input t_sBox1099.Box1099CalendarYear, (CalYear)
input t_sBox1099PurchaseTypeLink.Box1099PurchaseTypeLink_ID, (PurTypeLinkID)
input t_sBox1099PurchaseTypeLink.PurchaseType_ID, (PurTypeID)
output dataset tqPurTypeLinkByYear) in BBox1099 >
for first tqPurTypeLinkByYear no-lock:
assign
vcMessage = #T-75'A purchase type is already linked to a box for this year':99(64984)t-75#
oiReturnStatus = -1.
<M-74 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input 'PurchaseTypeID':U (icFieldName),
input t_sBox1099PurchaseTypeLink.PurchaseType_ID (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-7082':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcreturnsuper (oiReturnStatus)) in BBox1099>
if oiReturnStatus = -1 then
return.
end.
end.
end.
for each t_sBox1099 where (t_sBox1099.tc_Status = "N":U or
t_sBox1099.tc_Status = "C":U):
<Q-59 run Box1099ByYear (all) (Read) (NoCache)
(input t_sBox1099.Box1099CalendarYear, (BoxYear)
output dataset tqBox1099ByYear) in BBox1099 >
for each tqBox1099ByYear where tqBox1099ByYear.tcBox1099Code = t_sBox1099.Box1099Code
and tqBox1099ByYear.tc_rowid <> t_sBox1099.tc_Rowid no-lock:
assign
vcMessage = #T-49'A box for this calendar year already exists with this code':99(64335)t-49#
oiReturnStatus = -1.
<M-48 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input 'Box1099Code':U (icFieldName),
input t_sBox1099.Box1099Code (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBox1099.tc_rowid (icRowid),
input 'QadFin-6773':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcreturnsuper (oiReturnStatus)) in BBox1099>
end.
for each tqBox1099ByYear where tqBox1099ByYear.tcBox1099Reference = t_sBox1099.Box1099Reference
and tqBox1099ByYear.tc_rowid <> t_sBox1099.tc_Rowid no-lock:
assign
vcMessage = #T-51'A box for this calendar year already exists with this reference':99(64336)t-51#
oiReturnStatus = -1.
<M-52 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input 'Box1099Reference':U (icFieldName),
input t_sBox1099.Box1099Reference (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBox1099.tc_rowid (icRowid),
input 'QadFin-6775':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcreturnsuper (oiReturnStatus)) in BBox1099>
if oiReturnStatus = -1 then
return.
end.
end.
/* Check Purchase Type is not already linked to a Box for that year */
for each t_sBox1099PurchaseTypeLink where (t_sBox1099PurchaseTypeLink.tc_Status = "N":U):
if t_sBox1099PurchaseTypeLink.Box1099_ID <> ? or t_sBox1099PurchaseTypeLink.Box1099_ID <> 0 then do:
<Q-68 run YearForPurTypeLink (all) (Read) (NoCache)
(input t_sBox1099PurchaseTypeLink.Box1099_ID, (BoxID)
output dataset tqYearForPurTypeLink) in BBox1099 >
find first tqYearForPurTypeLink no-lock no-error.
if not available tqYearForPurTypeLink
then next.
<Q-69 run PurTypeLinkByYear (all) (Read) (NoCache)
(input tqYearForPurTypeLink.tiBox1099CalendarYear, (CalYear)
input t_sBox1099PurchaseTypeLink.Box1099PurchaseTypeLink_ID, (PurTypeLinkID)
input t_sBox1099PurchaseTypeLink.PurchaseType_ID, (PurTypeID)
output dataset tqPurTypeLinkByYear) in BBox1099 >
for first tqPurTypeLinkByYear no-lock:
assign
vcMessage = #T-71'A purchase type is already linked to a box for this year':99(64984)t-71#
oiReturnStatus = -1.
<M-70 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input 'PurchaseTypeID':U (icFieldName),
input t_sBox1099PurchaseTypeLink.PurchaseType_ID (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-6994':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcreturnsuper (oiReturnStatus)) in BBox1099>
if oiReturnStatus = -1 then
return.
end.
end.
end.
/* A Box cannot be deleted as long as there are invoices */
/* relating to a purchase type that is linked to the box */
for each t_sBox1099 where t_sBox1099.tc_Status = "D":U:
<Q-45 run InvoicesForPurchaseType (all) (Read) (NoCache)
(input t_sBox1099.Box1099_ID, (Box1099Id)
input ?, (CompanyId)
output dataset tqInvoicesForPurchaseType) in BBox1099 >
for first tqInvoicesForPurchaseType no-lock:
assign
vcMessage = #T-47'The box is linked to a purchase type that contains invoices and cannot be deleted.':99(64326)t-47#
oiReturnStatus = -1.
<M-46 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input 'Box1099Code':U (icFieldName),
input t_sBox1099.Box1099Code (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBox1099.tc_rowid (icRowid),
input 'QadFin-6766':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBox1099>
if oiReturnStatus = -1 then
return.
end.
end.
<ANCESTOR-CODE>