Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program3/bpaymentselection.p)
<I-14 {READDIRECTDBACCESS
&READTABLENAMES = "CInvoiceBank"}>
/* =========================================== */
/* Go through the PorposedLines for some types */
/* =========================================== */
for each tProposedLine where
tProposedLine.tlIsMultiple = false AND
(tProposedLine.tcObjectType = {&PAYMENTSELECTIONTYPE-INVOICE} or
tProposedLine.tcObjectType = {&PAYMENTSELECTIONTYPE-INVOICECORR} or
tProposedLine.tcObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTE} or
tProposedLine.tcObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTECORR} or
tProposedLine.tcObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENTINV} or
tProposedLine.tcObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCNCORR} or
tProposedLine.tcObjectType = {&PAYMENTSELECTIONTYPE-ADJUSTMENT})
break by tProposedLine.tiObject_ID:
/* ================================================================================================================ */
/* Actions for Multiple Lines: */
/* Fill in tProposedLine.tiInvoiceSeq and tProposedLine.tlIsMultiple and adadpt tProposedLine.tdOpenInvoiceAmountTC */
/* ================================================================================================================ */
if first-of(tProposedLine.tiObject_ID)
then assign viPropLineNumberPerInvoice = 1.
assign tProposedLine.tiInvoiceSeq = viPropLineNumberPerInvoice
viPropLineNumberPerInvoice = viPropLineNumberPerInvoice + 1.
if can-find(first btProposedLine where
btProposedLine.tiObject_ID = tProposedLine.tiObject_ID and
recid(btProposedLine) <> recid(tProposedLine))
then assign tProposedLine.tlIsMultiple = true.
else assign tProposedLine.tlIsMultiple = false.
/* Handle the case: One PaymentSelection Code for one Supplier Invoice with two different bank GL account. */
if tProposedLine.tlIsMultiple = false
then if can-find (first CInvoiceBank where
CInvoiceBank.CInvoice_ID = tProposedLine.tiObject_ID and
CInvoiceBank.BankNumber_ID <> tProposedLine.tiBankNumber_ID)
then assign tProposedLine.tlIsMultiple = true.
if tProposedLine.tlIsMultiple = true and
abs(tProposedLine.tdOpenInvoiceAmountTC) >= abs(tProposedLine.tdCInvoiceBankToPayTC - tProposedLine.tdWHTAmtTC - tProposedLine.tdHoldAmountTC)
then assign tProposedLine.tdOpenInvoiceAmountTC = tProposedLine.tdCInvoiceBankToPayTC - tProposedLine.tdWHTAmtTC - tProposedLine.tdHoldAmountTC.
/* ============================================================================= */
/* Store the number of decimals based upon the currency */
/* We can use the inherited data-item vcCurrencyDecimalsList for this as it */
/* holds all cuurrencies followed by the number of decimals this currency allows */
/* ============================================================================= */
if tProposedLine.tcInvoiceCurrencyCode = vcCompanyLC
then assign tProposedLine.tiNumDecTC = viCompanyLCDec.
else if tProposedLine.tcInvoiceCurrencyCode = vcCompanyCC
then assign tProposedLine.tiNumDecTC = viCompanyCCDec.
else if tProposedLine.tcInvoiceCurrencyCode <> '':U and
tProposedLine.tcInvoiceCurrencyCode <> ?
then do :
assign viEntryInList = lookup(tProposedLine.tcInvoiceCurrencyCode,vcCurrencyDecimalsList)
tProposedLine.tiNumDecTC = integer(entry(viEntryInList + 1,vcCurrencyDecimalsList))
no-error.
if error-status:error or
viEntryInList = ? or
viEntryInList = 0
then do :
<Q-26 run CurrencyByCode (all) (Read) (Cache)
(input tProposedLine.tcInvoiceCurrencyCode, (CurrencyCode)
output dataset tqCurrencyByCode) in BCurrency>
find first tqCurrencyByCode no-error.
if available tqCurrencyByCode and
tqCurrencyByCode.tiCurrencyNumberOfDecimals <> ?
then assign tProposedLine.tiNumDecTC = tqCurrencyByCode.tiCurrencyNumberOfDecimals.
end. /* if error-status:error or */
end. /* if tProposedLine.tcInvoiceCurrencyCode <> '':U and */
if not tProposedLine.tlProposedLineIsSelected
then assign tProposedLine.tdPaymentAmountTC = 0
tProposedLine.tdDiscountTC = 0
tProposedLine.tdAllocatedAmount = 0.
end. /* for each tProposedLine where */
/* =========================================== */
/* Go through the PorposedLines for some types */
/* =========================================== */
for each tProposedLine where
tProposedLine.tcObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENT} or
tProposedLine.tcObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCREDITNOTE}:
/* ================================== */
/* Set tProposedLine.tiInvoiceSeq = 1 */
/* ================================== */
assign tProposedLine.tiInvoiceSeq = 1.
/* ============================================================================= */
/* Store the number of decimals based upon the currency */
/* We can use the inherited data-item vcCurrencyDecimalsList for this as it */
/* holds all cuurrencies followed by the number of decimals this currency allows */
/* ============================================================================= */
if tProposedLine.tcInvoiceCurrencyCode = vcCompanyLC
then assign tProposedLine.tiNumDecTC = viCompanyLCDec.
else if tProposedLine.tcInvoiceCurrencyCode = vcCompanyCC
then assign tProposedLine.tiNumDecTC = viCompanyCCDec.
else if tProposedLine.tcInvoiceCurrencyCode <> '':U and
tProposedLine.tcInvoiceCurrencyCode <> ?
then do :
assign viEntryInList = lookup(tProposedLine.tcInvoiceCurrencyCode,vcCurrencyDecimalsList)
tProposedLine.tiNumDecTC = integer(entry(viEntryInList + 1,vcCurrencyDecimalsList))
no-error.
if error-status:error or
viEntryInList = ? or
viEntryInList = 0
then do :
<Q-62 run CurrencyByCode (all) (Read) (Cache)
(input tProposedLine.tcInvoiceCurrencyCode, (CurrencyCode)
output dataset tqCurrencyByCode) in BCurrency>
find first tqCurrencyByCode no-error.
if available tqCurrencyByCode and
tqCurrencyByCode.tiCurrencyNumberOfDecimals <> ?
then assign tProposedLine.tiNumDecTC = tqCurrencyByCode.tiCurrencyNumberOfDecimals.
end. /* if error-status:error or */
end. /* if tProposedLine.tcInvoiceCurrencyCode <> '':U and */
end. /* for each tProposedLine where */