project QadFinancials > class BBankEntry > method DefaultBankStateAllocBank
Description
Default the Bank State Alloc Bank Fields, this method can be called by UI
Parameters
icDocCurrencyCode | input | character | Document Currency Code |
icCurrencyCode | input | character | Currency Code : bank state currency code |
idBankStateLineExtBankRate | input | decimal | Bank State Line Ext Bank Rate : Bank exchange rate in original currency |
idBankStateLineExtBankRateScale | input | decimal | |
icBankStateLineExtCurrency | input | character | Bank State Line Ext Currency : original Currency Code |
idBankStateAllocAmountTC | input | decimal | Bank State Allocation Amount in TC |
idBankStateAllocAmountLC | input | decimal | Bank State Allocation Amount in LC |
idBankStateAllocDiscountTC | input | decimal | Bank State Allocation Discount in TC |
idBankStateAllocDiscountLC | input | decimal | Bank State Allocation Discount in LC |
itBankStateLineValueDate | input | date | Bank State Line Value Date |
idDocExchangeRate | input | decimal | Document Exchange Rate |
idDocExchangeRateScale | input | decimal | Document Scale Factor |
ilIsPrepayment | input | logical | Identify whether the it is creating a prepayment. |
idBankStateAllocWHTAmtTC | input | decimal | Bank State Allocation - WHT Amount TC |
odBankStateAllocBankAmountTC | output | decimal | Bank State Alloc Bank Amount TC : Allocation Amount in Bank Currency |
odBankStateAllocBankAmountLC | output | decimal | Bank State Alloc Bank Amount LC : Allocation amount in LC for bank currency |
odBankStateAllocBankRate | output | decimal | Bank State Alloc Bank Rate : Accounting Exchange Rate in bank currency |
otBankStateAllocBankValueDate | output | date | Bank State Alloc Bank Value Date : Validity Date in bank currency |
odBankStateAllocBankDiscTC | output | decimal | Bank Discount TC |
odBankStateAllocBankDiscLC | output | decimal | Bank Discount BC |
odBankStateAllocBankRateScale | output | decimal | |
odBankStateAllocBankWHTAmtTC | output | decimal | Bank State Allocation - Bank WHT Amount TC |
odBankStateAllocBankWHTAmtLC | output | decimal | Bank State Allocation - Bank WHT Amount LC |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
QadFitnesse
program code (program3/bbankentry.p)
assign vdExchangeRate = 0
vdExchangeRateScale = 0
vcExchangeRateTypeCode = <M-9 GetExchangeRateType () in BBankEntry>.
/* ====================== */
/* replace unknown values */
/* ====================== */
if icDocCurrencyCode = ? then assign icDocCurrencyCode = "":U.
if icCurrencyCode = ? then assign icCurrencyCode = "":U.
if idBankStateLineExtBankRate = ? then assign idBankStateLineExtBankRate = 0.
if idBankStateLineExtBankRateScale = ? then assign idBankStateLineExtBankRateScale = 1.
if icBankStateLineExtCurrency = ? then assign icBankStateLineExtCurrency = "":U.
if idBankStateAllocAmountTC = ? then assign idBankStateAllocAmountTC = 0.
if idBankStateAllocDiscountTC = ? then assign idBankStateAllocDiscountTC = 0.
if idDocExchangeRate = ? then assign idDocExchangeRate = 0.
if idDocExchangeRateScale = ? then assign idDocExchangeRateScale = 0.
if idBankStateAllocWHTAmtTC = ? then assign idBankStateAllocWHTAmtTC = 0.
/* ===================== */
/* calculate the amounts */
/* ===================== */
if icDocCurrencyCode = icCurrencyCode
then assign odBankStateAllocBankAmountTC = idBankStateAllocAmountTC
odBankStateAllocBankWHTAmtTC = idBankStateAllocWHTAmtTC
odBankStateAllocBankRate = 1
odBankStateAllocBankRateScale = 1
vdDiscountTC = idBankStateAllocDiscountTC
vdUnroundBankStateAllocAmountTC = idBankStateAllocAmountTC
vdUnroundBankStateAllocWHTAmtTC = idBankStateAllocWHTAmtTC.
else if idBankStateLineExtBankRate <> 0 and
icBankStateLineExtCurrency = icDocCurrencyCode
then assign odBankStateAllocBankAmountTC = <M-16 RoundAmount
(input idBankStateAllocAmountTC * idBankStateLineExtBankRate * idBankStateLineExtBankRateScale (idUnroundedAmount),
input 0 (iiCurrencyID),
input icBankStateLineExtCurrency (icCurrencyCode)) in business>
vdDiscountTC = <M-17 RoundAmount
(input idBankStateAllocDiscountTC * idBankStateLineExtBankRate * idBankStateLineExtBankRateScale (idUnroundedAmount),
input 0 (iiCurrencyID),
input icBankStateLineExtCurrency (icCurrencyCode)) in business>
odBankStateAllocBankWHTAmtTC = <M-64 RoundAmount
(input idBankStateAllocWHTAmtTC * idBankStateLineExtBankRate * idBankStateLineExtBankRateScale (idUnroundedAmount),
input 0 (iiCurrencyID),
input icBankStateLineExtCurrency (icCurrencyCode)) in BBankEntry>
vdUnroundBankStateAllocAmountTC = idBankStateAllocAmountTC * idBankStateLineExtBankRate * idBankStateLineExtBankRateScale
vdUnroundBankStateAllocWHTAmtTC = idBankStateAllocWHTAmtTC * idBankStateLineExtBankRate * idBankStateLineExtBankRateScale.
else do:
if idDocExchangeRate <> 0 and idDocExchangeRateScale <> 0 and vcCompanyLC = icCurrencyCode
then assign odBankStateAllocBankAmountTC = <M-25 RoundAmount
(input idBankStateAllocAmountTC * idDocExchangeRate * idDocExchangeRateScale (idUnroundedAmount),
input 0 (iiCurrencyID),
input icCurrencyCode (icCurrencyCode)) in business>
vdDiscountTC = <M-26 RoundAmount
(input idBankStateAllocDiscountTC * idDocExchangeRate * idDocExchangeRateScale (idUnroundedAmount),
input 0 (iiCurrencyID),
input icCurrencyCode (icCurrencyCode)) in business>
odBankStateAllocBankWHTAmtTC = <M-66 RoundAmount
(input idBankStateAllocWHTAmtTC * idDocExchangeRate * idDocExchangeRateScale (idUnroundedAmount),
input 0 (iiCurrencyID),
input icCurrencyCode (icCurrencyCode)) in BBankEntry>
vdUnroundBankStateAllocAmountTC = idBankStateAllocAmountTC * idDocExchangeRate * idDocExchangeRateScale
vdUnroundBankStateAllocWHTAmtTC = idBankStateAllocWHTAmtTC * idDocExchangeRate * idDocExchangeRateScale.
else do:
<M-69 run GetExchangeRate
(input viCompanyId (iiCompanyID),
input ? (iiFromCurrencyID),
input icDocCurrencyCode (icFromCurrencyCode),
input ? (iiToCurrencyID),
input icCurrencyCode (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input vcExchangeRateTypeCode (icExchangeRateTypeCode),
input itBankStateLineValueDate (itValidityDate),
output vdExchangeRate (odExchangeRate),
output vdExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
assign odBankStateAllocBankAmountTC = <M-20 RoundAmount
(input idBankStateAllocAmountTC * vdExchangeRate * vdExchangeRateScale (idUnroundedAmount),
input 0 (iiCurrencyID),
input icCurrencyCode (icCurrencyCode)) in business>
vdDiscountTC = <M-21 RoundAmount
(input idBankStateAllocDiscountTC * vdExchangeRate * vdExchangeRateScale (idUnroundedAmount),
input 0 (iiCurrencyID),
input icCurrencyCode (icCurrencyCode)) in business>
odBankStateAllocBankWHTAmtTC = <M-58 RoundAmount
(input idBankStateAllocWHTAmtTC * vdExchangeRate * vdExchangeRateScale (idUnroundedAmount),
input 0 (iiCurrencyID),
input icCurrencyCode (icCurrencyCode)) in BBankEntry>
vdUnroundBankStateAllocAmountTC = idBankStateAllocAmountTC * vdExchangeRate * vdExchangeRateScale
vdUnroundBankStateAllocWHTAmtTC = idBankStateAllocWHTAmtTC * vdExchangeRate * vdExchangeRateScale.
end.
end.
/* If it is not creating a prepayment, calculate the LC via the exchange rate in DB. */
if ilIsPrepayment = false
then do:
/* rate between banking currency and local currency of the company the banking entry is created in. */
if icCurrencyCode = vcCompanyLC
then assign odBankStateAllocBankRate = 1
odBankStateAllocBankRateScale = 1.
else if icBankStateLineExtCurrency = vcCompanyLC
then assign odBankStateAllocBankRate = 1 / idBankStateLineExtBankRate
odBankStateAllocBankRateScale = idBankStateLineExtBankRateScale.
else do:
<M-70 run GetExchangeRate
(input viCompanyId (iiCompanyID),
input ? (iiFromCurrencyID),
input icCurrencyCode (icFromCurrencyCode),
input viCompanyLCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input vcExchangeRateTypeCode (icExchangeRateTypeCode),
input itBankStateLineValueDate (itValidityDate),
output odBankStateAllocBankRate (odExchangeRate),
output odBankStateAllocBankRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end.
/* ================================================================== */
/* calculate Allocation LC in Bank currency and give date right value */
/* ================================================================== */
assign otBankStateAllocBankValueDate = itBankStateLineValueDate
odBankStateAllocBankAmountLC = <M-22 RoundAmount
(input vdUnroundBankStateAllocAmountTC * odBankStateAllocBankRate * odBankStateAllocBankRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
/* S_BTS 2617 */
/*odBankStateAllocBankDiscTC = vdDiscountTC*/
odBankStateAllocBankDiscTC = <M-23 RoundAmount
(input vdDiscountTC (idUnroundedAmount),
input 0 (iiCurrencyID),
input icCurrencyCode (icCurrencyCode)) in BApplicationProperty>
/* E_BTS 2617 */
odBankStateAllocBankDiscLC = <M-24 RoundAmount
(input vdDiscountTC * odBankStateAllocBankRate * odBankStateAllocBankRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
odBankStateAllocBankWHTAmtLC = <M-68 RoundAmount
(input vdUnroundBankStateAllocWHTAmtTC * odBankStateAllocBankRate * odBankStateAllocBankRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>.
end.
/* If it is creating a prepayment, assign the LC values and then calculate the exchangerate via LC and TC fields. */
else do:
if idDocExchangeRate <> 0 and idDocExchangeRateScale <> 0 and vcCompanyLC = icCurrencyCode
then assign odBankStateAllocBankAmountTC = <M-91 RoundAmount
(input idBankStateAllocAmountTC * idDocExchangeRate * idDocExchangeRateScale (idUnroundedAmount),
input 0 (iiCurrencyID),
input icCurrencyCode (icCurrencyCode)) in business>
vdDiscountTC = <M-7 RoundAmount
(input idBankStateAllocDiscountTC * idDocExchangeRate * idDocExchangeRateScale (idUnroundedAmount),
input 0 (iiCurrencyID),
input icCurrencyCode (icCurrencyCode)) in business>
vdUnroundBankStateAllocAmountTC=idBankStateAllocAmountTC * idDocExchangeRate * idDocExchangeRateScale.
assign odBankStateAllocBankAmountLC = <M-13 RoundAmount
(input idBankStateAllocAmountLC (idUnroundedAmount),
input 0 (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in business>
odBankStateAllocBankRate = odBankStateAllocBankAmountLC / odBankStateAllocBankAmountTC.
end.