Description
Part of APIGetToPayObejcts.
Divide because of code size limit.
Parameters
iiPaySel_ID | input | integer | |
icPayselCurrCode | input | character | |
itPaySelDate | input | date | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program3/bpaymentselection.p)
/* get existing paySelLines */
<Q-1 run PaySelLineByPaySel (all) (Read) (NoCache)
(input iiPaySel_ID, (PaySel_ID)
input ?, (PaySelLine_ID)
output dataset tqPaySelLineByPaySel) in BPaymentSelection >
/* create tProposedLine records for existing PaySelLine records */
for each tqPaySelLineByPaySel break by tqPaySelLineByPaySel.tiBankNumber_ID:
find tProposedLine where
tProposedLine.tiObject_ID = tqPaySelLineByPaySel.tiPaySelLineParentObject_ID and
tProposedLine.tiBankNumber_ID = tqPaySelLineByPaySel.tiBankNumber_ID
no-error.
if available tProposedLine
then next.
create tProposedLine.
<M-24 run PaySelLineCalcValues
(input tqPaySelLineByPaySel.tcPaySelLineObjectType (icPaySelLineObjectType),
input tqPaySelLineByPaySel.tiPaySelLineParentObject_ID (iiPaySelLineParentObject_ID),
output vcBusinessRelationCode (ocBusinessRelationCode),
output vcCreditorCode (ocCreditorCode),
output vcTSM (ocTSM),
output vcInternalNumber (ocInternalNumber),
output vcExternalNumber (ocExternalNumber),
output vtDiscountDueDate (otDiscountDueDate),
output vdDiscountPercentage (odDiscountPercentage),
output vtInvoiceDate (otInvoiceDate),
output vtDueDate (otDueDate),
output vcInvoiceCurrencyCode (ocInvoiceCurrencyCode),
output vdOpenInvoiceAmountTC (odOpenInvoiceAmountTC),
output vdOriginalInvoiceAmountTC (odOriginalInvoiceAmountTC),
output vdOriginalInvoiceAmountNetTC (odOriginalInvoiceAmountNetTC),
output vdInvoiceRate (odInvoiceRate),
output vdInvoiceRateScale (odInvoiceRateScale),
input itPaySelDate (itPaySelDate),
output vcDivisionCode (ocDivisionCode),
output viMasterID (oiMasterID),
output vdNonDiscountableAmountTC (odNonDiscountableAmountTC),
output vlCreditorIsWHT (olCreditorIsWHT),
output viInvoiceCompany_ID (oiInvoiceCompany_ID),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign tProposedLine.tc_Status = "":U
tProposedLine.tiProposedLine_ID = viProposedLine_ID
tProposedLine.tcObjectType = tqPaySelLineByPaySel.tcPaySelLineObjectType
tProposedLine.tiObject_ID = tqPaySelLineByPaySel.tiPaySelLineParentObject_ID
tProposedLine.tcBusinessRelationCode = vcBusinessRelationCode
tProposedLine.tcCreditorCode = vcCreditorCode
tProposedLine.tlCreditorIsWHT = vlCreditorIsWHT
tProposedLine.tiMaster_ID = viMasterID
tProposedLine.tcDivisionCode = vcDivisionCode
tProposedLine.tcTSM = vcTSM
tProposedLine.tcExternalNumber = vcExternalNumber
tProposedLine.tcInternalNumber = vcInternalNumber
tProposedLine.ttDiscountDueDate = vtDiscountDueDate
tProposedLine.tdDiscountPercentage = vdDiscountPercentage
tProposedLine.ttInvoiceDate = vtInvoiceDate
tProposedLine.tiInvoiceCompany_ID = viInvoiceCompany_ID
tProposedLine.ttDueDate = vtDueDate
tProposedLine.tcInvoiceCurrencyCode = vcInvoiceCurrencyCode
tProposedLine.tdInvoiceRate = vdInvoiceRate
tProposedLine.tdInvoiceRateScale = vdInvoiceRateScale
tProposedLine.tdPaymentAmountTC = tqPaySelLineByPaySel.tdPaySelLineAmountTC
tProposedLine.tdDiscountTC = tqPaySelLineByPaySel.tdPaySelLineDiscountTC
tProposedLine.tdOriginalInvoiceAmountNetTC = vdOriginalInvoiceAmountNetTC
tProposedLine.tdOriginalInvoiceAmountTC = vdOriginalInvoiceAmountTC
tProposedLine.tlProposedLineIsSelected = true
tProposedLine.tlProposedLineCanBeSelected = true
tProposedLine.tiAdditionNumber = 0
tProposedLine.tiBankNumber_ID = tqPaySelLineByPaySel.tiBankNumber_ID
tProposedLine.tdNonDiscAmtTC = vdNonDiscountableAmountTC.
/* process any stage records */
<Q-6 run PaySelLineStageByPaySelLine (all) (Read) (NoCache)
(input tqPaySelLineByPaySel.tiPaySelLine_ID, (PaySelLineID)
output dataset tqPaySelLineStageByPaySelLine) in BPaymentSelection >
for each tqPaySelLineStageByPaySelLine:
create tProposedLineStage.
assign tProposedLineStage.tiProposedLine_ID = viProposedLine_ID
tProposedLineStage.tdOpenStageAmountTC = tqPaySelLineStageByPaySelLine.tdPaySelLineStageOpenAmntTC
tProposedLineStage.tdOriginalStageAmounTC = tqPaySelLineStageByPaySelLine.tdPaySelLineStageOrigAmntTC
tProposedLineStage.tdStageDiscountAmountTC = tqPaySelLineStageByPaySelLine.tdPaySelLineStageDiscAmntTC
tProposedLineStage.tdStageInterestAmountTC = tqPaySelLineStageByPaySelLine.tdPaySelLineStageIntAmtTC
tProposedLineStage.tdStagePaymentAmountTC = tqPaySelLineStageByPaySelLine.tdPaySelLineStagePaymAmntTC
tProposedLineStage.tdWHTAmtTC = tqPaySelLineStageByPaySelLine.tdPaySelLineStageWHTAmtTC
tProposedLineStage.tiCInvoiceStage_ID = tqPaySelLineStageByPaySelLine.tiCInvoiceStage_ID
tProposedLineStage.tdStageDiscountPercentage = tqPaySelLineStageByPaySelLine.tdPaymentConditionPercentage
tProposedLineStage.ttStageDiscountDueDate = tqPaySelLineStageByPaySelLine.ttCInvoiceStageDiscDate.
end.
assign viProposedLine_ID = viProposedLine_ID + 1.
if tqPaySelLineByPaySel.tiBankNumber_ID <> ? and tqPaySelLineByPaySel.tiBankNumber_ID <> 0
then do:
if first-of(tqPaySelLineByPaySel.tiBankNumber_ID)
then do:
<Q-4 run BankNumberByID (all) (Read) (Cache)
(input tqPaySelLineByPaySel.tiBankNumber_ID, (BankNumber_ID)
input ?, (CompanyId)
output dataset tqBankNumberByID) in BBankNumber >
find first tqBankNumberByID no-error.
if available tqBankNumberByID
then assign tProposedLine.tcBankAccountNumber = if tqBankNumberByID.tcBankNumberFormatted <> "":U and tqBankNumberByID.tcBankNumberFormatted <> ? then tqBankNumberByID.tcBankNumberFormatted else tqBankNumberByID.tcBankNumber
tProposedLine.tcBankAccountExtension = tqBankNumberByID.tcBankNumberExtension
tProposedLine.tcValidationMask = tqBankNumberByID.tcBankNumberValidation
vcBankAccountNumber = tProposedLine.tcBankAccountNumber
vcBankAccountExtension = tProposedLine.tcBankAccountExtension
vcValidationMask = tProposedLine.tcValidationMask.
end.
else assign tProposedLine.tcBankAccountNumber = vcBankAccountNumber
tProposedLine.tcBankAccountExtension = vcBankAccountExtension
tProposedLine.tcValidationMask = vcValidationMask.
end.
/* calculate BC Amount */
if tProposedLine.tcInvoiceCurrencyCode <> icPaySelCurrCode and
tProposedLine.tcInvoiceCurrencyCode <> "":U and
tProposedLine.tcInvoiceCurrencyCode <> ? and
icPaySelCurrCode <> "":U and
icPaySelCurrCode <> ?
then do:
if icPayselCurrCode <> vcCompanyLC
then do:
<M-75 run GetExchangeRate
(input ? (iiCompanyID),
input ? (iiFromCurrencyID),
input icPayselCurrCode (icFromCurrencyCode),
input viCompanyLCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input tProposedLine.ttInvoiceDate (itValidityDate),
output vdExchangeRate (odExchangeRate),
output vdExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign vdExchangeRate = if vdExchangeRate <> 0 and
vdExchangeRate <> ? and
tProposedLine.tdInvoiceRate <> 0 and
tProposedLine.tdInvoiceRate <> ?
then (tProposedLine.tdInvoiceRate / vdExchangeRate / vdExchangeRateScale)
else 0.
end.
else assign vdExchangeRate = tProposedLine.tdInvoiceRate
vdExchangeRateScale = tProposedLine.tdInvoiceRateScale.
assign tProposedLine.tdPaymentAmountBC = tProposedLine.tdPaymentAmountTC * vdExchangeRate * vdExchangeRateScale.
end.
else assign tProposedLine.tdPaymentAmountBC = tProposedLine.tdPaymentAmountTC * tProposedLine.tdInvoiceRate * tProposedLine.tdInvoiceRateScale.
end.