project QadFinancials > class BDebtor > method CalcOpenOrderTotal
Description
This method calculates new value of total amount of open orders
Parameters
idNewSOAmount | input | decimal | |
idOldSOAmount | input | decimal | |
icSOCurrencyCode | input | character | |
icDebtorCurrencyCode | input | character | |
bdDebtorTotalSalesOrderBalance | input-output | decimal | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program3/bdebtor.p)
/* =================================================================================================== */
/* Method : CalculateOpenOrderTotal */
/* Desc : This method calculates new amount of all open orders */
/* --------------------------------------------------------------------------------------------------- */
/* Params: (I) NewSOAmount New amount of sales order */
/* (I) OldSOAmount Original amount of sales order */
/* (I) SOCurrencyCode Currency code of Sales Order */
/* (I) DebtorCurrencyCode Currency code of the debtor */
/* (B) DebtorToralSalesOrderBalance Debtor's total balance of sales order */
/* =================================================================================================== */
assign oiReturnStatus = -98.
/* =================================================================================================== */
/* Get exhange rate between debtor and sales order */
/* =================================================================================================== */
assign vdRate = 1
vdRateScale = 1.
if icSOCurrencyCode <> icDebtorCurrencyCode
then do:
<M-66 run GetExchangeRate
(input viCompanyId (iiCompanyID),
input ? (iiFromCurrencyID),
input icSOCurrencyCode (icFromCurrencyCode),
input ? (iiToCurrencyID),
input icDebtorCurrencyCode (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input today (itValidityDate),
output vdRate (odExchangeRate),
output vdRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BDebtor>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
end.
/* =================================================================================================== */
/* Calculate open amount in debtor currency */
/* =================================================================================================== */
assign vdOpenAmount = (idNewSOAmount - idOldSOAmount) * vdRate * vdRateScale
vdOpenAmount = <M-2 RoundAmount
(input vdOpenAmount (idUnroundedAmount),
input ? (iiCurrencyID),
input icDebtorCurrencyCode (icCurrencyCode)) in business>.
/* =================================================================================================== */
/* Update debtor's total sales order balance */
/* =================================================================================================== */
assign bdDebtorTotalSalesOrderBalance = bdDebtorTotalSalesOrderBalance + vdOpenAmount.
/* =================================================================================================== */
/* Return */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.