project QadFinancials > class BPosting > method ValidateComponentReversingPostingModifyOriginal
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bposting.p)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Modifying an original entry */
/* Both the original entry and the reversing entry must be updated */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Exception Handling */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
POSTINGBLOCK: DO:
/* Modifying the original entry */
For each btsPosting where
btsPosting.PostingIsAutoReversal = true and
btsPosting.PostingAutoReversalType = {&POSTINGAUTOREVERSALTYPE-ORIGINAL} and
btsPosting.tc_Status = "C":U:
/* DO NOT PROCEED IF THE METHOD IS CALLED DURING APPROVE?VERIFY ACTIVITY */
find first t_iPosting where t_iPosting.Posting_ID = btsPosting.Posting_ID no-error.
if available t_iPosting
then do:
if t_iPosting.PostingApproveStatus <> btsPosting.PostingApproveStatus or
t_iPosting.PostingVerifyStatus <> btsPosting.PostingVerifyStatus
then next.
end.
/* If the posting was loaded as part of the change of counterpart posting, *
* skipp processing of it */
if lookup(string(btsPosting.Posting_Id), vcAutoLoadReversingPostingIDs) > 0
then next.
if btsPosting.AutoReversalPosting_ID <> 0 or
btsPosting.AutoReversalPosting_ID <> ?
then do:
find first t_sPosting where
t_sPosting.Posting_ID = btsPosting.AutoReversalPosting_ID
no-error.
/* If posting is not in instance, read it from DB */
if not available t_sPosting
then do:
assign vcAutoLoadReversingPostingIDs = substitute("&1,&2",
vcAutoLoadReversingPostingIDs,
btsPosting.AutoReversalPosting_ID).
<M-81 run DataLoad
(input '':U (icRowids),
input btsPosting.AutoReversalPosting_ID (icPkeys),
input '':U (icObjectIds),
input '':U (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then do:
assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
assign vcMsgExplanation = <M-66 GetErrorExplanation
(input btsPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMsg = #T-49'The system cannot read details about the details of posting ID &1.':255(69152)T-49#
vcMsg = substitute(vcMsg, btsPosting.AutoReversalPosting_ID).
<M-34 run SetMessage
(input vcMsg (icMessage),
input '':U (icArguments),
input 'btsPosting.AutoReversalPosting_ID':U (icFieldName),
input btsPosting.AutoReversalPosting_ID (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input btsPosting.tc_Rowid (icRowid),
input 'QadFin-62790':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
leave POSTINGBLOCK.
end. /* if viFcReturnSuper < 0 */
end. /* if viFcReturnSuper <> 0 */
/* Create t_s records for the newly loaded Counterpart posting */
for each tPosting where
tPosting.Posting_ID = btsPosting.AutoReversalPosting_ID:
for each tPostingLine where
tPostingLine.tc_ParentRowid = tPosting.tc_Rowid:
for each tPostingSaf where
tPostingSaf.tc_ParentRowid = tPostingLine.tc_Rowid:
create t_sPostingSaf.
buffer-copy tPostingSaf to t_sPostingSaf.
end.
for each tPostingVat where
tPostingVat.tc_ParentRowid = tPostingLine.tc_Rowid:
create t_sPostingVat.
buffer-copy tPostingVat to t_sPostingVat.
end.
for each tPostingVatDelay where
tPostingVatDelay.tc_ParentRowid = tPostingLine.tc_Rowid:
create t_sPostingVatDelay.
buffer-copy tPostingVatDelay to t_sPostingVatDelay.
end.
create t_sPostingLine.
buffer-copy tPostingLine to t_sPostingLine.
end. /* for tPostingLine where */
create t_sPosting.
buffer-copy tPosting to t_sPosting.
end. /* for each tPosting where */
find first t_sPosting where
t_sPosting.Posting_ID = btsPosting.AutoReversalPosting_ID
no-error.
end. /* if not available tPosting */
if available t_sPosting
then do:
/* Mark the reversed posting as deleted */
<M-32 run DeletePosting
(input t_sPosting.tc_Rowid (icPostingRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturnStatus = 0 then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave POSTINGBLOCK.
buffer-copy btsPosting except tc_rowid tc_parentrowid tc_status Posting_ID PostingAutoReversalType AutoReversalPosting_ID PostingOriginatorReference
PostingVoucher PostingDate PostingYear PostingPeriod PostingYearPeriod Period_ID PeriodMark_ID tlSaveAsTemplate tcTemplateCode PostingCreationTimeString PostingAddGLNbr
to t_sPosting.
assign t_sPosting.tc_Status = 'C':U
t_sPosting.PostingDate = btsPosting.PostingAutoReversalDate
t_sPosting.PostingAddGLNbrDate = btsPosting.PostingAddGLNbrRevDate.
if t_sPosting.PostingDate <> ?
then do:
<Q-22 run PeriodByStartEndDate (all) (Read) (NoCache)
(input t_sPosting.Company_ID, (CompanyId)
input t_sPosting.PostingDate, (Date)
output dataset tqPeriodByStartEndDate) in BPeriod >
find first tqPeriodByStartEndDate no-error.
if available tqPeriodByStartEndDate
then assign t_sPosting.PostingYear = tqPeriodByStartEndDate.tiPeriodYear
t_sPosting.PostingPeriod = tqPeriodByStartEndDate.tiPeriodPeriod
t_sPosting.PostingYearPeriod = tqPeriodByStartEndDate.tiPeriodYearPeriod
t_sPosting.Period_ID = tqPeriodByStartEndDate.tiPeriod_ID.
else do:
assign vcMsgExplanation = <M-12 GetErrorExplanation
(input btsPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMsg = trim(#T-82'Cannot read date details for Posting with Posting_ID = &1.':100(999890325)T-82#)
vcMsg = substitute(vcMsg, btsPosting.AutoReversalPosting_ID).
<M-64 run SetMessage
(input vcMsg (icMessage),
input '':U (icArguments),
input ' btsPosting.AutoReversalPosting_ID':U (icFieldName),
input btsPosting.AutoReversalPosting_ID (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input btsPosting.tc_Rowid (icRowid),
input 'QadFin-615046':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
LEAVE POSTINGBLOCK.
end.
/* Assign the voucher number for the reversal entry */
find t_iPosting where
t_iPosting.tc_Rowid = t_sPosting.tc_Rowid
no-error.
if available t_iPosting and
t_iPosting.PostingYear <> t_sPosting.PostingYear or
t_iPosting.tcJournalCode <> t_sPosting.tcJournalCode
then do:
assign t_sPosting.PostingVoucher = 0.
<M-70 run GetPostingNumber
(input t_sPosting.tc_Rowid (ictcRowid),
input t_sPosting.PostingYear (iiYear),
input t_sPosting.tcJournalCode (icJournalCode),
output t_sPosting.PostingVoucher (oiVoucher),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturnStatus = 0 then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave POSTINGBLOCK.
end. /* if tPosting.Postingyear <> t_sposting.postingyear */
end. /* btsPosting.PostingAutoReversalDate <> ? */
for each btsPostingLine where
btsPostingLine.tc_parentrowid = btsPosting.tc_Rowid and
btsPostingLine.tc_Status <> "D":U:
find first t_sPostingLine where
t_sPostingLine.tc_ParentRowid = t_sPosting.tc_Rowid and
t_sPostingLine.tc_Status = "D":U and
t_sPostingLine.PostingLineSequence = btsPostingLine.PostinglineSequence
no-error.
if not available t_sPostingLine
then do:
<M-39 run AddDetailLine
(input 'PostingLine':U (icTable),
input t_sPosting.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturnStatus = 0 then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave POSTINGBLOCK.
create t_sPostingLine.
buffer-copy tPostingLine to t_sPostingLine.
end.
.
/* copy data into reversing one */
buffer-copy btsPostingLine except tc_rowid tc_parentrowid tc_status Posting_ID PostingLine_ID PostingLineCreditTC
PostingLineDebitTC PostingLineCreditLC PostingLineDebitLC PostingLineCreditCC
PostingLineDebitCC tcAllocationType to t_sPostingLine.
assign t_sPostingLine.tc_Status = (if t_sPostingLine.tc_Status = 'N':U then 'N':U else 'C':U).
if btsPosting.PostingIsCorrection
then assign t_sPostingLine.PostingLineCreditTC = btsPostingLine.PostingLineCreditTC * -1
t_sPostingLine.PostingLineDebitTC = btsPostingLine.PostingLineDebitTC * -1
t_sPostingLine.PostingLineCreditLC = btsPostingLine.PostingLineCreditLC * -1
t_sPostingLine.PostingLineDebitLC = btsPostingLine.PostingLineDebitLC * -1
t_sPostingLine.PostingLineCreditCC = btsPostingLine.PostingLineCreditCC * -1
t_sPostingLine.PostingLineDebitCC = btsPostingLine.PostingLineDebitCC * -1.
else assign t_sPostingLine.PostingLineCreditTC = btsPostingLine.PostingLineDebitTC
t_sPostingLine.PostingLineDebitTC = btsPostingLine.PostingLineCreditTC
t_sPostingLine.PostingLineCreditLC = btsPostingLine.PostingLineDebitLC
t_sPostingLine.PostingLineDebitLC = btsPostingLine.PostingLineCreditLC
t_sPostingLine.PostingLineCreditCC = btsPostingLine.PostingLineDebitCC
t_sPostingLine.PostingLineDebitCC = btsPostingLine.PostingLineCreditCC.
for each btsPostingVat where
btsPostingVat.tc_parentrowid = btsPostingLine.tc_rowid and
btsPostingVat.tc_Status <> "D":U:
find first t_sPostingVat where
t_sPostingVat.tc_ParentRowid = t_sPostingLine.tc_Rowid and
t_sPostingVat.tc_Status = "D":U
no-error.
if not available t_sPostingVat
then do:
<M-80 run AddDetailLine
(input 'PostingVat':U (icTable),
input t_sPostingLine.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturnStatus = 0 then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave POSTINGBLOCK.
create t_sPostingVat.
buffer-copy tPostingVat to t_sPostingVat.
end.
buffer-copy btsPostingVat except tc_rowid tc_parentrowid tc_status postingvat_id posting_id postingline_id to t_sPostingVat.
assign t_sPostingVat.tc_Status = (if t_sPostingVat.tc_Status = 'N':U then 'N':U else if btsPostingVat.tc_Status = "":U then "":U else 'C':U).
if btsPosting.PostingIsCorrection
then assign t_sPostingVat.PostingVatTaxCreditTC = btsPostingVat.PostingVatTaxCreditTC * -1
t_sPostingVat.PostingVatTaxDebitTC = btsPostingVat.PostingVatTaxDebitTC * -1
t_sPostingVat.PostingVatTaxCreditCC = btsPostingVat.PostingVatTaxCreditCC * -1
t_sPostingVat.PostingVatTaxDebitCC = btsPostingVat.PostingVatTaxDebitCC * -1
t_sPostingVat.PostingVatTaxCreditLC = btsPostingVat.PostingVatTaxCreditLC * -1
t_sPostingVat.PostingVatTaxDebitLC = btsPostingVat.PostingVatTaxDebitLC * -1
t_sPostingVat.PostingVatBaseCreditTC = btsPostingVat.PostingVatBaseCreditTC * -1
t_sPostingVat.PostingVatBaseDebitTC = btsPostingVat.PostingVatBaseDebitTC * -1
t_sPostingVat.PostingVatBaseCreditCC = btsPostingVat.PostingVatBaseCreditCC * -1
t_sPostingVat.PostingVatBaseDebitCC = btsPostingVat.PostingVatBaseDebitCC * -1
t_sPostingVat.PostingVatBaseCreditLC = btsPostingVat.PostingVatBaseCreditLC * -1
t_sPostingVat.PostingVatBaseDebitLC = btsPostingVat.PostingVatBaseDebitLC * -1.
else assign t_sPostingVat.PostingVatTaxCreditTC = btsPostingVat.PostingVatTaxDebitTC
t_sPostingVat.PostingVatTaxDebitTC = btsPostingVat.PostingVatTaxCreditTC
t_sPostingVat.PostingVatTaxCreditCC = btsPostingVat.PostingVatTaxDebitCC
t_sPostingVat.PostingVatTaxDebitCC = btsPostingVat.PostingVatTaxCreditCC
t_sPostingVat.PostingVatTaxCreditLC = btsPostingVat.PostingVatTaxDebitLC
t_sPostingVat.PostingVatTaxDebitLC = btsPostingVat.PostingVatTaxCreditLC
t_sPostingVat.PostingVatBaseCreditTC = btsPostingVat.PostingVatBaseDebitTC
t_sPostingVat.PostingVatBaseDebitTC = btsPostingVat.PostingVatBaseCreditTC
t_sPostingVat.PostingVatBaseCreditCC = btsPostingVat.PostingVatBaseDebitCC
t_sPostingVat.PostingVatBaseDebitCC = btsPostingVat.PostingVatBaseCreditCC
t_sPostingVat.PostingVatBaseCreditLC = btsPostingVat.PostingVatBaseDebitLC
t_sPostingVat.PostingVatBaseDebitLC = btsPostingVat.PostingVatBaseCreditLC.
end. /* for each btsPostingVat where */
for each btsPostingSaf where
btsPostingSaf.tc_parentrowid = btsPostingLine.tc_rowid and
btsPostingSaf.tc_Status <> "D":U:
find first t_sPostingSaf where
t_sPostingSaf.tc_parentrowid = t_sPostingLine.tc_rowid and
t_sPostingSaf.tc_Status = "D":U
no-error.
if not available t_sPostingSaf
then do:
<M-48 run AddDetailLine
(input 'PostingSaf':U (icTable),
input t_sPostingLine.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturnStatus = 0 then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave POSTINGBLOCK.
create t_sPostingSaf.
buffer-copy tPostingSaf to t_sPostingSaf.
end.
buffer-copy btsPostingSaf except tc_rowid tc_parentrowid tc_status posting_id postingline_id postingsaf_ID to t_sPostingSaf.
assign t_sPostingSaf.tc_Status = (if t_sPostingSaf.tc_Status = 'N':U then 'N':U else if btsPostingSaf.tc_Status = "":U then "":U else 'C':U).
end. /* for each btsPostingSaf where */
end. /* for each btsPostingLine where */
/* Do corection of the status to save the data */
for each t_sPostingLine where
t_sPostingLine.tc_ParentRowid = t_sPosting.tc_Rowid and
t_sPostingLine.tc_Status = "D":U:
for each t_sPostingSaf where
t_sPostingSaf.tc_ParentRowid = t_sPostingLine.tc_Rowid and
t_sPostingSaf.tc_Status = "D":U:
assign t_sPostingSaf.tc_Status = "":U.
end.
for each t_sPostingVat where
t_sPostingVat.tc_ParentRowid = t_sPostingLine.tc_Rowid and
t_sPostingVat.tc_Status = "D":U:
assign t_sPostingVat.tc_Status = "":U.
end.
end.
<M-37 run SetMessage
(input #T-98'This journal entry has a related reversing entry which will also be changed':100(999890084)T-98# (icMessage),
input '':U (icArguments),
input 'Posting Voucher':U (icFieldName),
input STRING(t_sPosting.PostingYear) + '/' + t_sPosting.tcJournalCode + '/' + STRING(t_sPosting.PostingVoucher) (icFieldValue),
input 'W':U (icType),
input 1 (iiSeverity),
input btsPosting.tc_Rowid (icRowid),
input 'QadFin-274586':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = if viLocalReturnStatus = 0
then 1
else viLocalReturnStatus.
end. /* if available tPosting then do */
end. /* if btsPosting.AutoReversalPosting_ID <> 0 */
end. /* For each btsPosting where */
END. /* POSTINGBLOCK */
/* Exception Handling */
assign oiReturnStatus = viLocalReturnStatus.