project QadFinancials > class BDInvoice > method GetPeriodDateForDeduction
Description
get period date by the input date.
Parameters
| itPostingDate | input | date | |
| oiPostingYear | output | integer | |
| oiPostingPeriod | output | integer | |
| otPostingDateOut | output | date | |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bdinvoice.p)
assign oiReturnStatus = -98
oiPostingYear = 0
oiPostingPeriod = 0.
if itPostingDate = ? then
do:
<M-16 run SetMessage
(input #T-48'Posting date is mandatory.':255(883024428)T-48# (icMessage),
input ? (icArguments),
input ? (icFieldName),
input ? (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input ? (icRowid),
input 'qadfin-298031':U (icFcMsgNumber),
input ? (icFcExplanation),
input ? (icFcIdentification),
input ? (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
return.
end.
<Q-47 run PeriodByStartEndDate (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input itPostingDate, (Date)
output dataset tqPeriodByStartEndDate) in BPeriod>
/* Check if the "Normal" Period is OK */
find first tqPeriodByStartEndDate where
tqPeriodByStartEndDate.tiCompany_ID = viCompanyId and
tqPeriodByStartEndDate.tcPeriodTypeCode = {&PERIODTYPECODE-NORMAL} and
tqPeriodByStartEndDate.tlPeriodIsPostingGLAllowed = true and
tqPeriodByStartEndDate.tlPeriodIsPostingSalesAllow = true
no-error.
if not available tqPeriodByStartEndDate
then find first tqPeriodByStartEndDate where
tqPeriodByStartEndDate.tiCompany_ID = viCompanyId and
tqPeriodByStartEndDate.tlPeriodIsPostingGLAllowed = true and
tqPeriodByStartEndDate.tlPeriodIsPostingSalesAllow = true
no-error.
if available tqPeriodByStartEndDate
then assign oiPostingYear = tqPeriodByStartEndDate.tiPeriodYear
oiPostingPeriod = tqPeriodByStartEndDate.tiPeriodPeriod
otPostingDateOut = itPostingDate.
else if itPostingDate = today then
do:
<Q-75 run PeriodByCompanyIsOpen (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input true, (IsPostingGLAllowed)
output dataset tqPeriodByCompanyIsOpen) in BPeriod>
/* Check if only one */
find tqPeriodByCompanyIsOpen where
tqPeriodByCompanyIsOpen.tiCompany_ID = viCompanyId and
tqPeriodByCompanyIsOpen.tlPeriodIsPostingGLAllowed = true and
tqPeriodByCompanyIsOpen.tlPeriodIsPostingSalesAllow = true
no-error.
if not available tqPeriodByCompanyIsOpen
then find last tqPeriodByCompanyIsOpen where
tqPeriodByCompanyIsOpen.tiCompany_ID = viCompanyId and
tqPeriodByCompanyIsOpen.tlPeriodIsPostingGLAllowed = true and
tqPeriodByCompanyIsOpen.ttPeriodEndDate <= today and
tqPeriodByCompanyIsOpen.tlPeriodIsPostingSalesAllow = true
no-error.
if available tqPeriodByCompanyIsOpen
then assign oiPostingYear = tqPeriodByCompanyIsOpen.tiPeriodYear
oiPostingPeriod = tqPeriodByCompanyIsOpen.tiPeriodPeriod
otPostingDateOut = tqPeriodByCompanyIsOpen.ttPeriodEndDate.
end.
assign oiReturnStatus = 0.