project QadFinancials > class BJournalEntryMultiCy > method ApiCreateCrossCyPostingsApplyCCyDefaults
Description
This method applies defaulting to the input dataset Fields values from the tPostingHeaderMultiCy are copied to tPostingMultiCy/tPostingLineMultiCy tables. Company id/codes are set in the tables also. This method can be overwritten by NI Customization If the customization code sets the variable vlIsCustomizedDefaultPostings is set to true, then this method code will not be run - the before or after method will then need to be implemented in NI Customization
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program9/bjournalentrymulticy.p)
/* ================================================================ */
/* This method applies defaulting to the input dataset */
/* Field values from the tPostingHeaderMultiCy are copied to */
/* tPostingMultiCy/tPostingLineMultiCy tables. Company id/codes */
/* are set in the tables also. */
/* */
/* This method can be overwritten by NI Customization */
/* If the customization code sets the variable */
/* vlIsCustomizedDefaultPostings is set to true, then this method */
/* code will not be run */
/* =============================================================== */
empty temp-table tPostingJournalEntryType.
if vlIsCustomizedDefaultPostings = true then
return.
<Q-7 run CompanyPrim (all) (Read) (NoCache)
(input ?, (LookupCompanyId)
input ?, (CompanyCode)
output dataset tqCompanyPrim) in BCompany >
/* only work on those tPostingHeaderMultiCy records which are not already posted */
for each tPostingHeaderMultiCy where
tPostingHeaderMultiCy.tlPostingHeaderIsPosted = false
on error undo, throw:
assign viEntityCount = 0.
/* Check the mandatory fields */
if tPostingHeaderMultiCy.tiPostingHeaderYear = 0 or tPostingHeaderMultiCy.tiPostingHeaderYear = ?
then do:
assign
vcMessageText = #T-55'Year is a mandatory field':255(976753226)T-55#
oiReturnStatus = -1.
<M-1 run SetMessage
(input vcMessageText (icMessage),
input '' (icArguments),
input 'PostingHeaderYear' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input tPostingHeaderMultiCy.tc_Rowid (icRowid),
input 'qadfin-143924':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
end. /* if tPostingHeaderMultiCy.tiPostingHeaderYear = 0 */
if tPostingHeaderMultiCy.tiPostingHeaderGLPeriod = 0 or tPostingHeaderMultiCy.tiPostingHeaderGLPeriod = ?
then do:
assign
vcMessageText = #T-5'Period is a mandatory field':255(67005413)T-5#
oiReturnStatus = -1.
<M-32 run SetMessage
(input vcMessageText (icMessage),
input '' (icArguments),
input 'PostingHeaderPeriod' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input tPostingHeaderMultiCy.tc_Rowid (icRowid),
input 'qadfin-550157':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
end. /* if tPostingHeaderMultiCy.tiPostingHeaderGLPeriod = 0 */
if tPostingHeaderMultiCy.ttPostingHeaderPostingDate = ?
then do:
assign
vcMessageText = #T-50'Posting Date is a mandatory field':255(243099991)T-50#
oiReturnStatus = -1.
<M-28 run SetMessage
(input vcMessageText (icMessage),
input '' (icArguments),
input 'PostingHeaderDate' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input tPostingHeaderMultiCy.tc_Rowid (icRowid),
input 'qadfin-273356':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
end. /* if tPostingHeaderMultiCy.ttPostingHeaderPostingDate = ? */
if tPostingHeaderMultiCy.tcPostingHeaderJournalCode = "" or tPostingHeaderMultiCy.tcPostingHeaderJournalCode = ?
then do:
assign
vcMessageText = #T-2'Daybook Code is a mandatory field':255(259947593)T-2#
oiReturnStatus = -1.
<M-4 run SetMessage
(input vcMessageText (icMessage),
input '' (icArguments),
input 'PostingHeaderJournalCode' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input tPostingHeaderMultiCy.tc_Rowid (icRowid),
input 'qadfin-659546':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
end. /* if tPostingHeaderMultiCy.tcPostingHeaderJournalCode = "" */
if tPostingHeaderMultiCy.tcPostingHeaderDescription = "" or tPostingHeaderMultiCy.tcPostingHeaderDescription = ?
then do:
assign
vcMessageText = #T-70'Description is a mandatory field':255(97167749)T-70#
oiReturnStatus = -1.
<M-53 run SetMessage
(input vcMessageText (icMessage),
input '' (icArguments),
input 'PostingHeaderDescription' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input tPostingHeaderMultiCy.tc_Rowid (icRowid),
input 'qadfin-931504':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
end. /* if tPostingHeaderMultiCy.tcPostingHeaderDescription = "" */
/*If no currency is specified we want to default it from the base currency of the current company */
if tPostingHeaderMultiCy.tcPostingHeaderCurrencyCode = "" or tPostingHeaderMultiCy.tcPostingHeaderCurrencyCode = ?
then do:
if vcCompanyLC <> "" or vcCompanyLC<> ?
then assign tPostingHeaderMultiCy.tcPostingHeaderCurrencyCode = vcCompanyLC.
else do:
assign
vcMessageText = #T-18'Could not retrieve base currency. Currency can not be blank':255(374668215)T-18#
oiReturnStatus = -1.
<M-90 run SetMessage
(input vcMessageText (icMessage),
input '' (icArguments),
input 'PostingHeadMultiCy.tcCurrencyCode' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 1 (iiSeverity),
input tPostingHeaderMultiCy.tc_rowid (icRowid),
input 'qadfin-707819':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
end. /* else do */
end. /* default header currency */
/* set the defaults from tPostingHeaderMultiCy */
for each tPostingMultiCy
where tPostingMultiCy.tc_parentRowid = tPostingHeaderMultiCy.tc_rowid:
assign viEntityCount = viEntityCount + 1.
if tPostingMultiCy.Postingdate = ?
then assign tPostingMultiCy.Postingdate = tPostingHeaderMultiCy.ttPostingHeaderPostingDate.
if tPostingMultiCy.PostingText = "" or tPostingMultiCy.PostingText = ?
then assign tPostingMultiCy.PostingText = tPostingHeaderMultiCy.tcPostingHeaderDescription.
if tPostingMultiCy.tcJournalCode= "" or tPostingMultiCy.tcJournalCode= ?
then assign tPostingMultiCy.tcJournalCode= tPostingHeaderMultiCy.tcPostingHeaderJournalCode.
if tPostingMultiCy.tcCompanyCode = "" or
tPostingMultiCy.tcCompanyCode = ?
then assign tPostingMultiCy.tcCompanyCode = vcCompanyCode
tPostingMultiCy.company_id = viCompanyID.
else do:
Find first tqCompanyPrim where
tqCompanyPrim.tcCompanyCode = tPostingMultiCy.tcCompanyCode
no-lock no-error.
if not available tqCompanyPrim
then do:
assign vcMessageText = #T-13'Company can not be blank - please enter a company code':255(166325585)T-13#
vcMsgExplanation = <M-25 GetErrorExplanation
(input tPostingMultiCy.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
oiReturnStatus = -1.
<M-73 run SetMessage
(input vcMessageText (icMessage),
input '' (icArguments),
input 'PostingMultiCy.tcCompanyCode' (icFieldName),
input tPostingMultiCy.tcCompanyCode (icFieldValue),
input 'E' (icType),
input 1 (iiSeverity),
input tPostingMultiCy.tc_rowid (icRowid),
input 'qadfin-916256':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
end. /* if not available tqCompanyPrim */
else assign tPostingMultiCy.company_id = tqCompanyPrim.tiCompany_ID.
end. /* if tPostingMultiCy.tcCompanyCode = "" */
if tPostingMultiCy.Company_ID <> 0 and
tPostingMultiCy.Company_ID <> ? and
tPostingMultiCy.Postingdate <> ? and
(tPostingMultiCy.PostingYear = 0 or
tPostingMultiCy.PostingYear = ? or
tPostingMultiCy.PostingPeriod = 0 or
tPostingMultiCy.PostingPeriod = ?)
then do :
<Q-34 run PeriodByStartEndDateStatus (all) (Read) (NoCache)
(input tPostingMultiCy.Company_ID, (CompanyId)
input tPostingMultiCy.PostingDate, (Date)
input ?, (PeriodStatus)
input ?, (PeriodId)
input ?, (PeriodIsPostingGLAllowed)
output dataset tqPeriodByStartEndDateStatus) in BPeriod>
Find first tqPeriodByStartEndDateStatus where
tqPeriodByStartEndDateStatus.ttPeriodStartDate <= tPostingMultiCy.PostingDate And
tqPeriodByStartEndDateStatus.ttPeriodEndDate >= tPostingMultiCy.PostingDate And
tqPeriodByStartEndDateStatus.tiPeriodYear = (if tPostingMultiCy.PostingYear <> 0 and
tPostingMultiCy.PostingYear <> ?
then tPostingMultiCy.PostingYear
else tqPeriodByStartEndDateStatus.tiPeriodYear) And
tqPeriodByStartEndDateStatus.tiPeriodPeriod = (if tPostingMultiCy.PostingPeriod <> 0 and
tPostingMultiCy.PostingPeriod <> ?
then tPostingMultiCy.PostingPeriod
else tqPeriodByStartEndDateStatus.tiPeriodPeriod)
no-lock no-error.
if available tqPeriodByStartEndDateStatus
then do :
if tPostingMultiCy.PostingYear = 0 or
tPostingMultiCy.PostingYear = ?
then assign tPostingMultiCy.PostingYear = tqPeriodByStartEndDateStatus.tiPeriodYear.
if tPostingMultiCy.PostingPeriod = 0 or
tPostingMultiCy.PostingPeriod = ?
then assign tPostingMultiCy.PostingPeriod = tqPeriodByStartEndDateStatus.tiPeriodPeriod.
end. /* if available tqPeriodByStartEndDateStatus */
end. /* if tPostingMultiCy.Company_ID <> 0 and */
/* tPostingMultiCy.PostingOriginIsExternal must be assigned to true to post */
/* these records using ApiStdMaintainTTMulti */
assign tPostingMultiCy.PostingOriginIsExternal = true.
for each tPostingLineMultiCy
where tPostingLineMultiCy.tc_parentrowid = tPostingMultiCy.tc_rowid on error undo, throw:
if tPostingLineMultiCy.tcGLCode = "" or tPostingLineMultiCy.tcGLCode = ?
then do:
assign
vcMsgExplanation = <M-81 GetErrorExplanation
(input tPostingMultiCy.tc_Rowid (icPostingRowId),
input tPostingLineMultiCy.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
vcMessageText = trim(substitute(#T-56'GL Code is mandatory and must be specified for entity &1.':255(794611661)T-56#,tPostingMultiCy.tcCompanyCode)).
oiReturnStatus = -1.
<M-11 run SetMessage
(input vcMessageText (icMessage),
input '' (icArguments),
input 'PostingLineMultiCy.tcGLCode' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 1 (iiSeverity),
input tPostingLineMultiCy.tc_rowid (icRowid),
input 'qadfin-416913':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
end. /* if tPostingLineMultiCy.tcGLCode */
if tPostingLineMultiCy.PostingLineText = "" or tPostingLineMultiCy.PostingLineText = ?
then assign tPostingLineMultiCy.PostingLineText = tPostingMultiCy.PostingText.
if tPostingLineMultiCy.PostingDate = ?
then assign tPostingLineMultiCy.PostingDate = tPostingMultiCy.PostingDate .
if tPostingLineMultiCy.tcCurrencyCode = "" or tPostingLineMultiCy.tcCurrencyCode = ?
then assign tPostingLineMultiCy.tcCurrencyCode = tPostingHeaderMultiCy.tcPostingHeaderCurrencyCode .
assign
tPostingLineMultiCy.company_id = tPostingMultiCy.company_id.
end. /* end of for each tPostingLineMultiCy */
end. /* end of foreach tPostingMultiCy */
create tPostingJournalEntryType.
/* if there is one entity then it is journal entry, not cross company*/
if viEntityCount = 1 then
do:
assign tPostingJournalEntryType.tc_Rowid = tPostingHeaderMultiCy.tc_Rowid
tPostingJournalEntryType.tiJournalEntryType = {&JOURNALENTRY-NORMALEXCELINT}. /* Journal Entry */
end.
else do: /*cross company */
assign tPostingJournalEntryType.tc_Rowid = tPostingHeaderMultiCy.tc_Rowid
tPostingJournalEntryType.tiJournalEntryType = {&JOURNALENTRY-CROSSCOMPANYEXCELINT}. /* Cross Company */
end.
end. /* end of for each tPostingHeaderMulti */