project QadFinancials > class BDInvoice > method CreateDIPostingCalculateAmounts
Description
Calculate the amounts for the di posting
Parameters
ilIsDebtorControlAccount | input | logical | Is Debtor Control Account ? |
icDInvoiceType | input | character | Invoice Type |
idInvoiceAmountTC | input | decimal | Invoice Amount TC |
idInvoiceAmountLC | input | decimal | Invoice Amount BC |
idInvoiceAmountCC | input | decimal | Invoice Amount CC |
icPostingType | input | character | Posting Type |
odDebitTC | output | decimal | Debit TC |
odDebitLC | output | decimal | Debit BC |
odDebitCC | output | decimal | Debit CC |
odCreditTC | output | decimal | Credit TC |
odCreditLC | output | decimal | Credit BC |
odCreditCC | output | decimal | Credit CC |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
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 = ?.