project QadFinancials > class BDInvoice > method CreateDIMovementInitial
Parameters
iiDInvoiceId | input | integer | |
icDInvoiceType | input | character | |
icPostingType | input | character | |
iiControlPostingLineId | input | integer | |
idInvoiceAmountTC | input | decimal | |
idInvoiceAmountCC | input | decimal | |
idInvoiceAmountLC | input | decimal | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bdinvoice.p)
/* Create initial DInvoice Movement record */
if not can-find(first tDInvoiceMovement where
tDInvoiceMovement.tc_ParentRowid = tDInvoice.tc_Rowid)
then do:
<M-1 run AddDetailLine (input 'DInvoiceMovement':U (icTable),
input tDInvoice.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
if viFcReturnSuper < 0 or
oiReturnStatus = 0 and viFcReturnSuper > 0
then assign oiReturnStatus = viFcReturnSuper.
assign tDInvoiceMovement.DInvoice_ID = iiDInvoiceId
tDInvoiceMovement.PostingLine_Id = iiControlPostingLineId
tDInvoiceMovement.DInvoiceMovementType = {&MOVEMENTTYPE-INITIAL}.
if tDInvoice.DInvoiceBalanceDebitTC <> ? and
tDInvoice.DInvoiceBalanceDebitTC <> 0
then assign tDInvoice.DInvoiceBalanceDebitTC =
tDInvoice.DInvoiceBalanceDebitTC -
(if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then 0
else idInvoiceAmountTC) +
(if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then idInvoiceAmountTC
else 0)
tDInvoice.DInvoiceBalanceDebitLC =
tDInvoice.DInvoiceBalanceDebitLC -
(if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then 0
else idInvoiceAmountLC) +
(if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then idInvoiceAmountLC
else 0)
tDInvoice.DInvoiceBalanceDebitCC =
tDInvoice.DInvoiceBalanceDebitCC -
(if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then 0
else vdDInvoiceAmountCC) +
(if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then vdDInvoiceAmountCC
else 0).
if tDInvoice.DInvoiceBalanceCreditTC <> ? and
tDInvoice.DInvoiceBalanceCreditTC <> 0
then assign tDInvoice.DInvoiceBalanceCreditTC =
tDInvoice.DInvoiceBalanceCreditTC +
(if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then 0
else idInvoiceAmountTC) -
(if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then idInvoiceAmountTC
else 0)
tDInvoice.DInvoiceBalanceCreditLC =
tDInvoice.DInvoiceBalanceCreditLC +
(if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then 0
else idInvoiceAmountLC) -
(if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then idInvoiceAmountLC
else 0)
tDInvoice.DInvoiceBalanceCreditCC =
tDInvoice.DInvoiceBalanceCreditCC +
(if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then 0
else vdDInvoiceAmountCC) -
(if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then vdDInvoiceAmountCC
else 0).
if (tDInvoice.DInvoiceBalanceDebitTC = ? or
tDInvoice.DInvoiceBalanceDebitTC = 0) and
(tDInvoice.DInvoiceBalanceCreditTC = ? or
tDInvoice.DInvoiceBalanceCreditTC = 0)
then do:
if icPostingType = {&POSTINGTYPE-DEBIT}
then assign tDInvoice.DInvoiceBalanceDebitTC = tDInvoice.DInvoiceBalanceDebitTC + idInvoiceAmountTC
tDInvoice.DInvoiceBalanceDebitLC = tDInvoice.DInvoiceBalanceDebitLC + idInvoiceAmountLC
tDInvoice.DInvoiceBalanceDebitCC = tDInvoice.DInvoiceBalanceDebitCC + vdDInvoiceAmountCC.
if icPostingType = {&POSTINGTYPE-CREDIT}
then assign tDInvoice.DInvoiceBalanceCreditTC = tDInvoice.DInvoiceBalanceCreditTC + idInvoiceAmountTC
tDInvoice.DInvoiceBalanceCreditLC = tDInvoice.DInvoiceBalanceCreditLC + idInvoiceAmountLC
tDInvoice.DInvoiceBalanceCreditCC = tDInvoice.DInvoiceBalanceCreditCC + vdDInvoiceAmountCC.
end.
assign tDInvoice.DInvoiceBalanceTC = tDInvoice.DInvoiceBalanceDebitTC - tDInvoice.DInvoiceBalanceCreditTC
tDInvoice.DInvoiceBalanceLC = tDInvoice.DInvoiceBalanceDebitLC - tDInvoice.DInvoiceBalanceCreditLC
tDInvoice.DInvoiceBalanceCC = tDInvoice.DInvoiceBalanceDebitCC - tDInvoice.DInvoiceBalanceCreditCC
tDInvoice.DInvoiceIsOpen =
tDInvoice.DInvoiceBalanceTC <> 0 or
tDInvoice.DInvoiceBalanceLC <> 0 or
tDInvoice.DInvoiceBalanceCC <> 0
tDInvoice.tc_status =
if tDInvoice.tc_Status = "":U
then "C":U
else tDInvoice.tc_Status.
end.