project QadFinancials > class BDInvoice > method CreateDIPostingCalculateAmounts

Description

Calculate the amounts for the di posting


Parameters


ilIsDebtorControlAccountinputlogicalIs Debtor Control Account ?
icDInvoiceTypeinputcharacterInvoice Type
idInvoiceAmountTCinputdecimalInvoice Amount TC
idInvoiceAmountLCinputdecimalInvoice Amount BC
idInvoiceAmountCCinputdecimalInvoice Amount CC
icPostingTypeinputcharacterPosting Type
odDebitTCoutputdecimalDebit TC
odDebitLCoutputdecimalDebit BC
odDebitCCoutputdecimalDebit CC
odCreditTCoutputdecimalCredit TC
odCreditLCoutputdecimalCredit BC
odCreditCCoutputdecimalCredit CC
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDInvoice.CreateDIPosting
method BDInvoice.CreateDIPostingSales


program code (program3/bdinvoice.p)

if ilIsDebtorControlAccount
then do:
    case icDInvoiceType:
        when {&INVOICETYPE-INVOICE} or 
        when {&INVOICETYPE-FINANCECHARGE} or
        when {&INVOICETYPE-INVOICECORRECTION}
        then assign odDebitTC  = idInvoiceAmountTC
                    odCreditTC = 0
                    odDebitLC  = idInvoiceAmountLC
                    odCreditLC = 0
                    odDebitCC  = idInvoiceAmountCC
                    odCreditCC = 0.
        when {&INVOICETYPE-CREDITNOTE} or 
        when {&INVOICETYPE-CREDITNOTECORRECTION}
        then assign odDebitTC  = 0
                    odCreditTC = idInvoiceAmountTC
                    odDebitLC  = 0
                    odCreditLC = idInvoiceAmountLC
                    odDebitCC  = 0
                    odCreditCC = idInvoiceAmountCC.
        when {&INVOICETYPE-ADJUSTMENT} or when {&INVOICETYPE-PREPAYMENT} or when {&INVOICETYPE-DEDUCTION}
        then assign odDebitTC  = if icPostingType = {&POSTINGTYPE-DEBIT}
                                 then idInvoiceAmountTC
                                 else 0
                    odCreditTC = if icPostingType = {&POSTINGTYPE-CREDIT}
                                 then idInvoiceAmountTC
                                 else 0
                    odDebitLC  = if icPostingType = {&POSTINGTYPE-DEBIT}
                                 then idInvoiceAmountLC
                                 else 0
                    odCreditLC = if icPostingType = {&POSTINGTYPE-CREDIT}
                                 then idInvoiceAmountLC
                                 else 0
                    odDebitCC  = if icPostingType = {&POSTINGTYPE-DEBIT}
                                 then idInvoiceAmountCC
                                 else 0
                    odCreditCC = if icPostingType = {&POSTINGTYPE-CREDIT}
                                 then idInvoiceAmountCC
                                 else 0.
    end case.
end.
else do:
    case icDInvoiceType:
        when {&INVOICETYPE-INVOICE} or 
        when {&INVOICETYPE-FINANCECHARGE} or
        when {&INVOICETYPE-INVOICECORRECTION}
        then assign odDebitTC  = 0
                    odCreditTC = idInvoiceAmountTC
                    odDebitLC  = 0
                    odCreditLC = idInvoiceAmountLC
                    odDebitCC  = 0
                    odCreditCC = idInvoiceAmountCC.
        when {&INVOICETYPE-CREDITNOTE} or 
        when {&INVOICETYPE-CREDITNOTECORRECTION}
        then assign odDebitTC  = idInvoiceAmountTC
                    odCreditTC = 0
                    odDebitLC  = idInvoiceAmountLC
                    odCreditLC = 0
                    odDebitCC  = idInvoiceAmountCC
                    odCreditCC = 0.
        when {&INVOICETYPE-ADJUSTMENT} or when {&INVOICETYPE-PREPAYMENT} or when {&INVOICETYPE-DEDUCTION}
        then assign odDebitTC  = if icPostingType = {&POSTINGTYPE-CREDIT}
                                 then idInvoiceAmountTC
                                 else 0
                    odCreditTC = if icPostingType = {&POSTINGTYPE-DEBIT}
                                 then idInvoiceAmountTC
                                 else 0
                    odDebitLC  = if icPostingType = {&POSTINGTYPE-CREDIT}
                                 then idInvoiceAmountLC
                                 else 0
                    odCreditLC = if icPostingType = {&POSTINGTYPE-DEBIT}
                                 then idInvoiceAmountLC
                                 else 0
                    odDebitCC  = if icPostingType = {&POSTINGTYPE-CREDIT}
                                 then idInvoiceAmountCC
                                 else 0
                    odCreditCC = if icPostingType = {&POSTINGTYPE-DEBIT}
                                 then idInvoiceAmountCC
                                 else 0.
    end case.
end.

/* when CC amounts are both zero, assign them with ? so they get calculated automatically in the posting */
if odDebitCC = 0 and odCreditCC = 0
then assign odDebitCC  = ?
            odCreditCC = ?.