project QadFinancials > class BDDocument > method AdditionalUpdatesPostingXref
Parameters
icPostingRowid | input | character | |
iiPeriodYear | input | integer | |
iiPeriodPeriod | input | integer | |
icJournalCode | input | character | |
iiPostingId | input | integer | |
blStart6 | input-output | logical | |
blStart7 | input-output | logical | |
blStart8 | input-output | logical | |
iiPostingVoucher | input | integer | Posting voucher from posting header |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bddocument.p)
for each tDDocumentInvoiceXref where
tDDocumentInvoiceXref.tc_ParentRowid = tDDocument.tc_Rowid:
/* We don't have to handle the tDDocumentInvoiceXref record when Create new payment */
if tDDocumentInvoiceXref.tc_Status = "D":U and
vcActivityCode = "Create":U
then next.
/* Get initial allocation values */
if tDDocumentInvoiceXref.tc_Status <> "N":U
then do:
find t_iDDocumentInvoiceXref where
t_iDDocumentInvoiceXref.tc_Rowid = tDDocumentInvoiceXref.tc_Rowid
no-error.
if not available t_iDDocumentInvoiceXref
then do:
<M-1 run SetMessage
(input trim(#T-5'Initial values not found for customer payment invoice cross-reference with row ID $1.':250(1658)t-5#) (icMessage),
input tDDocumentInvoiceXref.tc_Rowid (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-2585':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
return.
end.
end.
/* Calculate changed amount */
assign vdAmount = if tDDocumentInvoiceXref.tc_Status = "D":U or
can-do({&DOCUMENTSTATUS-INIT} + "," + {&DOCUMENTSTATUS-BOUNCED} + "," + {&DOCUMENTSTATUS-VOID}, tDDocument.DDocumentStatus)
then 0
else tDDocumentInvoiceXref.DDocumentInvoiceXrefAlloTC -
tDDocumentInvoiceXref.DDocumentInvoiceXrefDiscTC.
if tDDocumentInvoiceXref.tc_Status <> "N":U
then assign vdAmount = vdAmount -
(t_iDDocumentInvoiceXref.DDocumentInvoiceXrefAlloTC -
t_iDDocumentInvoiceXref.DDocumentInvoiceXrefDiscTC).
/* Handle DInvoice and Prepayment */
if tDDocumentInvoiceXref.DInvoice_ID <> 0 and
tDDocumentInvoiceXref.DInvoice_ID <> ?
then do:
<M-2 run AdditionalUpdatesPostingXrefDI
(input vdAmount (idAmount),
input icPostingRowid (icPostingRowid),
input-output bdDocumentAmountLC (bdDocumentAmountLC),
input-output bdDocumentAmountCC (bdDocumentAmountCC),
input-output blStart6 (blStart6),
input-output blStart7 (blStart7),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
end.
/* Handle PrePayments - In Creation mode only */
if tDDocumentInvoiceXref.tcDInvoiceType = {&INVOICETYPE-PREPAYMENT} and
(tDDocumentInvoiceXref.DInvoice_ID = 0 or
tDDocumentInvoiceXref.DInvoice_ID = ?) and
tDDocumentInvoiceXref.tc_Status = "N":U
then do:
<M-3 run AdditionalUpdatesPostingPrePayment
(input iiPeriodYear (iiPeriodYear),
input iiPeriodPeriod (iiPeriodPeriod),
input icJournalCode (icJournalCode),
input iiPostingId (iiPostingId),
input icPostingRowid (icPostingRowid),
input-output blStart6 (blStart6),
input-output blStart8 (blStart8),
input iiPostingVoucher (iiPostingVoucher),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
end.
/*Handle Deduction - In Creation mode only */
if tDDocumentInvoiceXref.tcDInvoiceType = {&INVOICETYPE-DEDUCTION} and
(tDDocumentInvoiceXref.DInvoice_ID = 0 or
tDDocumentInvoiceXref.DInvoice_ID = ?) and
tDDocumentInvoiceXref.tc_Status = "N":U
then do:
<M-81 run AdditionalUpdatesPostingDeduction
(input iiPeriodYear (iiPeriodYear),
input iiPeriodPeriod (iiPeriodPeriod),
input icJournalCode (icJournalCode),
input iiPostingId (iiPostingId),
input icPostingRowid (icPostingRowid),
input-output blStart8 (blStart8),
input iiPostingVoucher (iiPostingVoucher),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
end.
/* Set sign of allocated amount */
if tDDocumentInvoiceXref.tcAllocAmountCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
then do:
assign tDDocumentInvoiceXref.DDocumentInvoiceXrefAlloTC = - tDDocumentInvoiceXref.DDocumentInvoiceXrefAlloTC.
if tDDocumentInvoiceXref.tc_Status <> "N":U
then assign t_iDDocumentInvoiceXref.DDocumentInvoiceXrefAlloTC = - t_iDDocumentInvoiceXref.DDocumentInvoiceXrefAlloTC.
if tDDocumentInvoiceXref.tc_Status = "":U
then assign tDDocumentInvoiceXref.tc_Status = "C":U.
end.
/* Make sure that Xref record is removed if necessary */
if tDDocumentInvoiceXref.DDocumentInvoiceXrefAlloTC = 0 and
tDDocumentInvoiceXref.tc_Status <> "D":U or
can-do({&DOCUMENTSTATUS-INIT} + ",":U + {&DOCUMENTSTATUS-BOUNCED}, tDDocument.DDocumentStatus)
then do:
if tDDocumentInvoiceXref.tc_Status <> "N":U
then assign tDDocumentInvoiceXref.tc_Status = "D":U.
else delete tDDocumentInvoiceXref.
next.
end.
/* Each record needs a DInvoice_ID */
if tDDocumentInvoiceXref.DInvoice_ID = 0 or
tDDocumentInvoiceXref.DInvoice_ID = ?
then do:
<M-4 run SetMessage
(input trim(#T-6'Each cross-reference between payment and invoice requires a customer invoice.':250(1659)T-6#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tDDocument.tc_Rowid (icRowid),
input 'QADFIN-2586':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
assign oiReturnStatus = -1.
return.
end.
end.